summaryrefslogtreecommitdiff
path: root/jstests/sharding/bouncing_count.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/bouncing_count.js')
-rw-r--r--jstests/sharding/bouncing_count.js100
1 files changed, 48 insertions, 52 deletions
diff --git a/jstests/sharding/bouncing_count.js b/jstests/sharding/bouncing_count.js
index f4deb4335e5..68097fb23a3 100644
--- a/jstests/sharding/bouncing_count.js
+++ b/jstests/sharding/bouncing_count.js
@@ -2,71 +2,67 @@
* Tests whether new sharding is detected on insert by mongos
*/
(function() {
- 'use strict';
+'use strict';
- // TODO: SERVER-33830 remove shardAsReplicaSet: false
- var st = new ShardingTest({shards: 10, mongos: 3, other: {shardAsReplicaSet: false}});
+// TODO: SERVER-33830 remove shardAsReplicaSet: false
+var st = new ShardingTest({shards: 10, mongos: 3, other: {shardAsReplicaSet: false}});
- var mongosA = st.s0;
- var mongosB = st.s1;
- var mongosC = st.s2;
+var mongosA = st.s0;
+var mongosB = st.s1;
+var mongosC = st.s2;
- var admin = mongosA.getDB("admin");
- var config = mongosA.getDB("config");
+var admin = mongosA.getDB("admin");
+var config = mongosA.getDB("config");
- var collA = mongosA.getCollection("foo.bar");
- var collB = mongosB.getCollection("" + collA);
- var collC = mongosB.getCollection("" + collA);
+var collA = mongosA.getCollection("foo.bar");
+var collB = mongosB.getCollection("" + collA);
+var collC = mongosB.getCollection("" + collA);
- var shards = [
- st.shard0,
- st.shard1,
- st.shard2,
- st.shard3,
- st.shard4,
- st.shard5,
- st.shard6,
- st.shard7,
- st.shard8,
- st.shard9
- ];
+var shards = [
+ st.shard0,
+ st.shard1,
+ st.shard2,
+ st.shard3,
+ st.shard4,
+ st.shard5,
+ st.shard6,
+ st.shard7,
+ st.shard8,
+ st.shard9
+];
- assert.commandWorked(admin.runCommand({enableSharding: "" + collA.getDB()}));
- st.ensurePrimaryShard(collA.getDB().getName(), st.shard1.shardName);
- assert.commandWorked(admin.runCommand({shardCollection: "" + collA, key: {_id: 1}}));
+assert.commandWorked(admin.runCommand({enableSharding: "" + collA.getDB()}));
+st.ensurePrimaryShard(collA.getDB().getName(), st.shard1.shardName);
+assert.commandWorked(admin.runCommand({shardCollection: "" + collA, key: {_id: 1}}));
- jsTestLog("Splitting up the collection...");
+jsTestLog("Splitting up the collection...");
- // Split up the collection
- for (var i = 0; i < shards.length; i++) {
- assert.commandWorked(admin.runCommand({split: "" + collA, middle: {_id: i}}));
- assert.commandWorked(
- admin.runCommand({moveChunk: "" + collA, find: {_id: i}, to: shards[i].shardName}));
- }
+// Split up the collection
+for (var i = 0; i < shards.length; i++) {
+ assert.commandWorked(admin.runCommand({split: "" + collA, middle: {_id: i}}));
+ assert.commandWorked(
+ admin.runCommand({moveChunk: "" + collA, find: {_id: i}, to: shards[i].shardName}));
+}
- mongosB.getDB("admin").runCommand({flushRouterConfig: 1});
- mongosC.getDB("admin").runCommand({flushRouterConfig: 1});
+mongosB.getDB("admin").runCommand({flushRouterConfig: 1});
+mongosC.getDB("admin").runCommand({flushRouterConfig: 1});
- printjson(collB.count());
- printjson(collC.count());
+printjson(collB.count());
+printjson(collC.count());
- // Change up all the versions...
- for (var i = 0; i < shards.length; i++) {
- assert.commandWorked(admin.runCommand({
- moveChunk: "" + collA,
- find: {_id: i},
- to: shards[(i + 1) % shards.length].shardName
- }));
- }
+// Change up all the versions...
+for (var i = 0; i < shards.length; i++) {
+ assert.commandWorked(admin.runCommand(
+ {moveChunk: "" + collA, find: {_id: i}, to: shards[(i + 1) % shards.length].shardName}));
+}
- // Make sure mongos A is up-to-date
- mongosA.getDB("admin").runCommand({flushRouterConfig: 1});
+// Make sure mongos A is up-to-date
+mongosA.getDB("admin").runCommand({flushRouterConfig: 1});
- jsTestLog("Running count!");
+jsTestLog("Running count!");
- printjson(collB.count());
- printjson(collC.find().toArray());
-
- st.stop();
+printjson(collB.count());
+printjson(collC.find().toArray());
+st.stop();
})();