summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuerui Fa <xuerui.fa@mongodb.com>2020-04-17 13:28:51 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-05 14:34:48 +0000
commit424b2cd6118a919f3e780c37ed59c570e525e8fe (patch)
treed412396f10d642c3088e2a5778624f0dbe7ff7ce
parent9b2e44368a14930dc4c9e57b87be64115c4c45f1 (diff)
downloadmongo-424b2cd6118a919f3e780c37ed59c570e525e8fe.tar.gz
SERVER-47634: Make metrics test in stepup.js more robust
(cherry picked from commit 321cb6f478bd1969ef4c7a90b210a21272354f41)
-rw-r--r--jstests/replsets/stepup.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/jstests/replsets/stepup.js b/jstests/replsets/stepup.js
index 026f26332b1..e8b9d38b5de 100644
--- a/jstests/replsets/stepup.js
+++ b/jstests/replsets/stepup.js
@@ -36,8 +36,11 @@ assert.commandWorked(
// Wait for the secondary to catch up by replicating a doc to both nodes.
assert.writeOK(primary.getDB("test").bar.insert({x: 3}, {writeConcern: {w: "majority"}}));
-// Step up the secondary. Retry since the old primary may step down when we try to ask for its vote.
+// Step up the secondary. Retry since the old primary may step down when we try to ask for its
+// vote.
+let numStepUpCmds = 0;
assert.soonNoExcept(function() {
+ numStepUpCmds++;
return secondary.adminCommand({replSetStepUp: 1}).ok;
});
@@ -49,8 +52,10 @@ const newSecondaryStatus = assert.commandWorked(secondary.adminCommand({serverSt
// Check that both the 'called' and 'successful' fields of stepUpCmd have been incremented in
// serverStatus, and that they have not been incremented in any of the other election reason
// counters.
-verifyServerStatusElectionReasonCounterChange(
- initialSecondaryStatus.electionMetrics, newSecondaryStatus.electionMetrics, "stepUpCmd", 1);
+verifyServerStatusElectionReasonCounterChange(initialSecondaryStatus.electionMetrics,
+ newSecondaryStatus.electionMetrics,
+ "stepUpCmd",
+ numStepUpCmds);
verifyServerStatusElectionReasonCounterChange(initialSecondaryStatus.electionMetrics,
newSecondaryStatus.electionMetrics,
"priorityTakeover",