diff options
-rw-r--r-- | buildscripts/resmokeconfig/suites/feature_flag_multiversion.yml | 13 | ||||
-rw-r--r-- | buildscripts/resmokeconfig/suites/multiversion.yml | 3 | ||||
-rw-r--r-- | buildscripts/resmokeconfig/suites/multiversion_auth.yml | 3 | ||||
-rw-r--r-- | etc/evergreen.yml | 14 | ||||
-rw-r--r-- | jstests/multiVersion/genericSetFCVUsage/run_feature_flag_multiversion_test.js | 61 | ||||
-rw-r--r-- | src/mongo/idl/SConscript | 2 | ||||
-rw-r--r-- | src/mongo/idl/feature_flag_test.idl | 5 | ||||
-rw-r--r-- | src/mongo/shell/feature_compatibility_version.js | 39 |
8 files changed, 138 insertions, 2 deletions
diff --git a/buildscripts/resmokeconfig/suites/feature_flag_multiversion.yml b/buildscripts/resmokeconfig/suites/feature_flag_multiversion.yml new file mode 100644 index 00000000000..86d66750a49 --- /dev/null +++ b/buildscripts/resmokeconfig/suites/feature_flag_multiversion.yml @@ -0,0 +1,13 @@ +# This test suite only includes run_feature_flag_multiversion_test.js as this test should only be +# run on build variants that have the featureFlagToaster and featureFlagSpoon feature flags enabled. +test_kind: js_test + +selector: + roots: + - jstests/multiVersion/genericSetFCVUsage/run_feature_flag_multiversion_test.js + +# Multiversion tests start their own mongod's. +executor: + config: + shell_options: + nodb: '' diff --git a/buildscripts/resmokeconfig/suites/multiversion.yml b/buildscripts/resmokeconfig/suites/multiversion.yml index 2dd6305b139..bb1ec6b7023 100644 --- a/buildscripts/resmokeconfig/suites/multiversion.yml +++ b/buildscripts/resmokeconfig/suites/multiversion.yml @@ -17,6 +17,9 @@ selector: # TODO SERVER-42919: recent work on the ReplicaSetMonitor means that mongoS no longer crashes when # it attempts to connect to an upgraded mongoD. Un-blacklist when SERVER-42919 fixes this issue. - jstests/multiVersion/genericSetFCVUsage/crash_mongos_against_upgraded_cluster.js + exclude_with_any_tags: + - featureFlagToaster + - featureFlagSpoon # Multiversion tests start their own mongod's. executor: diff --git a/buildscripts/resmokeconfig/suites/multiversion_auth.yml b/buildscripts/resmokeconfig/suites/multiversion_auth.yml index b1935a79edc..ba2f80dfab6 100644 --- a/buildscripts/resmokeconfig/suites/multiversion_auth.yml +++ b/buildscripts/resmokeconfig/suites/multiversion_auth.yml @@ -21,6 +21,9 @@ selector: # TODO SERVER-42919: recent work on the ReplicaSetMonitor means that mongoS no longer crashes when # it attempts to connect to an upgraded mongoD. Un-blacklist when SERVER-42919 fixes this issue. - jstests/multiVersion/genericSetFCVUsage/crash_mongos_against_upgraded_cluster.js + exclude_with_any_tags: + - featureFlagToaster + - featureFlagSpoon # Multiversion tests start their own mongod's. executor: diff --git a/etc/evergreen.yml b/etc/evergreen.yml index b0c08f8dd60..6a8abfbdb24 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -6163,6 +6163,17 @@ tasks: use_multiversion: /data/multiversion fallback_num_sub_suites: 1 +# Tests the runFeatureFlagMultiversionTest helper. +# This requires the 'featureFlagToaster' and 'featureFlagSpoon' parameters to be set to true on +# build variants that enable this task. +- name: feature_flag_multiversion_gen + commands: + - func: "generate resmoke tasks" + vars: + resmoke_args: "--storageEngine=wiredTiger" + use_multiversion: /data/multiversion + fallback_num_sub_suites: 1 + - name: unittest_shell_hang_analyzer_gen commands: - func: "generate resmoke tasks" @@ -10429,7 +10440,7 @@ buildvariants: burn_in_tag_buildvariants: enterprise-rhel-62-64-bit-majority-read-concern-off enterprise-rhel-62-64-bit-inmem linux-64-duroff enterprise-rhel-62-64-bit-multiversion num_scons_link_jobs_available: 0.99 test_flags: >- - --mongodSetParameters="{featureFlagTimeseriesCollection: true}" + --mongodSetParameters="{featureFlagTimeseriesCollection: true, featureFlagToaster: true, featureFlagSpoon: true}" tasks: - name: compile_parallel_TG distros: @@ -10454,6 +10465,7 @@ buildvariants: - rhel62-large - name: disk_wiredtiger - name: .encrypt + - name: feature_flag_multiversion_gen - name: idl_tests - name: initial_sync_fuzzer_gen - name: .integration diff --git a/jstests/multiVersion/genericSetFCVUsage/run_feature_flag_multiversion_test.js b/jstests/multiVersion/genericSetFCVUsage/run_feature_flag_multiversion_test.js new file mode 100644 index 00000000000..41d8d9ba898 --- /dev/null +++ b/jstests/multiVersion/genericSetFCVUsage/run_feature_flag_multiversion_test.js @@ -0,0 +1,61 @@ +/** + * Tests the behavior of the 'runFeatureFlagMultiversionTest' helper. + * This test requires that the featureFlagToaster and featureFlagSpoon parameters to be enabled and + * the featureFlagFryer parameter to be disabled. + * + * Add test tags for the feature flags depended on by this test. + * @tags: [featureFlagToaster, featureFlagSpoon] + */ + +(function() { +'use strict'; + +let numLastLTSRuns = 0; +let numLastContRuns = 0; + +function runTest(downgradeFCV) { + let name = "feature_flag_test"; + let nodes = {n0: {binVersion: "latest"}}; + let rst = new ReplSetTest({name: name, nodes: nodes}); + rst.startSet(); + rst.initiate(); + + let primary = rst.getPrimary(); + let adminDB = primary.getDB("admin"); + assert.commandWorked(adminDB.adminCommand({setFeatureCompatibilityVersion: downgradeFCV})); + checkFCV(adminDB, downgradeFCV); + if (downgradeFCV === lastLTSFCV) { + numLastLTSRuns++; + } else { + numLastContRuns++; + } + rst.stopSet(); +} + +try { + // We expect the test run to fail when using a non-existent feature flag. + runFeatureFlagMultiversionTest("nonExistentFeatureFlag", runTest); +} catch (error) { +} + +// No tests should have been run when a non-existent feature flag is passed in. +assert.eq(numLastLTSRuns, 0); +assert.eq(numLastContRuns, 0); + +// No tests should have been run when a disabled feature flag is passed in. +runFeatureFlagMultiversionTest("featureFlagFryer", runTest); +assert.eq(numLastLTSRuns, 0); +assert.eq(numLastContRuns, 0); + +// Pass in a feature flag that is slated for release in the latest version. This should run against +// both the last-lts and last-continuous FCV. +runFeatureFlagMultiversionTest("featureFlagToaster", runTest); +assert.eq(numLastLTSRuns, 1); +assert.eq(numLastContRuns, 1); + +// Pass in a feature flag that was released in an older version. This should only run against the +// last-lts FCV. +runFeatureFlagMultiversionTest("featureFlagSpoon", runTest); +assert.eq(numLastLTSRuns, 2); +assert.eq(numLastContRuns, 1); +})();
\ No newline at end of file diff --git a/src/mongo/idl/SConscript b/src/mongo/idl/SConscript index 92f99142b64..6ec8319fa38 100644 --- a/src/mongo/idl/SConscript +++ b/src/mongo/idl/SConscript @@ -32,6 +32,7 @@ env.Library( target='feature_flag', source=[ 'feature_flag.cpp', + 'feature_flag_test.idl', ], LIBDEPS=[ '$BUILD_DIR/mongo/base', @@ -54,7 +55,6 @@ env.CppUnitTest( 'server_parameter_with_storage_test.cpp', 'config_option_no_init_test.idl', 'config_option_test.idl', - 'feature_flag_test.idl', 'server_parameter_specialized_test.idl', 'server_parameter_with_storage_test.idl', 'unittest.idl', diff --git a/src/mongo/idl/feature_flag_test.idl b/src/mongo/idl/feature_flag_test.idl index fc76119c208..2bbc4a1378d 100644 --- a/src/mongo/idl/feature_flag_test.idl +++ b/src/mongo/idl/feature_flag_test.idl @@ -35,6 +35,11 @@ feature_flags: cpp_varname: gFeatureFlagToaster default: false + featureFlagFryer: + description: "Create a feature flag" + cpp_varname: gFeatureFlagFryer + default: false + featureFlagBlender: description: "Create a feature flag" cpp_varname: gFeatureFlagBlender diff --git a/src/mongo/shell/feature_compatibility_version.js b/src/mongo/shell/feature_compatibility_version.js index 6e95a30ba4c..fd4ea3250c2 100644 --- a/src/mongo/shell/feature_compatibility_version.js +++ b/src/mongo/shell/feature_compatibility_version.js @@ -91,3 +91,42 @@ function removeFCVDocument(adminDB) { assert.commandWorked(res, "failed to list collections"); assert.eq(newUUID, res.cursor.firstBatch[0].info.uuid); } + +/** + * Runs 'testFunc' with the last-lts FCV as an argument. If 'featureFlag' has a release version + * equal to the latest FCV, 'testFunc' will also be run a second time but with last-continuous FCV + * as the argument. + * + * If featureFlag does not exist in the server, throw an error. + * If featureFlag is not enabled, return without running 'testFunct'. + * + * 'testFunc' is expected to be a function that accepts a valid downgrade FCV as input. + */ +function runFeatureFlagMultiversionTest(featureFlag, testFunc) { + jsTestLog("Running standalone to gather parameter info about featureFlag: " + featureFlag); + // Spin up a standalone to check the release version of 'featureFlag'. + let standalone = MongoRunner.runMongod(); + let adminDB = standalone.getDB("admin"); + let res; + try { + res = assert.commandWorked(adminDB.runCommand({getParameter: 1, [featureFlag]: 1}), + "Failed to call getParameter on feature flag: " + featureFlag); + } finally { + MongoRunner.stopMongod(standalone); + } + + if (res && !res[featureFlag]["value"]) { + jsTestLog("Feature flag: " + featureFlag + " is not enabled. Skipping test."); + return; + } + + jsTestLog("Running testFunc with last-lts FCV."); + testFunc(lastLTSFCV); + if (res && res[featureFlag].hasOwnProperty("version") && + MongoRunner.compareBinVersions(res[featureFlag]["version"].toString(), "latest") === 0) { + // The feature associated with 'featureFlag' will be released in the latest FCV. We should + // also run upgrade/downgrade behavior against the last-continuous FCV. + jsTestLog("Running testFunc with last-continuous FCV."); + testFunc(lastContinuousFCV); + } +} |