(function() {
|
"use strict"; load("jstests/libs/check_log.js"); const st = new ShardingTest({ shards: 1, verbose: 2 }); jsTest.log("about to create database 'test' on 'otherShard'");
|
let otherShard = MongoRunner.runMongod({'shardsvr': ''});
|
assert.commandWorked(otherShard.getDB("test").getCollection("foo").insert({ x: 1 })); const configPrimary = st.configRS.getPrimary(); jsTest.log("about to start addShard");
|
assert.commandWorked(configPrimary.adminCommand({ configureFailPoint: "hangAddShardAfterCheckingDatabases", mode: "alwaysOn" }));
|
let addShardHandle = startParallelShell('assert.commandWorked(db.adminCommand({ addShard: "' + otherShard.host + '" }));', st.s.port); jsTest.log("wait for failpoint in addShard to be hit");
|
checkLog.contains(configPrimary, "Hit hangAddShardAfterCheckingDatabase failpoint"); jsTest.log("about to create database 'test' on cluster");
|
assert.commandWorked(st.s.adminCommand({ enableSharding: "test" }));
|
assert.eq(st.shard0.shardName, st.s.getDB("config").getCollection("databases").findOne({ _id: "test" }).primary); jsTest.log("about to allow addShard to complete");
|
assert.commandWorked(st.configRS.getPrimary().adminCommand({ configureFailPoint: "hangAddShardAfterCheckingDatabases", mode: "off" }));
|
addShardHandle(); assert.eq(st.shard0.shardName, st.s.getDB("config").getCollection("databases").findOne({ _id: "test" }).primary); // expect fail MongoRunner.stopMongod(otherShard);
|
st.stop();})();
|