diff options
Diffstat (limited to 'jstests/core/timeseries/timeseries_id_index.js')
-rw-r--r-- | jstests/core/timeseries/timeseries_id_index.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/jstests/core/timeseries/timeseries_id_index.js b/jstests/core/timeseries/timeseries_id_index.js index 824a0ff1550..e3bc20d6648 100644 --- a/jstests/core/timeseries/timeseries_id_index.js +++ b/jstests/core/timeseries/timeseries_id_index.js @@ -1,7 +1,8 @@ /** - * Verifies that the _id index cannot be created on a time-series collection. + * Verifies that the _id index can be created on a timeseries collection. * * @tags: [ + * requires_fcv_52, * does_not_support_stepdowns, * does_not_support_transactions, * requires_getmore, @@ -18,8 +19,10 @@ assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField const bucketsColl = db.getCollection("system.buckets." + coll.getName()); -const res = bucketsColl.createIndex({"_id": 1}); -assert.commandFailedWithCode(res, ErrorCodes.CannotCreateIndex); -assert(res.errmsg.includes("cannot create the _id index on a clustered collection") || - res.errmsg.includes("cannot create an _id index on a collection already clustered by _id")); +assert.commandWorked(bucketsColl.createIndex({"_id": 1})); +assert.commandWorked(bucketsColl.createIndex({"_id": 1}, {clustered: true, unique: true})); + +// Passing 'clustered' without unique, regardless of the type of clustered collection, is illegal. +assert.commandFailedWithCode(bucketsColl.createIndex({"_id": 1}, {clustered: true}), + ErrorCodes.CannotCreateIndex); })(); |