Files
mongo/jstests/sharding/hash_shard_num_chunks.js
Kaloian Manassiev 706ac90265 SERVER-21186 Make all sharding tests use default verbosity of 1
The default ShardingTest verbosity is currently zero, but we have many
tests, which bump it to 1 and even higher.

Since verbosity level of 0 is sometimes insufficient for investigating
transient failures, this change makes the default to be 1 and removes all
places, which explicitly make it 1 or higher.
2015-11-11 11:01:18 -05:00

42 lines
1.2 KiB
JavaScript

// Hash sharding with initial chunk count set.
// @tags: [ hashed ]
(function() {
var s = new ShardingTest({ shards: 3, mongos: 1 });
s.stopBalancer();
var dbname = "test";
var coll = "foo";
var db = s.getDB(dbname);
assert.commandWorked(db.adminCommand({ enablesharding: dbname }));
s.ensurePrimaryShard(dbname, 'shard0001');
assert.commandWorked(db.adminCommand({ shardcollection: dbname + "." + coll,
key: { a: "hashed" },
numInitialChunks: 500 }));
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();
})();