diff options
Diffstat (limited to 'jstests/sharding/movechunk_interrupt_at_primary_stepdown.js')
-rw-r--r-- | jstests/sharding/movechunk_interrupt_at_primary_stepdown.js | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/jstests/sharding/movechunk_interrupt_at_primary_stepdown.js b/jstests/sharding/movechunk_interrupt_at_primary_stepdown.js index 7158d12c719..3a03a485dc9 100644 --- a/jstests/sharding/movechunk_interrupt_at_primary_stepdown.js +++ b/jstests/sharding/movechunk_interrupt_at_primary_stepdown.js @@ -9,69 +9,69 @@ load('./jstests/libs/chunk_manipulation_util.js'); (function() { - 'use strict'; +'use strict'; - // Intentionally use a config server with 1 node so that the step down and promotion to primary - // are guaranteed to happen on the same host - var st = new ShardingTest({config: 1, shards: 2}); - var mongos = st.s0; +// Intentionally use a config server with 1 node so that the step down and promotion to primary +// are guaranteed to happen on the same host +var st = new ShardingTest({config: 1, shards: 2}); +var mongos = st.s0; - assert.commandWorked(mongos.adminCommand({enableSharding: 'TestDB'})); - st.ensurePrimaryShard('TestDB', st.shard0.shardName); - assert.commandWorked(mongos.adminCommand({shardCollection: 'TestDB.TestColl', key: {Key: 1}})); +assert.commandWorked(mongos.adminCommand({enableSharding: 'TestDB'})); +st.ensurePrimaryShard('TestDB', st.shard0.shardName); +assert.commandWorked(mongos.adminCommand({shardCollection: 'TestDB.TestColl', key: {Key: 1}})); - var coll = mongos.getDB('TestDB').TestColl; +var coll = mongos.getDB('TestDB').TestColl; - // We have one chunk initially - assert.writeOK(coll.insert({Key: 0, Value: 'Test value'})); +// We have one chunk initially +assert.writeOK(coll.insert({Key: 0, Value: 'Test value'})); - pauseMigrateAtStep(st.shard1, migrateStepNames.deletedPriorDataInRange); +pauseMigrateAtStep(st.shard1, migrateStepNames.deletedPriorDataInRange); - // For startParallelOps to write its state - var staticMongod = MongoRunner.runMongod({}); +// For startParallelOps to write its state +var staticMongod = MongoRunner.runMongod({}); - var joinMoveChunk = moveChunkParallel( - staticMongod, mongos.host, {Key: 0}, null, 'TestDB.TestColl', st.shard1.shardName); - waitForMigrateStep(st.shard1, migrateStepNames.deletedPriorDataInRange); +var joinMoveChunk = moveChunkParallel( + staticMongod, mongos.host, {Key: 0}, null, 'TestDB.TestColl', st.shard1.shardName); +waitForMigrateStep(st.shard1, migrateStepNames.deletedPriorDataInRange); - // Stepdown the primary in order to force the balancer to stop. Use a timeout of 5 seconds for - // both step down operations, because mongos will retry to find the CSRS primary for up to 20 - // seconds and we have two successive ones. - assert.commandWorked(st.configRS.getPrimary().adminCommand({replSetStepDown: 5, force: true})); +// Stepdown the primary in order to force the balancer to stop. Use a timeout of 5 seconds for +// both step down operations, because mongos will retry to find the CSRS primary for up to 20 +// seconds and we have two successive ones. +assert.commandWorked(st.configRS.getPrimary().adminCommand({replSetStepDown: 5, force: true})); - // Ensure a new primary is found promptly - st.configRS.getPrimary(30000); +// Ensure a new primary is found promptly +st.configRS.getPrimary(30000); - assert.eq(1, - mongos.getDB('config') - .chunks.find({ns: 'TestDB.TestColl', shard: st.shard0.shardName}) - .itcount()); - assert.eq(0, - mongos.getDB('config') - .chunks.find({ns: 'TestDB.TestColl', shard: st.shard1.shardName}) - .itcount()); +assert.eq(1, + mongos.getDB('config') + .chunks.find({ns: 'TestDB.TestColl', shard: st.shard0.shardName}) + .itcount()); +assert.eq(0, + mongos.getDB('config') + .chunks.find({ns: 'TestDB.TestColl', shard: st.shard1.shardName}) + .itcount()); - // At this point, the balancer is in recovery mode. Ensure that stepdown can be done again and - // the recovery mode interrupted. - assert.commandWorked(st.configRS.getPrimary().adminCommand({replSetStepDown: 5, force: true})); +// At this point, the balancer is in recovery mode. Ensure that stepdown can be done again and +// the recovery mode interrupted. +assert.commandWorked(st.configRS.getPrimary().adminCommand({replSetStepDown: 5, force: true})); - // Ensure a new primary is found promptly - st.configRS.getPrimary(30000); +// Ensure a new primary is found promptly +st.configRS.getPrimary(30000); - unpauseMigrateAtStep(st.shard1, migrateStepNames.deletedPriorDataInRange); +unpauseMigrateAtStep(st.shard1, migrateStepNames.deletedPriorDataInRange); - // Ensure that migration succeeded - joinMoveChunk(); +// Ensure that migration succeeded +joinMoveChunk(); - assert.eq(0, - mongos.getDB('config') - .chunks.find({ns: 'TestDB.TestColl', shard: st.shard0.shardName}) - .itcount()); - assert.eq(1, - mongos.getDB('config') - .chunks.find({ns: 'TestDB.TestColl', shard: st.shard1.shardName}) - .itcount()); +assert.eq(0, + mongos.getDB('config') + .chunks.find({ns: 'TestDB.TestColl', shard: st.shard0.shardName}) + .itcount()); +assert.eq(1, + mongos.getDB('config') + .chunks.find({ns: 'TestDB.TestColl', shard: st.shard1.shardName}) + .itcount()); - st.stop(); - MongoRunner.stopMongod(staticMongod); +st.stop(); +MongoRunner.stopMongod(staticMongod); })(); |