summaryrefslogtreecommitdiff
path: root/jstests/replsets/reconfig_ignores_term_field.js
blob: 2cc48ac950d0f7bfd007d82f6100117b56b7cdb4 (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
/*
 * Test that replSetReconfig ignores the term value provided by a user.
 *
 * @tags: [requires_fcv_44]
 */

(function() {

// Start a 2 node replica set where one of the nodes has priority 0 to
// prevent unnecessary elections.
var replTest = new ReplSetTest({nodes: 1});
var nodes = replTest.startSet();
replTest.initiate();

// After the first election, the term should be 1.
var primary = replTest.getPrimary();

jsTestLog("Reconfig command ignores user provided term, 50");
var config = primary.getDB("local").system.replset.findOne();
printjson(config);
config.version++;
config.members[nodes.indexOf(primary)].priority = 1;  // Legal reconfig.
config.term = 50;
assert.commandWorked(primary.getDB("admin").runCommand({replSetReconfig: config}));
replTest.awaitReplication();

config = primary.getDB("local").system.replset.findOne();
assert.eq(config.term, 1);
replTest.stopSet();
}());