summaryrefslogtreecommitdiff
path: root/jstests/sharding/hash_shard_non_empty.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_non_empty.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_non_empty.js')
-rw-r--r--jstests/sharding/hash_shard_non_empty.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/jstests/sharding/hash_shard_non_empty.js b/jstests/sharding/hash_shard_non_empty.js
new file mode 100644
index 00000000000..f45e1c2113c
--- /dev/null
+++ b/jstests/sharding/hash_shard_non_empty.js
@@ -0,0 +1,22 @@
+// Hash sharding on a non empty collection should not pre-split.
+
+var s = new ShardingTest({ name : jsTestName(), 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();
+
+db.getCollection(coll).insert({ a : 1 });
+
+db.getCollection(coll).ensureIndex({ a: "hashed"});
+var res = db.adminCommand({ shardcollection : dbname + "." + coll, key : { a : "hashed" } });
+assert.eq(res.ok, 1, "shardcollection didn't work");
+db.printShardingStatus();
+var numChunks = s.config.chunks.count();
+assert.eq(numChunks, 1 , "sharding non-empty collection should not pre-split");
+
+s.stop();
+