diff options
author | Daniel Gómez Ferro <daniel.gomezferro@mongodb.com> | 2022-02-02 07:59:01 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-02 08:46:57 +0000 |
commit | c7f5e389e4488fcf7bd7a9a2ca4149080c409242 (patch) | |
tree | d1a14dfeaef42df491009b45db32c5b7f3ab6a3d /jstests | |
parent | 98d1971726bc2bc7bd8d13365291d79bb9b61a6e (diff) | |
download | mongo-c7f5e389e4488fcf7bd7a9a2ca4149080c409242.tar.gz |
SERVER-62811 Allow special index types on cluster keys
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/clustered_collection_creation.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/jstests/core/clustered_collection_creation.js b/jstests/core/clustered_collection_creation.js index 3c24f860526..34b5d39a8a6 100644 --- a/jstests/core/clustered_collection_creation.js +++ b/jstests/core/clustered_collection_creation.js @@ -6,7 +6,7 @@ * non-replicated collections. * * @tags: [ - * requires_fcv_52, + * requires_fcv_53, * assumes_against_mongod_not_mongos, * assumes_no_implicit_collection_creation_after_drop, * does_not_support_stepdowns, @@ -38,6 +38,12 @@ const validateCompoundSecondaryIndexes = function(db, coll, clusterKey) { coll.drop(); }; +const overrideIndexType = function(clusterKey, indexType) { + for (const field of Object.keys(clusterKey)) { + return Object.assign(Object.assign({}, clusterKey), {[field]: indexType}); + } +}; + // Tests it is legal to call createIndex on the cluster key with or without {'clustered': true} as // an option. Additionally, confirms it is illegal to call createIndex with the 'clustered' option // on a pattern that is not the cluster key. @@ -75,6 +81,15 @@ const validateCreateIndexOnClusterKey = function(db, collName, fullCreateOptions const listIndexes1 = assert.commandWorked(db[collName].runCommand("listIndexes")); assert.eq(listIndexes1.cursor.firstBatch.length, 1); assert.docEq(listIndexes1.cursor.firstBatch[0], listIndexes0.cursor.firstBatch[0]); + + // It's possible to create 'hashed','2d','2dsphere' and 'text' indexes on the cluster key. + assert.commandWorked(db[collName].createIndex(overrideIndexType(clusterKey, 'hashed'))); + assert.commandWorked(db[collName].createIndex(overrideIndexType(clusterKey, '2d'))); + assert.commandWorked(db[collName].createIndex(overrideIndexType(clusterKey, '2dsphere'))); + assert.commandWorked(db[collName].createIndex(overrideIndexType(clusterKey, 'text'))); + + const finalIndexes = assert.commandWorked(db[collName].runCommand("listIndexes")); + assert.eq(finalIndexes.cursor.firstBatch.length, 5); }; // It is illegal to drop the clusteredIndex. Verify that the various ways of dropping the |