summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/columnstore_index_persistence.js
blob: ad9b4d77a2a30cdea051cdcb3a71dc2453e35417 (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
38
39
40
41
42
43
44
45
/**
 * Tests that a columnstore index can be persisted and found in listIndexes after a server restart.
 *
 * @tags: [
 *  requires_persistence,
 *  # Replication requires journaling support so this tag also implies exclusion from
 *  # --nojournal test configurations.
 *  requires_replication,
 * ]
 */

(function() {
'use strict';

load('jstests/libs/index_catalog_helpers.js');

const rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();

let primary = rst.getPrimary();
const columnstoreIndexesEnabled =
    assert.commandWorked(primary.adminCommand({getParameter: 1, featureFlagColumnstoreIndexes: 1}))
        .featureFlagColumnstoreIndexes.value;

if (!columnstoreIndexesEnabled) {
    jsTestLog('Skipping test because the columnstore index feature flag is disabled');
    rst.stopSet();
    return;
}

const collName = 'columnstore_index_persistence';
let db_primary = primary.getDB('test');
let coll_primary = db_primary.getCollection(collName);

assert.commandWorked(coll_primary.createIndex({"$**": "columnstore"}));

// Restarts the primary and checks the index spec is persisted.
rst.restart(primary);
rst.waitForPrimary();
const indexList = rst.getPrimary().getDB('test').getCollection(collName).getIndexes();
assert.neq(null, IndexCatalogHelpers.findByKeyPattern(indexList, {"$**": "columnstore"}));

rst.stopSet();
})();