summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Tuckman <ted.tuckman@mongodb.com>2021-04-09 16:06:21 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-09 17:02:15 +0000
commit0f35984965301f2327082aff72ff93383313557d (patch)
treefa8f594c96c3ee222d13b4b7a71ccf71b52d3fd8
parentb40f9038d2527cecbc07a4abdf792231b82db244 (diff)
downloadmongo-0f35984965301f2327082aff72ff93383313557d.tar.gz
SERVER-54694 Register $setWindowFields with min FCV
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js22
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js25
-rw-r--r--src/mongo/db/pipeline/document_source_set_window_fields.cpp4
3 files changed, 47 insertions, 4 deletions
diff --git a/jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js b/jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js
index cfd672e79d5..ac12d9b81b7 100644
--- a/jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js
+++ b/jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js
@@ -12,6 +12,9 @@
const testName = "collection_validator_feature_compatibility_version";
const dbpath = MongoRunner.dataPath + testName;
+// An array of feature flags that must be enabled to run feature flag tests.
+const featureFlagsToEnable = [];
+
// These arrays should be populated with
//
// { validator: { ... }, nonMatchingDocument: { ... }, lastStableErrCode }
@@ -28,6 +31,7 @@ const testCasesLastContinuous = [
// Populate with any new expressions.
//
];
+const testCasesLastContinuousWithFeatureFlags = [];
const testCasesLastStable = testCasesLastContinuous.concat([
// These expressions were introduced in 4.9.
@@ -93,11 +97,12 @@ const testCasesLastStable = testCasesLastContinuous.concat([
lastStableErrCode: 168
},
]);
+const testCasesLastStableWithFeatureFlags = testCasesLastContinuousWithFeatureFlags.concat([]);
// Tests Feature Compatibility Version behavior of the validator of a collection by executing test
// cases 'testCases' and using a previous stable version 'lastVersion' of mongod. 'lastVersion' can
// have values "last-lts" and "last-continuous".
-function testCollectionValidatorFCVBehavior(lastVersion, testCases) {
+function testCollectionValidatorFCVBehavior(lastVersion, testCases, featureFlags = []) {
if (testCases.length === 0) {
jsTestLog("Skipping setup for tests against " + lastVersion + " since there are none");
return;
@@ -107,6 +112,17 @@ function testCollectionValidatorFCVBehavior(lastVersion, testCases) {
assert.neq(null, conn, "mongod was unable to start up");
let testDB = conn.getDB(testName);
+ for (let i = 0; i < featureFlags.length; i++) {
+ const command = {"getParameter": 1};
+ command[featureFlags[i]] = 1;
+ const featureEnabled =
+ assert.commandWorked(testDB.adminCommand(command))[featureFlags[i]].value;
+ if (!featureEnabled) {
+ jsTestLog("Skipping test because the " + featureFlags[i] + " feature flag is disabled");
+ MongoRunner.stopMongod(conn);
+ return;
+ }
+ }
let adminDB = conn.getDB("admin");
@@ -297,5 +313,9 @@ function testCollectionValidatorFCVBehavior(lastVersion, testCases) {
}
testCollectionValidatorFCVBehavior("last-lts", testCasesLastStable);
+testCollectionValidatorFCVBehavior(
+ "last-lts", testCasesLastStableWithFeatureFlags, featureFlagsToEnable);
testCollectionValidatorFCVBehavior("last-continuous", testCasesLastContinuous);
+testCollectionValidatorFCVBehavior(
+ "last-continuous", testCasesLastContinuousWithFeatureFlags, featureFlagsToEnable);
}());
diff --git a/jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js b/jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js
index 2ff1201baa9..a73ea7d1fda 100644
--- a/jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js
+++ b/jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js
@@ -12,12 +12,16 @@
const testName = "view_definition_feature_compatibility_version_multiversion";
const dbpath = MongoRunner.dataPath + testName;
+// An array of feature flags that must be enabled to run feature flag tests.
+const featureFlagsToEnable = ["featureFlagWindowFunctions"];
+
// These arrays should be populated with aggregation pipelines that use
// aggregation features in new versions of mongod. This test ensures that a view
// definition accepts the new aggregation feature when the feature compatibility version is the
// latest version, and rejects it when the feature compatibility version is the last
// version.
const testCasesLastContinuous = [];
+const testCasesLastContinuousWithFeatureFlags = [];
// Anything that's incompatible with the last continuous release is incompatible with the last
// stable release.
@@ -50,10 +54,14 @@ const testCasesLastStable = testCasesLastContinuous.concat([
[{$project: {x: {$dateTrunc: {date: new Date("2020-02-02T02:02:02"), unit: "month"}}}}],
]);
+const testCasesLastStableWithFeatureFlags = testCasesLastContinuousWithFeatureFlags.concat([
+ [{$setWindowFields: {sortBy: {_id: 1}, output: {sum: {$sum: {input: "$val"}}}}}],
+]);
+
// Tests Feature Compatibility Version behavior of view creation while using aggregation pipelines
// 'testCases' and using a previous stable version 'lastVersion' of mongod.
// 'lastVersion' can have values "last-lts" and "last-continuous".
-function testViewDefinitionFCVBehavior(lastVersion, testCases) {
+function testViewDefinitionFCVBehavior(lastVersion, testCases, featureFlags = []) {
if (testCases.length === 0) {
jsTestLog("Skipping setup for tests against " + lastVersion + " since there are none");
return;
@@ -62,6 +70,17 @@ function testViewDefinitionFCVBehavior(lastVersion, testCases) {
let conn = MongoRunner.runMongod({dbpath: dbpath, binVersion: "latest"});
assert.neq(null, conn, "mongod was unable to start up");
let testDB = conn.getDB(testName);
+ for (let i = 0; i < featureFlags.length; i++) {
+ const command = {"getParameter": 1};
+ command[featureFlags[i]] = 1;
+ const featureEnabled =
+ assert.commandWorked(testDB.adminCommand(command))[featureFlags[i]].value;
+ if (!featureEnabled) {
+ jsTestLog("Skipping test because the " + featureFlags[i] + " feature flag is disabled");
+ MongoRunner.stopMongod(conn);
+ return;
+ }
+ }
// Explicitly set feature compatibility version to the latest version.
assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV}));
@@ -235,5 +254,9 @@ function testViewDefinitionFCVBehavior(lastVersion, testCases) {
}
testViewDefinitionFCVBehavior("last-lts", testCasesLastStable);
+testViewDefinitionFCVBehavior(
+ "last-lts", testCasesLastStableWithFeatureFlags, featureFlagsToEnable);
testViewDefinitionFCVBehavior("last-continuous", testCasesLastContinuous);
+testViewDefinitionFCVBehavior(
+ "last-continuous", testCasesLastContinuousWithFeatureFlags, featureFlagsToEnable);
}());
diff --git a/src/mongo/db/pipeline/document_source_set_window_fields.cpp b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
index c87f6732c54..adbee021680 100644
--- a/src/mongo/db/pipeline/document_source_set_window_fields.cpp
+++ b/src/mongo/db/pipeline/document_source_set_window_fields.cpp
@@ -53,7 +53,7 @@ REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
document_source_set_window_fields::createFromBson,
LiteParsedDocumentSource::AllowedWithApiStrict::kAlways,
LiteParsedDocumentSource::AllowedWithClientType::kAny,
- boost::none,
+ ServerGlobalParams::FeatureCompatibility::Version::kVersion50,
::mongo::feature_flags::gFeatureFlagWindowFunctions.isEnabledAndIgnoreFCV());
REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
@@ -62,7 +62,7 @@ REGISTER_DOCUMENT_SOURCE_CONDITIONALLY(
DocumentSourceInternalSetWindowFields::createFromBson,
LiteParsedDocumentSource::AllowedWithApiStrict::kInternal,
LiteParsedDocumentSource::AllowedWithClientType::kAny,
- boost::none,
+ ServerGlobalParams::FeatureCompatibility::Version::kVersion50,
::mongo::feature_flags::gFeatureFlagWindowFunctions.isEnabledAndIgnoreFCV());
list<intrusive_ptr<DocumentSource>> document_source_set_window_fields::createFromBson(