For streamable isMaster, drivers would like to add tests that fail isMaster commands, like this:
db.adminCommand({"configureFailpoint": "failCommand", "mode": {"times": 2}, "data": {"failCommands": ["isMaster"], "errorCode": 94, "closeConnection": false}})
And:
db.adminCommand({"configureFailpoint": "failCommand", "mode": "alwaysOn", "data": {"failCommands": ["isMaster"], "errorCode": 94, "closeConnection": false}})
However, failing isMaster with failCommand is tricky because:
- driver tests often have 1 (or more) MongoClients running in the background of the test suite. These clients will likely trigger the failpoint in addition to the MongoClient we want to test.
- using "mode": "alwaysOn" makes it impossible for a driver to re-discover the server after it is marked Unknown because SDAM discovery depends on a successful isMaster. This means it may not be possible to disable the "alwaysOn" failpoint without other workarounds. (A driver needs to reserve a connection in order to disable the failpoint and/or ensure that the node is still selectable.)
It would be great if the failCommand failpoint was able to filter which clients trigger the failure.
One proposal to fix these issues would be to implement an "appName" filter on the failCommand failpoint. "appName" would work similar to the "threadName" (SERVER-38054) feature but instead of the individual connection name (eg "conn8") we'd use the "appName" from the connection handshake. This would allow driver tests to control which clients trigger a failpoint:
db.adminCommand({"configureFailpoint": "failCommand", "mode": "alwaysOn", "data": {"failCommands": ["isMaster"], "errorCode": 94, "closeConnection": false, "appName": "failingIsMasterTest"}}) ... # Only this client will trigger the failpoint client = MongoClient(appName="failingIsMasterTest")