summaryrefslogtreecommitdiff
path: root/jstests/sharding/add_and_remove_shard_from_zone.js
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-01-28 20:55:04 -0500
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-01-29 22:15:56 -0500
commit1c61dfa3307c2009dd29c893b8d2b08af6bcf7d6 (patch)
tree0c1158d649100c015c8e30d142a4b04a62213e90 /jstests/sharding/add_and_remove_shard_from_zone.js
parent09abfff1c4ad2f98a9b83093b7e8b6454bc7c393 (diff)
downloadmongo-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.js40
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();
+})();