summaryrefslogtreecommitdiff
path: root/jstests/sharding/reshard_collection_basic.js
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
commit959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch)
treeacc8d60aedb12b70048e676e8a7349deb0010db8 /jstests/sharding/reshard_collection_basic.js
parent76588293975fc059cf076779e4283e6ffaf8afff (diff)
New upstream version 6.0.20upstream
Diffstat (limited to 'jstests/sharding/reshard_collection_basic.js')
-rw-r--r--jstests/sharding/reshard_collection_basic.js40
1 files changed, 27 insertions, 13 deletions
diff --git a/jstests/sharding/reshard_collection_basic.js b/jstests/sharding/reshard_collection_basic.js
index 4b527757ecd..2dee0d4e5e7 100644
--- a/jstests/sharding/reshard_collection_basic.js
+++ b/jstests/sharding/reshard_collection_basic.js
@@ -212,29 +212,37 @@ let presetReshardedChunks =
*/
jsTest.log('Fail if sharding is disabled.');
-assert.commandFailedWithCode(mongos.adminCommand({reshardCollection: ns, key: {newKey: 1}}),
- ErrorCodes.NamespaceNotFound);
+assert.commandFailedWithCode(
+ mongos.adminCommand({reshardCollection: ns, key: {newKey: 1}, numInitialChunks: 1}),
+ ErrorCodes.NamespaceNotFound);
assert.commandWorked(mongos.adminCommand({enableSharding: kDbName}));
jsTest.log("Fail if collection is unsharded.");
-assert.commandFailedWithCode(mongos.adminCommand({reshardCollection: ns, key: {newKey: 1}}),
- ErrorCodes.NamespaceNotSharded);
+assert.commandFailedWithCode(
+ mongos.adminCommand({reshardCollection: ns, key: {newKey: 1}, numInitialChunks: 1}),
+ ErrorCodes.NamespaceNotSharded);
assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: {oldKey: 1}}));
jsTest.log("Fail if missing required key.");
-assert.commandFailedWithCode(mongos.adminCommand({reshardCollection: ns}), 40414);
+assert.commandFailedWithCode(mongos.adminCommand({reshardCollection: ns, numInitialChunks: 1}),
+ 40414);
jsTest.log("Fail if unique is specified and is true.");
assert.commandFailedWithCode(
- mongos.adminCommand({reshardCollection: ns, key: {newKey: 1}, unique: true}),
+ mongos.adminCommand(
+ {reshardCollection: ns, key: {newKey: 1}, unique: true, numInitialChunks: 1}),
ErrorCodes.BadValue);
jsTest.log("Fail if collation is specified and is not {locale: 'simple'}.");
-assert.commandFailedWithCode(
- mongos.adminCommand({reshardCollection: ns, key: {newKey: 1}, collation: {locale: 'en_US'}}),
- ErrorCodes.BadValue);
+assert.commandFailedWithCode(mongos.adminCommand({
+ reshardCollection: ns,
+ key: {newKey: 1},
+ collation: {locale: 'en_US'},
+ numInitialChunks: 1
+}),
+ ErrorCodes.BadValue);
jsTest.log("Fail if both numInitialChunks and _presetReshardedChunks are provided.");
assert.commandFailedWithCode(mongos.adminCommand({
@@ -263,6 +271,7 @@ jsTest.log("Fail if zone provided is invalid for storage.");
assert.commandFailedWithCode(mongos.adminCommand({
reshardCollection: ns,
key: {"_id": "hashed"},
+ numInitialChunks: 1,
zones: [{min: {"_id": {"$minKey": 1}}, max: {"_id": {"$maxKey": 1}}, zone: "Namezone"}]
}),
ErrorCodes.BadValue);
@@ -301,13 +310,16 @@ assert.commandFailedWithCode(mongos.getDB('test').system.resharding.mycoll.inser
mongos.getDB(kDbName)[collName].drop();
jsTest.log("Succeed when correct locale is provided.");
-assertReshardCollOk({reshardCollection: ns, key: {newKey: 1}, collation: {locale: 'simple'}}, 1);
+assertReshardCollOk(
+ {reshardCollection: ns, key: {newKey: 1}, collation: {locale: 'simple'}, numInitialChunks: 1},
+ 1);
jsTest.log("Succeed base case.");
-assertReshardCollOk({reshardCollection: ns, key: {newKey: 1}}, 1);
+assertReshardCollOk({reshardCollection: ns, key: {newKey: 1}, numInitialChunks: 1}, 1);
jsTest.log("Succeed if unique is specified and is false.");
-assertReshardCollOk({reshardCollection: ns, key: {newKey: 1}, unique: false}, 1);
+assertReshardCollOk({reshardCollection: ns, key: {newKey: 1}, unique: false, numInitialChunks: 1},
+ 1);
jsTest.log(
"Succeed if _presetReshardedChunks is provided and test commands are enabled (default).");
@@ -344,6 +356,7 @@ assertReshardCollOk({
key: {newKey: 1},
unique: false,
collation: {locale: 'simple'},
+ numInitialChunks: 1,
zones: [{zone: newZoneName, min: {newKey: 5}, max: {newKey: 10}}]
},
3);
@@ -353,8 +366,8 @@ assertReshardCollOk({
reshardCollection: ns,
key: {newKey: 1},
unique: false,
- numInitialChunks: 1,
collation: {locale: 'simple'},
+ numInitialChunks: 1,
zones: [{zone: newZoneName, min: {newKey: MinKey}, max: {newKey: MaxKey}}]
},
1);
@@ -380,6 +393,7 @@ assertReshardCollOk({
key: {oldKey: 1, newKey: 1},
unique: false,
collation: {locale: 'simple'},
+ numInitialChunks: 1,
zones: [{zone: existingZoneName, min: {oldKey: 0}, max: {oldKey: 5}}]
},
3);