summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Banala <arun.banala@mongodb.com>2020-01-15 11:43:04 +0000
committerA. Jesse Jiryu Davis <jesse@mongodb.com>2020-01-27 15:40:41 -0500
commita8b7e6dd5793eedd7663f9f95a50c45a1f8512fd (patch)
treeec6bf41e927d3766d66f991cfdbc2ab61e19c669
parent4e414a420c8c0e943ba373efff1778a663445695 (diff)
downloadmongo-a8b7e6dd5793eedd7663f9f95a50c45a1f8512fd.tar.gz
SERVER-44256 Allow compound hashed indexes to be built in non-test deployments
-rw-r--r--src/mongo/db/catalog/index_key_validate.cpp4
-rw-r--r--src/mongo/db/catalog/index_key_validate_test.cpp19
2 files changed, 3 insertions, 20 deletions
diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp
index c25fe90e159..2c45fc02389 100644
--- a/src/mongo/db/catalog/index_key_validate.cpp
+++ b/src/mongo/db/catalog/index_key_validate.cpp
@@ -40,7 +40,6 @@
#include "mongo/base/status.h"
#include "mongo/base/status_with.h"
-#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/field_ref.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/index/wildcard_key_generator.h"
@@ -310,8 +309,7 @@ StatusWith<BSONObj> validateIndexSpec(
const auto isFeatureDisabled =
(featureCompatibility.isVersionInitialized() &&
featureCompatibility.getVersion() <
- ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) ||
- !getTestCommandsEnabled();
+ ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44);
if (isFeatureDisabled && (indexSpecElem.embeddedObject().nFields() > 1) &&
(IndexNames::findPluginName(indexSpecElem.embeddedObject()) ==
IndexNames::HASHED)) {
diff --git a/src/mongo/db/catalog/index_key_validate_test.cpp b/src/mongo/db/catalog/index_key_validate_test.cpp
index b71769d0e5b..6075f27d773 100644
--- a/src/mongo/db/catalog/index_key_validate_test.cpp
+++ b/src/mongo/db/catalog/index_key_validate_test.cpp
@@ -30,7 +30,6 @@
#include "mongo/platform/basic.h"
#include "mongo/db/catalog/index_key_validate.h"
-#include "mongo/db/commands/test_commands_enabled.h"
#include <limits>
@@ -288,18 +287,11 @@ TEST(IndexKeyValidateTest, CompoundHashedIndexWithFCV44) {
ServerGlobalParams::FeatureCompatibility fcv;
fcv.setVersion(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44);
- // Validation fails when 'enableTestCommands' flag is not set.
- auto status = index_key_validate::validateIndexSpec(
- nullptr, fromjson("{key: {a : 'hashed', b: 1}, name: 'index'}"), fcv);
- ASSERT_NOT_OK(status);
- ASSERT_EQ(status.getStatus().code(), 16763);
-
- // Validation succeeds with hashed prefix in the index and 'enableTestCommands' flag enabled.
- setTestCommandsEnabled(true);
+ // Validation succeeds with hashed prefix in the index.
ASSERT_OK(index_key_validate::validateIndexSpec(
nullptr, fromjson("{key: {a : 'hashed', b: 1}, name: 'index'}"), fcv));
- // Validation succeeds with hashed non-prefix in the index.
+ // Validation succeeds with non-hashed prefix in the index.
ASSERT_OK(index_key_validate::validateIndexSpec(
nullptr, fromjson("{key: {b: 1, a : 'hashed', c: 1}, name: 'index'}"), fcv));
}
@@ -317,13 +309,6 @@ TEST(IndexKeyValidateTest, CompoundHashedIndexWithFCV42) {
nullptr, fromjson("{key: {a : 'hashed', b: 1}, name: 'index'}"), fcv);
ASSERT_NOT_OK(status);
ASSERT_EQ(status.getStatus().code(), 16763);
-
- // validation fails even with 'enableTestCommands' flag enabled.
- setTestCommandsEnabled(true);
- status = index_key_validate::validateIndexSpec(
- nullptr, fromjson("{key: {a : 'hashed', b: 1}, name: 'index'}"), fcv);
- ASSERT_NOT_OK(status);
- ASSERT_EQ(status.getStatus().code(), 16763);
}
} // namespace