2018-09-26 17:26:36 +02:00
|
|
|
// @tags: [requires_wiredtiger, requires_replication]
|
|
|
|
(function() {
|
2019-07-27 00:20:35 +02:00
|
|
|
"use strict";
|
2018-09-26 17:26:36 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var rst = new ReplSetTest({
|
|
|
|
nodes: [
|
|
|
|
{"enableMajorityReadConcern": ""},
|
|
|
|
{"enableMajorityReadConcern": "false"},
|
|
|
|
{"enableMajorityReadConcern": "true"}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
rst.startSet();
|
|
|
|
rst.initiate();
|
|
|
|
rst.awaitSecondaryNodes();
|
2018-09-26 17:26:36 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
rst.getPrimary().getDB("test").getCollection("test").insert({});
|
|
|
|
rst.awaitReplication();
|
2018-09-26 17:26:36 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
// 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"}}));
|
2018-09-26 17:26:36 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
rst.stopSet();
|
2018-09-26 17:26:36 +02:00
|
|
|
})();
|