summaryrefslogtreecommitdiff
path: root/jstests/replsets/get_default_write_concern_majority.js
blob: 619b4d9ccb812e52d9d4989c1dae9941ae7edb80 (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
/**
 * This tests the behavior of changing the default write concern to the implicit default if there is
 * no CWWC.
 * @tags: [
 * ]
 */
(function() {
'use strict';
load("jstests/libs/write_concern_util.js");  // For isDefaultWriteConcernMajorityFlagEnabled.

jsTestLog("Test PSS configuration will set defaultWC to majority.");
let replTest = new ReplSetTest({name: 'default_wc_majority', nodes: 3});
replTest.startSet();
replTest.initiate();
let primary = replTest.getPrimary();

let res = assert.commandWorked(primary.adminCommand({getDefaultRWConcern: 1}));
if (isDefaultWriteConcernMajorityFlagEnabled(primary)) {
    assert(res.hasOwnProperty("defaultWriteConcern"));
    assert.eq({w: "majority", wtimeout: 0}, res.defaultWriteConcern, tojson(res));
} else {
    assert(!res.hasOwnProperty("defaultWriteConcern"));
}

replTest.stopSet();

jsTestLog("Test PSA configuration will set defaultWC to {w:1}.");
replTest = new ReplSetTest({name: 'default_wc_w_1', nodes: [{}, {}, {arbiter: true}]});
replTest.startSet();
replTest.initiate();
primary = replTest.getPrimary();

res = assert.commandWorked(primary.adminCommand({getDefaultRWConcern: 1}));
assert(!res.hasOwnProperty("defaultWriteConcern"));

replTest.stopSet();
})();