summaryrefslogtreecommitdiff
path: root/jstests/multiVersion
diff options
context:
space:
mode:
authorJason Chan <jason.chan@mongodb.com>2020-10-26 21:53:43 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-29 16:26:39 +0000
commit5852774abcbc02af9e8b03a241c46cad3050a6ea (patch)
tree43cf0d75708038cd4eba29ed463abc9629cd4ce1 /jstests/multiVersion
parente74d2512df1ad2309b46bd9d2d49d0e1628fcc31 (diff)
downloadmongo-5852774abcbc02af9e8b03a241c46cad3050a6ea.tar.gz
SERVER-51112 Add runFeatureFlagMultiversionTest helper for targeted upgrade/downgrade tests
Diffstat (limited to 'jstests/multiVersion')
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/run_feature_flag_multiversion_test.js61
1 files changed, 61 insertions, 0 deletions
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