2018-06-25 20:38:41 +02:00
|
|
|
/**
|
|
|
|
* This is a basic test that checks that, with election handoff enabled, a primary that steps down
|
|
|
|
* sends a ReplSetStepUp request to an eligible candidate. This test uses a three-node replica
|
|
|
|
* set, where one of the secondaries is unelectable, so the test expects the other one to get
|
|
|
|
* chosen for election handoff.
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
2019-07-27 00:20:35 +02:00
|
|
|
"use strict";
|
|
|
|
load("jstests/replsets/libs/election_handoff.js");
|
2018-06-25 20:38:41 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
const testName = "election_handoff_one_unelectable";
|
|
|
|
const numNodes = 3;
|
|
|
|
const rst = ReplSetTest({name: testName, nodes: numNodes});
|
|
|
|
const nodes = rst.nodeList();
|
|
|
|
rst.startSet();
|
2018-06-25 20:38:41 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
const config = rst.getReplSetConfig();
|
|
|
|
config.members[1].priority = 0;
|
2018-06-25 20:38:41 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
// Make sure there are no election timeouts firing for the duration of the test. This helps
|
|
|
|
// ensure that the test will only pass if the election handoff succeeds.
|
|
|
|
config.settings = {
|
|
|
|
"electionTimeoutMillis": 12 * 60 * 60 * 1000
|
|
|
|
};
|
|
|
|
rst.initiate(config);
|
2018-06-25 20:38:41 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
ElectionHandoffTest.testElectionHandoff(rst, 0, 2);
|
2018-06-25 20:38:41 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
rst.stopSet();
|
2018-06-25 20:38:41 +02:00
|
|
|
})();
|