diff options
author | Didier Nadeau <didier.nadeau@mongodb.com> | 2021-11-15 14:19:42 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-15 14:43:35 +0000 |
commit | fe9052cee98bcff412a06c3e8eaf9e54ea82a14c (patch) | |
tree | 0dccd3fc35ff41545a988f8f5a07aa1388ff3d02 /jstests | |
parent | 912d318e7f44241ee6ecacdcffd83f1539c5c43e (diff) | |
download | mongo-fe9052cee98bcff412a06c3e8eaf9e54ea82a14c.tar.gz |
SERVER-60865 Implement DonorAbortSplit command
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/tenant_split_abort.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/jstests/replsets/tenant_split_abort.js b/jstests/replsets/tenant_split_abort.js new file mode 100644 index 00000000000..c9e966400b0 --- /dev/null +++ b/jstests/replsets/tenant_split_abort.js @@ -0,0 +1,55 @@ +/* + * Test invocation of donorAbortSplit command + * @tags: [requires_fcv_52, featureFlagShardSplit] + */ + +load("jstests/libs/fail_point_util.js"); +load('jstests/libs/parallel_shell_helpers.js'); + +function findMigration(primary, uuid) { + const donorsCollection = primary.getDB("config").getCollection("tenantSplitDonors"); + return donorsCollection.findOne({"_id": uuid}); +} + +function assertDocumentState(primary, uuid, state) { + const migrationDoc = findMigration(primary, uuid); + assert(migrationDoc); + assert.eq(migrationDoc.state, state); +} + +function startReplica(numNodes) { + const replTest = new ReplSetTest({name: 'testSet', nodes: numNodes}); + + jsTestLog("Starting replica set for test"); + const donorNodes = replTest.startSet(); + replTest.initiate(); + + return replTest; +} + +function runSuccess() { + "use strict"; + + jsTestLog("Starting runSuccess"); + + // Skip db hash check because secondary is left with a different config. + TestData.skipCheckDBHashes = true; + + const replTest = startReplica(3); + const primary = replTest.getPrimary(); + const adminDb = primary.getDB("admin"); + const migrationId = UUID(); + + jsTestLog("Asserting no state document exist before command"); + assert.isnull(findMigration(primary, migrationId)); + + jsTestLog("Running donorAbortSplit command"); + assert.commandWorked(adminDb.runCommand({donorAbortSplit: 1, migrationId: migrationId})); + + jsTestLog("Asserting state document exist after command"); + assertDocumentState(primary, migrationId, "aborted"); + + replTest.stopSet(); +} + +runSuccess(); |