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/sharding/version2.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/sharding/version2.js')
-rw-r--r-- | jstests/sharding/version2.js | 91 |
1 files changed, 51 insertions, 40 deletions
diff --git a/jstests/sharding/version2.js b/jstests/sharding/version2.js index 0bf8c5892b5..6bdc4601206 100644 --- a/jstests/sharding/version2.js +++ b/jstests/sharding/version2.js @@ -1,21 +1,22 @@ (function() { -'use strict'; + 'use strict'; -var s = new ShardingTest({ name: "version2", shards: 1 }); + var s = new ShardingTest({name: "version2", shards: 1}); -assert.commandWorked(s.s0.adminCommand({ enablesharding: "alleyinsider" })); -assert.commandWorked(s.s0.adminCommand({ shardcollection: "alleyinsider.foo", key: { num: 1 } })); -assert.commandWorked(s.s0.adminCommand({ shardcollection: "alleyinsider.bar", key: { num: 1 } })); + assert.commandWorked(s.s0.adminCommand({enablesharding: "alleyinsider"})); + assert.commandWorked(s.s0.adminCommand({shardcollection: "alleyinsider.foo", key: {num: 1}})); + assert.commandWorked(s.s0.adminCommand({shardcollection: "alleyinsider.bar", key: {num: 1}})); -var a = s._connections[0].getDB("admin"); + var a = s._connections[0].getDB("admin"); -// Setup from one client -assert.eq(a.runCommand({ "getShardVersion": "alleyinsider.foo", configdb: s._configDB }).mine.i, 0); -assert.eq(a.runCommand({ "getShardVersion": "alleyinsider.foo", configdb: s._configDB }).global.i, 0); + // Setup from one client + assert.eq(a.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).mine.i, + 0); + assert.eq(a.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).global.i, + 0); -var fooEpoch = s.getDB('config').chunks.findOne({ ns: 'alleyinsider.foo' }).lastmodEpoch; -assert.commandWorked( - a.runCommand({ + var fooEpoch = s.getDB('config').chunks.findOne({ns: 'alleyinsider.foo'}).lastmodEpoch; + assert.commandWorked(a.runCommand({ setShardVersion: "alleyinsider.foo", configdb: s._configDB, authoritative: true, @@ -25,44 +26,54 @@ assert.commandWorked( shardHost: s.s.host, })); -printjson(s.config.chunks.findOne()); + printjson(s.config.chunks.findOne()); -assert.eq(a.runCommand({ "getShardVersion": "alleyinsider.foo", configdb: s._configDB }).mine.t, 1); -assert.eq(a.runCommand({ "getShardVersion": "alleyinsider.foo", configdb: s._configDB }).global.t, 1); + assert.eq(a.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).mine.t, + 1); + assert.eq(a.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).global.t, + 1); -// From a different client -var a2 = connect(s._connections[0].name + "/admin"); + // From a different client + var a2 = connect(s._connections[0].name + "/admin"); -assert.eq(a2.runCommand({ "getShardVersion": "alleyinsider.foo", configdb: s._configDB }).global.t, 1, "a2 global 1"); -assert.eq(a2.runCommand({ "getShardVersion": "alleyinsider.foo", configdb: s._configDB }).mine.i, 0, "a2 mine 1"); + assert.eq( + a2.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).global.t, + 1, + "a2 global 1"); + assert.eq(a2.runCommand({"getShardVersion": "alleyinsider.foo", configdb: s._configDB}).mine.i, + 0, + "a2 mine 1"); -function simpleFindOne(){ - return a2.getMongo().getDB("alleyinsider").foo.findOne(); -} + function simpleFindOne() { + return a2.getMongo().getDB("alleyinsider").foo.findOne(); + } -var barEpoch = s.getDB('config').chunks.findOne({ ns: 'alleyinsider.bar' }).lastmodEpoch; -assert.commandWorked(a2.runCommand({ setShardVersion: "alleyinsider.bar", - configdb: s._configDB, - version: new Timestamp(1, 0), - versionEpoch: barEpoch, - shard: 'shard0000', - authoritative: true }), - "setShardVersion bar temp"); - -assert.throws(simpleFindOne, [], "should complain about not in sharded mode 1"); + var barEpoch = s.getDB('config').chunks.findOne({ns: 'alleyinsider.bar'}).lastmodEpoch; + assert.commandWorked(a2.runCommand({ + setShardVersion: "alleyinsider.bar", + configdb: s._configDB, + version: new Timestamp(1, 0), + versionEpoch: barEpoch, + shard: 'shard0000', + authoritative: true + }), + "setShardVersion bar temp"); + assert.throws(simpleFindOne, [], "should complain about not in sharded mode 1"); -// the only way that setSharVersion passes is if the shard agrees with the version -// the shard takes its version from config directly -// TODO bump timestamps in config -// assert(a2.runCommand({ "setShardVersion": "alleyinsider.foo", configdb: s._configDB, version: 2 }).ok == 1, "setShardVersion a2-1"); + // the only way that setSharVersion passes is if the shard agrees with the version + // the shard takes its version from config directly + // TODO bump timestamps in config + // assert(a2.runCommand({ "setShardVersion": "alleyinsider.foo", configdb: s._configDB, version: + // 2 }).ok == 1, "setShardVersion a2-1"); -// simpleFindOne(); // now should run ok + // simpleFindOne(); // now should run ok -// assert(a2.runCommand({ "setShardVersion": "alleyinsider.foo", configdb: s._configDB, version: 3 }).ok == 1, "setShardVersion a2-2"); + // assert(a2.runCommand({ "setShardVersion": "alleyinsider.foo", configdb: s._configDB, version: + // 3 }).ok == 1, "setShardVersion a2-2"); -// simpleFindOne(); // newer version is ok + // simpleFindOne(); // newer version is ok -s.stop(); + s.stop(); })(); |