summaryrefslogtreecommitdiff
path: root/jstests/sharding/merge_chunks_test.js
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:17:50 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:18:14 -0500
commit4ae691e8edc87d0e3cfb633bb91c328426be007b (patch)
tree52079a593f54382ca13a2e741633eab1b6271893 /jstests/sharding/merge_chunks_test.js
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/sharding/merge_chunks_test.js')
-rw-r--r--jstests/sharding/merge_chunks_test.js150
1 files changed, 67 insertions, 83 deletions
diff --git a/jstests/sharding/merge_chunks_test.js b/jstests/sharding/merge_chunks_test.js
index 2a853bbd1d9..6b00a6532ea 100644
--- a/jstests/sharding/merge_chunks_test.js
+++ b/jstests/sharding/merge_chunks_test.js
@@ -2,121 +2,105 @@
// Tests that merging chunks via mongos works/doesn't work with different chunk configurations
//
(function() {
-'use strict';
+ 'use strict';
-var st = new ShardingTest({ shards : 2, mongos : 2 });
+ var st = new ShardingTest({shards: 2, mongos: 2});
-var mongos = st.s0;
-var staleMongos = st.s1;
-var admin = mongos.getDB( "admin" );
-var shards = mongos.getCollection( "config.shards" ).find().toArray();
-var coll = mongos.getCollection( "foo.bar" );
+ var mongos = st.s0;
+ var staleMongos = st.s1;
+ var admin = mongos.getDB("admin");
+ var shards = mongos.getCollection("config.shards").find().toArray();
+ var coll = mongos.getCollection("foo.bar");
-assert( admin.runCommand({ enableSharding : coll.getDB() + "" }).ok );
-printjson( admin.runCommand({ movePrimary : coll.getDB() + "", to : shards[0]._id }) );
-assert( admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }).ok );
+ assert(admin.runCommand({enableSharding: coll.getDB() + ""}).ok);
+ printjson(admin.runCommand({movePrimary: coll.getDB() + "", to: shards[0]._id}));
+ assert(admin.runCommand({shardCollection: coll + "", key: {_id: 1}}).ok);
-// Create ranges MIN->0,0->10,(hole),20->40,40->50,50->90,(hole),100->110,110->MAX on first shard
-jsTest.log( "Creating ranges..." );
+ // Create ranges MIN->0,0->10,(hole),20->40,40->50,50->90,(hole),100->110,110->MAX on first
+ // shard
+ jsTest.log("Creating ranges...");
-assert( admin.runCommand({ split : coll + "", middle : { _id : 0 } }).ok );
-assert( admin.runCommand({ split : coll + "", middle : { _id : 10 } }).ok );
-assert( admin.runCommand({ split : coll + "", middle : { _id : 20 } }).ok );
-assert( admin.runCommand({ split : coll + "", middle : { _id : 40 } }).ok );
-assert( admin.runCommand({ split : coll + "", middle : { _id : 50 } }).ok );
-assert( admin.runCommand({ split : coll + "", middle : { _id : 90 } }).ok );
-assert( admin.runCommand({ split : coll + "", middle : { _id : 100 } }).ok );
-assert( admin.runCommand({ split : coll + "", middle : { _id : 110 } }).ok );
+ assert(admin.runCommand({split: coll + "", middle: {_id: 0}}).ok);
+ assert(admin.runCommand({split: coll + "", middle: {_id: 10}}).ok);
+ assert(admin.runCommand({split: coll + "", middle: {_id: 20}}).ok);
+ assert(admin.runCommand({split: coll + "", middle: {_id: 40}}).ok);
+ assert(admin.runCommand({split: coll + "", middle: {_id: 50}}).ok);
+ assert(admin.runCommand({split: coll + "", middle: {_id: 90}}).ok);
+ assert(admin.runCommand({split: coll + "", middle: {_id: 100}}).ok);
+ assert(admin.runCommand({split: coll + "", middle: {_id: 110}}).ok);
-assert( admin.runCommand({ moveChunk : coll + "", find : { _id : 10 }, to : shards[1]._id }).ok );
-assert( admin.runCommand({ moveChunk : coll + "", find : { _id : 90 }, to : shards[1]._id }).ok );
+ assert(admin.runCommand({moveChunk: coll + "", find: {_id: 10}, to: shards[1]._id}).ok);
+ assert(admin.runCommand({moveChunk: coll + "", find: {_id: 90}, to: shards[1]._id}).ok);
-st.printShardingStatus();
+ st.printShardingStatus();
-// Insert some data into each of the consolidated ranges
-assert.writeOK(coll.insert({ _id : 0 }));
-assert.writeOK(coll.insert({ _id : 40 }));
-assert.writeOK(coll.insert({ _id : 110 }));
+ // Insert some data into each of the consolidated ranges
+ assert.writeOK(coll.insert({_id: 0}));
+ assert.writeOK(coll.insert({_id: 40}));
+ assert.writeOK(coll.insert({_id: 110}));
-var staleCollection = staleMongos.getCollection( coll + "" );
+ var staleCollection = staleMongos.getCollection(coll + "");
-jsTest.log( "Trying merges that should fail..." );
+ jsTest.log("Trying merges that should fail...");
-// S0: min->0, 0->10, 20->40, 40->50, 50->90, 100->110, 110->max
-// S1: 10->20, 90->100
+ // S0: min->0, 0->10, 20->40, 40->50, 50->90, 100->110, 110->max
+ // S1: 10->20, 90->100
-// Make sure merging non-exact chunks is invalid
+ // Make sure merging non-exact chunks is invalid
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : MinKey }, { _id : 5 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 5 }, { _id : 10 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 15 }, { _id : 50 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 20 }, { _id : 55 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 105 }, { _id : MaxKey }] }).ok );
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: MinKey}, {_id: 5}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 5}, {_id: 10}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 15}, {_id: 50}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 20}, {_id: 55}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 105}, {_id: MaxKey}]}).ok);
-// Make sure merging single chunks is invalid
+ // Make sure merging single chunks is invalid
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : MinKey }, { _id : 0 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 20 }, { _id : 40 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 110 }, { _id : MaxKey }] }).ok );
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: MinKey}, {_id: 0}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 20}, {_id: 40}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 110}, {_id: MaxKey}]}).ok);
-// Make sure merging over holes is invalid
+ // Make sure merging over holes is invalid
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 0 }, { _id : 40 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 40 }, { _id : 110 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 50 }, { _id : 110 }] }).ok );
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 0}, {_id: 40}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 40}, {_id: 110}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 50}, {_id: 110}]}).ok);
-// Make sure merging between shards is invalid
+ // Make sure merging between shards is invalid
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 0 }, { _id : 20 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 10 }, { _id : 40 }] }).ok );
-assert( !admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 40 }, { _id : 100 }] }).ok );
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 0}, {_id: 20}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 10}, {_id: 40}]}).ok);
+ assert(!admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 40}, {_id: 100}]}).ok);
-assert.eq( 3, staleCollection.find().itcount() );
+ assert.eq(3, staleCollection.find().itcount());
-jsTest.log( "Trying merges that should succeed..." );
+ jsTest.log("Trying merges that should succeed...");
-assert( admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : MinKey }, { _id : 10 }] }).ok );
+ assert(admin.runCommand({mergeChunks: coll + "", bounds: [{_id: MinKey}, {_id: 10}]}).ok);
-assert.eq( 3, staleCollection.find().itcount() );
+ assert.eq(3, staleCollection.find().itcount());
-// S0: min->10, 20->40, 40->50, 50->90, 100->110, 110->max
-// S1: 10->20, 90->100
+ // S0: min->10, 20->40, 40->50, 50->90, 100->110, 110->max
+ // S1: 10->20, 90->100
-// Make sure merging three chunks is valid.
+ // Make sure merging three chunks is valid.
-jsTest.log(tojson( admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 20 }, { _id : 90 }] }) ));
+ jsTest.log(tojson(admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 20}, {_id: 90}]})));
-// S0: min->10, 20->90, 100->110, 110->max
-// S1: 10->20, 90->100
+ // S0: min->10, 20->90, 100->110, 110->max
+ // S1: 10->20, 90->100
-assert.eq( 3, staleCollection.find().itcount() );
+ assert.eq(3, staleCollection.find().itcount());
-assert( admin.runCommand({ mergeChunks : coll + "",
- bounds : [{ _id : 100 }, { _id : MaxKey }] }).ok );
+ assert(admin.runCommand({mergeChunks: coll + "", bounds: [{_id: 100}, {_id: MaxKey}]}).ok);
-assert.eq( 3, staleCollection.find().itcount() );
+ assert.eq(3, staleCollection.find().itcount());
-// S0: min->10, 20->90, 100->max
-// S1: 10->20, 90->100
+ // S0: min->10, 20->90, 100->max
+ // S1: 10->20, 90->100
-st.printShardingStatus();
+ st.printShardingStatus();
-st.stop();
+ st.stop();
})();