diff options
Diffstat (limited to 'jstests/sharding/authConnectionHook.js')
-rw-r--r-- | jstests/sharding/authConnectionHook.js | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/jstests/sharding/authConnectionHook.js b/jstests/sharding/authConnectionHook.js index 4356180107d..516b0d34554 100644 --- a/jstests/sharding/authConnectionHook.js +++ b/jstests/sharding/authConnectionHook.js @@ -1,7 +1,12 @@ -// Test for SERVER-8786 - if the first operation on an authenticated shard is moveChunk, it breaks the cluster. -var st = new ShardingTest({ keyFile : 'jstests/libs/key1', shards : 2, chunkSize: 1, verbose : 2, - other : { nopreallocj : 1, verbose : 2, useHostname : true, - configOptions : { verbose : 2 }}}); +// Test for SERVER-8786 - if the first operation on an authenticated shard is moveChunk, it breaks +// the cluster. +var st = new ShardingTest({ + keyFile: 'jstests/libs/key1', + shards: 2, + chunkSize: 1, + verbose: 2, + other: {nopreallocj: 1, verbose: 2, useHostname: true, configOptions: {verbose: 2}} +}); var mongos = st.s; var adminDB = mongos.getDB('admin'); @@ -11,18 +16,18 @@ adminDB.createUser({user: 'admin', pwd: 'password', roles: jsTest.adminUserRoles adminDB.auth('admin', 'password'); -adminDB.runCommand({enableSharding : "test"}); +adminDB.runCommand({enableSharding: "test"}); st.ensurePrimaryShard('test', 'shard0001'); -adminDB.runCommand({shardCollection : "test.foo", key : {x : 1}}); +adminDB.runCommand({shardCollection: "test.foo", key: {x: 1}}); for (var i = 0; i < 100; i++) { - db.foo.insert({x:i}); + db.foo.insert({x: i}); } -adminDB.runCommand({split: "test.foo", middle: {x:50}}); -var curShard = st.getShard("test.foo", {x:75}); +adminDB.runCommand({split: "test.foo", middle: {x: 50}}); +var curShard = st.getShard("test.foo", {x: 75}); var otherShard = st.getOther(curShard).name; -adminDB.runCommand({moveChunk: "test.foo", find: {x:25}, to: otherShard, _waitForDelete:true}); +adminDB.runCommand({moveChunk: "test.foo", find: {x: 25}, to: otherShard, _waitForDelete: true}); st.printShardingStatus(); @@ -30,16 +35,13 @@ MongoRunner.stopMongod(st.shard0); st.shard0 = MongoRunner.runMongod({restart: st.shard0}); // May fail the first couple times due to socket exceptions -assert.soon( function() { - var res = adminDB.runCommand({moveChunk: "test.foo", - find: {x:75}, - to: otherShard}); - printjson(res); - return res.ok; - }); - - -printjson(db.foo.findOne({x:25})); -printjson(db.foo.findOne({x:75})); +assert.soon(function() { + var res = adminDB.runCommand({moveChunk: "test.foo", find: {x: 75}, to: otherShard}); + printjson(res); + return res.ok; +}); + +printjson(db.foo.findOne({x: 25})); +printjson(db.foo.findOne({x: 75})); st.stop(); |