summaryrefslogtreecommitdiff
path: root/jstests/sharding/resharding_prohibited_commands.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/resharding_prohibited_commands.js')
-rw-r--r--jstests/sharding/resharding_prohibited_commands.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/jstests/sharding/resharding_prohibited_commands.js b/jstests/sharding/resharding_prohibited_commands.js
index d06a9561d2a..9f7d73b57c3 100644
--- a/jstests/sharding/resharding_prohibited_commands.js
+++ b/jstests/sharding/resharding_prohibited_commands.js
@@ -118,6 +118,7 @@ const waitUntilReshardingInitializedOnDonor = () => {
* @param {Function} config.setup
* @param {AfterReshardingCallback} afterReshardingFn
*/
+
const withReshardingInBackground =
(duringReshardingFn,
{setup = () => {}, expectedErrorCode, afterReshardingFn = () => {}} = {}) => {
@@ -132,22 +133,34 @@ const withReshardingInBackground =
},
duringReshardingFn,
{expectedErrorCode: expectedErrorCode, afterReshardingFn: afterReshardingFn});
-
assertCommandsSucceedAfterReshardingOpFinishes(mongos.getDB(databaseName));
assert.commandWorked(sourceCollection.dropIndex(indexCreatedByTest));
};
// Tests that the prohibited commands work if the resharding operation is aborted.
+let awaitAbort;
withReshardingInBackground(() => {
waitUntilReshardingInitializedOnDonor();
+ assert.neq(null,
+ mongos.getCollection("config.reshardingOperations").findOne({ns: sourceNamespace}));
+ awaitAbort = startParallelShell(funWithArgs(function(sourceNamespace) {
+ db.adminCommand({abortReshardCollection: sourceNamespace});
+ }, sourceNamespace), mongos.port);
+ // Wait for the coordinator to remove coordinator document from config.reshardingOperations
+ // as a result of the recipients and donors transitioning to done due to abort.
+ assert.soon(() => {
+ const coordinatorDoc =
+ mongos.getCollection("config.reshardingOperations").findOne({ns: sourceNamespace});
- assert.commandWorked(mongos.adminCommand({abortReshardCollection: sourceNamespace}));
+ return coordinatorDoc === null || coordinatorDoc.state === "aborting";
+ });
}, {
expectedErrorCode: ErrorCodes.ReshardCollectionAborted,
});
+awaitAbort();
// Tests that the prohibited commands succeed if the resharding operation succeeds. During the
-// operation it makes sures that the prohibited commands are rejected during the resharding
+// operation it makes sure that the prohibited commands are rejected during the resharding
// operation.
withReshardingInBackground(() => {
waitUntilReshardingInitializedOnDonor();