summaryrefslogtreecommitdiff
path: root/jstests/sharding/test_stacked_migration_cleanup.js
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:27:20 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:27:56 -0500
commit8c5ff5834ab1f61e68b7839cd99c3de1f87c2121 (patch)
treeef4d91cc230300a6a48eeeac696ca15df6db1212 /jstests/sharding/test_stacked_migration_cleanup.js
parent0875be78b405016736ff42e3a50166be7561c2f8 (diff)
downloadmongo-8c5ff5834ab1f61e68b7839cd99c3de1f87c2121.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/sharding/test_stacked_migration_cleanup.js')
-rw-r--r--jstests/sharding/test_stacked_migration_cleanup.js93
1 files changed, 47 insertions, 46 deletions
diff --git a/jstests/sharding/test_stacked_migration_cleanup.js b/jstests/sharding/test_stacked_migration_cleanup.js
index fc4a71933ed..76b06505040 100644
--- a/jstests/sharding/test_stacked_migration_cleanup.js
+++ b/jstests/sharding/test_stacked_migration_cleanup.js
@@ -1,67 +1,68 @@
-// Tests "stacking" multiple migration cleanup threads and their behavior when the collection changes
+// Tests "stacking" multiple migration cleanup threads and their behavior when the collection
+// changes
(function() {
-'use strict';
+ 'use strict';
-// start up a new sharded cluster
-var st = new ShardingTest({ shards : 2, mongos : 1 });
+ // start up a new sharded cluster
+ var st = new ShardingTest({shards: 2, mongos: 1});
-var mongos = st.s;
-var admin = mongos.getDB("admin");
-var shards = mongos.getDB("config").shards.find().toArray();
-var coll = mongos.getCollection("foo.bar");
+ var mongos = st.s;
+ var admin = mongos.getDB("admin");
+ var shards = mongos.getDB("config").shards.find().toArray();
+ var coll = mongos.getCollection("foo.bar");
-// Enable sharding of the collection
-assert.commandWorked(mongos.adminCommand({ enablesharding : coll.getDB() + "" }));
-st.ensurePrimaryShard(coll.getDB() + "", shards[0]._id);
-assert.commandWorked(mongos.adminCommand({ shardcollection : coll + "", key: { _id : 1 } }));
+ // Enable sharding of the collection
+ assert.commandWorked(mongos.adminCommand({enablesharding: coll.getDB() + ""}));
+ st.ensurePrimaryShard(coll.getDB() + "", shards[0]._id);
+ assert.commandWorked(mongos.adminCommand({shardcollection: coll + "", key: {_id: 1}}));
-var numChunks = 30;
+ var numChunks = 30;
-// Create a bunch of chunks
-for (var i = 0; i < numChunks; i++) {
- assert.commandWorked(mongos.adminCommand({ split : coll + "", middle : { _id : i } }));
-}
+ // Create a bunch of chunks
+ for (var i = 0; i < numChunks; i++) {
+ assert.commandWorked(mongos.adminCommand({split: coll + "", middle: {_id: i}}));
+ }
-jsTest.log("Inserting a lot of small documents...");
+ jsTest.log("Inserting a lot of small documents...");
-// Insert a lot of small documents to make multiple cursor batches
-var bulk = coll.initializeUnorderedBulkOp();
-for (var i = 0; i < 10 * 1000; i++) {
- bulk.insert({ _id : i });
-}
-assert.writeOK(bulk.execute());
+ // Insert a lot of small documents to make multiple cursor batches
+ var bulk = coll.initializeUnorderedBulkOp();
+ for (var i = 0; i < 10 * 1000; i++) {
+ bulk.insert({_id: i});
+ }
+ assert.writeOK(bulk.execute());
-jsTest.log("Opening a mongod cursor...");
+ jsTest.log("Opening a mongod cursor...");
-// Open a new cursor on the mongod
-var cursor = coll.find();
-var next = cursor.next();
+ // Open a new cursor on the mongod
+ var cursor = coll.find();
+ var next = cursor.next();
-jsTest.log("Moving a bunch of chunks to stack cleanup...");
+ jsTest.log("Moving a bunch of chunks to stack cleanup...");
-// Move a bunch of chunks, but don't close the cursor so they stack.
-for (var i = 0; i < numChunks; i++) {
- printjson(mongos.adminCommand({ moveChunk : coll + "", find : { _id : i }, to : shards[1]._id }));
-}
+ // Move a bunch of chunks, but don't close the cursor so they stack.
+ for (var i = 0; i < numChunks; i++) {
+ printjson(mongos.adminCommand({moveChunk: coll + "", find: {_id: i}, to: shards[1]._id}));
+ }
-jsTest.log("Dropping and re-creating collection...");
+ jsTest.log("Dropping and re-creating collection...");
-coll.drop();
+ coll.drop();
-bulk = coll.initializeUnorderedBulkOp();
-for (var i = 0; i < numChunks; i++) {
- bulk.insert({ _id : i });
-}
-assert.writeOK(bulk.execute());
+ bulk = coll.initializeUnorderedBulkOp();
+ for (var i = 0; i < numChunks; i++) {
+ bulk.insert({_id: i});
+ }
+ assert.writeOK(bulk.execute());
-sleep(10 * 1000);
+ sleep(10 * 1000);
-jsTest.log("Checking that documents were not cleaned up...");
+ jsTest.log("Checking that documents were not cleaned up...");
-for (var i = 0; i < numChunks; i++) {
- assert.neq(null, coll.findOne({ _id : i }));
-}
+ for (var i = 0; i < numChunks; i++) {
+ assert.neq(null, coll.findOne({_id: i}));
+ }
-st.stop();
+ st.stop();
})();