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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
/**
* Checks that setClusterParameter behaves as expected during initial sync and restart.
*
* @tags: [
* # Requires all nodes to be running the latest binary.
* requires_fcv_60,
* featureFlagClusterWideConfig,
* does_not_support_stepdowns
* ]
*/
(function() {
'use strict';
load('jstests/libs/cluster_server_parameter_utils.js');
// Checks that up-to-date cluster parameters are transferred over to newly-added replica set nodes
// as part of initial sync.
function checkClusterParameterInitialSync(rst) {
// Update some parameter values.
let newIntParameter = {
_id: "testIntClusterParameter",
intData: 5,
};
let newStrParameter = {
_id: "testStrClusterParameter",
strData: "on",
};
runSetClusterParameter(rst.getPrimary(), newIntParameter);
runSetClusterParameter(rst.getPrimary(), newStrParameter);
// Check that the new values are visible on the majority of the nodes.
runGetClusterParameterReplicaSet(rst,
["testIntClusterParameter", "testStrClusterParameter"],
[newIntParameter, newStrParameter]);
// Add a new node to the replica set, reinitiate the set, and wait for it to become a secondary
// with all data fully replicated to it.
const newNode = rst.add({});
rst.reInitiate();
rst.waitForState(newNode, ReplSetTest.State.SECONDARY);
rst.awaitReplication();
// Check that the new node has the latest cluster parameter values.
runGetClusterParameterNode(newNode,
["testIntClusterParameter", "testStrClusterParameter"],
[newIntParameter, newStrParameter]);
// Check that setClusterParameter properly works with the reconfigured replica set.
newIntParameter.intData = 30;
newStrParameter.strData = "sleep";
runSetClusterParameter(rst.getPrimary(), newIntParameter);
runSetClusterParameter(rst.getPrimary(), newStrParameter);
// Check that the new values are visible on the majority of the nodes.
runGetClusterParameterReplicaSet(rst,
["testIntClusterParameter", "testStrClusterParameter"],
[newIntParameter, newStrParameter]);
}
// Checks that restarted replica sets start with the most recent majority-written cluster parameter
// values.
function checkClusterParameterRestart(rst) {
// Update some parameter values.
let newIntParameter = {
_id: "testIntClusterParameter",
intData: 8,
};
let newStrParameter = {
_id: "testStrClusterParameter",
strData: "dormant",
};
runSetClusterParameter(rst.getPrimary(), newIntParameter);
runSetClusterParameter(rst.getPrimary(), newStrParameter);
// Check that the new values are visible on the majority of the nodes.
runGetClusterParameterReplicaSet(rst,
["testIntClusterParameter", "testStrClusterParameter"],
[newIntParameter, newStrParameter]);
// Bounce restart all of the nodes.
rst.nodeList().forEach((_, index) => {
rst.restart(index);
});
// Check that restarted replica set still has the most recent setClusterParameter values.
runGetClusterParameterReplicaSet(rst,
["testIntClusterParameter", "testStrClusterParameter"],
[newIntParameter, newStrParameter]);
}
const rst = new ReplSetTest({
nodes: 2,
});
rst.startSet();
rst.initiate();
checkClusterParameterInitialSync(rst);
checkClusterParameterRestart(rst);
rst.stopSet();
})();
|