diff options
author | clang-format-7.0.1 <adam.martin@10gen.com> | 2019-07-26 18:20:35 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2019-07-27 11:02:23 -0400 |
commit | 134a4083953270e8a11430395357fb70a29047ad (patch) | |
tree | dd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/replsets/stepdown3.js | |
parent | 1e46b5049003f427047e723ea5fab15b5a9253ca (diff) | |
download | mongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz |
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/replsets/stepdown3.js')
-rw-r--r-- | jstests/replsets/stepdown3.js | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/jstests/replsets/stepdown3.js b/jstests/replsets/stepdown3.js index f40caabe242..508645cdf5a 100644 --- a/jstests/replsets/stepdown3.js +++ b/jstests/replsets/stepdown3.js @@ -3,49 +3,48 @@ // This test requires the fsync command to force a secondary to be stale. // @tags: [requires_fsync] (function() { - 'use strict'; - - var replTest = new ReplSetTest({name: 'testSet', nodes: 2}); - var nodes = replTest.startSet(); - replTest.initiate(); - var master = replTest.getPrimary(); - - // do a write to allow stepping down of the primary; - // otherwise, the primary will refuse to step down - print("\ndo a write"); - master.getDB("test").foo.insert({x: 1}); - replTest.awaitReplication(); - - // do another write, because the first one might be longer than 10 seconds ago - // on the secondary (due to starting up), and we need to be within 10 seconds - // to step down. - var options = {writeConcern: {w: 2, wtimeout: 30000}}; - assert.writeOK(master.getDB("test").foo.insert({x: 2}, options)); - // lock secondary, to pause replication - print("\nlock secondary"); - var locked = replTest._slaves[0]; - printjson(locked.getDB("admin").runCommand({fsync: 1, lock: 1})); - - // do a write - print("\ndo a write"); - master.getDB("test").foo.insert({x: 3}); - - // step down the primary asyncronously - print("stepdown"); - var command = - "sleep(4000); assert.commandWorked(db.adminCommand( { replSetStepDown : 60, force : 1 } ));"; - var awaitShell = startParallelShell(command, master.port); - - print("getlasterror; should return an error"); - let result = master.getDB("test").runCommand({getLastError: 1, w: 2, wtimeout: 10 * 60 * 1000}); - assert(ErrorCodes.isNotMasterError(result.code)); - print("result of gle:"); - printjson(result); - - awaitShell(); - - // unlock and shut down - printjson(locked.getDB("admin").fsyncUnlock()); - replTest.stopSet(); - +'use strict'; + +var replTest = new ReplSetTest({name: 'testSet', nodes: 2}); +var nodes = replTest.startSet(); +replTest.initiate(); +var master = replTest.getPrimary(); + +// do a write to allow stepping down of the primary; +// otherwise, the primary will refuse to step down +print("\ndo a write"); +master.getDB("test").foo.insert({x: 1}); +replTest.awaitReplication(); + +// do another write, because the first one might be longer than 10 seconds ago +// on the secondary (due to starting up), and we need to be within 10 seconds +// to step down. +var options = {writeConcern: {w: 2, wtimeout: 30000}}; +assert.writeOK(master.getDB("test").foo.insert({x: 2}, options)); +// lock secondary, to pause replication +print("\nlock secondary"); +var locked = replTest._slaves[0]; +printjson(locked.getDB("admin").runCommand({fsync: 1, lock: 1})); + +// do a write +print("\ndo a write"); +master.getDB("test").foo.insert({x: 3}); + +// step down the primary asyncronously +print("stepdown"); +var command = + "sleep(4000); assert.commandWorked(db.adminCommand( { replSetStepDown : 60, force : 1 } ));"; +var awaitShell = startParallelShell(command, master.port); + +print("getlasterror; should return an error"); +let result = master.getDB("test").runCommand({getLastError: 1, w: 2, wtimeout: 10 * 60 * 1000}); +assert(ErrorCodes.isNotMasterError(result.code)); +print("result of gle:"); +printjson(result); + +awaitShell(); + +// unlock and shut down +printjson(locked.getDB("admin").fsyncUnlock()); +replTest.stopSet(); })(); |