diff options
author | Medha Potluri <medha.potluri@mongodb.com> | 2019-07-08 14:59:41 -0400 |
---|---|---|
committer | Medha Potluri <medha.potluri@mongodb.com> | 2019-07-29 10:44:09 -0400 |
commit | 2ae4fd3e580c90ecfca524d02b9a484f671768f0 (patch) | |
tree | 6a64bf9c1aa9f7e0b470774ee5fde950bd130cd0 /jstests/replsets | |
parent | 102c20ab166050ae7357732070bc8262aa61749c (diff) | |
download | mongo-2ae4fd3e580c90ecfca524d02b9a484f671768f0.tar.gz |
SERVER-41509 Track the number of attempted stepDowns in serverStatus
Diffstat (limited to 'jstests/replsets')
-rw-r--r-- | jstests/replsets/stepdown.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/jstests/replsets/stepdown.js b/jstests/replsets/stepdown.js index ecba409427f..7ff4142314f 100644 --- a/jstests/replsets/stepdown.js +++ b/jstests/replsets/stepdown.js @@ -6,6 +6,7 @@ * @tags: [requires_fsync] */ +load("jstests/replsets/libs/election_metrics.js"); load("jstests/replsets/rslib.js"); // We are bypassing collection validation because this test runs "shutdown" command so the server is @@ -60,6 +61,8 @@ try { assert.writeOK(master.getDB("foo").bar.insert({x: i})); } + const intitialServerStatus = assert.commandWorked(master.adminCommand({serverStatus: 1})); + jsTestLog('Do stepdown of primary ' + master + ' that should not work'); // this should fail, so we don't need to try/catch @@ -67,10 +70,34 @@ try { 'Step down ' + master + ' expected error: ' + tojson(assert.commandFailed(master.getDB("admin").runCommand({replSetStepDown: 10})))); + // Check that the 'total' field of 'replSetStepDown' has been incremented in serverStatus and + // that it has not been incremented for 'replSetStepDownWithForce'. + let newServerStatus = assert.commandWorked(master.adminCommand({serverStatus: 1})); + verifyServerStatusChange(intitialServerStatus.metrics.commands.replSetStepDown, + newServerStatus.metrics.commands.replSetStepDown, + "total", + 1); + verifyServerStatusChange(intitialServerStatus.metrics.commands.replSetStepDownWithForce, + newServerStatus.metrics.commands.replSetStepDownWithForce, + "total", + 0); + jsTestLog('Do stepdown of primary ' + master + ' that should work'); assert.commandWorked( master.adminCommand({replSetStepDown: ReplSetTest.kDefaultTimeoutMS, force: true})); + // Check that the 'total' fields of 'replSetStepDown' and 'replSetStepDownWithForce' have been + // incremented in serverStatus. + newServerStatus = assert.commandWorked(master.adminCommand({serverStatus: 1})); + verifyServerStatusChange(intitialServerStatus.metrics.commands.replSetStepDown, + newServerStatus.metrics.commands.replSetStepDown, + "total", + 2); + verifyServerStatusChange(intitialServerStatus.metrics.commands.replSetStepDownWithForce, + newServerStatus.metrics.commands.replSetStepDownWithForce, + "total", + 1); + jsTestLog('Checking isMaster on ' + master); var r2 = assert.commandWorked(master.getDB("admin").runCommand({ismaster: 1})); jsTestLog('Result from running isMaster on ' + master + ': ' + tojson(r2)); |