summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamyukta Lanka <samy.lanka@mongodb.com>2019-10-07 01:24:49 +0000
committerevergreen <evergreen@mongodb.com>2019-10-07 01:24:49 +0000
commitb1e94ad7bc13524358199fc1909c356085cf7bcf (patch)
tree73fc2f90f8c77459da444d424a221e2fd9e9343a
parenteee672e434e932b0690d01219278aaf385980cde (diff)
downloadmongo-b1e94ad7bc13524358199fc1909c356085cf7bcf.tar.gz
SERVER-42534 Step down primary for less time in freeze_timeout.js and increase electionTimeoutMillis
(cherry picked from commit 488adcaea8526492411d433229a765d5bd7dd5db)
-rw-r--r--jstests/replsets/freeze_timeout.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/jstests/replsets/freeze_timeout.js b/jstests/replsets/freeze_timeout.js
index 0bf193bbdc6..e883a842d3e 100644
--- a/jstests/replsets/freeze_timeout.js
+++ b/jstests/replsets/freeze_timeout.js
@@ -8,15 +8,17 @@ load('jstests/replsets/libs/election_metrics.js');
jsTestLog('1: initialize single node replica set');
const replSet = new ReplSetTest({name: 'freeze_timeout', nodes: 1});
-const nodes = replSet.startSet();
-const config = replSet.getReplSetConfig();
-replSet.initiate(config);
-replSet.awaitReplication();
+replSet.startSet();
+
+// Increase the election timeout to 24 hours so that elections are not called due to election
+// timeouts, since we need them to be called for the kSingleNodePromptElection election reason.
+replSet.initiateWithHighElectionTimeout();
+
let primary = replSet.getPrimary();
const initialPrimaryStatus = assert.commandWorked(primary.adminCommand({serverStatus: 1}));
jsTestLog('2: step down primary');
-assert.commandWorked(primary.getDB("admin").runCommand({replSetStepDown: 10, force: 1}));
+assert.commandWorked(primary.getDB("admin").runCommand({replSetStepDown: 1, force: 1}));
jsTestLog('3: wait for stepped down node to become primary again');
primary = replSet.getPrimary();
@@ -30,16 +32,12 @@ verifyServerStatusElectionReasonCounterChange(
initialPrimaryStatus.electionMetrics, newPrimaryStatus.electionMetrics, "freezeTimeout", 1);
jsTestLog('4: step down primary again');
-assert.commandWorked(primary.getDB("admin").runCommand({replSetStepDown: 10, force: 1}));
-
-jsTestLog('5: freeze stepped down primary for 30 seconds');
-primary.getDB("admin").runCommand({replSetFreeze: 30});
-sleep(1000);
+assert.commandWorked(primary.getDB("admin").runCommand({replSetStepDown: 30, force: 1}));
-jsTestLog('6: unfreeze stepped down primary after waiting for 1 second');
+jsTestLog('5: unfreeze stepped down primary');
primary.getDB("admin").runCommand({replSetFreeze: 0});
-jsTestLog('7: wait for unfrozen node to become primary again');
+jsTestLog('6: wait for unfrozen node to become primary again');
primary = replSet.getPrimary();
// Check that both the 'called' and 'successful' fields of the 'freezeTimeout' election reason