summaryrefslogtreecommitdiff
path: root/jstests/serverless/shard_split_invalid_inputs.js
blob: 11b25eeedf143548e59128f5bbae98a4e3850c84 (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
/**
 * Tests that the commitShardSplit commands throw an error if the provided
 * tenantId is unsupported (i.e. '', 'admin', 'local' or 'config') or if there is no recipient node.
 *
 * @tags: [
 *   incompatible_with_eft,
 *   incompatible_with_macos,
 *   incompatible_with_windows_tls,
 *   requires_persistence,
 *   requires_fcv_62,
 *   serverless,
 * ]
 */

import {ShardSplitTest} from "jstests/serverless/libs/shard_split_test.js";

const test =
    new ShardSplitTest({recipientSetName: "recipientSet", recipientTagName: "recipientTag"});

const donorPrimary = test.donor.getPrimary();

const tenantId = ObjectId();

jsTestLog("Testing 'commitShardSplit' command without recipient nodes.");

assert.commandFailedWithCode(donorPrimary.adminCommand({
    commitShardSplit: 1,
    migrationId: UUID(),
    tenantIds: [tenantId],
    recipientSetName: test.recipientSetName,
    recipientTagName: test.recipientTagName
}),
                             ErrorCodes.TenantMigrationAborted);

test.addRecipientNodes();

jsTestLog("Testing 'commitShardSplit' with unsupported tenantIds.");
const unsupportedtenantIds = ['admin', 'admin', 'local', 'config'];
unsupportedtenantIds.forEach((invalidTenantId) => {
    const operation = test.createSplitOperation([invalidTenantId]);
    assert.commandFailedWithCode(operation.commit(), ErrorCodes.BadValue);
});

test.stop();