Files
mongo/jstests/sharding/merge_chunks_test_with_md_ops.js
Kaloian Manassiev e2e4c75844 SERVER-21050 Continuous config stepdown logging changes
This commit is part of the overall change to enable continuous config
server stepdown and it includes improvements to logging and test
validation. It does not actually enable the stepdown thread.
2015-12-21 15:20:12 -05:00

58 lines
2.0 KiB
JavaScript

// Tests that merging chunks does not prevent cluster from doing other metadata ops
(function() {
'use strict';
var st = new ShardingTest({ shards: 2 });
var mongos = st.s0;
var admin = mongos.getDB("admin");
var shards = mongos.getCollection("config.shards").find().toArray();
var coll = mongos.getCollection("foo.bar");
assert.commandWorked(admin.runCommand({ enableSharding: coll.getDB() + "" }));
st.ensurePrimaryShard(coll.getDB() + "", shards[0]._id);
assert.commandWorked(admin.runCommand({ shardCollection: coll + "", key: { _id: 1 } }));
st.printShardingStatus();
// Split and merge the first chunk repeatedly
jsTest.log("Splitting and merging repeatedly...");
for (var i = 0; i < 5; i++) {
assert.commandWorked(admin.runCommand({ split: coll + "", middle: { _id: i } }));
assert.commandWorked(admin.runCommand({ mergeChunks: coll + "",
bounds: [ { _id: MinKey }, { _id: MaxKey } ] }));
printjson(mongos.getDB("config").chunks.find().toArray());
}
// Move the first chunk to the other shard
jsTest.log("Moving to another shard...");
assert.commandWorked(admin.runCommand({ moveChunk: coll + "",
find: { _id: 0 },
to: shards[1]._id }));
// Split and merge the chunk repeatedly
jsTest.log("Splitting and merging repeatedly (again)...");
for (var i = 0; i < 5; i++) {
assert.commandWorked(admin.runCommand({ split: coll + "", middle: { _id: i } }));
assert.commandWorked(admin.runCommand({ mergeChunks: coll + "",
bounds: [{ _id: MinKey }, { _id: MaxKey }] }));
printjson(mongos.getDB("config").chunks.find().toArray());
}
// Move the chunk back to the original shard
jsTest.log("Moving to original shard...");
assert.commandWorked(admin.runCommand({ moveChunk: coll + "",
find: { _id: 0 },
to: shards[0]._id }));
st.printShardingStatus();
st.stop();
})();