summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/timeseries_create_index_option_defaults.js
blob: 50e0d41af69a14effbd9467a899be1f6db4d2378 (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
32
33
34
35
36
37
/**
 * Tests that the indexOptionDefaults collection creation option is applied when creating indexes on
 * a time-series collection.
 *
 * @tags: [
 *   requires_persistence,
 *   requires_wiredtiger,
 * ]
 */
(function() {
'use strict';

const conn = MongoRunner.runMongod();

const testDB = conn.getDB('test');
const coll = testDB.getCollection(jsTestName());

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);
})();