summaryrefslogtreecommitdiff
path: root/jstests/sharding/migrateBig.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/migrateBig.js')
-rw-r--r--jstests/sharding/migrateBig.js95
1 files changed, 47 insertions, 48 deletions
diff --git a/jstests/sharding/migrateBig.js b/jstests/sharding/migrateBig.js
index 5cdc03d292e..e525a909fea 100644
--- a/jstests/sharding/migrateBig.js
+++ b/jstests/sharding/migrateBig.js
@@ -1,68 +1,67 @@
(function() {
- 'use strict';
+'use strict';
- var s = new ShardingTest({name: "migrateBig", shards: 2, other: {chunkSize: 1}});
+var s = new ShardingTest({name: "migrateBig", shards: 2, other: {chunkSize: 1}});
- assert.writeOK(
- s.config.settings.update({_id: "balancer"}, {$set: {_waitForDelete: true}}, true));
- assert.commandWorked(s.s0.adminCommand({enablesharding: "test"}));
- s.ensurePrimaryShard('test', s.shard1.shardName);
- assert.commandWorked(s.s0.adminCommand({shardcollection: "test.foo", key: {x: 1}}));
+assert.writeOK(s.config.settings.update({_id: "balancer"}, {$set: {_waitForDelete: true}}, true));
+assert.commandWorked(s.s0.adminCommand({enablesharding: "test"}));
+s.ensurePrimaryShard('test', s.shard1.shardName);
+assert.commandWorked(s.s0.adminCommand({shardcollection: "test.foo", key: {x: 1}}));
- var db = s.getDB("test");
- var coll = db.foo;
+var db = s.getDB("test");
+var coll = db.foo;
- var big = "";
- while (big.length < 10000)
- big += "eliot";
+var big = "";
+while (big.length < 10000)
+ big += "eliot";
- var bulk = coll.initializeUnorderedBulkOp();
- for (var x = 0; x < 100; x++) {
- bulk.insert({x: x, big: big});
- }
- assert.writeOK(bulk.execute());
+var bulk = coll.initializeUnorderedBulkOp();
+for (var x = 0; x < 100; x++) {
+ bulk.insert({x: x, big: big});
+}
+assert.writeOK(bulk.execute());
- assert.commandWorked(s.s0.adminCommand({split: "test.foo", middle: {x: 30}}));
- assert.commandWorked(s.s0.adminCommand({split: "test.foo", middle: {x: 66}}));
- assert.commandWorked(s.s0.adminCommand(
- {movechunk: "test.foo", find: {x: 90}, to: s.getOther(s.getPrimaryShard("test")).name}));
+assert.commandWorked(s.s0.adminCommand({split: "test.foo", middle: {x: 30}}));
+assert.commandWorked(s.s0.adminCommand({split: "test.foo", middle: {x: 66}}));
+assert.commandWorked(s.s0.adminCommand(
+ {movechunk: "test.foo", find: {x: 90}, to: s.getOther(s.getPrimaryShard("test")).name}));
- s.printShardingStatus();
+s.printShardingStatus();
- print("YO : " + s.getPrimaryShard("test").host);
- var direct = new Mongo(s.getPrimaryShard("test").host);
- print("direct : " + direct);
+print("YO : " + s.getPrimaryShard("test").host);
+var direct = new Mongo(s.getPrimaryShard("test").host);
+print("direct : " + direct);
- var directDB = direct.getDB("test");
+var directDB = direct.getDB("test");
- for (var done = 0; done < 2 * 1024 * 1024; done += big.length) {
- assert.writeOK(directDB.foo.insert({x: 50 + Math.random(), big: big}));
- }
+for (var done = 0; done < 2 * 1024 * 1024; done += big.length) {
+ assert.writeOK(directDB.foo.insert({x: 50 + Math.random(), big: big}));
+}
- s.printShardingStatus();
+s.printShardingStatus();
- // This is a large chunk, which should not be able to move
- assert.commandFailed(s.s0.adminCommand(
- {movechunk: "test.foo", find: {x: 50}, to: s.getOther(s.getPrimaryShard("test")).name}));
+// This is a large chunk, which should not be able to move
+assert.commandFailed(s.s0.adminCommand(
+ {movechunk: "test.foo", find: {x: 50}, to: s.getOther(s.getPrimaryShard("test")).name}));
- for (var i = 0; i < 20; i += 2) {
- try {
- assert.commandWorked(s.s0.adminCommand({split: "test.foo", middle: {x: i}}));
- } catch (e) {
- // We may have auto split on some of these, which is ok
- print(e);
- }
+for (var i = 0; i < 20; i += 2) {
+ try {
+ assert.commandWorked(s.s0.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.startBalancer();
+s.startBalancer();
- 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);
- s.stop();
+s.stop();
})();