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/maintenance.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/replsets/maintenance.js')
-rw-r--r-- | jstests/replsets/maintenance.js | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/jstests/replsets/maintenance.js b/jstests/replsets/maintenance.js index 28032383e76..7e49e07e396 100644 --- a/jstests/replsets/maintenance.js +++ b/jstests/replsets/maintenance.js @@ -1,7 +1,7 @@ -var replTest = new ReplSetTest( {name: 'unicomplex', nodes: 2} ); -var conns = replTest.startSet({ verbose: 1 }); +var replTest = new ReplSetTest({name: 'unicomplex', nodes: 2}); +var conns = replTest.startSet({verbose: 1}); var config = replTest.getReplSetConfig(); config.members[0].priority = 2; replTest.initiate(config); @@ -11,17 +11,20 @@ replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60000); var master = replTest.getPrimary(); for (i = 0; i < 20; i++) { - master.getDB("bar").foo.insert({x:1,y:i,abc:123,str:"foo bar baz"}); + master.getDB("bar").foo.insert({x: 1, y: i, abc: 123, str: "foo bar baz"}); } for (i = 0; i < 20; i++) { - master.getDB("bar").foo.update({ y: i }, { $push: { foo: "barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"}}); + master.getDB("bar").foo.update({y: i}, {$push: {foo: "barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"}}); } replTest.awaitReplication(); -assert.soon(function() { return conns[1].getDB("admin").isMaster().secondary; }); +assert.soon(function() { + return conns[1].getDB("admin").isMaster().secondary; +}); -join = startParallelShell( "db.getSisterDB('bar').runCommand({compact : 'foo'});", replTest.ports[1] ); +join = + startParallelShell("db.getSisterDB('bar').runCommand({compact : 'foo'});", replTest.ports[1]); print("joining"); join(); @@ -31,7 +34,8 @@ var secondarySoon = function() { var x = 0; assert.soon(function() { var im = conns[1].getDB("admin").isMaster(); - if (x++ % 5 == 0) printjson(im); + if (x++ % 5 == 0) + printjson(im); return im.secondary; }); }; @@ -41,7 +45,7 @@ secondarySoon(); print("make sure compact works on a secondary (SERVER-3923)"); master.getDB("foo").bar.drop(); replTest.awaitReplication(); -var result = conns[1].getDB("foo").runCommand({compact : "bar"}); +var result = conns[1].getDB("foo").runCommand({compact: "bar"}); assert.eq(result.ok, 0, tojson(result)); secondarySoon(); @@ -49,7 +53,7 @@ secondarySoon(); print("use replSetMaintenance command to go in/out of maintence mode"); print("primary cannot go into maintence mode"); -result = master.getDB("admin").runCommand({replSetMaintenance : 1}); +result = master.getDB("admin").runCommand({replSetMaintenance: 1}); assert.eq(result.ok, 0, tojson(result)); print("check getMore works on a secondary, not on a recovering node"); @@ -59,32 +63,29 @@ for (var i = 0; i < 5; i++) { } print("secondary can"); -result = conns[1].getDB("admin").runCommand({replSetMaintenance : 1}); +result = conns[1].getDB("admin").runCommand({replSetMaintenance: 1}); assert.eq(result.ok, 1, tojson(result)); print("make sure secondary goes into recovering"); var x = 0; assert.soon(function() { var im = conns[1].getDB("admin").isMaster(); - if (x++ % 5 == 0) printjson(im); + if (x++ % 5 == 0) + printjson(im); return !im.secondary && !im.ismaster; }); print("now getmore shouldn't work"); -var ex = assert.throws( - function(){ - lastDoc = null; - while (cursor.hasNext()) { - lastDoc = cursor.next(); - } - }, - [] /*no params*/, - "getmore didn't fail"); - -assert(ex.message.match("13436"), "wrong error code -- " + ex ); - -result = conns[1].getDB("admin").runCommand({replSetMaintenance : 0}); +var ex = assert.throws(function() { + lastDoc = null; + while (cursor.hasNext()) { + lastDoc = cursor.next(); + } +}, [] /*no params*/, "getmore didn't fail"); + +assert(ex.message.match("13436"), "wrong error code -- " + ex); + +result = conns[1].getDB("admin").runCommand({replSetMaintenance: 0}); assert.eq(result.ok, 1, tojson(result)); secondarySoon(); - |