summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/timeseries_create.js
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-04-07 07:21:43 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-07 11:41:13 +0000
commitda95c2722a598b83c71d95cee9b170298cb829ed (patch)
treefa87976a63f1fe74c9ebbbd862c78bc8218968cb /jstests/noPassthrough/timeseries_create.js
parent093f0a96afe9ee9b3cdddad1566b8d40fa900b42 (diff)
downloadmongo-da95c2722a598b83c71d95cee9b170298cb829ed.tar.gz
SERVER-55823 add test case for indexOptionDefaults on a time-series collection
Diffstat (limited to 'jstests/noPassthrough/timeseries_create.js')
-rw-r--r--jstests/noPassthrough/timeseries_create.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/noPassthrough/timeseries_create.js b/jstests/noPassthrough/timeseries_create.js
index 08f5534ea5b..7887a222295 100644
--- a/jstests/noPassthrough/timeseries_create.js
+++ b/jstests/noPassthrough/timeseries_create.js
@@ -4,6 +4,7 @@
*
* @tags: [
* requires_fcv_49,
+ * requires_wiredtiger,
* ]
*/
(function() {
@@ -151,6 +152,7 @@ testTimeseriesNamespaceExists((testDB, collName) => {
{
const testDB = conn.getDB(dbName);
const coll = testDB.getCollection('timeseries_' + collCount++);
+ coll.drop();
assert.commandWorked(
testDB.createCollection(coll.getName(), {timeseries: {timeField: "time"}}));
const bucketsColl = testDB.getCollection('system.buckets.' + coll.getName());
@@ -179,5 +181,29 @@ testTimeseriesNamespaceExists((testDB, collName) => {
assert.commandWorked(testDB.runCommand({drop: coll.getName(), writeConcern: {w: "majority"}}));
}
+// Tests that the indexOptionDefaults collection creation option is applied when creating indexes
+// on a time-series collection.
+// This test case uses wiredtiger collection/index creation options, which should already be
+// enforced by the use of the 'requires_wiredtiger' test tag at the top of this file.
+{
+ const testDB = conn.getDB(dbName);
+ const coll = testDB.getCollection('timeseries_' + collCount++);
+ coll.drop();
+ assert.commandFailedWithCode(testDB.createCollection(coll.getName(), {
+ timeseries: {timeField: 'tt', metaField: 'mm'},
+ indexOptionDefaults: {storageEngine: {wiredTiger: {configString: 'invalid_option=xxx,'}}}
+ }),
+ ErrorCodes.BadValue);
+ // Sample wiredtiger configuration option from wt_index_option_defaults.js.
+ assert.commandWorked(testDB.createCollection(coll.getName(), {
+ timeseries: {timeField: 'tt', metaField: 'mm'},
+ indexOptionDefaults: {storageEngine: {wiredTiger: {configString: 'split_pct=88,'}}}
+ }));
+ assert.commandWorked(coll.insert({tt: ISODate(), mm: 'aaa'}));
+ assert.commandWorked(coll.createIndex({mm: 1}));
+ const indexCreationString = coll.stats({indexDetails: true}).indexDetails.mm_1.creationString;
+ assert.neq(-1, indexCreationString.indexOf(',split_pct=88,'), indexCreationString);
+}
+
MongoRunner.stopMongod(conn);
})();