diff options
author | Kim Tao <kimbery.tao@10gen.com> | 2018-12-09 17:38:45 -0500 |
---|---|---|
committer | Kim Tao <kimberly.tao@mongodb.com> | 2018-12-11 18:07:32 -0500 |
commit | 5a4fa1d1d7bb23939c104432bb8297778a69e7cc (patch) | |
tree | ac18ff1e06128c1fd3c29f7a334acea6b6d90cfe /jstests | |
parent | 5378eb39b3dbe598ee2362d2ffb0200e48037758 (diff) | |
download | mongo-5a4fa1d1d7bb23939c104432bb8297778a69e7cc.tar.gz |
SERVER-38392: remove assertion that we can't shard a non-empty collection associated with tagsr4.0.5-rc0
(cherry picked from commit 778f905b2905c00b6f394d8db6e7d12e87d7ad3d)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/shard_collection_existing_zones.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/jstests/sharding/shard_collection_existing_zones.js b/jstests/sharding/shard_collection_existing_zones.js index d6cb10c304e..8782e4e132b 100644 --- a/jstests/sharding/shard_collection_existing_zones.js +++ b/jstests/sharding/shard_collection_existing_zones.js @@ -128,6 +128,52 @@ assert.commandWorked(testDB.runCommand({drop: kCollName})); } + /** + * Tests that a non-empty collection associated with zones can be sharded. + */ + function testNonemptyZonedCollection() { + var shardKey = {x: 1}; + var shards = configDB.shards.find().toArray(); + var testColl = testDB.getCollection(kCollName); + var ranges = [ + {min: {x: 0}, max: {x: 10}}, + {min: {x: 10}, max: {x: 20}}, + {min: {x: 20}, max: {x: 40}} + ]; + + for (let i = 0; i < 40; i++) { + assert.writeOK(testColl.insert({x: i})); + } + + assert.commandWorked(testColl.createIndex(shardKey)); + + for (let i = 0; i < shards.length; i++) { + assert.commandWorked( + mongos.adminCommand({addShardToZone: shards[i]._id, zone: zoneName + i})); + assert.commandWorked(mongos.adminCommand({ + updateZoneKeyRange: ns, + min: ranges[i].min, + max: ranges[i].max, + zone: zoneName + i + })); + } + + assert.commandWorked(mongos.adminCommand({shardCollection: ns, key: shardKey})); + + // Check that there is initially 1 chunk. + assert.eq(1, configDB.chunks.count({ns: ns})); + + st.startBalancer(); + + // Check that the chunks were moved properly. + assert.soon(() => { + let res = configDB.chunks.count({ns: ns}); + return res === 5; + }, 'balancer never ran', 10 * 60 * 1000, 1000); + + assert.commandWorked(testDB.runCommand({drop: kCollName})); + } + // test that shardCollection checks that a zone is associated with a shard. testShardZoneAssociationValidation({x: 1}, false, false); @@ -152,5 +198,7 @@ testChunkSplits(false); testChunkSplits(true); + testNonemptyZonedCollection(); + st.stop(); })(); |