diff options
Diffstat (limited to 'jstests/sharding/listshards.js')
-rw-r--r-- | jstests/sharding/listshards.js | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/jstests/sharding/listshards.js b/jstests/sharding/listshards.js index c1c6c5703de..b11a6e13831 100644 --- a/jstests/sharding/listshards.js +++ b/jstests/sharding/listshards.js @@ -3,6 +3,7 @@ // (function() { 'use strict'; +load('jstests/sharding/libs/remove_shard_util.js'); // TODO SERVER-50144 Remove this and allow orphan checking. // This test calls removeShard which can leave docs in config.rangeDeletions in state "pending", @@ -20,10 +21,10 @@ const checkShardName = function(shardName, shardsArray) { return found; }; -const shardTest = +const st = new ShardingTest({name: 'listShardsTest', shards: 1, mongos: 1, other: {useHostname: true}}); -const mongos = shardTest.s0; +const mongos = st.s0; let res = mongos.adminCommand('listShards'); assert.commandWorked(res, 'listShards command failed'); let shardsArray = res.shards; @@ -34,7 +35,7 @@ const rs1 = new ReplSetTest({name: 'repl', nodes: 1, useHostName: true, nodeOptions: {shardsvr: ""}}); rs1.startSet(); rs1.initiate(); -res = shardTest.admin.runCommand({addShard: rs1.getURL()}); +res = st.admin.runCommand({addShard: rs1.getURL()}); assert.commandWorked(res, 'addShard command failed'); res = mongos.adminCommand('listShards'); assert.commandWorked(res, 'listShards command failed'); @@ -44,20 +45,7 @@ assert(checkShardName('repl', shardsArray), 'listShards command didn\'t return replica set shard: ' + tojson(shardsArray)); // remove 'repl' shard -assert.soon(function() { - var res = shardTest.admin.runCommand({removeShard: 'repl'}); - if (!res.ok && res.code === ErrorCodes.ShardNotFound) { - // If the config server primary steps down right after removing the config.shards doc - // for the shard but before responding with "state": "completed", the mongos would retry - // the _configsvrRemoveShard command against the new config server primary, which would - // not find the removed shard in its ShardRegistry if it has done a ShardRegistry reload - // after the config.shards doc for the shard was removed. This would cause the command - // to fail with ShardNotFound. - return true; - } - assert.commandWorked(res, 'removeShard command failed'); - return res.state === 'completed'; -}, 'failed to remove the replica set shard'); +removeShard(st, 'repl'); res = mongos.adminCommand('listShards'); assert.commandWorked(res, 'listShards command failed'); @@ -67,5 +55,5 @@ assert(!checkShardName('repl', shardsArray), 'listShards command returned removed replica set shard: ' + tojson(shardsArray)); rs1.stopSet(); -shardTest.stop(); +st.stop(); })(); |