diff options
Diffstat (limited to 'jstests/replsets/libs/election_handoff.js')
-rw-r--r-- | jstests/replsets/libs/election_handoff.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/jstests/replsets/libs/election_handoff.js b/jstests/replsets/libs/election_handoff.js index 6bb903c1b2c..b81aca51363 100644 --- a/jstests/replsets/libs/election_handoff.js +++ b/jstests/replsets/libs/election_handoff.js @@ -10,13 +10,19 @@ var ElectionHandoffTest = (function() { load("jstests/replsets/rslib.js"); const kStepDownPeriodSecs = 30; + const kSIGTERM = 15; /** * Exercises and validates an election handoff scenario by stepping down the primary and * ensuring that the node at "expectedCandidateId" is stepped up in its place. The desired * configuration of the replica set is passed in as its ReplSetTest instance. + * + * The options parameter contains extra options for the handoff. Currently supported options + * are: + * stepDownBySignal - When this option is set, the primary will be stepped down by stopping + * and restarting with sigterm, rather than with a replSetStepDown command */ - function testElectionHandoff(rst, initialPrimaryId, expectedCandidateId) { + function testElectionHandoff(rst, initialPrimaryId, expectedCandidateId, options = {}) { const config = rst.getReplSetConfigFromNode(); const numNodes = config.members.length; const memberInfo = config.members[expectedCandidateId]; @@ -50,10 +56,15 @@ var ElectionHandoffTest = (function() { rst.awaitNodesAgreeOnAppliedOpTime(); // Step down the current primary. - assert.adminCommandWorkedAllowingNetworkError(primary, { - replSetStepDown: kStepDownPeriodSecs, - secondaryCatchUpPeriodSecs: kStepDownPeriodSecs / 2 - }); + if (options["stepDownBySignal"]) { + rst.stop(initialPrimaryId, kSIGTERM, {}, {forRestart: true}); + rst.start(initialPrimaryId, {}, true); + } else { + assert.adminCommandWorkedAllowingNetworkError(primary, { + replSetStepDown: kStepDownPeriodSecs, + secondaryCatchUpPeriodSecs: kStepDownPeriodSecs / 2 + }); + } jsTestLog(`Checking that the secondary with id ${expectedCandidateId} is stepped up...`); @@ -77,4 +88,4 @@ var ElectionHandoffTest = (function() { return {testElectionHandoff: testElectionHandoff, stepDownPeriodSecs: kStepDownPeriodSecs}; -})();
\ No newline at end of file +})(); |