blob: f20cceef768d8c76c0b4c523331ad26a7132c129 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/**
* Verifies that the _id index cannot be created on a time-series collection.
*
* @tags: [
* does_not_support_stepdowns,
* does_not_support_transactions,
* requires_getmore,
* ]
*/
(function() {
"use strict";
load("jstests/core/timeseries/libs/timeseries.js");
if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) {
jsTestLog("Skipping test because the time-series collection feature flag is disabled");
return;
}
const coll = db.timeseries_id_index;
coll.drop();
const timeFieldName = "time";
assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
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 an _id index on a collection already clustered by _id"));
})();
|