2022-03-14 21:09:34 +00:00
|
|
|
/**
|
|
|
|
|
* Tests that runs a shard split to completion.
|
2022-10-12 20:45:59 +00:00
|
|
|
* @tags: [requires_fcv_62, serverless]
|
2022-03-14 21:09:34 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-01-04 16:01:17 +00:00
|
|
|
import {
|
|
|
|
|
assertMigrationState,
|
|
|
|
|
findSplitOperation,
|
|
|
|
|
ShardSplitTest
|
|
|
|
|
} from "jstests/serverless/libs/shard_split_test.js";
|
2022-03-14 21:09:34 +00:00
|
|
|
|
2022-11-18 23:04:18 +00:00
|
|
|
const tenantIds = [ObjectId(), ObjectId()];
|
2022-11-07 15:54:21 +00:00
|
|
|
const test = new ShardSplitTest({quickGarbageCollection: true});
|
2022-03-14 21:09:34 +00:00
|
|
|
test.addRecipientNodes();
|
|
|
|
|
test.donor.awaitSecondaryNodes();
|
|
|
|
|
|
2022-06-02 17:56:32 +00:00
|
|
|
const donorPrimary = test.getDonorPrimary();
|
2022-04-12 13:54:25 +00:00
|
|
|
const operation = test.createSplitOperation(tenantIds);
|
2022-12-19 14:02:29 +00:00
|
|
|
const result = assert.commandWorked(operation.commit());
|
2022-06-02 17:56:32 +00:00
|
|
|
assertMigrationState(donorPrimary, operation.migrationId, "committed");
|
2022-12-19 14:02:29 +00:00
|
|
|
|
|
|
|
|
// Confirm blockOpTime in result matches the state document before forgetting the operation
|
|
|
|
|
const stateDoc = findSplitOperation(donorPrimary, operation.migrationId);
|
|
|
|
|
assert.eq(stateDoc.blockOpTime.ts, result.blockOpTime.ts);
|
|
|
|
|
|
2022-04-12 13:54:25 +00:00
|
|
|
operation.forget();
|
2022-03-30 12:44:27 +00:00
|
|
|
|
2022-06-02 17:56:32 +00:00
|
|
|
const status = donorPrimary.adminCommand({serverStatus: 1});
|
|
|
|
|
assert.eq(status.shardSplits.totalCommitted, 1);
|
|
|
|
|
assert.eq(status.shardSplits.totalAborted, 0);
|
|
|
|
|
assert.gt(status.shardSplits.totalCommittedDurationMillis, 0);
|
|
|
|
|
assert.gt(status.shardSplits.totalCommittedDurationWithoutCatchupMillis, 0);
|
2022-03-14 21:09:34 +00:00
|
|
|
|
2022-06-02 17:56:32 +00:00
|
|
|
test.cleanupSuccesfulCommitted(operation.migrationId, tenantIds);
|
2022-03-14 21:09:34 +00:00
|
|
|
test.stop();
|