diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-11-17 17:36:12 -0500 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2015-11-18 18:25:52 -0500 |
commit | 68dfaba3e86fbce302fa62f33b644d8b36944423 (patch) | |
tree | 306fd7c8fc5b7503240a76ed8242bdb51740de1c /jstests/libs | |
parent | f42a080cc0341d42ea5d5e42aa96366e0d952864 (diff) | |
download | mongo-68dfaba3e86fbce302fa62f33b644d8b36944423.tar.gz |
SERVER-21489 enableSharding should return error if sharding is already enabled
Diffstat (limited to 'jstests/libs')
-rw-r--r-- | jstests/libs/override_methods/implicitly_shard_accessed_collections.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/jstests/libs/override_methods/implicitly_shard_accessed_collections.js b/jstests/libs/override_methods/implicitly_shard_accessed_collections.js index 45ba5af116f..ab69f1cb817 100644 --- a/jstests/libs/override_methods/implicitly_shard_accessed_collections.js +++ b/jstests/libs/override_methods/implicitly_shard_accessed_collections.js @@ -21,6 +21,7 @@ ]; DB.prototype.getCollection = function() { + var dbName = this.getName(); var collection = originalGetCollection.apply(this, arguments); var fullName = collection.getFullName(); @@ -36,8 +37,12 @@ } } - var res = this.adminCommand({enableSharding: this.getName()}); - assert.commandWorked(res, "enabling sharding on the '" + this.getName() + "' db failed"); + var res = this.adminCommand({enableSharding: dbName}); + + // enableSharding may only be called once for a database. + if (res.code !== ErrorCodes.AlreadyInitialized) { + assert.commandWorked(res, "enabling sharding on the '" + dbName + "' db failed"); + } res = this.adminCommand({shardCollection: fullName, key: {_id: 'hashed'}}); assert.commandWorked(res, "sharding '" + fullName + "' with a hashed _id key failed"); |