diff options
Diffstat (limited to 'jstests/sharding/not_allowed_on_sharded_collection_cmd.js')
-rw-r--r-- | jstests/sharding/not_allowed_on_sharded_collection_cmd.js | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/jstests/sharding/not_allowed_on_sharded_collection_cmd.js b/jstests/sharding/not_allowed_on_sharded_collection_cmd.js index 2649994c300..7190e8b6bba 100644 --- a/jstests/sharding/not_allowed_on_sharded_collection_cmd.js +++ b/jstests/sharding/not_allowed_on_sharded_collection_cmd.js @@ -2,25 +2,24 @@ // collections. (function() { - const st = new ShardingTest({shards: 2, mongos: 2}); +const st = new ShardingTest({shards: 2, mongos: 2}); - const dbName = 'test'; - const coll = 'foo'; - const ns = dbName + '.' + coll; +const dbName = 'test'; +const coll = 'foo'; +const ns = dbName + '.' + coll; - const freshMongos = st.s0.getDB(dbName); - const staleMongos = st.s1.getDB(dbName); +const freshMongos = st.s0.getDB(dbName); +const staleMongos = st.s1.getDB(dbName); - assert.commandWorked(staleMongos.adminCommand({enableSharding: dbName})); - assert.commandWorked(freshMongos.adminCommand({shardCollection: ns, key: {_id: 1}})); +assert.commandWorked(staleMongos.adminCommand({enableSharding: dbName})); +assert.commandWorked(freshMongos.adminCommand({shardCollection: ns, key: {_id: 1}})); - // Test that commands that should not be runnable on sharded collection do not work on sharded - // collections, using both fresh mongos and stale mongos instances. - assert.commandFailedWithCode(freshMongos.runCommand({convertToCapped: coll, size: 64 * 1024}), - ErrorCodes.IllegalOperation); - assert.commandFailedWithCode(staleMongos.runCommand({convertToCapped: coll, size: 32 * 1024}), - ErrorCodes.IllegalOperation); - - st.stop(); +// Test that commands that should not be runnable on sharded collection do not work on sharded +// collections, using both fresh mongos and stale mongos instances. +assert.commandFailedWithCode(freshMongos.runCommand({convertToCapped: coll, size: 64 * 1024}), + ErrorCodes.IllegalOperation); +assert.commandFailedWithCode(staleMongos.runCommand({convertToCapped: coll, size: 32 * 1024}), + ErrorCodes.IllegalOperation); +st.stop(); })(); |