Skip to content

Commit

Permalink
Sync server discovery integration spec tests (#980)
Browse files Browse the repository at this point in the history
Add support for readPreference argument to runAdminCommand

JAVA-4677
  • Loading branch information
jyemin authored Jul 15, 2022
1 parent 0523b3d commit ac5dde8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mongodb.MongoClientSettings;
import com.mongodb.MongoCommandException;
import com.mongodb.MongoNamespace;
import com.mongodb.ReadPreference;
import com.mongodb.ServerCursor;
import com.mongodb.WriteConcern;
import com.mongodb.client.model.CreateCollectionOptions;
Expand Down Expand Up @@ -411,4 +412,8 @@ public void runAdminCommand(final String command) {
public void runAdminCommand(final BsonDocument command) {
new CommandReadOperation<>("admin", command, new BsonDocumentCodec()).execute(getBinding());
}

public void runAdminCommand(final BsonDocument command, final ReadPreference readPreference) {
new CommandReadOperation<>("admin", command, new BsonDocumentCodec()).execute(getBinding(readPreference));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 2
"times": 4
},
"data": {
"failCommands": [
Expand Down Expand Up @@ -162,22 +162,6 @@
}
]
}
},
{
"name": "assertEventCount",
"object": "testRunner",
"arguments": {
"event": "ServerMarkedUnknownEvent",
"count": 1
}
},
{
"name": "assertEventCount",
"object": "testRunner",
"arguments": {
"event": "PoolClearedEvent",
"count": 1
}
}
],
"expectations": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 2
"times": 4
},
"data": {
"failCommands": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 2
"times": 4
},
"data": {
"failCommands": [
Expand Down Expand Up @@ -160,22 +160,6 @@
}
]
}
},
{
"name": "assertEventCount",
"object": "testRunner",
"arguments": {
"event": "ServerMarkedUnknownEvent",
"count": 1
}
},
{
"name": "assertEventCount",
"object": "testRunner",
"arguments": {
"event": "PoolClearedEvent",
"count": 1
}
}
],
"expectations": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,27 @@
"name": "recordPrimary",
"object": "testRunner"
},
{
"name": "runAdminCommand",
"object": "testRunner",
"command_name": "replSetFreeze",
"arguments": {
"command": {
"replSetFreeze": 0
},
"readPreference": {
"mode": "Secondary"
}
}
},
{
"name": "runAdminCommand",
"object": "testRunner",
"command_name": "replSetStepDown",
"arguments": {
"command": {
"replSetStepDown": 1,
"secondaryCatchUpPeriodSecs": 1,
"replSetStepDown": 30,
"secondaryCatchUpPeriodSecs": 30,
"force": false
}
}
Expand All @@ -61,7 +74,7 @@
"name": "waitForPrimaryChange",
"object": "testRunner",
"arguments": {
"timeoutMS": 5000
"timeoutMS": 15000
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,13 @@ public Void execute() {
newPrimary = getCurrentPrimary();
}
} else if (operationName.equals("runAdminCommand")) {
collectionHelper.runAdminCommand(operation.getDocument("arguments").getDocument("command"));
BsonDocument arguments = operation.getDocument("arguments");
BsonDocument command = arguments.getDocument("command");
if (arguments.containsKey("readPreference")) {
collectionHelper.runAdminCommand(command, helper.getReadPreference(arguments));
} else {
collectionHelper.runAdminCommand(command);
}
} else if (operationName.equals("assertSessionPinned")) {
final BsonDocument arguments = operation.getDocument("arguments", new BsonDocument());
assertNotNull(sessionsMap.get(arguments.getString("session").getValue()).getPinnedServerAddress());
Expand Down

0 comments on commit ac5dde8

Please sign in to comment.