summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog/index_spec_validate_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/catalog/index_spec_validate_test.cpp')
-rw-r--r--src/mongo/db/catalog/index_spec_validate_test.cpp56
1 files changed, 16 insertions, 40 deletions
diff --git a/src/mongo/db/catalog/index_spec_validate_test.cpp b/src/mongo/db/catalog/index_spec_validate_test.cpp
index 32255f51ab3..a1c19e32427 100644
--- a/src/mongo/db/catalog/index_spec_validate_test.cpp
+++ b/src/mongo/db/catalog/index_spec_validate_test.cpp
@@ -43,6 +43,7 @@
#include "mongo/db/query/query_knobs.h"
#include "mongo/db/query/query_test_service_context.h"
#include "mongo/db/server_options.h"
+#include "mongo/unittest/ensure_fcv.h"
#include "mongo/unittest/unittest.h"
namespace mongo {
@@ -51,37 +52,12 @@ namespace {
using index_key_validate::validateIndexSpec;
using index_key_validate::validateIdIndexSpec;
using index_key_validate::validateIndexSpecCollation;
+using unittest::EnsureFCV;
const NamespaceString kTestNamespace("test", "index_spec_validate");
constexpr OperationContext* kDefaultOpCtx = nullptr;
/**
- * Helper class to ensure proper FCV & test commands enabled.
- */
-class TestCommandFcvGuard {
-
-public:
- TestCommandFcvGuard() {
- _prevVersion = serverGlobalParams.featureCompatibility.getVersion();
- serverGlobalParams.featureCompatibility.setVersion(
- ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
- // TODO: Remove test command enabling/disabling in SERVER-36198
- _prevEnabled = getTestCommandsEnabled();
- setTestCommandsEnabled(true);
- }
-
- ~TestCommandFcvGuard() {
- serverGlobalParams.featureCompatibility.setVersion(_prevVersion);
- setTestCommandsEnabled(_prevEnabled);
- }
-
-private:
- bool _prevEnabled;
- ServerGlobalParams::FeatureCompatibility::Version _prevVersion;
-};
-
-
-/**
* Helper function used to return the fields of a BSONObj in a consistent order.
*/
BSONObj sorted(const BSONObj& obj) {
@@ -833,7 +809,7 @@ TEST(IndexSpecPartialFilterTest, AcceptsValidPartialFilterExpression) {
}
TEST(IndexSpecWildcard, SucceedsWithInclusion) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -845,7 +821,7 @@ TEST(IndexSpecWildcard, SucceedsWithInclusion) {
}
TEST(IndexSpecWildcard, SucceedsWithExclusion) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -857,7 +833,7 @@ TEST(IndexSpecWildcard, SucceedsWithExclusion) {
}
TEST(IndexSpecWildcard, SucceedsWithExclusionIncludingId) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -869,7 +845,7 @@ TEST(IndexSpecWildcard, SucceedsWithExclusionIncludingId) {
}
TEST(IndexSpecWildcard, SucceedsWithInclusionExcludingId) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -881,7 +857,7 @@ TEST(IndexSpecWildcard, SucceedsWithInclusionExcludingId) {
}
TEST(IndexSpecWildcard, FailsWithInclusionExcludingIdSubfield) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -893,7 +869,7 @@ TEST(IndexSpecWildcard, FailsWithInclusionExcludingIdSubfield) {
}
TEST(IndexSpecWildcard, FailsWithExclusionIncludingIdSubfield) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -905,7 +881,7 @@ TEST(IndexSpecWildcard, FailsWithExclusionIncludingIdSubfield) {
}
TEST(IndexSpecWildcard, FailsWithImproperFeatureCompatabilityVersion) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
@@ -917,7 +893,7 @@ TEST(IndexSpecWildcard, FailsWithImproperFeatureCompatabilityVersion) {
}
TEST(IndexSpecWildcard, FailsWithMixedProjection) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -929,7 +905,7 @@ TEST(IndexSpecWildcard, FailsWithMixedProjection) {
}
TEST(IndexSpecWildcard, FailsWithComputedFieldsInProjection) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -942,7 +918,7 @@ TEST(IndexSpecWildcard, FailsWithComputedFieldsInProjection) {
}
TEST(IndexSpecWildcard, FailsWhenProjectionPluginNotWildcard) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("a" << 1) << "name"
<< "indexName"
@@ -954,7 +930,7 @@ TEST(IndexSpecWildcard, FailsWhenProjectionPluginNotWildcard) {
}
TEST(IndexSpecWildcard, FailsWhenProjectionIsNotAnObject) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -966,7 +942,7 @@ TEST(IndexSpecWildcard, FailsWhenProjectionIsNotAnObject) {
}
TEST(IndexSpecWildcard, FailsWithEmptyProjection) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("$**" << 1) << "name"
<< "indexName"
@@ -978,7 +954,7 @@ TEST(IndexSpecWildcard, FailsWithEmptyProjection) {
}
TEST(IndexSpecWildcard, FailsWhenInclusionWithSubpath) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("a.$**" << 1) << "name"
<< "indexName"
@@ -990,7 +966,7 @@ TEST(IndexSpecWildcard, FailsWhenInclusionWithSubpath) {
}
TEST(IndexSpecWildcard, FailsWhenExclusionWithSubpath) {
- TestCommandFcvGuard guard;
+ EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42);
auto result = validateIndexSpec(kDefaultOpCtx,
BSON("key" << BSON("a.$**" << 1) << "name"
<< "indexName"