summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/wt_disable_majority_reads.js
blob: d4b0d66e7b928bdd576d8629b2f57b178c542b3b (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
// @tags: [requires_wiredtiger]
(function() {
    "use strict";

    var rst = new ReplSetTest({
        nodes: [
            {"enableMajorityReadConcern": ""},
            {"enableMajorityReadConcern": "false"},
            {"enableMajorityReadConcern": "true"}
        ]
    });
    rst.startSet();
    rst.initiate();
    rst.awaitSecondaryNodes();

    rst.getPrimary().getDB("test").getCollection("test").insert({});
    rst.awaitReplication();

    // Node 0 is using the default, which is `enableMajorityReadConcern: true`. Thus a majority
    // read should succeed.
    assert.commandWorked(rst.nodes[0].getDB("test").runCommand(
        {"find": "test", "readConcern": {"level": "majority"}}));
    // Node 1 disables majority reads. Check for the appropriate error code.
    assert.commandFailedWithCode(rst.nodes[1].getDB("test").runCommand(
                                     {"find": "test", "readConcern": {"level": "majority"}}),
                                 ErrorCodes.ReadConcernMajorityNotEnabled);
    // Same as Node 0.
    assert.commandWorked(rst.nodes[2].getDB("test").runCommand(
        {"find": "test", "readConcern": {"level": "majority"}}));

    rst.stopSet();
})();