diff options
author | Medha Potluri <medha.potluri@mongodb.com> | 2019-07-09 15:02:13 -0400 |
---|---|---|
committer | Medha Potluri <medha.potluri@mongodb.com> | 2019-08-13 12:28:28 -0400 |
commit | d14ee9513924f63572324debc7721ca2ef93c22f (patch) | |
tree | bd9f1c5a1f5e2ca40287d8e2731b94dde91133ce /jstests/replsets/catchup.js | |
parent | 0265512bc30a8f45231bb02e63ce3251e9d185dd (diff) | |
download | mongo-d14ee9513924f63572324debc7721ca2ef93c22f.tar.gz |
SERVER-41503 Track the target opTime for catchup in replSetStatus on primaries
Diffstat (limited to 'jstests/replsets/catchup.js')
-rw-r--r-- | jstests/replsets/catchup.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/jstests/replsets/catchup.js b/jstests/replsets/catchup.js index 6657e6b9076..d6bd38af46e 100644 --- a/jstests/replsets/catchup.js +++ b/jstests/replsets/catchup.js @@ -118,6 +118,15 @@ verifyCatchUpConclusionReason(initialNewPrimaryStatus.electionMetrics, newNewPrimaryStatus.electionMetrics, 'numCatchUpsAlreadyCaughtUp'); +// Check that the 'electionCandidateMetrics' section of the replSetGetStatus response does not have +// a 'targetCatchupOpTime' field if the target opTime for catchup is not set. +let res = assert.commandWorked(newPrimary.adminCommand({replSetGetStatus: 1})); +assert(res.electionCandidateMetrics, + () => "Response should have an 'electionCandidateMetrics' field: " + tojson(res)); +assert(!res.electionCandidateMetrics.targetCatchupOpTime, + () => "Response should not have an 'electionCandidateMetrics.targetCatchupOpTime' field: " + + tojson(res.electionCandidateMetrics)); + jsTest.log("Case 2: The primary needs to catch up, succeeds in time."); initialNewPrimaryStatus = assert.commandWorked(rst.getSecondaries()[0].adminCommand({serverStatus: 1})); @@ -140,6 +149,19 @@ verifyCatchUpConclusionReason(initialNewPrimaryStatus.electionMetrics, newNewPrimaryStatus.electionMetrics, 'numCatchUpsSucceeded'); +// Check that the 'electionCandidateMetrics' section of the replSetGetStatus response has a +// 'targetCatchupOpTime' field once heartbeats have updated the target opTime for catchup, and that +// it has the correct value. +res = assert.commandWorked(stepUpResults.newPrimary.adminCommand({replSetGetStatus: 1})); +assert(res.electionCandidateMetrics, + () => "Response should have an 'electionCandidateMetrics' field: " + tojson(res)); +assert(res.electionCandidateMetrics.targetCatchupOpTime, + () => "Response should have an 'electionCandidateMetrics.targetCatchupOpTime' field: " + + tojson(res.electionCandidateMetrics)); +assert.eq(res.electionCandidateMetrics.targetCatchupOpTime.ts, + stepUpResults.latestOpOnOldPrimary.ts); +assert.eq(res.electionCandidateMetrics.targetCatchupOpTime.t, stepUpResults.latestOpOnOldPrimary.t); + // Wait for all secondaries to catch up rst.awaitReplication(); // Check the latest op on old primary is preserved on the new one. |