summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/two_phase_index_build_ops_disabled_through_applyops.js
blob: ae6b035e0895af93bf7fa010d508a89364abddc7 (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
/**
 * Ensures that oplog entries specific to two-phase index builds are not allow when run through
 * applyOps.
 *
 * @tags: [
 *   requires_replication,
 * ]
 */

(function() {

const replSet = new ReplSetTest({
    nodes: [
        {},
        {
            // Disallow elections on secondary.
            rsConfig: {
                priority: 0,
                votes: 0,
            },
        },
    ]
});

replSet.startSet();
replSet.initiate();

const testDB = replSet.getPrimary().getDB('test');
const coll = testDB.twoPhaseIndexBuild;
const cmdNs = testDB.getName() + ".$cmd";

coll.insert({a: 1});

assert.commandFailedWithCode(testDB.adminCommand({
    applyOps: [{op: "c", ns: cmdNs, o: {startIndexBuild: coll.getName(), key: {a: 1}, name: 'a_1'}}]
}),
                             [ErrorCodes.CommandNotSupported, ErrorCodes.FailedToParse]);

assert.commandFailedWithCode(testDB.adminCommand({
    applyOps:
        [{op: "c", ns: cmdNs, o: {commitIndexBuild: coll.getName(), key: {a: 1}, name: 'a_1'}}]
}),
                             [ErrorCodes.CommandNotSupported, ErrorCodes.FailedToParse]);

assert.commandFailedWithCode(testDB.adminCommand({
    applyOps: [{op: "c", ns: cmdNs, o: {abortIndexBuild: coll.getName(), key: {a: 1}, name: 'a_1'}}]
}),
                             [ErrorCodes.CommandNotSupported, ErrorCodes.FailedToParse]);

replSet.stopSet();
})();