From ec63b35f98596e6289fddb371dd089003820c985 Mon Sep 17 00:00:00 2001 From: Ali Mir Date: Thu, 7 Nov 2024 11:08:12 -0500 Subject: [PATCH] SERVER-87429 Create targeted jstest for magic restore and resharding (#28684) GitOrigin-RevId: 0f6b57174f742d9d4043e7395335adef278ca9ee --- jstests/libs/sharded_magic_restore_test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jstests/libs/sharded_magic_restore_test.js b/jstests/libs/sharded_magic_restore_test.js index 0f6736b45ce..987b9eb226f 100644 --- a/jstests/libs/sharded_magic_restore_test.js +++ b/jstests/libs/sharded_magic_restore_test.js @@ -208,9 +208,23 @@ export class ShardedMagicRestoreTest { this.magicRestoreTests.forEach((magicRestoreTest, idx) => { const rstOptions = {"replSet": magicRestoreTest.rst.name}; + // When performing a shard rename, we must replace the replica set '_id' field on the + // config. Cloud will determine the new config to insert into a node during restore, so + // we don't have to do this replacement in the server. + const replicaSetConfig = magicRestoreTest.getExpectedConfig(); + if (this.shardingRename) { + for (let i = 0; i < this.numShards; i++) { + if (replicaSetConfig._id == this.shardingRename[i].sourceShardName) { + replicaSetConfig._id = this.shardingRename[i].destinationShardName; + break; + } + } + this.expectedConfig = replicaSetConfig; + } + let restoreConfiguration = { "nodeType": idx > 0 ? "shard" : "configServer", - "replicaSetConfig": magicRestoreTest.getExpectedConfig(), + "replicaSetConfig": replicaSetConfig, "maxCheckpointTs": this.maxCheckpointTs };