summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergi Mateo Bellido <sergi.mateo-bellido@mongodb.com>2021-07-27 12:24:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-08-20 07:14:00 +0000
commitd673ef4ac0953b0b32a4f077a558caec899f2067 (patch)
tree1fe31f251e434b2da92c9fc8f8d7cd128621c0e8
parent7fb7ecca9a3775fbabb4a1262786a61b81c8e87e (diff)
downloadmongo-d673ef4ac0953b0b32a4f077a558caec899f2067.tar.gz
SERVER-58868 Enable/Remove a commented moveChunk + AllowMigrations test
(cherry picked from commit 235da36e33a9b1b17fc3640fa9202598cca03883)
-rw-r--r--jstests/sharding/move_chunk_allowMigrations.js67
1 files changed, 33 insertions, 34 deletions
diff --git a/jstests/sharding/move_chunk_allowMigrations.js b/jstests/sharding/move_chunk_allowMigrations.js
index 3b4e2db9234..c9c1d9d0b6e 100644
--- a/jstests/sharding/move_chunk_allowMigrations.js
+++ b/jstests/sharding/move_chunk_allowMigrations.js
@@ -29,40 +29,39 @@ const setUpDb = function setUpDatabaseAndEnableSharding() {
};
// Tests that moveChunk does not succeed when {allowMigrations: false}
-// (function testAllowMigrationsFalsePreventsMoveChunk() {
-// setUpDb();
-
-// const collName = "collA";
-// const ns = dbName + "." + collName;
-
-// assert.commandWorked(st.s.getDB(dbName).getCollection(collName).insert({_id: 0}));
-// assert.commandWorked(st.s.getDB(dbName).getCollection(collName).insert({_id: 1}));
-// assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 1}}));
-
-// // Confirm that an inProgress moveChunk fails once {allowMigrations: false}
-// const fp = configureFailPoint(st.shard0, "moveChunkHangAtStep5");
-// const awaitResult = startParallelShell(
-// funWithArgs(function(ns, toShardName) {
-// assert.commandFailedWithCode(
-// db.adminCommand({moveChunk: ns, find: {_id: 0}, to: toShardName}),
-// ErrorCodes.ConflictingOperationInProgress);
-// }, ns, st.shard1.shardName), st.s.port);
-// fp.wait();
-// assert.commandWorked(
-// configDB.collections.update({_id: ns}, {$set: {allowMigrations: false}}, {upsert:
-// true}));
-// fp.off();
-// awaitResult();
-
-// // {allowMigrations: false} is set, sending a new moveChunk command should also fail.
-// assert.commandFailedWithCode(
-// st.s.adminCommand({moveChunk: ns, find: {_id: 0}, to: st.shard1.shardName}),
-// ErrorCodes.ConflictingOperationInProgress);
-
-// // Confirm shard0 reports {allowMigrations: false} in the local cache as well
-// const cachedEntry = st.shard0.getDB("config").cache.collections.findOne({_id: ns});
-// assert.eq(false, cachedEntry.allowMigrations);
-// })();
+(function testAllowMigrationsFalsePreventsMoveChunk() {
+ setUpDb();
+
+ const collName = "collA";
+ const ns = dbName + "." + collName;
+
+ assert.commandWorked(st.s.getDB(dbName).getCollection(collName).insert({_id: 0}));
+ assert.commandWorked(st.s.getDB(dbName).getCollection(collName).insert({_id: 1}));
+ assert.commandWorked(st.s.adminCommand({shardCollection: ns, key: {_id: 1}}));
+
+ // Confirm that an inProgress moveChunk fails once {allowMigrations: false}
+ const fp = configureFailPoint(st.shard0, "moveChunkHangAtStep4");
+ const awaitResult = startParallelShell(
+ funWithArgs(function(ns, toShardName) {
+ assert.commandFailedWithCode(
+ db.adminCommand({moveChunk: ns, find: {_id: 0}, to: toShardName}),
+ ErrorCodes.ConflictingOperationInProgress);
+ }, ns, st.shard1.shardName), st.s.port);
+ fp.wait();
+ assert.commandWorked(st.configRS.getPrimary().adminCommand(
+ {_configsvrSetAllowMigrations: ns, allowMigrations: false, writeConcern: {w: "majority"}}));
+ fp.off();
+ awaitResult();
+
+ // {allowMigrations: false} is set, sending a new moveChunk command should also fail.
+ assert.commandFailedWithCode(
+ st.s.adminCommand({moveChunk: ns, find: {_id: 0}, to: st.shard1.shardName}),
+ ErrorCodes.ConflictingOperationInProgress);
+
+ // Confirm shard0 reports {allowMigrations: false} in the local cache as well
+ const cachedEntry = st.shard0.getDB("config").cache.collections.findOne({_id: ns});
+ assert.eq(false, cachedEntry.allowMigrations);
+})();
// Tests {allowMigrations: false} disables balancing for collB and does not interfere with balancing
// for collA.