summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Osta <luis.osta@mongodb.com>2021-06-30 16:58:11 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-07-27 16:45:55 +0000
commit292b0ee13aed4689714ab506703bd6eb92785ad5 (patch)
tree03905bea8e7eb38bc4c19faef33fd09a9af0aa05
parentca7a3ba8e51377f3cf9e8fdf3e1883c1ea8bfdb5 (diff)
downloadmongo-292b0ee13aed4689714ab506703bd6eb92785ad5.tar.gz
SERVER-57759 Run movePrimary command before sharding the source collection in the ReshardingTest fixture
-rw-r--r--jstests/sharding/libs/resharding_test_fixture.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/jstests/sharding/libs/resharding_test_fixture.js b/jstests/sharding/libs/resharding_test_fixture.js
index 5bfde1c09b1..99d115d414d 100644
--- a/jstests/sharding/libs/resharding_test_fixture.js
+++ b/jstests/sharding/libs/resharding_test_fixture.js
@@ -183,6 +183,15 @@ var ReshardingTest = class {
const sourceCollection = this._st.s.getCollection(ns);
const sourceDB = sourceCollection.getDB();
+ assert.commandWorked(sourceDB.adminCommand({enableSharding: sourceDB.getName()}));
+
+ // mongos won't know about the temporary resharding collection and will therefore assume the
+ // collection is unsharded. We configure one of the recipient shards to be the primary shard
+ // for the database so mongos still ends up routing operations to a shard which owns the
+ // temporary resharding collection.
+ this._st.ensurePrimaryShard(sourceDB.getName(), primaryShardName);
+ this._primaryShardName = primaryShardName;
+
CreateShardedCollectionUtil.shardCollectionWithChunks(
sourceCollection, shardKeyPattern, chunks);
@@ -192,13 +201,6 @@ var ReshardingTest = class {
this._tempNs = `${sourceDB.getName()}.system.resharding.${sourceCollectionUUIDString}`;
- // mongos won't know about the temporary resharding collection and will therefore assume the
- // collection is unsharded. We configure one of the recipient shards to be the primary shard
- // for the database so mongos still ends up routing operations to a shard which owns the
- // temporary resharding collection.
- this._st.ensurePrimaryShard(sourceDB.getName(), primaryShardName);
- this._primaryShardName = primaryShardName;
-
return sourceCollection;
}