summaryrefslogtreecommitdiff
path: root/jstests/sharding/index_commands_shard_targeting.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/index_commands_shard_targeting.js')
-rw-r--r--jstests/sharding/index_commands_shard_targeting.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/jstests/sharding/index_commands_shard_targeting.js b/jstests/sharding/index_commands_shard_targeting.js
index c9f70fc8f50..d7a5f0d0c86 100644
--- a/jstests/sharding/index_commands_shard_targeting.js
+++ b/jstests/sharding/index_commands_shard_targeting.js
@@ -55,8 +55,7 @@ function assertCommandChecksShardVersions(st, dbName, collName, testCase) {
// (no chunks).
ShardVersioningUtil.assertCollectionVersionOlderThan(st.shard0, ns, latestCollectionVersion);
- // Assert that the targeted shards have the latest collection version after the command is
- // run.
+ // Assert that the targeted shards have the latest collection version after the command is run.
ShardVersioningUtil.assertCollectionVersionEquals(st.shard1, ns, latestCollectionVersion);
ShardVersioningUtil.assertCollectionVersionEquals(st.shard2, ns, latestCollectionVersion);
}
@@ -181,6 +180,19 @@ const testCases = {
}
};
},
+ collMod: collName => {
+ return {
+ command: {collMod: collName, validator: {x: {$type: "string"}}},
+ assertCommandRanOnShard: (shard) => {
+ assert.commandFailedWithCode(
+ shard.getCollection(dbName + "." + collName).insert({x: 1}),
+ ErrorCodes.DocumentValidationFailure);
+ },
+ assertCommandDidNotRunOnShard: (shard) => {
+ assert.commandWorked(shard.getCollection(dbName + "." + collName).insert({x: 1}));
+ }
+ };
+ },
};
assert.commandWorked(st.s.adminCommand({enableSharding: dbName}));