summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/clustered_collection_create_index_clustered_nonreplicated.js
blob: cbd1186b4d643852690eb23971fcf416dcb1b108 (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
/**
 * Tests createIndexes with the 'clustered' option on a replicated collection. Note: there are
 * different restrictions for non-replicated versus replicated clustered collections - eg replicated
 * collections can only be created with cluster key _id whereas non-replicated collections can be
 * created with arbitrary single field cluster keys.
 *
 * @tags: [
 *   requires_fcv_52,
 *   # Does not support sharding
 *   assumes_against_mongod_not_mongos,
 *   assumes_unsharded_collection,
 * ]
 */
(function() {
"use strict";

load("jstests/libs/clustered_collections/clustered_collection_util.js");
load("jstests/libs/clustered_collections/clustered_collection_create_index_clustered_common.js");

const conn = MongoRunner.runMongod();

if (ClusteredCollectionUtil.areClusteredIndexesEnabled(conn) == false) {
    jsTestLog('Skipping test because the clustered indexes feature flag is disabled');
    MongoRunner.stopMongod(conn);
    return;
}

const nonReplicatedDB = conn.getDB("local");
const collName = "coll";
const nonReplicatedColl = nonReplicatedDB[collName];

CreateIndexesClusteredTest.runBaseTests(nonReplicatedDB, collName);

CreateIndexesClusteredTest.assertCreateIndexesImplicitCreateSucceeds(nonReplicatedDB, collName, {
    createIndexes: collName,
    indexes: [{key: {a: 1}, name: "clusterKeyYay", clustered: true, unique: true}]
});

MongoRunner.stopMongod(conn);
})();