0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/jstests/sharding/shard_keycount.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2011-03-06 08:51:59 +01:00
// Tests splitting a chunk twice
(function() {
'use strict';
2011-03-06 08:51:59 +01:00
var s = new ShardingTest({name: "shard_keycount", shards: 2, mongos: 1, other: {chunkSize: 1}});
var dbName = "test";
var collName = "foo";
var ns = dbName + "." + collName;
2011-03-06 08:51:59 +01:00
var db = s.getDB(dbName);
2011-03-06 08:51:59 +01:00
for (var i = 0; i < 10; i++) {
db.foo.insert({_id: i});
}
2011-03-06 08:51:59 +01:00
// Enable sharding on DB
assert.commandWorked(s.s0.adminCommand({enablesharding: dbName}));
s.ensurePrimaryShard(dbName, s.shard1.shardName);
2011-03-06 08:51:59 +01:00
// Enable sharding on collection
assert.commandWorked(s.s0.adminCommand({shardcollection: ns, key: {_id: 1}}));
2011-03-06 08:51:59 +01:00
// Split into two chunks
assert.commandWorked(s.s0.adminCommand({split: ns, find: {_id: 3}}));
2011-03-06 08:51:59 +01:00
var coll = db.getCollection(collName);
2011-03-06 08:51:59 +01:00
// Split chunk again
assert.commandWorked(s.s0.adminCommand({split: ns, find: {_id: 3}}));
2011-03-06 08:51:59 +01:00
assert.writeOK(coll.update({_id: 3}, {_id: 3}));
2011-03-06 08:51:59 +01:00
// Split chunk again
assert.commandWorked(s.s0.adminCommand({split: ns, find: {_id: 3}}));
2011-03-06 08:51:59 +01:00
assert.writeOK(coll.update({_id: 3}, {_id: 3}));
2011-03-06 08:51:59 +01:00
// Split chunk again
assert.commandWorked(s.s0.adminCommand({split: ns, find: {_id: 3}}));
2011-03-06 08:51:59 +01:00
s.stop();
})();