summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2021-05-24 09:55:04 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-24 20:31:30 +0000
commite465a2c8dcc8d8f0676eaf266e809a71d946c07c (patch)
treeb622964ffdae1599979aea1ee92ddfe6b8c69fda /jstests/core
parentb5a61bb4682788503b4e4808069754ba5d914b1b (diff)
downloadmongo-e465a2c8dcc8d8f0676eaf266e809a71d946c07c.tar.gz
SERVER-56934 Make expireAfterSeconds a top-level collection option
(cherry picked from commit b173494aa6b84b5d44c5f958fd78dd469596a314)
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/timeseries/clustered_index_options.js27
-rw-r--r--jstests/core/timeseries/clustered_index_types.js2
-rw-r--r--jstests/core/timeseries/timeseries_create_drop.js12
-rw-r--r--jstests/core/timeseries/timeseries_expire.js2
-rw-r--r--jstests/core/timeseries/timeseries_expire_collmod.js43
5 files changed, 43 insertions, 43 deletions
diff --git a/jstests/core/timeseries/clustered_index_options.js b/jstests/core/timeseries/clustered_index_options.js
index ad8a620f6af..8bdf755c72a 100644
--- a/jstests/core/timeseries/clustered_index_options.js
+++ b/jstests/core/timeseries/clustered_index_options.js
@@ -32,20 +32,20 @@ const tsColl = testDB.clustered_index_options;
const tsCollName = tsColl.getName();
const bucketsCollName = 'system.buckets.' + tsCollName;
-assert.commandWorked(testDB.createCollection(bucketsCollName, {clusteredIndex: {}}));
+assert.commandWorked(testDB.createCollection(bucketsCollName, {clusteredIndex: false}));
assert.commandWorked(testDB.dropDatabase());
-assert.commandWorked(testDB.createCollection(bucketsCollName, {clusteredIndex: {}}));
+assert.commandWorked(testDB.createCollection(bucketsCollName, {clusteredIndex: true}));
assert.commandWorked(testDB.dropDatabase());
assert.commandWorked(
- testDB.createCollection(bucketsCollName, {clusteredIndex: {expireAfterSeconds: 10}}));
+ testDB.createCollection(bucketsCollName, {clusteredIndex: true, expireAfterSeconds: 10}));
assert.commandWorked(testDB.dropDatabase());
// Round-trip creating a time-series collection. Use the output of listCollections to re-create
// the buckets collection.
assert.commandWorked(
- testDB.createCollection(tsCollName, {timeseries: {timeField: 'time', expireAfterSeconds: 10}}));
+ testDB.createCollection(tsCollName, {timeseries: {timeField: 'time'}, expireAfterSeconds: 10}));
let res =
assert.commandWorked(testDB.runCommand({listCollections: 1, filter: {name: bucketsCollName}}));
@@ -59,16 +59,25 @@ res =
assert.eq(options, res.cursor.firstBatch[0].options);
assert.commandWorked(testDB.dropDatabase());
-assert.commandFailedWithCode(testDB.createCollection(bucketsCollName, {clusteredIndex: {bad: 1}}),
- 40415);
+assert.commandFailedWithCode(testDB.createCollection(bucketsCollName, {clusteredIndex: {}}),
+ ErrorCodes.TypeMismatch);
+assert.commandFailedWithCode(testDB.createCollection(bucketsCollName, {clusteredIndex: 'a'}),
+ ErrorCodes.TypeMismatch);
assert.commandFailedWithCode(
testDB.createCollection(bucketsCollName,
- {clusteredIndex: {}, idIndex: {key: {_id: 1}, name: '_id_'}}),
+ {clusteredIndex: true, idIndex: {key: {_id: 1}, name: '_id_'}}),
ErrorCodes.InvalidOptions);
// Using the 'clusteredIndex' option on any namespace other than a buckets namespace should fail.
-assert.commandFailedWithCode(testDB.createCollection(tsCollName, {clusteredIndex: {}}),
+assert.commandFailedWithCode(testDB.createCollection(tsCollName, {clusteredIndex: true}),
ErrorCodes.InvalidOptions);
-assert.commandFailedWithCode(testDB.createCollection('test', {clusteredIndex: {}}),
+assert.commandFailedWithCode(testDB.createCollection('test', {clusteredIndex: true}),
+ ErrorCodes.InvalidOptions);
+
+// Using the 'expireAfterSeconds' option on any namespace other than a time-series namespace or a
+// clustered time-series buckets namespace should fail.
+assert.commandFailedWithCode(testDB.createCollection('test', {expireAfterSeconds: 10}),
+ ErrorCodes.InvalidOptions);
+assert.commandFailedWithCode(testDB.createCollection(bucketsCollName, {expireAfterSeconds: 10}),
ErrorCodes.InvalidOptions);
})(); \ No newline at end of file
diff --git a/jstests/core/timeseries/clustered_index_types.js b/jstests/core/timeseries/clustered_index_types.js
index 5bb30ad007c..b5241af6aaf 100644
--- a/jstests/core/timeseries/clustered_index_types.js
+++ b/jstests/core/timeseries/clustered_index_types.js
@@ -26,7 +26,7 @@ const collName = 'system.buckets.test';
const coll = db[collName];
coll.drop();
-assert.commandWorked(db.createCollection(collName, {clusteredIndex: {}}));
+assert.commandWorked(db.createCollection(collName, {clusteredIndex: true}));
// Expect that duplicates are rejected.
let oid = new ObjectId();
diff --git a/jstests/core/timeseries/timeseries_create_drop.js b/jstests/core/timeseries/timeseries_create_drop.js
index 71c48bf5397..50f78c446fd 100644
--- a/jstests/core/timeseries/timeseries_create_drop.js
+++ b/jstests/core/timeseries/timeseries_create_drop.js
@@ -42,7 +42,7 @@ coll.drop();
// Create should create both bucket collection and view
assert.commandWorked(db.createCollection(
coll.getName(),
- {timeseries: {timeField: timeFieldName, expireAfterSeconds: expireAfterSecondsNum}}));
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
assert.contains(viewName, db.getCollectionNames());
assert.contains(bucketsCollName, db.getCollectionNames());
@@ -56,7 +56,7 @@ assert.commandWorked(
db.adminCommand({configureFailPoint: failpoint, mode: "alwaysOn", data: {ns: viewNs}}));
assert.commandFailed(db.createCollection(
coll.getName(),
- {timeseries: {timeField: timeFieldName, expireAfterSeconds: expireAfterSecondsNum}}));
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
assert.contains(bucketsCollName, db.getCollectionNames());
@@ -69,7 +69,7 @@ assert.eq(db.getCollectionNames().findIndex(c => c == bucketsCollName), -1);
// Trying to create again yields the same result as fail point is still enabled
assert.commandFailed(db.createCollection(
coll.getName(),
- {timeseries: {timeField: timeFieldName, expireAfterSeconds: expireAfterSecondsNum}}));
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
assert.contains(bucketsCollName, db.getCollectionNames());
@@ -79,14 +79,14 @@ assert.commandWorked(db.adminCommand({configureFailPoint: failpoint, mode: "off"
// Different timeField should fail
assert.commandFailed(db.createCollection(
coll.getName(),
- {timeseries: {timeField: timeFieldName + "2", expireAfterSeconds: expireAfterSecondsNum}}));
+ {timeseries: {timeField: timeFieldName + "2"}, expireAfterSeconds: expireAfterSecondsNum}));
assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
assert.contains(bucketsCollName, db.getCollectionNames());
// Different expireAfterSeconds should fail
assert.commandFailed(db.createCollection(
coll.getName(),
- {timeseries: {timeField: timeFieldName, expireAfterSeconds: expireAfterSecondsNum + 1}}));
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum + 1}));
assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
assert.contains(bucketsCollName, db.getCollectionNames());
@@ -98,7 +98,7 @@ assert.contains(bucketsCollName, db.getCollectionNames());
// Same parameters should succeed
assert.commandWorked(db.createCollection(
coll.getName(),
- {timeseries: {timeField: timeFieldName, expireAfterSeconds: expireAfterSecondsNum}}));
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
assert.contains(viewName, db.getCollectionNames());
assert.contains(bucketsCollName, db.getCollectionNames());
})();
diff --git a/jstests/core/timeseries/timeseries_expire.js b/jstests/core/timeseries/timeseries_expire.js
index 9cf35126e84..9a4f20bdf7f 100644
--- a/jstests/core/timeseries/timeseries_expire.js
+++ b/jstests/core/timeseries/timeseries_expire.js
@@ -25,7 +25,7 @@ TimeseriesTest.run((insert) => {
const expireAfterSeconds = NumberLong(5);
assert.commandWorked(db.createCollection(
coll.getName(),
- {timeseries: {timeField: timeFieldName, expireAfterSeconds: expireAfterSeconds}}));
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSeconds}));
assert.contains(bucketsColl.getName(), db.getCollectionNames());
// Inserts a measurement with a time in the past to ensure the measurement will be removed
diff --git a/jstests/core/timeseries/timeseries_expire_collmod.js b/jstests/core/timeseries/timeseries_expire_collmod.js
index 8a0cc2d4faf..75bf199e0b1 100644
--- a/jstests/core/timeseries/timeseries_expire_collmod.js
+++ b/jstests/core/timeseries/timeseries_expire_collmod.js
@@ -33,7 +33,7 @@ const timeFieldName = 'time';
const expireAfterSeconds = NumberLong(5);
assert.commandWorked(db.createCollection(
coll.getName(),
- {timeseries: {timeField: timeFieldName, expireAfterSeconds: expireAfterSeconds}}));
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSeconds}));
const bucketsColl = db.getCollection('system.buckets.' + coll.getName());
@@ -42,45 +42,37 @@ const collNotClustered = db.getCollection(coll.getName() + '_not_clustered');
collNotClustered.drop();
assert.commandWorked(db.createCollection(collNotClustered.getName()));
assert.commandFailedWithCode(
- db.runCommand({collMod: collNotClustered.getName(), clusteredIndex: {expireAfterSeconds: 10}}),
+ db.runCommand({collMod: collNotClustered.getName(), expireAfterSeconds: 10}),
ErrorCodes.InvalidOptions);
// Check for invalid input on the time-series collection.
-assert.commandFailedWithCode(
- db.runCommand({collMod: coll.getName(), clusteredIndex: {expireAfterSeconds: "10"}}),
- ErrorCodes.InvalidOptions);
-assert.commandFailedWithCode(
- db.runCommand({collMod: coll.getName(), clusteredIndex: {expireAfterSeconds: {}}}),
- ErrorCodes.TypeMismatch);
-assert.commandFailedWithCode(
- db.runCommand({collMod: coll.getName(), clusteredIndex: {expireAfterSeconds: -10}}),
- ErrorCodes.InvalidOptions);
-assert.commandFailedWithCode(db.runCommand({collMod: coll.getName(), clusteredIndex: {}}), 40414);
+assert.commandFailedWithCode(db.runCommand({collMod: coll.getName(), expireAfterSeconds: "10"}),
+ ErrorCodes.InvalidOptions);
+assert.commandFailedWithCode(db.runCommand({collMod: coll.getName(), expireAfterSeconds: {}}),
+ ErrorCodes.TypeMismatch);
+assert.commandFailedWithCode(db.runCommand({collMod: coll.getName(), expireAfterSeconds: -10}),
+ ErrorCodes.InvalidOptions);
// Check for invalid input on the underlying bucket collection.
assert.commandFailedWithCode(
- db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: "10"}}),
+ db.runCommand({collMod: bucketsColl.getName(), expireAfterSeconds: "10"}),
ErrorCodes.InvalidOptions);
assert.commandFailedWithCode(
- db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: {}}}),
+ db.runCommand({collMod: bucketsColl.getName(), expireAfterSeconds: {}}),
ErrorCodes.TypeMismatch);
assert.commandFailedWithCode(
- db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: -10}}),
+ db.runCommand({collMod: bucketsColl.getName(), expireAfterSeconds: -10}),
ErrorCodes.InvalidOptions);
assert.commandFailedWithCode(db.runCommand({
collMod: bucketsColl.getName(),
- clusteredIndex: {expireAfterSeconds: NumberLong("4611686018427387904")}
+ expireAfterSeconds: NumberLong("4611686018427387904"),
}),
ErrorCodes.InvalidOptions);
-assert.commandFailedWithCode(db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {}}),
- 40414);
let res = assert.commandWorked(
db.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}}));
-assert(res.cursor.firstBatch[0].options.hasOwnProperty("clusteredIndex"),
- bucketsColl.getName() + ': ' + expireAfterSeconds + ': ' + tojson(res));
assert.eq(expireAfterSeconds,
- res.cursor.firstBatch[0].options.clusteredIndex.expireAfterSeconds,
+ res.cursor.firstBatch[0].options.expireAfterSeconds,
bucketsColl.getName() + ': ' + expireAfterSeconds + ': ' + tojson(res));
/**
@@ -90,19 +82,18 @@ assert.eq(expireAfterSeconds,
const runTest = function(collToChange, expireAfterSeconds) {
assert.commandWorked(db.runCommand({
collMod: collToChange.getName(),
- clusteredIndex: {expireAfterSeconds: expireAfterSeconds}
+ expireAfterSeconds: expireAfterSeconds,
}));
res = assert.commandWorked(
db.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}}));
if (expireAfterSeconds !== 'off') {
assert.eq(expireAfterSeconds,
- res.cursor.firstBatch[0].options.clusteredIndex.expireAfterSeconds,
+ res.cursor.firstBatch[0].options.expireAfterSeconds,
collToChange.getFullName() + ': ' + expireAfterSeconds + ': ' + tojson(res));
} else {
- assert(
- !res.cursor.firstBatch[0].options.clusteredIndex.hasOwnProperty("expireAfterSeconds"),
- collToChange.getFullName() + ': ' + expireAfterSeconds + ': ' + tojson(res));
+ assert(!res.cursor.firstBatch[0].options.hasOwnProperty("expireAfterSeconds"),
+ collToChange.getFullName() + ': ' + expireAfterSeconds + ': ' + tojson(res));
}
};