summaryrefslogtreecommitdiff
path: root/jstests/replsets/election_handoff_higher_priority.js
diff options
context:
space:
mode:
authorVesselina Ratcheva <vesselina.ratcheva@10gen.com>2018-06-25 14:38:41 -0400
committerVesselina Ratcheva <vesselina.ratcheva@10gen.com>2018-07-12 15:52:05 -0400
commit069e6f06b4e0faef45661ac043c7a4ebcf026d96 (patch)
treee1e6b7a404227320360d7ded76d11e0f2bd52141 /jstests/replsets/election_handoff_higher_priority.js
parent2e975546f4676e1ba65e3376c08bd43bee14305f (diff)
downloadmongo-069e6f06b4e0faef45661ac043c7a4ebcf026d96.tar.gz
SERVER-35623 Send a replSetStepUp command to an eligible candidate on stepdown
Diffstat (limited to 'jstests/replsets/election_handoff_higher_priority.js')
-rw-r--r--jstests/replsets/election_handoff_higher_priority.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/jstests/replsets/election_handoff_higher_priority.js b/jstests/replsets/election_handoff_higher_priority.js
new file mode 100644
index 00000000000..78a866a1201
--- /dev/null
+++ b/jstests/replsets/election_handoff_higher_priority.js
@@ -0,0 +1,31 @@
+/**
+ * This is a test that checks that, with election handoff is 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 has a higher priority than the other. The test
+ * expects that that secondary gets chosen as the election handoff candidate.
+ */
+
+(function() {
+ "use strict";
+ load("jstests/replsets/libs/election_handoff.js");
+
+ const testName = "election_handoff_higher_priority";
+ const numNodes = 3;
+ const rst = ReplSetTest({name: testName, nodes: numNodes});
+ const nodes = rst.nodeList();
+ rst.startSet();
+
+ const config = rst.getReplSetConfig();
+ config.members[0].priority = 3;
+ config.members[1].priority = 1;
+ config.members[2].priority = 2;
+
+ // 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);
+
+ ElectionHandoffTest.testElectionHandoff(rst, 0, 2);
+
+ rst.stopSet();
+})(); \ No newline at end of file