summaryrefslogtreecommitdiff
path: root/jstests/sharding/hash_shard_num_chunks.js
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2013-04-05 11:30:08 -0400
committerRandolph Tan <randolph@10gen.com>2013-04-09 09:54:04 -0400
commit8f18c1f029f040760bafa222fa2976d3102e579f (patch)
tree2b3facc66a4699f7463d4505d1a453646b4dd949 /jstests/sharding/hash_shard_num_chunks.js
parentd34383a1c346d039a002579408dc2bde3b9f111f (diff)
downloadmongo-8f18c1f029f040760bafa222fa2976d3102e579f.tar.gz
SERVER-9260 Race in hash_presplit.js
Split the each test case into different files to isolate them from each other.
Diffstat (limited to 'jstests/sharding/hash_shard_num_chunks.js')
-rw-r--r--jstests/sharding/hash_shard_num_chunks.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/sharding/hash_shard_num_chunks.js b/jstests/sharding/hash_shard_num_chunks.js
new file mode 100644
index 00000000000..cf4bb481c14
--- /dev/null
+++ b/jstests/sharding/hash_shard_num_chunks.js
@@ -0,0 +1,35 @@
+// Hash sharding with initial chunk count set.
+
+var s = new ShardingTest({ shards : 3, mongos : 1, verbose : 1 });
+var dbname = "test";
+var coll = "foo";
+var db = s.getDB(dbname);
+db.adminCommand({ enablesharding : dbname });
+
+//for simplicity turn off balancer
+s.stopBalancer();
+
+var res = db.adminCommand({ shardcollection : dbname + "." + coll,
+ key : { a : "hashed" },
+ numInitialChunks : 500 });
+assert.eq(res.ok, 1, "shardcollection didn't work");
+db.printShardingStatus();
+var numChunks = s.config.chunks.count();
+assert.eq(numChunks, 500 , "should be exactly 500 chunks");
+
+var shards = s.config.shards.find();
+shards.forEach(
+ // check that each shard has one third the numInitialChunks
+ function (shard){
+ var numChunksOnShard = s.config.chunks.find({"shard" : shard._id}).count();
+ assert.gte(numChunksOnShard, Math.floor(500/3));
+ }
+);
+
+// Check that the collection gets dropped correctly (which doesn't happen if pre-splitting
+// fails to create the collection on all shards).
+res = db.runCommand({ "drop" : coll });
+assert.eq(res.ok, 1, "couldn't drop empty, pre-split collection");
+
+s.stop();
+