Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
3.0.11, 3.2.9, 3.3.11
-
None
-
Sharding
-
ALL
Description
Repro steps below, not a regression. Checked back to 3.0.x
(function() {
|
'use strict';
|
var checkCollectionExists = function(coll) {
|
var collArray = coll.getDB().runCommand("listCollections").cursor.firstBatch;
|
var colls = collArray.filter(function(spec) { return spec.name === coll.getName(); });
|
assert.eq(1, colls.length, tojson(collArray));
|
}
|
|
|
var st = new ShardingTest({shards: 2});
|
var mongos = st.s;
|
var configDb = st.s.getDB("config");
|
var shard0 = st.shard0.shardName;
|
var shard1 = st.shard1.shardName;
|
var coll = mongos.getCollection('test.list_collections');
|
|
|
assert.commandWorked(mongos.adminCommand({ enableSharding: coll.getDB() + ""}));
|
assert.commandWorked(
|
mongos.adminCommand({ shardCollection: coll + "", key: { "x" : 1 }}));
|
|
|
jsTestLog("insert a single document into mycoll");
|
assert.writeOK(coll.insert({ "x" : 1 }));
|
checkCollectionExists(coll);
|
|
|
jsTestLog("check that primary shard is " + shard0 + " then moving primary to " + shard1);
|
assert.eq(1, configDb.databases.count({ "_id" : coll.getDB().getName(), "primary" : shard0 }));
|
assert.commandWorked(mongos.adminCommand({ movePrimary: coll.getDB().getName(), to: shard1}));
|
checkCollectionExists(coll);
|
|
|
st.stop();
|
})();
|