diff options
author | Matt Broadstone <mbroadst@mongodb.com> | 2022-05-31 18:44:18 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-31 19:14:13 +0000 |
commit | b9da1f22bd8eb4bcca71250907a97b4ca5a13911 (patch) | |
tree | 003a92a9d3f26c1a130f10a695e59e569c2b2058 /jstests/serverless | |
parent | 6a00ca3f6fd410127f1434ad3e9074d3e856355b (diff) | |
download | mongo-b9da1f22bd8eb4bcca71250907a97b4ca5a13911.tar.gz |
SERVER-66832 Ensure split config is removed after any decision
Diffstat (limited to 'jstests/serverless')
-rw-r--r-- | jstests/serverless/shard_split_reconfig.js | 53 | ||||
-rw-r--r-- | jstests/serverless/shard_split_remove_split_config_after_decision.js | 78 |
2 files changed, 78 insertions, 53 deletions
diff --git a/jstests/serverless/shard_split_reconfig.js b/jstests/serverless/shard_split_reconfig.js deleted file mode 100644 index cc94795c421..00000000000 --- a/jstests/serverless/shard_split_reconfig.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Test that shard split generates and apply a split config. - * - * @tags: [requires_fcv_52, featureFlagShardSplit, serverless] - */ - -load("jstests/libs/fail_point_util.js"); -load('jstests/libs/parallel_shell_helpers.js'); -load("jstests/serverless/libs/basic_serverless_test.js"); - -function shardSplitApplySplitConfig() { - "use strict"; - - jsTestLog("Checking that shard split correctly reconfig the nodes."); - - // Skip db hash check because secondary is left with a different config. - TestData.skipCheckDBHashes = true; - const tenantIds = ["tenant1", "tenant2"]; - - const test = new BasicServerlessTest({ - recipientTagName: "recipientNode", - recipientSetName: "recipient", - quickGarbageCollection: true - }); - test.addRecipientNodes(); - - const donorPrimary = test.donor.getPrimary(); - - const operation = test.createSplitOperation(tenantIds); - - jsTestLog("Running commitShardSplit command"); - assert.commandWorked(operation.commit()); - - jsTestLog("Asserting a split config has been applied"); - // We need to pass `nodeId` below because there might be 2 primaries available at the same time - // from both the donor and the recipient nodes. - const configDoc = test.donor.getReplSetConfigFromNode(donorPrimary.nodeId); - assert(configDoc, "There must be a config document"); - assert.eq(configDoc["members"].length, 3); - assert(configDoc["recipientConfig"]); - assert.eq(configDoc["recipientConfig"]["_id"], "recipient"); - assert.eq(configDoc["recipientConfig"]["members"].length, 3); - - jsTestLog("Asserting state document exist after command"); - assertMigrationState(donorPrimary, operation.migrationId, "committed"); - - operation.forget(); - - test.waitForGarbageCollection(operation.migrationId, tenantIds); - test.stop(); -} - -shardSplitApplySplitConfig(); diff --git a/jstests/serverless/shard_split_remove_split_config_after_decision.js b/jstests/serverless/shard_split_remove_split_config_after_decision.js new file mode 100644 index 00000000000..e27d4ffe367 --- /dev/null +++ b/jstests/serverless/shard_split_remove_split_config_after_decision.js @@ -0,0 +1,78 @@ +/* + * Test that a split config is removed after a decision is reached. + * + * @tags: [requires_fcv_52, featureFlagShardSplit, serverless] + */ + +load("jstests/libs/fail_point_util.js"); +load("jstests/serverless/libs/basic_serverless_test.js"); + +function assertSplitConfigExists(donorPrimary) { + jsTestLog("Asserting a split config has been applied"); + const config = assert.commandWorked(donorPrimary.adminCommand({replSetGetConfig: 1})).config; + assert(config, "There must be a config document"); + assert.eq(config["members"].length, 3); + assert(config["recipientConfig"]); + assert.eq(config["recipientConfig"]["_id"], "recipient"); + assert.eq(config["recipientConfig"]["members"].length, 3); +} + +function assertSplitConfigDoesNotExist(donorPrimary) { + jsTestLog("Asserting a split config does not exist"); + const config = assert.commandWorked(donorPrimary.adminCommand({replSetGetConfig: 1})).config; + assert(config, "There must be a config document"); + assert.eq(null, config["recipientConfig"]); +} + +function splitConfigRemovedAfterDecision(simulateErrorToAbortOperation) { + "use strict"; + + simulateErrorToAbortOperation = simulateErrorToAbortOperation || false; + + // Skip db hash check because secondary is left with a different config. + TestData.skipCheckDBHashes = true; + const tenantIds = ["tenant1", "tenant2"]; + const test = new BasicServerlessTest({ + recipientTagName: "recipientNode", + recipientSetName: "recipient", + quickGarbageCollection: true + }); + + test.addRecipientNodes(); + + const donorPrimary = test.donor.getPrimary(); + const beforeConfigRemovalFp = + configureFailPoint(donorPrimary, "pauseShardSplitBeforeSplitConfigRemoval"); + const afterDecisionFp = configureFailPoint(donorPrimary, "pauseShardSplitAfterDecision"); + if (simulateErrorToAbortOperation) { + configureFailPoint(donorPrimary, "abortShardSplitBeforeLeavingBlockingState"); + } + + const operation = test.createSplitOperation(tenantIds); + if (simulateErrorToAbortOperation) { + assert.commandFailed(operation.commit()); + } else { + assert.commandWorked(operation.commit()); + } + + beforeConfigRemovalFp.wait(); + if (simulateErrorToAbortOperation) { + assertMigrationState(donorPrimary, operation.migrationId, "aborted"); + } else { + assertMigrationState(donorPrimary, operation.migrationId, "committed"); + } + + assertSplitConfigExists(donorPrimary); + beforeConfigRemovalFp.off(); + + afterDecisionFp.wait(); + assertSplitConfigDoesNotExist(donorPrimary); + afterDecisionFp.off(); + + operation.forget(); + test.waitForGarbageCollection(operation.migrationId, tenantIds); + test.stop(); +} + +splitConfigRemovedAfterDecision(false); +splitConfigRemovedAfterDecision(true); |