File: hash_shard_non_empty.js

package info (click to toggle)
mongodb 1%3A2.4.8-2~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 81,908 kB
  • sloc: cpp: 739,744; ansic: 152,098; sh: 13,810; python: 11,864; makefile: 1,011; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (22 lines) | stat: -rw-r--r-- 721 bytes parent folder | download | duplicates (3)
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();