diff options
author | Medha Potluri <medha.potluri@mongodb.com> | 2019-08-07 15:25:21 -0400 |
---|---|---|
committer | Medha Potluri <medha.potluri@mongodb.com> | 2019-08-13 13:34:56 -0400 |
commit | ee47f663b7473b0b56b401922a532e809c516a50 (patch) | |
tree | 47497bad14ad8f5722bf395f046d67283d258cbd /jstests/replsets | |
parent | 6e3fd1902f1977d6372c6fdfab4fd9ab73c89aea (diff) | |
download | mongo-ee47f663b7473b0b56b401922a532e809c516a50.tar.gz |
SERVER-41507 Track the time the new term oplog entry was written in replSetStatus on primaries
Diffstat (limited to 'jstests/replsets')
-rw-r--r-- | jstests/replsets/catchup.js | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/jstests/replsets/catchup.js b/jstests/replsets/catchup.js index d6bd38af46e..9a837346c33 100644 --- a/jstests/replsets/catchup.js +++ b/jstests/replsets/catchup.js @@ -133,11 +133,34 @@ initialNewPrimaryStatus = var stepUpResults = stopReplicationAndEnforceNewPrimaryToCatchUp(); +// Check that the 'electionCandidateMetrics' section of the replSetGetStatus response does not have +// a 'newTermStartDate' field before the transition to primary is complete. +res = assert.commandWorked(stepUpResults.newPrimary.adminCommand({replSetGetStatus: 1})); +assert(res.electionCandidateMetrics, + () => "Response should have an 'electionCandidateMetrics' field: " + tojson(res)); +assert(!res.electionCandidateMetrics.newTermStartDate, + () => "Response should not have an 'electionCandidateMetrics.newTermStartDate' field: " + + tojson(res.electionCandidateMetrics)); + // Disable fail point to allow replication. restartServerReplication(stepUpResults.oldSecondaries); // getPrimary() blocks until the primary finishes drain mode. assert.eq(stepUpResults.newPrimary, rst.getPrimary()); +// Wait until the new primary completes the transition to primary and writes a no-op. +checkLog.contains(stepUpResults.newPrimary, "transition to primary complete"); +// Check that the new primary's term has been updated because of the no-op. +assert.eq(getLatestOp(stepUpResults.newPrimary).t, stepUpResults.latestOpOnNewPrimary.t + 1); + +// Check that the 'electionCandidateMetrics' section of the replSetGetStatus response has a +// 'newTermStartDate' field once the transition to primary is complete. +res = assert.commandWorked(stepUpResults.newPrimary.adminCommand({replSetGetStatus: 1})); +assert(res.electionCandidateMetrics, + () => "Response should have an 'electionCandidateMetrics' field: " + tojson(res)); +assert(res.electionCandidateMetrics.newTermStartDate, + () => "Response should have an 'electionCandidateMetrics.newTermStartDate' field: " + + tojson(res.electionCandidateMetrics)); + // Check that the 'numCatchUps' field has been incremented in serverStatus. newNewPrimaryStatus = assert.commandWorked(stepUpResults.newPrimary.adminCommand({serverStatus: 1})); @@ -152,9 +175,6 @@ verifyCatchUpConclusionReason(initialNewPrimaryStatus.electionMetrics, // 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)); |