[SERVER-47535] Ability to mock command responses on the server Created: 14/Apr/20  Updated: 04/Jun/20  Resolved: 04/Jun/20

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Tomer Yakir Assignee: Benjamin Caimano (Inactive)
Resolution: Won't Fix Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-44466 Add "errorDocument" field to failComm... Closed
Participants:

 Description   

Some tests require reproduction of non-trivial conditions such as network instability between cluster members.
It'd be great if we can have a mechanism similar to configureFailPoint: "failCommand" where we'll be able to mock the server response.
Ideally we'd be able to replace parts of the response - for example, set commitmentState: false for replSetGetConfig.



 Comments   
Comment by Eric Milkie [ 14/Apr/20 ]

My second proposal is to set up a failpoint with the response it needs to return for the command. It can be made more complicated (choose the command to return the response; modify part of the response; et cetera). The failpoint command logic has a way to pass a BSONObj that can be used for this, or we can come up with a new command like the one I proposed above.

Comment by Eric Milkie [ 14/Apr/20 ]

A more complicated and featureful way to do this in two steps would be something like:

db.runCommand({stageNextResponseForTest:1, response: { bson-response-subobject } });
db.runCommand({replSetGetConfig:1}) // would return the response you staged on this connection

Comment by Eric Milkie [ 14/Apr/20 ]

Would something like a "reflect" feature work, where you could turn on a failpoint (or not, even), and then do something like this:

db.runCommand({replSetGetConfig:1, reflectResponseForTest: { {bson-subobject-of-what-you-want-the-response-to-look-like} })

Generated at Thu Feb 08 05:14:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.