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
52
53
54
55
56
57
58
59
|
/**
* Test that a heartbeat reconfig propagated from the primary to a new secondary
* successfully sets the default write concern on the secondary. To do this, we start either a PSS
* or PSA replica set. We then add a fourth secondary to the replica set, and verify that it sets
* its implicit default write concern correctly. We don't test cases with cluster-wide write concern
* set, because then the secondary won't set its implicit default write concern from a heartbeat
* reconfig.
* @tags: [
* ]
*/
(function() {
'use strict';
load("jstests/replsets/rslib.js");
function runTest(hasArbiter) {
jsTestLog("Running test with hasArbiter: " + tojson(hasArbiter));
let replSetNodes = 3;
if (hasArbiter) {
replSetNodes = [{}, {}, {arbiter: true}];
}
const rst = new ReplSetTest({
nodes: replSetNodes,
});
rst.startSet();
rst.initiate();
const primary = rst.getPrimary();
const newSecondary = rst.add();
assert.soon(() => isConfigCommitted(primary));
const config = rst.getReplSetConfigFromNode();
config.members.push({_id: 3, host: newSecondary.host});
config.version++;
assert.commandWorked(primary.adminCommand({replSetReconfig: config}));
assert.soon(() => isConfigCommitted(primary));
rst.waitForConfigReplication(primary);
rst.awaitReplication();
let res = assert.commandWorked(newSecondary.adminCommand({getDefaultRWConcern: 1}));
// A PSS set will have a default write concern of {w: "majority"}. A PSA set will have a default
// write concern of {w: 1}.
if (hasArbiter) {
assert(!res.defaultWriteConcern, tojson(res));
} else {
assert.eq(res.defaultWriteConcern, {w: "majority", wtimeout: 0}, tojson(res));
}
assert.eq(res.defaultWriteConcernSource, "implicit", tojson(res));
rst.stopSet();
}
runTest(false /* hasArbiter */);
runTest(true /* hasArbiter */);
})();
|