diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:17:50 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2016-03-09 12:18:14 -0500 |
commit | 4ae691e8edc87d0e3cfb633bb91c328426be007b (patch) | |
tree | 52079a593f54382ca13a2e741633eab1b6271893 /jstests/replsets/drain.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/replsets/drain.js')
-rw-r--r-- | jstests/replsets/drain.js | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/jstests/replsets/drain.js b/jstests/replsets/drain.js index 95472471f48..5d20ff6a9d6 100644 --- a/jstests/replsets/drain.js +++ b/jstests/replsets/drain.js @@ -9,17 +9,19 @@ // 7. Enable applying ops. // 8. Ensure the ops in queue are applied and that the PRIMARY begins to accept writes as usual. -(function () { +(function() { "use strict"; var replSet = new ReplSetTest({name: 'testSet', nodes: 3}); var nodes = replSet.nodeList(); replSet.startSet(); - replSet.initiate({"_id" : "testSet", - "members" : [ - {"_id" : 0, "host" : nodes[0]}, - {"_id" : 1, "host" : nodes[1]}, - {"_id" : 2, "host" : nodes[2], "arbiterOnly" : true}]}); - + replSet.initiate({ + "_id": "testSet", + "members": [ + {"_id": 0, "host": nodes[0]}, + {"_id": 1, "host": nodes[1]}, + {"_id": 2, "host": nodes[2], "arbiterOnly": true} + ] + }); var primary = replSet.getPrimary(); var secondary = replSet.getSecondary(); @@ -28,18 +30,16 @@ // Do an initial insert to prevent the secondary from going into recovery var numDocuments = 20; var bulk = primary.getDB("foo").foo.initializeUnorderedBulkOp(); - var bigString = Array(1024*1024).toString(); - assert.writeOK(primary.getDB("foo").foo.insert({ big: bigString})); + var bigString = Array(1024 * 1024).toString(); + assert.writeOK(primary.getDB("foo").foo.insert({big: bigString})); replSet.awaitReplication(); - assert.commandWorked( - secondary.getDB("admin").runCommand({ - configureFailPoint: 'rsSyncApplyStop', - mode: 'alwaysOn'}), - 'failed to enable fail point on secondary'); + assert.commandWorked(secondary.getDB("admin").runCommand( + {configureFailPoint: 'rsSyncApplyStop', mode: 'alwaysOn'}), + 'failed to enable fail point on secondary'); var bufferCountBefore = secondary.getDB('foo').serverStatus().metrics.repl.buffer.count; for (var i = 1; i < numDocuments; ++i) { - bulk.insert({ big: bigString}); + bulk.insert({big: bigString}); } assert.writeOK(bulk.execute()); jsTestLog('Number of documents inserted into collection on primary: ' + numDocuments); @@ -50,19 +50,19 @@ var bufferCount = serverStatus.metrics.repl.buffer.count; var bufferCountChange = bufferCount - bufferCountBefore; jsTestLog('Number of operations buffered on secondary since stopping applier: ' + - bufferCountChange); + bufferCountChange); return bufferCountChange >= numDocuments - 1; }, 'secondary did not buffer operations for new inserts on primary', 30000, 1000); // Kill primary; secondary will enter drain mode to catch up - primary.getDB("admin").shutdownServer({force:true}); + primary.getDB("admin").shutdownServer({force: true}); - var electionTimeout = (isPV0 ? 60 : 20 ) * 1000; // Timeout in milliseconds + var electionTimeout = (isPV0 ? 60 : 20) * 1000; // Timeout in milliseconds replSet.waitForState(secondary, ReplSetTest.State.PRIMARY, electionTimeout); // Ensure new primary is not yet writable jsTestLog('New primary should not be writable yet'); - assert.writeError(secondary.getDB("foo").flag.insert({sentinel:2})); + assert.writeError(secondary.getDB("foo").flag.insert({sentinel: 2})); assert(!secondary.getDB("admin").runCommand({"isMaster": 1}).ismaster); // Ensure new primary is not yet readable without slaveOk bit. @@ -70,14 +70,16 @@ jsTestLog('New primary should not be readable yet, without slaveOk bit'); var res = secondary.getDB("foo").runCommand({find: "foo"}); assert.commandFailed(res); - assert.eq(ErrorCodes.NotMasterNoSlaveOk, res.code, - "find failed with unexpected error code: " + tojson(res)); + assert.eq(ErrorCodes.NotMasterNoSlaveOk, + res.code, + "find failed with unexpected error code: " + tojson(res)); // Nor should it be readable with the slaveOk bit. secondary.slaveOk = true; res = secondary.getDB("foo").runCommand({find: "foo"}); assert.commandFailed(res); - assert.eq(ErrorCodes.NotMasterOrSecondary, res.code, - "find failed with unexpected error code: " + tojson(res)); + assert.eq(ErrorCodes.NotMasterOrSecondary, + res.code, + "find failed with unexpected error code: " + tojson(res)); secondary.slaveOk = false; assert.commandFailedWithCode( @@ -86,8 +88,7 @@ waitForDrainFinish: 5000, }), ErrorCodes.ExceededTimeLimit, - 'replSetTest waitForDrainFinish should time out when draining is not allowed to complete' - ); + 'replSetTest waitForDrainFinish should time out when draining is not allowed to complete'); // Allow draining to complete jsTestLog('Disabling fail point on new primary to allow draining to complete'); @@ -95,18 +96,17 @@ secondary.getDB("admin").runCommand({configureFailPoint: 'rsSyncApplyStop', mode: 'off'}), 'failed to disable fail point on new primary'); primary = replSet.getPrimary(); - + assert.commandWorked( secondary.adminCommand({ replSetTest: 1, waitForDrainFinish: 5000, }), - 'replSetTest waitForDrainFinish should work when draining is allowed to complete' - ); + 'replSetTest waitForDrainFinish should work when draining is allowed to complete'); // Ensure new primary is writable jsTestLog('New primary should be writable after draining is complete'); - assert.writeOK(primary.getDB("foo").flag.insert({sentinel:1})); + assert.writeOK(primary.getDB("foo").flag.insert({sentinel: 1})); // Check for at least two entries. There was one prior to freezing op application on the // secondary and we cannot guarantee all writes reached the secondary's op queue prior to // shutting down the original primary. |