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/migrateBig.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/sharding/migrateBig.js')
-rw-r--r-- | jstests/sharding/migrateBig.js | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/jstests/sharding/migrateBig.js b/jstests/sharding/migrateBig.js index 73a292033bc..8895d14c0d6 100644 --- a/jstests/sharding/migrateBig.js +++ b/jstests/sharding/migrateBig.js @@ -1,80 +1,80 @@ (function() { -var s = new ShardingTest({ name: "migrateBig", - shards: 2, - other: { chunkSize: 1 } }); + var s = new ShardingTest({name: "migrateBig", shards: 2, other: {chunkSize: 1}}); -s.config.settings.update( { _id: "balancer" }, { $set : { _waitForDelete : true } } , true); -s.adminCommand( { enablesharding : "test" } ); -s.ensurePrimaryShard('test', 'shard0001'); -s.adminCommand( { shardcollection : "test.foo" , key : { x : 1 } } ); + s.config.settings.update({_id: "balancer"}, {$set: {_waitForDelete: true}}, true); + s.adminCommand({enablesharding: "test"}); + s.ensurePrimaryShard('test', 'shard0001'); + s.adminCommand({shardcollection: "test.foo", key: {x: 1}}); -db = s.getDB( "test" ); -coll = db.foo; + db = s.getDB("test"); + coll = db.foo; -big = ""; -while ( big.length < 10000 ) - big += "eliot"; + big = ""; + while (big.length < 10000) + big += "eliot"; -var bulk = coll.initializeUnorderedBulkOp(); -for ( x=0; x<100; x++ ) { - bulk.insert( { x : x , big : big } ); -} -assert.writeOK(bulk.execute()); - -s.printShardingStatus(); - -s.adminCommand( { split : "test.foo" , middle : { x : 30 } } ); -s.adminCommand( { split : "test.foo" , middle : { x : 66 } } ); -s.adminCommand( { movechunk : "test.foo" , - find : { x : 90 } , - to : s.getOther( s.getPrimaryShard( "test" ) ).name } ); - -s.printShardingStatus(); + var bulk = coll.initializeUnorderedBulkOp(); + for (x = 0; x < 100; x++) { + bulk.insert({x: x, big: big}); + } + assert.writeOK(bulk.execute()); -print( "YO : " + s.getPrimaryShard( "test" ).host ); -direct = new Mongo( s.getPrimaryShard( "test" ).host ); -print( "direct : " + direct ); + s.printShardingStatus(); -directDB = direct.getDB( "test" ); + s.adminCommand({split: "test.foo", middle: {x: 30}}); + s.adminCommand({split: "test.foo", middle: {x: 66}}); + s.adminCommand( + {movechunk: "test.foo", find: {x: 90}, to: s.getOther(s.getPrimaryShard("test")).name}); -for ( done=0; done<2*1024*1024; done+=big.length ){ - assert.writeOK(directDB.foo.insert( { x : 50 + Math.random() , big : big } )); -} + s.printShardingStatus(); -s.printShardingStatus(); + print("YO : " + s.getPrimaryShard("test").host); + direct = new Mongo(s.getPrimaryShard("test").host); + print("direct : " + direct); -assert.throws( function(){ - s.adminCommand({ movechunk : "test.foo" , - find : { x : 50 } , - to : s.getOther( s.getPrimaryShard( "test" ) ).name }); -}, [], "move should fail" ); + directDB = direct.getDB("test"); -for ( i=0; i<20; i+= 2 ) { - try { - s.adminCommand( { split : "test.foo" , middle : { x : i } } ); + for (done = 0; done < 2 * 1024 * 1024; done += big.length) { + assert.writeOK(directDB.foo.insert({x: 50 + Math.random(), big: big})); } - catch ( e ) { - // we may have auto split on some of these - // which is ok - print(e); + + s.printShardingStatus(); + + assert.throws(function() { + s.adminCommand({ + movechunk: "test.foo", + find: {x: 50}, + to: s.getOther(s.getPrimaryShard("test")).name + }); + }, [], "move should fail"); + + for (i = 0; i < 20; i += 2) { + try { + s.adminCommand({split: "test.foo", middle: {x: i}}); + } catch (e) { + // we may have auto split on some of these + // which is ok + print(e); + } } -} -s.printShardingStatus(); + s.printShardingStatus(); -s.config.settings.update( { _id: "balancer" }, { $set : { stopped: false } } , true ); + s.config.settings.update({_id: "balancer"}, {$set: {stopped: false}}, true); -assert.soon( function(){ - var x = s.chunkDiff( "foo" , "test" ); - print( "chunk diff: " + x ); - return x < 2; -}, "no balance happened" , 8 * 60 * 1000 , 2000 ); + assert.soon(function() { + var x = s.chunkDiff("foo", "test"); + print("chunk diff: " + x); + return x < 2; + }, "no balance happened", 8 * 60 * 1000, 2000); -assert.soon( function(){ return !s.isAnyBalanceInFlight(); } ); + assert.soon(function() { + return !s.isAnyBalanceInFlight(); + }); -assert.eq( coll.count() , coll.find().itcount() ); + assert.eq(coll.count(), coll.find().itcount()); -s.stop(); + s.stop(); })(); |