diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2019-01-28 20:55:04 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2019-01-29 22:15:56 -0500 |
commit | 1c61dfa3307c2009dd29c893b8d2b08af6bcf7d6 (patch) | |
tree | 0c1158d649100c015c8e30d142a4b04a62213e90 /jstests/sharding/add_and_remove_shard_from_zone.js | |
parent | 09abfff1c4ad2f98a9b83093b7e8b6454bc7c393 (diff) | |
download | mongo-1c61dfa3307c2009dd29c893b8d2b08af6bcf7d6.tar.gz |
SERVER-39234 Ensure `shardCollection` initial split works the same between config server and shard primary
Diffstat (limited to 'jstests/sharding/add_and_remove_shard_from_zone.js')
-rw-r--r-- | jstests/sharding/add_and_remove_shard_from_zone.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/jstests/sharding/add_and_remove_shard_from_zone.js b/jstests/sharding/add_and_remove_shard_from_zone.js new file mode 100644 index 00000000000..d4773597259 --- /dev/null +++ b/jstests/sharding/add_and_remove_shard_from_zone.js @@ -0,0 +1,40 @@ +/** + * Basic integration tests for addShardToZone command. More detailed tests can be found + * in sharding_catalog_add_shard_to_zone_test.cpp. + */ +(function() { + 'use strict'; + + let st = new ShardingTest({shards: 1}); + let mongos = st.s0; + + let config = mongos.getDB('config'); + var shardName = st.shard0.shardName; + + // Test adding shard with no zone to a new zone. + assert.commandWorked(mongos.adminCommand({addShardToZone: shardName, zone: 'x'})); + var shardDoc = config.shards.findOne(); + assert.eq(['x'], shardDoc.tags); + + // Test adding zone to a shard with existing zones. + assert.commandWorked(mongos.adminCommand({addShardToZone: shardName, zone: 'y'})); + shardDoc = config.shards.findOne(); + assert.eq(['x', 'y'], shardDoc.tags); + + // Test removing shard from existing zone. + assert.commandWorked(mongos.adminCommand({removeShardFromZone: shardName, zone: 'x'})); + shardDoc = config.shards.findOne(); + assert.eq(['y'], shardDoc.tags); + + // Test removing shard from zone that no longer exists. + assert.commandWorked(mongos.adminCommand({removeShardFromZone: shardName, zone: 'x'})); + shardDoc = config.shards.findOne(); + assert.eq(['y'], shardDoc.tags); + + // Test removing the last zone from a shard + assert.commandWorked(mongos.adminCommand({removeShardFromZone: shardName, zone: 'y'})); + shardDoc = config.shards.findOne(); + assert.eq([], shardDoc.tags); + + st.stop(); +})(); |