summaryrefslogtreecommitdiff
path: root/jstests/sharding/auto_rebalance_parallel.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/auto_rebalance_parallel.js')
-rw-r--r--jstests/sharding/auto_rebalance_parallel.js42
1 files changed, 20 insertions, 22 deletions
diff --git a/jstests/sharding/auto_rebalance_parallel.js b/jstests/sharding/auto_rebalance_parallel.js
index d9f2f00715e..1e55e8cbc11 100644
--- a/jstests/sharding/auto_rebalance_parallel.js
+++ b/jstests/sharding/auto_rebalance_parallel.js
@@ -1,8 +1,5 @@
/**
* Tests that the cluster is balanced in parallel in one balancer round (standalone).
- * @tags: [
- * requires_fcv_60,
- * ]
*/
(function() {
@@ -10,7 +7,7 @@
load("jstests/sharding/libs/find_chunks_util.js");
-const st = new ShardingTest({shards: 4, other: {chunkSize: 1, enableAutoSplitter: false}});
+var st = new ShardingTest({shards: 4});
var config = st.s0.getDB('config');
assert.commandWorked(st.s0.adminCommand({enableSharding: 'TestDB'}));
@@ -21,34 +18,35 @@ function prepareCollectionForBalance(collName) {
var coll = st.s0.getCollection(collName);
- 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}));
+ // 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'}));
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 3 of the chunks to st.shard1.shardName so we have option to do parallel balancing
+ // 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));
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(
- 3, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard0.shardName}).itcount());
+ 2, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard0.shardName}).itcount());
assert.eq(
- 3, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard1.shardName}).itcount());
+ 2, findChunksUtil.findChunksByNs(config, collName, {shard: st.shard1.shardName}).itcount());
}
function checkCollectionBalanced(collName) {
- st.verifyCollectionIsBalanced(st.s.getCollection(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());
}
function countMoves(collName) {
@@ -64,8 +62,8 @@ const testColl1InitialMoves = countMoves('TestDB.TestColl1');
const testColl2InitialMoves = countMoves('TestDB.TestColl2');
st.startBalancer();
-st.awaitBalance("TestColl1", "TestDB");
-st.awaitBalance("TestColl2", "TestDB");
+st.waitForBalancer(true, 60000);
+st.waitForBalancer(true, 60000);
st.stopBalancer();
checkCollectionBalanced('TestDB.TestColl1');