0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/jstests/noPassthrough/wt_disable_majority_reads.js

33 lines
1.0 KiB
JavaScript
Raw Normal View History

// @tags: [requires_wiredtiger, requires_replication]
(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();
})();