mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 00:17:37 +01:00
771dabd098
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
// Tests that commands that should not be runnable on sharded collections cannot be run on sharded
|
|
// collections.
|
|
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
|
|
|
const st = new ShardingTest({shards: 2, mongos: 2});
|
|
|
|
const dbName = 'test';
|
|
const coll = 'foo';
|
|
const ns = dbName + '.' + coll;
|
|
|
|
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}}));
|
|
|
|
// 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.NamespaceCannotBeSharded);
|
|
assert.commandFailedWithCode(staleMongos.runCommand({convertToCapped: coll, size: 32 * 1024}),
|
|
ErrorCodes.NamespaceCannotBeSharded);
|
|
assert(!freshMongos.getCollection(coll).isCapped());
|
|
|
|
st.stop();
|