diff options
Diffstat (limited to 'jstests/serverless')
4 files changed, 134 insertions, 6 deletions
diff --git a/jstests/serverless/libs/basic_serverless_test.js b/jstests/serverless/libs/basic_serverless_test.js index 0f374cb192c..3c6ae92556b 100644 --- a/jstests/serverless/libs/basic_serverless_test.js +++ b/jstests/serverless/libs/basic_serverless_test.js @@ -544,6 +544,12 @@ class BasicServerlessTest { } BasicServerlessTest.kConfigSplitDonorsNS = "config.tenantSplitDonors"; +BasicServerlessTest.DonorState = { + kUninitialized: "uninitialized", + kBlocking: "blocking", + kCommitted: "committed", + kAborted: "aborted" +}; function findSplitOperation(primary, migrationId) { const donorsCollection = primary.getCollection(BasicServerlessTest.kConfigSplitDonorsNS); diff --git a/jstests/serverless/shard_split_abort_during_upgrade_downgrade.js b/jstests/serverless/shard_split_abort_during_upgrade_downgrade.js new file mode 100644 index 00000000000..32ddb38b339 --- /dev/null +++ b/jstests/serverless/shard_split_abort_during_upgrade_downgrade.js @@ -0,0 +1,65 @@ +/* + * Prove that shard splits are aborted during FCV upgrade/downgrade. + * + * @tags: [requires_fcv_52, featureFlagShardSplit, serverless] + */ + +(function() { +"use strict"; +load("jstests/libs/fail_point_util.js"); +load("jstests/serverless/libs/basic_serverless_test.js"); + +// Shard split commands are gated by a feature flag, which will not be supported when we +// downgrade versions. Eventually, we will run this test when we have two consecutive versions +// that support `commitShardSplit` without a feature flag. This check will be removed as part +// of SERVER-66965. +if (MongoRunner.compareBinVersions(latestFCV, "6.2") < 0) { + return; +} + +// Skip db hash check because secondary is left with a different config. +TestData.skipCheckDBHashes = true; +const test = new BasicServerlessTest({ + recipientTagName: "recipientNode", + recipientSetName: "recipient", + quickGarbageCollection: true +}); + +test.addRecipientNodes(); + +const donorPrimary = testFixture.donor.getPrimary(); +const tenantIds = ["tenant1", "tenant2"]; + +jsTestLog("Assert shard splits are aborted when downgrading."); +const downgradeFCV = lastContinuousFCV; +const hangWhileDowngradingFp = configureFailPoint(donorPrimary, "hangWhileDowngrading"); +const downgradeThread = new Thread((host, downgradeFCV) => { + const db = new Mongo(host); + assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: downgradeFCV})); +}, donorPrimary.host, downgradeFCV); + +downgradeThread.start(); +hangWhileDowngradingFp.wait(); +const firstSplit = test.createSplitOperation(tenantIds); +assert.commandFailedWithCode(firstSplit.commit(), ErrorCodes.TenantMigrationAborted); +hangWhileDowngradingFp.off(); +downgradeThread.join(); +firstSplit.forget(); + +jsTestLog("Assert shard splits are aborted when upgrading."); +const hangWhileUpgradingFp = configureFailPoint(donorPrimary, "hangWhileUpgrading"); +const upgradeThread = new Thread((host) => { + const db = new Mongo(host); + assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: latestFCV})); +}, donorPrimary.host); + +upgradeThread.start(); +hangWhileUpgradingFp.wait(); +const secondSplit = test.createSplitOperation(tenantIds); +assert.commandFailedWithCode(secondSplit.commit(), ErrorCodes.TenantMigrationAborted); +hangWhileUpgradingFp.off(); +upgradeThread.join(); +secondSplit.forget(); + +test.stop(); +})(); diff --git a/jstests/serverless/shard_split_abort_on_setfcv.js b/jstests/serverless/shard_split_abort_on_setfcv.js new file mode 100644 index 00000000000..5de893203ae --- /dev/null +++ b/jstests/serverless/shard_split_abort_on_setfcv.js @@ -0,0 +1,57 @@ +/* + * Prove that shard splits are eagerly aborted when the `setFeatureCompatibilityVersion` command is + * received for both upgrade and downgrade paths. + * + * @tags: [requires_fcv_52, featureFlagShardSplit, serverless] + */ + +(function() { +"use strict"; +load("jstests/libs/fail_point_util.js"); +load("jstests/serverless/libs/basic_serverless_test.js"); + +// Skip db hash check because secondary is left with a different config. +TestData.skipCheckDBHashes = true; +const test = new BasicServerlessTest({ + recipientTagName: "recipientNode", + recipientSetName: "recipient", + quickGarbageCollection: true +}); + +test.addRecipientNodes(); + +const donorPrimary = test.donor.getPrimary(); +const tenantIds = ["tenant1", "tenant2"]; +const pauseAfterBlockingFp = configureFailPoint(donorPrimary, "pauseShardSplitAfterBlocking"); + +jsTestLog("Test FCV Downgrade"); +const split = test.createSplitOperation(tenantIds); +const commitThread = split.commitAsync(); +pauseAfterBlockingFp.wait(); +assert.commandWorked( + donorPrimary.adminCommand({setFeatureCompatibilityVersion: lastContinuousFCV})); +pauseAfterBlockingFp.off(); +assert.commandFailedWithCode(commitThread.returnData(), ErrorCodes.TenantMigrationAborted); + +jsTestLog("Test FCV Upgrade"); +if (lastContinuousFCV == "6.0") { + const secondSplit = test.createSplitOperation(tenantIds); + assert.commandFailedWithCode(secondSplit.commit(), ErrorCodes.IllegalOperation); +} else { + // `forgetShardSplit` will not be available until the downgraded version also supports the + // 'shard split' feature. + split.forget(); + test.cleanupSuccesfulAborted(split.migrationId, tenantIds); + + const secondSplit = test.createSplitOperation(tenantIds); + const commitThread = secondSplit.commitAsync(); + pauseAfterBlockingFp.wait(); + assert.commandWorked(donorPrimary.adminCommand({setFeatureCompatibilityVersion: latestFCV})); + pauseAfterBlockingFp.off(); + assert.commandFailedWithCode(commitThread.returnData(), ErrorCodes.TenantMigrationAborted); + secondSplit.forget(); + test.cleanupSuccesfulAborted(secondSplit.migrationId, tenantIds); +} + +test.stop(); +})(); diff --git a/jstests/serverless/shard_split_enabled.js b/jstests/serverless/shard_split_enabled.js index 6cc27de9db7..a58aec52d1d 100644 --- a/jstests/serverless/shard_split_enabled.js +++ b/jstests/serverless/shard_split_enabled.js @@ -50,13 +50,13 @@ function makeShardSplitTest() { let commitUUID = UUID(); let res = adminDB.runCommand(test.makeCommitShardSplitCmd(commitUUID)); assert.neq(res.code, - 6057900, + ErrorCodes.IllegalOperation, `commitShardSplitCmd shouldn't reject when featureFlagShardSplit is enabled`); test.removeRecipientNodesFromDonor(); res = adminDB.runCommand(test.makeForgetShardSplitCmd(commitUUID)); assert.neq(res.code, - 6057900, + ErrorCodes.IllegalOperation, `forgetShardSplit shouldn't reject when featureFlagShardSplit is enabled`); test.waitForGarbageCollection(commitUUID, tenantIds); @@ -64,22 +64,22 @@ function makeShardSplitTest() { let abortUUID = UUID(); res = adminDB.runCommand(test.makeAbortShardSplitCmd(abortUUID)); assert.neq(res.code, - 6057902, + ErrorCodes.IllegalOperation, `abortShardSplitCmd shouldn't reject when featureFlagShardSplit is enabled`); assert.commandWorked(adminDB.adminCommand({setFeatureCompatibilityVersion: downgradeFCV})); assert.commandFailedWithCode( adminDB.runCommand(test.makeCommitShardSplitCmd(UUID())), - 6057900, + ErrorCodes.IllegalOperation, `commitShardSplitCmd should reject when featureFlagShardSplit is disabled`); assert.commandFailedWithCode( adminDB.runCommand(test.makeAbortShardSplitCmd(UUID())), - 6057902, + ErrorCodes.IllegalOperation, `abortShardSplitCmd should reject when featureFlagShardSplit is disabled`); assert.commandFailedWithCode( adminDB.runCommand(test.makeForgetShardSplitCmd(UUID())), - 6236600, + ErrorCodes.IllegalOperation, `forgetShardSplit should reject when featureFlagShardSplit is disabled`); // shut down replica set |