diff options
Diffstat (limited to 'jstests/sharding/auto_rebalance_parallel.js')
| -rw-r--r-- | jstests/sharding/auto_rebalance_parallel.js | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/jstests/sharding/auto_rebalance_parallel.js b/jstests/sharding/auto_rebalance_parallel.js index 1e55e8cbc11..d9f2f00715e 100644 --- a/jstests/sharding/auto_rebalance_parallel.js +++ b/jstests/sharding/auto_rebalance_parallel.js @@ -1,5 +1,8 @@ /** * Tests that the cluster is balanced in parallel in one balancer round (standalone). + * @tags: [ + * requires_fcv_60, + * ] */ (function() { @@ -7,7 +10,7 @@ load("jstests/sharding/libs/find_chunks_util.js"); -var st = new ShardingTest({shards: 4}); +const st = new ShardingTest({shards: 4, other: {chunkSize: 1, enableAutoSplitter: false}}); var config = st.s0.getDB('config'); assert.commandWorked(st.s0.adminCommand({enableSharding: 'TestDB'})); @@ -18,35 +21,34 @@ function prepareCollectionForBalance(collName) { var coll = st.s0.getCollection(collName); - // Create 4 chunks initially and ensure they get balanced within 1 balancer round - assert.commandWorked(coll.insert({Key: 1, Value: 'Test value 1'})); - assert.commandWorked(coll.insert({Key: 10, Value: 'Test value 10'})); - assert.commandWorked(coll.insert({Key: 20, Value: 'Test value 20'})); - assert.commandWorked(coll.insert({Key: 30, Value: 'Test value 30'})); + const bigString = 'X'.repeat(1024 * 1024); // 1MB + // Create 6 chunks initially and ensure they get balanced within 1 balancer round + assert.commandWorked(coll.insert({Key: 1, Value: 'Test value 1', s: bigString})); + assert.commandWorked(coll.insert({Key: 10, Value: 'Test value 10', s: bigString})); + assert.commandWorked(coll.insert({Key: 20, Value: 'Test value 20', s: bigString})); + assert.commandWorked(coll.insert({Key: 30, Value: 'Test value 30', s: bigString})); + assert.commandWorked(coll.insert({Key: 40, Value: 'Test value 40', s: bigString})); + assert.commandWorked(coll.insert({Key: 50, Value: 'Test value 50', s: bigString})); assert.commandWorked(st.splitAt(collName, {Key: 10})); assert.commandWorked(st.splitAt(collName, {Key: 20})); assert.commandWorked(st.splitAt(collName, {Key: 30})); + assert.commandWorked(st.splitAt(collName, {Key: 40})); + assert.commandWorked(st.splitAt(collName, {Key: 50})); - // Move two of the chunks to st.shard1.shardName so we have option to do parallel balancing - assert.commandWorked(st.moveChunk(collName, {Key: 20}, st.shard1.shardName)); + // Move 3 of the chunks to st.shard1.shardName so we have option to do parallel balancing assert.commandWorked(st.moveChunk(collName, {Key: 30}, st.shard1.shardName)); + assert.commandWorked(st.moveChunk(collName, {Key: 40}, st.shard1.shardName)); + assert.commandWorked(st.moveChunk(collName, {Key: 50}, st.shard1.shardName)); assert.eq( - 2, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard0.shardName}).itcount()); + 3, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard0.shardName}).itcount()); assert.eq( - 2, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard1.shardName}).itcount()); + 3, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard1.shardName}).itcount()); } function checkCollectionBalanced(collName) { - assert.eq( - 1, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard0.shardName}).itcount()); - assert.eq( - 1, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard1.shardName}).itcount()); - assert.eq( - 1, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard2.shardName}).itcount()); - assert.eq( - 1, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard3.shardName}).itcount()); + st.verifyCollectionIsBalanced(st.s.getCollection(collName)); } function countMoves(collName) { @@ -62,8 +64,8 @@ const testColl1InitialMoves = countMoves('TestDB.TestColl1'); const testColl2InitialMoves = countMoves('TestDB.TestColl2'); st.startBalancer(); -st.waitForBalancer(true, 60000); -st.waitForBalancer(true, 60000); +st.awaitBalance("TestColl1", "TestDB"); +st.awaitBalance("TestColl2", "TestDB"); st.stopBalancer(); checkCollectionBalanced('TestDB.TestColl1'); |
