summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorArun Banala <arun.banala@mongodb.com>2021-11-29 12:59:18 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-01-07 15:28:33 +0000
commit9dde75ce972cf230b5afcc3a2427d80b3d7b5e47 (patch)
tree67105e982efaaab851838853f9698553379c7d0c /jstests
parent660480ddf90b1d4b61bab72dd307ff869ce59e2d (diff)
downloadmongo-9dde75ce972cf230b5afcc3a2427d80b3d7b5e47.tar.gz
SERVER-61590 Add null check before accesssing time-series options in the shardCollection code path
(cherry picked from commit fcea6b10c2ea966433cf009382bf432c9afe1e20)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/timeseries_shard_collection.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/jstests/sharding/timeseries_shard_collection.js b/jstests/sharding/timeseries_shard_collection.js
index c831180164a..6a8c95421da 100644
--- a/jstests/sharding/timeseries_shard_collection.js
+++ b/jstests/sharding/timeseries_shard_collection.js
@@ -311,6 +311,27 @@ if (TimeseriesTest.shardedtimeseriesCollectionsEnabled(st.shard0)) {
runShardKeyPatternValidation(true);
runShardKeyPatternValidation(false);
+ // Verify that the shardCollection command fails if the 'system.buckets' collection does not
+ // have time-series options.
+ sDB.getCollection("ts").drop();
+ sDB.createCollection("system.buckets.ts");
+ assert.commandFailedWithCode(st.s.adminCommand({
+ shardCollection: 'test.ts',
+ key: {time: 1},
+ }),
+ 6159000);
+ assert.commandFailedWithCode(
+ st.s.adminCommand(
+ {shardCollection: 'test.ts', key: {time: 1}, timeseries: {timeField: 'time'}}),
+ 6159000);
+
+ // Cannot shard a system namespace.
+ assert.commandFailedWithCode(st.s.adminCommand({
+ shardCollection: 'test.system.bucket.ts',
+ key: {time: 1},
+ }),
+ ErrorCodes.IllegalOperation);
+
} else {
(function timeseriesCollectionsCannotBeSharded() {
assert.commandFailedWithCode(