summaryrefslogtreecommitdiff
path: root/jstests/sharding/hash_shard_non_empty.js
blob: f45e1c2113c16e0ef2869795769f63a72c6613d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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();