summaryrefslogtreecommitdiff
path: root/jstests/serverless/shard_split_recipient_removes_access_blockers.js
blob: 5398c8aba0530767f8c1e50cc6d83dd68a6d31d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Test that tenant access blockers are removed when applying the recipient config
 *
 * @tags: [requires_fcv_52, featureFlagShardSplit, serverless]
 */

load("jstests/libs/fail_point_util.js");
load("jstests/serverless/libs/basic_serverless_test.js");

(function() {
"use strict";

// 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 operation = test.createSplitOperation(tenantIds);

const donorAfterBlockingFailpoint =
    configureFailPoint(donorPrimary.getDB("admin"), "pauseShardSplitAfterBlocking");
test.recipientNodes.forEach(
    node => configureFailPoint(node.getDB("admin"), "skipShardSplitRecipientCleanup"));

const commitOp = operation.commitAsync();
donorAfterBlockingFailpoint.wait();

jsTestLog("Asserting recipient nodes have installed access blockers");
assert.soon(() => test.recipientNodes.every(node => {
    const accessBlockers = BasicServerlessTest.getTenantMigrationAccessBlocker({node});
    return tenantIds.every(tenantId => accessBlockers && accessBlockers.hasOwnProperty(tenantId) &&
                               !!accessBlockers[tenantId].donor);
}));
donorAfterBlockingFailpoint.off();

commitOp.join();
assert.commandWorked(commitOp.returnData());

jsTestLog("Asserting recipient nodes have removed access blockers");
assert.soon(() => test.recipientNodes.every(node => {
    return BasicServerlessTest.getTenantMigrationAccessBlocker({node}) == null;
}));

test.stop();
})();