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/coll_epoch_test1.js | |
parent | a025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff) | |
download | mongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz |
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/sharding/coll_epoch_test1.js')
-rw-r--r-- | jstests/sharding/coll_epoch_test1.js | 108 |
1 files changed, 56 insertions, 52 deletions
diff --git a/jstests/sharding/coll_epoch_test1.js b/jstests/sharding/coll_epoch_test1.js index fa24a035da7..28962732c25 100644 --- a/jstests/sharding/coll_epoch_test1.js +++ b/jstests/sharding/coll_epoch_test1.js @@ -1,6 +1,7 @@ -// Tests various cases of dropping and recreating collections in the same namespace with multiple mongoses +// Tests various cases of dropping and recreating collections in the same namespace with multiple +// mongoses -var st = new ShardingTest({ shards : 3, mongos : 3, verbose : 1 }); +var st = new ShardingTest({shards: 3, mongos: 3, verbose: 1}); // Balancer is by default stopped, thus it will not interfere // Use separate mongoses for admin, inserting data, and validating results, so no @@ -8,15 +9,15 @@ var st = new ShardingTest({ shards : 3, mongos : 3, verbose : 1 }); var insertMongos = st.s2; var staleMongos = st.s1; -var config = st.s.getDB( "config" ); -var admin = st.s.getDB( "admin" ); -var coll = st.s.getCollection( "foo.bar" ); +var config = st.s.getDB("config"); +var admin = st.s.getDB("admin"); +var coll = st.s.getCollection("foo.bar"); -insertMongos.getDB( "admin" ).runCommand({ setParameter : 1, traceExceptions : true }); +insertMongos.getDB("admin").runCommand({setParameter: 1, traceExceptions: true}); var shards = {}; -config.shards.find().forEach( function( doc ){ - shards[ doc._id ] = new Mongo( doc.host ); +config.shards.find().forEach(function(doc) { + shards[doc._id] = new Mongo(doc.host); }); // @@ -24,53 +25,54 @@ config.shards.find().forEach( function( doc ){ // in the background // -jsTest.log( "Enabling sharding for the first time..." ); +jsTest.log("Enabling sharding for the first time..."); -admin.runCommand({ enableSharding : coll.getDB() + "" }); +admin.runCommand({enableSharding: coll.getDB() + ""}); st.ensurePrimaryShard(coll.getDB().getName(), 'shard0001'); -admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }); +admin.runCommand({shardCollection: coll + "", key: {_id: 1}}); -var bulk = insertMongos.getCollection( coll + "" ).initializeUnorderedBulkOp(); -for( var i = 0; i < 100; i++ ) { - bulk.insert({ _id : i, test : "a" }); +var bulk = insertMongos.getCollection(coll + "").initializeUnorderedBulkOp(); +for (var i = 0; i < 100; i++) { + bulk.insert({_id: i, test: "a"}); } -assert.writeOK( bulk.execute() ); -assert.eq( 100, staleMongos.getCollection( coll + "" ).find({ test : "a" }).itcount() ); +assert.writeOK(bulk.execute()); +assert.eq(100, staleMongos.getCollection(coll + "").find({test: "a"}).itcount()); coll.drop(); // -// Test that inserts and queries go to the correct shard even when the collection has been +// Test that inserts and queries go to the correct shard even when the collection has been // re-sharded in the background // -jsTest.log( "Re-enabling sharding with a different key..." ); +jsTest.log("Re-enabling sharding with a different key..."); -admin.runCommand({ enableSharding : coll.getDB() + "" }); +admin.runCommand({enableSharding: coll.getDB() + ""}); st.ensurePrimaryShard(coll.getDB().getName(), 'shard0001'); -coll.ensureIndex({ notId : 1 }); -admin.runCommand({ shardCollection : coll + "", key : { notId : 1 } }); +coll.ensureIndex({notId: 1}); +admin.runCommand({shardCollection: coll + "", key: {notId: 1}}); -bulk = insertMongos.getCollection( coll + "" ).initializeUnorderedBulkOp(); -for( var i = 0; i < 100; i++ ) { - bulk.insert({ notId : i, test : "b" }); +bulk = insertMongos.getCollection(coll + "").initializeUnorderedBulkOp(); +for (var i = 0; i < 100; i++) { + bulk.insert({notId: i, test: "b"}); } -assert.writeOK( bulk.execute() ); -assert.eq( 100, staleMongos.getCollection( coll + "" ).find({ test : "b" }).itcount() ); -assert.eq( 0, staleMongos.getCollection( coll + "" ).find({ test : { $in : [ "a" ] } }).itcount() ); +assert.writeOK(bulk.execute()); +assert.eq(100, staleMongos.getCollection(coll + "").find({test: "b"}).itcount()); +assert.eq(0, staleMongos.getCollection(coll + "").find({test: {$in: ["a"]}}).itcount()); coll.drop(); // -// Test that inserts and queries go to the correct shard even when the collection has been +// Test that inserts and queries go to the correct shard even when the collection has been // unsharded and moved to a different primary // -jsTest.log( "Re-creating unsharded collection from a sharded collection on different primary..." ); +jsTest.log("Re-creating unsharded collection from a sharded collection on different primary..."); -var getOtherShard = function( shard ){ - for( id in shards ){ - if( id != shard ) return id; +var getOtherShard = function(shard) { + for (id in shards) { + if (id != shard) + return id; } }; @@ -81,40 +83,42 @@ if (st.configRS) { // the most recent config data. st.configRS.awaitLastOpCommitted(); } -jsTest.log( "moved primary..." ); +jsTest.log("moved primary..."); -bulk = insertMongos.getCollection( coll + "" ).initializeUnorderedBulkOp(); -for( var i = 0; i < 100; i++ ) - bulk.insert({ test : "c" }); -assert.writeOK( bulk.execute() ); +bulk = insertMongos.getCollection(coll + "").initializeUnorderedBulkOp(); +for (var i = 0; i < 100; i++) + bulk.insert({test: "c"}); +assert.writeOK(bulk.execute()); -assert.eq( 100, staleMongos.getCollection( coll + "" ).find({ test : "c" }).itcount() ); -assert.eq( 0, staleMongos.getCollection( coll + "" ).find({ test : { $in : [ "a", "b" ] } }).itcount() ); +assert.eq(100, staleMongos.getCollection(coll + "").find({test: "c"}).itcount()); +assert.eq(0, staleMongos.getCollection(coll + "").find({test: {$in: ["a", "b"]}}).itcount()); coll.drop(); // -// Test that inserts and queries go to correct shard even when the collection has been unsharded, +// Test that inserts and queries go to correct shard even when the collection has been unsharded, // resharded, and moved to a different primary // -jsTest.log( "Re-creating sharded collection with different primary..." ); +jsTest.log("Re-creating sharded collection with different primary..."); -admin.runCommand({ enableSharding : coll.getDB() + "" }); -admin.runCommand({ movePrimary : coll.getDB() + "", - to : getOtherShard( config.databases.findOne({ _id : coll.getDB() + "" }).primary ) }); -admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }); +admin.runCommand({enableSharding: coll.getDB() + ""}); +admin.runCommand({ + movePrimary: coll.getDB() + "", + to: getOtherShard(config.databases.findOne({_id: coll.getDB() + ""}).primary) +}); +admin.runCommand({shardCollection: coll + "", key: {_id: 1}}); -bulk = insertMongos.getCollection( coll + "" ).initializeUnorderedBulkOp(); -for( var i = 0; i < 100; i++ ) - bulk.insert({ test : "d" }); -assert.writeOK( bulk.execute() ); +bulk = insertMongos.getCollection(coll + "").initializeUnorderedBulkOp(); +for (var i = 0; i < 100; i++) + bulk.insert({test: "d"}); +assert.writeOK(bulk.execute()); -assert.eq( 100, staleMongos.getCollection( coll + "" ).find({ test : "d" }).itcount() ); -assert.eq( 0, staleMongos.getCollection( coll + "" ).find({ test : { $in : [ "a", "b", "c" ] } }).itcount() ); +assert.eq(100, staleMongos.getCollection(coll + "").find({test: "d"}).itcount()); +assert.eq(0, staleMongos.getCollection(coll + "").find({test: {$in: ["a", "b", "c"]}}).itcount()); coll.drop(); -jsTest.log( "Done!" ); +jsTest.log("Done!"); st.stop(); |