From 1809b6dfc2df4e95bbbc5e4e1e1753410086263f Mon Sep 17 00:00:00 2001 From: XueruiFa Date: Wed, 12 Apr 2023 14:07:18 +0000 Subject: [PATCH] SERVER-76005: Fix evergreen redness post 7.1 FCV upgrade --- .../matrix_suites/overrides/multiversion.yml | 2 + .../resmokeconfig/suites/multiversion.yml | 1 + .../suites/multiversion_auth.yml | 1 + etc/evergreen.yml | 2 +- ...batched_multi_deletes_large_transaction.js | 2 +- .../timeseries_collection_mixed_type.js | 2 + ...owngrade_from_latest_to_last_continuous.js | 8 +- ...validator_feature_compatibility_version.js | 9 +- .../major_version_upgrade.js | 2 +- ...efinition_feature_compatibility_version.js | 90 +++----- .../analyze_shard_key_ttl_indexes_setFCV.js | 118 ---------- ...change_streams_images_collection_option.js | 41 ---- .../compound_wildcard_indexes_downgrade.js | 129 ----------- .../dbCheck_snapshotRead.js | 83 ------- .../fle2_range_downgrade.js | 49 ---- .../invalid_index_options.js | 95 -------- .../partial_indexes_downgrade.js | 44 ---- .../recordPreImages_option_upgrade.js | 69 ------ ...ding_to_upgraded_with_capped_collection.js | 91 -------- ...pgraded_with_encrypted_field_collection.js | 83 ------- ...ed_with_partial_ttl_index_on_timeseries.js | 106 --------- ...nt_invalid_downgrade_with_catalog_shard.js | 91 -------- .../timeseries_index.js | 24 -- .../capped_collections_downgrade.js | 39 ---- ...meseries_bucketing_parameters_downgrade.js | 124 ---------- ...meseries_bucketing_parameters_downgrade.js | 212 ------------------ .../timeseries_ttl_index_downgrade.js | 69 ------ .../all_commands_downgrading_to_upgraded.js | 9 +- ...onfig_settings_schema_upgrade_downgrade.js | 38 ---- 29 files changed, 49 insertions(+), 1584 deletions(-) delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/analyze_shard_key_ttl_indexes_setFCV.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/cannot_downgrade_config_server_with_change_streams_images_collection_option.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/compound_wildcard_indexes_downgrade.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/dbCheck_snapshotRead.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/fle2_range_downgrade.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/invalid_index_options.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/partial_indexes_downgrade.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/recordPreImages_option_upgrade.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_capped_collection.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_encrypted_field_collection.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_partial_ttl_index_on_timeseries.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_prevent_invalid_downgrade_with_catalog_shard.js delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/timeseries_index.js delete mode 100644 jstests/noPassthrough/capped_collections_downgrade.js delete mode 100644 jstests/noPassthrough/sharded_timeseries_bucketing_parameters_downgrade.js delete mode 100644 jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js delete mode 100644 jstests/noPassthrough/timeseries_ttl_index_downgrade.js delete mode 100644 jstests/sharding/config_settings_schema_upgrade_downgrade.js diff --git a/buildscripts/resmokeconfig/matrix_suites/overrides/multiversion.yml b/buildscripts/resmokeconfig/matrix_suites/overrides/multiversion.yml index 11956227a03..c59f966d6c3 100644 --- a/buildscripts/resmokeconfig/matrix_suites/overrides/multiversion.yml +++ b/buildscripts/resmokeconfig/matrix_suites/overrides/multiversion.yml @@ -113,6 +113,7 @@ # Skip any tests that run with auth explicitly. - jstests/multiVersion/genericBinVersion/load_keys_on_upgrade.js exclude_with_any_tags: + - DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE - name: multiversion_sanity_check_selector value: @@ -129,6 +130,7 @@ - multiversion_incompatible - backport_required_multiversion - replica_sets_multiversion_backport_required_multiversion + - DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE exclude_files: - jstests/replsets/initial_sync_rename_collection.js - jstests/replsets/initial_sync_drop_collection.js diff --git a/buildscripts/resmokeconfig/suites/multiversion.yml b/buildscripts/resmokeconfig/suites/multiversion.yml index aa7939823f5..30180ca1ab9 100644 --- a/buildscripts/resmokeconfig/suites/multiversion.yml +++ b/buildscripts/resmokeconfig/suites/multiversion.yml @@ -20,6 +20,7 @@ selector: exclude_with_any_tags: - featureFlagToaster - featureFlagSpoon + - DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE # 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 aacf5eb8d94..cc3b2f115d0 100644 --- a/buildscripts/resmokeconfig/suites/multiversion_auth.yml +++ b/buildscripts/resmokeconfig/suites/multiversion_auth.yml @@ -28,6 +28,7 @@ selector: exclude_with_any_tags: - featureFlagToaster - featureFlagSpoon + - DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE # Multiversion tests start their own mongod's. executor: diff --git a/etc/evergreen.yml b/etc/evergreen.yml index 9c7649e5b49..6154d711c59 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -1840,7 +1840,7 @@ buildvariants: # No feature flag tests since they aren't compatible with the older binaries. test_flags: >- --runNoFeatureFlagTests - --excludeWithAnyTags=incompatible_with_shard_merge + --excludeWithAnyTags=incompatible_with_shard_merge,DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE - <<: *linux-x86-multiversion-template name: &enterprise-rhel-80-64-bit-future-git-tag-multiversion enterprise-rhel-80-64-bit-future-git-tag-multiversion diff --git a/jstests/multiVersion/genericBinVersion/batched_multi_deletes_large_transaction.js b/jstests/multiVersion/genericBinVersion/batched_multi_deletes_large_transaction.js index 6eac1f49355..fce188ac47b 100644 --- a/jstests/multiVersion/genericBinVersion/batched_multi_deletes_large_transaction.js +++ b/jstests/multiVersion/genericBinVersion/batched_multi_deletes_large_transaction.js @@ -5,7 +5,7 @@ * able to take advantage of this feature. * * @tags: [ - * requires_replication, + * requires_replication, DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE * ] */ (function() { diff --git a/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js b/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js index 3b9bbf90cab..d06c7b52028 100644 --- a/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js +++ b/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js @@ -1,6 +1,8 @@ /** * Test that variable-type fields are found correctly in upgraded timeseries collections with dirty * data. + * + * @tags: [DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE] */ (function() { diff --git a/jstests/multiVersion/genericSetFCVUsage/cannot_downgrade_from_latest_to_last_continuous.js b/jstests/multiVersion/genericSetFCVUsage/cannot_downgrade_from_latest_to_last_continuous.js index 37a931971ae..87dbea4ebca 100644 --- a/jstests/multiVersion/genericSetFCVUsage/cannot_downgrade_from_latest_to_last_continuous.js +++ b/jstests/multiVersion/genericSetFCVUsage/cannot_downgrade_from_latest_to_last_continuous.js @@ -66,9 +66,11 @@ function runShardingTest() { st.stop(); } -runStandaloneTest(); -runReplicaSetTest(); -runShardingTest(); +if (lastContinuousFCV != lastLTSFCV) { + runStandaloneTest(); + runReplicaSetTest(); + runShardingTest(); +} TestData.setParameters.disableTransitionFromLatestToLastContinuous = false; })(); diff --git a/jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js b/jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js index f72d4e764e8..a776c55dd4a 100644 --- a/jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js +++ b/jstests/multiVersion/genericSetFCVUsage/collection_validator_feature_compatibility_version.js @@ -3,7 +3,7 @@ * the feature compatibility version is older than the latest version. * * We restart mongod during the test and expect it to have the same data after restarting. - * @tags: [requires_persistence] + * @tags: [requires_persistence, DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE] */ (function() { @@ -32,12 +32,7 @@ const testCasesLastContinuous = [ // ]; const testCasesLastContinuousWithFeatureFlags = [ - // TODO SERVER-70689: Remove this case when 7.0 becomes lastLTS. - { - validator: {$expr: {$eq: ["$$USER_ROLES", []]}}, - nonMatchingDocument: {a: 1}, - lastStableErrCode: 17276 - } + ]; const testCasesLastStable = testCasesLastContinuous.concat([]); diff --git a/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js b/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js index 85949d3d064..d765a7dbf08 100644 --- a/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js +++ b/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js @@ -8,7 +8,7 @@ * - Insert a document into the new collection. * - Create an index on the new collection. * - * @tags: [requires_v4_0] + * @tags: [requires_v4_0, DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE] */ (function() { diff --git a/jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js b/jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js index 2b7ed55bd95..a2014d0fed2 100644 --- a/jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js +++ b/jstests/multiVersion/genericSetFCVUsage/view_definition_feature_compatibility_version.js @@ -3,7 +3,7 @@ * feature compatibility version is older than the latest version. * * We restart mongod during the test and expect it to have the same data after restarting. - * @tags: [requires_persistence] + * @tags: [requires_persistence, DISABLED_TEMPORARILY_DUE_TO_FCV_UPGRADE] */ (function() { @@ -21,10 +21,7 @@ const featureFlagsToEnable = ["featureFlagUserRoles"]; // latest version, and rejects it when the feature compatibility version is the last // version. const testCasesLastContinuous = []; -const testCasesLastContinuousWithFeatureFlags = [ - // TODO SERVER-70689: Remove this case when 7.0 becomes lastLTS. - [{$project: {z: "$$USER_ROLES"}}] -]; +const testCasesLastContinuousWithFeatureFlags = []; // Anything that's incompatible with the last continuous release is incompatible with the last // stable release. @@ -32,14 +29,6 @@ const testCasesLastStable = testCasesLastContinuous.concat([]); const testCasesLastStableWithFeatureFlags = testCasesLastContinuousWithFeatureFlags.concat([]); -// The addition of the $$USER_ROLES system variable is slightly different than the usual use case of -// this test file. This means that some of the following commands won't work/fail as expected for -// the $$USER_ROLES test case. -// TODO SERVER-70689: Remove this function and references to it. -function testCaseDoesNotReferenceUserRoles(testCase) { - return testCase[0].$project.z != "$$USER_ROLES"; -} - // 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". @@ -94,27 +83,21 @@ function testViewDefinitionFCVBehavior(lastVersion, testCases, featureFlags = [] // Read against an existing view using new query features should not fail. testCases.forEach((pipe, i) => { - if (testCaseDoesNotReferenceUserRoles(pipe)) { - // The $$USER_ROLES value will be evaluated every time the view is queried, so the - // following query would fail since we are running an older FCV. - // TODO SERVER-70689: Remove the guard of this if-statement and keep the body. - assert.commandWorked(testDB.runCommand({find: "firstView" + i}), - `Failed to query view with pipeline ${tojson(pipe)}`); - } + // The $$USER_ROLES value will be evaluated every time the view is queried, so the + // following query would fail since we are running an older FCV. + assert.commandWorked(testDB.runCommand({find: "firstView" + i}), + `Failed to query view with pipeline ${tojson(pipe)}`); }); // Trying to create a new view in the same database as existing invalid view should fail, // even if the new view doesn't use any new query features. - if (testCaseDoesNotReferenceUserRoles(testCases[0])) { - // Since the $$USER_ROLES variable won't be evaluated during this view creation, the view - // creation will succeed even though we are on an older FCV. - // TODO SERVER-70689: Remove the guard of this if-statement and keep the body. - assert.commandFailedWithCode( - testDB.createView("newViewOldFeatures", "coll", [{$project: {_id: 1}}]), - ErrorCodes.QueryFeatureNotAllowed, - `Expected *not* to be able to create view on database ${testDB} while in FCV ${ - binVersionToFCV(lastVersion)}`); - } + // Since the $$USER_ROLES variable won't be evaluated during this view creation, the view + // creation will succeed even though we are on an older FCV. + assert.commandFailedWithCode( + testDB.createView("newViewOldFeatures", "coll", [{$project: {_id: 1}}]), + ErrorCodes.QueryFeatureNotAllowed, + `Expected *not* to be able to create view on database ${testDB} while in FCV ${ + binVersionToFCV(lastVersion)}`); // Trying to create a new view succeeds if it's on a separate database. const testDB2 = conn.getDB(testName + '2'); @@ -171,13 +154,10 @@ function testViewDefinitionFCVBehavior(lastVersion, testCases, featureFlags = [] // Read against an existing view using new query features should not fail. testCases.forEach((pipe, i) => { - if (testCaseDoesNotReferenceUserRoles(pipe)) { - // The view is evaluated on the fly, and the FCV is still set to the last version so the - // evaluation of $$USER_ROLES will cause this to fail. - // TODO SERVER-70689: Remove the guard of this if-statement and keep the body. - assert.commandWorked(testDB.runCommand({find: "firstView" + i}), - `Failed to query view with pipeline ${tojson(pipe)}`); - } + // The view is evaluated on the fly, and the FCV is still set to the last version so the + // evaluation of $$USER_ROLES will cause this to fail. + assert.commandWorked(testDB.runCommand({find: "firstView" + i}), + `Failed to query view with pipeline ${tojson(pipe)}`); }); // Set the feature compatibility version back to the latest version. @@ -220,29 +200,21 @@ function testViewDefinitionFCVBehavior(lastVersion, testCases, featureFlags = [] // In this case, using $$USER_ROLES on the last FCV version will cause the view // creation to fail during parsing because the necessary feature flag will not have been // enabled due to the older FCV. - // TODO SERVER-70689: Remove the guard of this if-statement and keep the body. - if (testCaseDoesNotReferenceUserRoles(pipe)) { - // Even though the feature compatibility version is the last version, we should still be - // able to create a view using new query features, because - // internalValidateFeaturesAsPrimary is false. - assert.commandWorked( - testDB.createView("thirdView" + i, "coll", pipe), - `Expected to be able to create view with pipeline ${tojson(pipe)} while in FCV` + - ` ${ - binVersionToFCV( - lastVersion)} with internalValidateFeaturesAsPrimary=false`); + // Even though the feature compatibility version is the last version, we should still be + // able to create a view using new query features, because + // internalValidateFeaturesAsPrimary is false. + assert.commandWorked( + testDB.createView("thirdView" + i, "coll", pipe), + `Expected to be able to create view with pipeline ${tojson(pipe)} while in FCV` + + ` ${binVersionToFCV(lastVersion)} with internalValidateFeaturesAsPrimary=false`); - // We should also be able to modify a view to use new query features. - assert(testDB["thirdView" + i].drop(), - `Drop of view with pipeline ${tojson(pipe)} failed`); - assert.commandWorked(testDB.createView("thirdView" + i, "coll", [])); - assert.commandWorked( - testDB.runCommand({collMod: "thirdView" + i, viewOn: "coll", pipeline: pipe}), - `Expected to be able to modify view to use pipeline ${tojson(pipe)} while in FCV` + - ` ${ - binVersionToFCV( - lastVersion)} with internalValidateFeaturesAsPrimary=false`); - } + // We should also be able to modify a view to use new query features. + assert(testDB["thirdView" + i].drop(), `Drop of view with pipeline ${tojson(pipe)} failed`); + assert.commandWorked(testDB.createView("thirdView" + i, "coll", [])); + assert.commandWorked( + testDB.runCommand({collMod: "thirdView" + i, viewOn: "coll", pipeline: pipe}), + `Expected to be able to modify view to use pipeline ${tojson(pipe)} while in FCV` + + ` ${binVersionToFCV(lastVersion)} with internalValidateFeaturesAsPrimary=false`); }); MongoRunner.stopMongod(conn); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/analyze_shard_key_ttl_indexes_setFCV.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/analyze_shard_key_ttl_indexes_setFCV.js deleted file mode 100644 index 99b465d3bbf..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/analyze_shard_key_ttl_indexes_setFCV.js +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Tests that version upgrade creates the TTL indexes for config.sampledQueries and - * config.sampledQueriesDiff. - * - * @tags: [requires_fcv_70] - */ - -(function() { -"use strict"; - -load('./jstests/multiVersion/libs/multi_rs.js'); -load('./jstests/multiVersion/libs/multi_cluster.js'); -load("./jstests/sharding/analyze_shard_key/libs/query_sampling_util.js"); - -/** - * Verifies that a proper TTL index exists for the query sample collection - */ -function assertTTLIndexExists(node, collName, indexName) { - const configDB = node.getDB("config"); - let foundIndexSpec = undefined; - assert.soon(() => { - const indexSpecs = - assert.commandWorked(configDB.runCommand({"listIndexes": collName})).cursor.firstBatch; - for (var i = 0; i < indexSpecs.length; ++i) { - if (indexSpecs[i].name == indexName) { - foundIndexSpec = indexSpecs[i]; - return true; - } - } - return false; - }); - assert.eq(foundIndexSpec.key, {"expireAt": 1}); - assert.eq(foundIndexSpec.expireAfterSeconds, 0); -} - -function assertTTLIndexesExist(node) { - assertTTLIndexExists(node, "sampledQueries", "SampledQueriesTTLIndex"); - assertTTLIndexExists(node, "sampledQueriesDiff", "SampledQueriesDiffTTLIndex"); - assertTTLIndexExists(node, "analyzeShardKeySplitPoints", "AnalyzeShardKeySplitPointsTTLIndex"); -} - -for (let oldVersion of ["last-lts", "last-continuous"]) { - jsTest.log("Start testing with version " + oldVersion); - var st = new ShardingTest({ - shards: 1, - rs: {nodes: 2}, - mongos: 1, - other: { - mongosOptions: {binVersion: oldVersion}, - configOptions: {binVersion: oldVersion}, - shardOptions: {binVersion: oldVersion}, - rsOptions: {binVersion: oldVersion} - } - }); - st.configRS.awaitReplication(); - - //////// Upgrade to latest - - // Upgrade the config servers - jsTest.log('upgrading config servers'); - st.upgradeCluster("latest", {upgradeMongos: false, upgradeShards: false}); - // Restart mongos to clear all cache and force it to do remote calls. - st.restartMongoses(); - - // Upgrade the shards - jsTest.log('upgrading shard servers'); - st.upgradeCluster("latest", {upgradeMongos: false, upgradeConfigs: false}); - awaitRSClientHosts(st.s, st.rs0.getPrimary(), {ok: true, ismaster: true}); - // Restart mongos to clear all cache and force it to do remote calls. - st.restartMongoses(); - - assertTTLIndexesExist(st.rs0.getPrimary()); - - // Upgrade mongos - jsTest.log('upgrading mongos servers'); - st.upgradeCluster("latest", {upgradeConfigs: false, upgradeShards: false}); - // Restart mongos to clear all cache and force it to do remote calls. - st.restartMongoses(); - - assertTTLIndexesExist(st.rs0.getPrimary()); - - // Check that version document is unmodified. - version = st.s.getCollection('config.version').findOne(); - var clusterID = version.clusterId; - assert.eq(clusterID, version.clusterId); - - //////// Downgrade back - - jsTest.log('downgrading mongos servers'); - st.downgradeCluster(oldVersion, {downgradeConfigs: false, downgradeShards: false}); - // Restart mongos to clear all cache and force it to do remote calls. - st.restartMongoses(); - - assertTTLIndexesExist(st.rs0.getPrimary()); - - jsTest.log('downgrading shard servers'); - st.downgradeCluster(oldVersion, {downgradeMongos: false, downgradeConfigs: false}); - awaitRSClientHosts(st.s, st.rs0.getPrimary(), {ok: true, ismaster: true}); - // Restart mongos to clear all cache and force it to do remote calls. - st.restartMongoses(); - - for (let conn of [st.rs0.getPrimary(), st.rs0.getSecondary()]) { - assertTTLIndexesExist(conn); - } - - jsTest.log('downgrading config servers'); - st.downgradeCluster(oldVersion, {downgradeMongos: false, downgradeShards: false}); - // Restart mongos to clear all cache and force it to do remote calls. - st.restartMongoses(); - - // Check that version document is unmodified. - version = st.s.getCollection('config.version').findOne(); - assert.eq(clusterID, version.clusterId); - - jsTest.log("End testing with version " + oldVersion); - st.stop(); -} -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/cannot_downgrade_config_server_with_change_streams_images_collection_option.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/cannot_downgrade_config_server_with_change_streams_images_collection_option.js deleted file mode 100644 index d3bd5813974..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/cannot_downgrade_config_server_with_change_streams_images_collection_option.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Verifies a config server cannot downgrade with a collection with changeStreamPreAndPostImages - * enabled. - * - * @tags: [requires_fcv_70, featureFlagCatalogShard, featureFlagTransitionToCatalogShard] - */ -(function() { -"use strict"; - -const st = new ShardingTest({config: 1, shards: 1}); - -// A collection on a shard with changeStreamPreAndPostImages shouldn't impact downgrade. -const validShardNS = "foo.bar"; -assert.commandWorked(st.s.getCollection(validShardNS).insert({x: 1})); -assert.commandWorked( - st.s.getDB("foo").runCommand({collMod: "bar", changeStreamPreAndPostImages: {enabled: true}})); - -// A collection on the config server with changeStreamPreAndPostImages should prevent downgrade. The -// config server can only downgrade when in dedicated mode and in this mode the only user -// accessible collections on it are in the config and admin databases, which never allow this -// option, so we have to create a collection on a separate db via direct connection. -const directConfigNS = "directDB.onConfig"; -assert.commandWorked(st.configRS.getPrimary().getCollection(directConfigNS).insert({x: 1})); -assert.commandWorked(st.configRS.getPrimary().getDB("directDB").runCommand({ - collMod: "onConfig", - changeStreamPreAndPostImages: {enabled: true} -})); - -assert.commandFailedWithCode(st.s.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - -// Unset the option on the config server collection and now the config server can downgrade. -assert.commandWorked(st.configRS.getPrimary().getDB("directDB").runCommand({ - collMod: "onConfig", - changeStreamPreAndPostImages: {enabled: false} -})); - -assert.commandWorked(st.s.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - -st.stop(); -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/compound_wildcard_indexes_downgrade.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/compound_wildcard_indexes_downgrade.js deleted file mode 100644 index 807c0de0428..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/compound_wildcard_indexes_downgrade.js +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Tests that we will fail on startup if the compound wildcard indexes were not removed before we - * downgrade from 7.0 to 'last-lts'. Downgrading FCV will allow continued use of a CWI as long as - * the version of mongod is still 7.0, but will disallow any new creation of a CWI. - * - * @tags: [ - * featureFlagCompoundWildcardIndexes, - * requires_fcv_70, - * ] - */ - -(function() { -'use strict'; - -load("jstests/libs/analyze_plan.js"); // For getPlanStages. - -const dbpath = MongoRunner.dataPath + 'compound_wildcard_indexes_downgrade'; -resetDbpath(dbpath); - -// If we have a CWI on the admin database, we want to make sure we can startup properly despite FCV -// not being initialized yet. It's possible to hit an invariant if featureFlag.isEnabled is called -// without checking fcv.isVersionInitialized. -const dbName = 'admin'; -const dbNameTest = "compound_wildcard_indexes_downgrade"; -const collName = 'compound_wildcard_indexes_downgrade'; - -const latestVersion = "latest"; -const lastLTSVersion = "last-lts"; - -const keyPattern = { - "a.$**": 1, - b: 1 -}; - -// Startup with latest, create a compound wildcard index, stop mongod. -{ - const conn = - MongoRunner.runMongod({dbpath: dbpath, binVersion: latestVersion, noCleanData: true}); - const db = conn.getDB(dbName); - const coll = db[collName]; - - assert.commandWorked(coll.createIndex(keyPattern)); - - assert.commandWorked(coll.insert({a: {c: 1}, b: 1})); - assert.commandWorked(coll.insert({a: 30, b: 20})); - - MongoRunner.stopMongod(conn); -} - -// Test that we are able to restart a mongod if there exists any CWI on the 'admin' DB and the FCV -// may not be initialized. -{ - const conn = - MongoRunner.runMongod({dbpath: dbpath, binVersion: latestVersion, noCleanData: true}); - const db = conn.getDB(dbName); - const coll = db[collName]; - - // Drop the CWI for downgrading. - assert.commandWorked(coll.dropIndex(keyPattern)); - - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: '6.0'})); - MongoRunner.stopMongod(conn); -} - -// A normal downgrade process should drop all CWI. Now there's no CWI, we should be able to start a -// last-lts mongod. -{ - const conn = - MongoRunner.runMongod({dbpath: dbpath, binVersion: lastLTSVersion, noCleanData: true}); - - MongoRunner.stopMongod(conn); -} - -// Tests on a regular database. Test that 1) FCV can be downgraded with the existence of CWI, 2) -// continued use of CWI after FCV downgraded, 3) cannot create more CWI, and 4) a downgraded mongod -// fails to start up if CWI is not removed. -{ - let conn = - MongoRunner.runMongod({dbpath: dbpath, binVersion: latestVersion, noCleanData: true}); - let db = conn.getDB(dbNameTest); - let coll = db[collName]; - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: '7.0'})); - - assert.commandWorked(coll.createIndex(keyPattern)); - - // Test that it succeeds to downgrade the FCV with the existence of CWI, but it should fail to - // start a mongod with the existence of a CWI. - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: '6.0'})); - - // Test that the CWI can still be used after FCV downgraded. - const exp = coll.find({"a.c": 1}).explain(); - const winningPlan = getWinningPlan(exp.queryPlanner); - const ixScans = getPlanStages(winningPlan, "IXSCAN"); - assert.gt(ixScans.length, 0, exp); - assert.docEq(ixScans[0].indexName, "a.$**_1_b_1", ixScans); - - // We cannot create more CWI if FCV is below 7.0. - assert.commandFailedWithCode(coll.createIndex({"b.$**": 1, c: 1}), - ErrorCodes.CannotCreateIndex); - - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: '7.0'})); - - // We can create more CWI if FCV is 7.0. - assert.commandWorked(coll.createIndex({"b.$**": 1, c: 1})); - - MongoRunner.stopMongod(conn); - - // To successfully downgrade a mongod, user must drop all CWI first. - assert.throws(() => MongoRunner.runMongod( - {dbpath: dbpath, binVersion: lastLTSVersion, noCleanData: true}), - [], - "MongoD should fail because wildcard indexes do not allow compounding"); - - // Start a "latest" mongod and drop all indexes to successfully downgrade the mongod. - conn = MongoRunner.runMongod({dbpath: dbpath, binVersion: latestVersion, noCleanData: true}); - db = conn.getDB(dbNameTest); - coll = db[collName]; - coll.dropIndexes(); - - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: '6.0'})); - - MongoRunner.stopMongod(conn); - - // We can downgrade now as all indexes have been removed. - conn = MongoRunner.runMongod({dbpath: dbpath, binVersion: lastLTSVersion, noCleanData: true}); - - MongoRunner.stopMongod(conn); -} -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/dbCheck_snapshotRead.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/dbCheck_snapshotRead.js deleted file mode 100644 index 729289bd9a5..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/dbCheck_snapshotRead.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Ensure that a 6.0 version replicating a dbCheck oplog entry with the removed snapshotRead:false - * option does not crash when a 'latest' version receives the entry. - * - * @tags: [ - * requires_replication, - * ] - */ -(function() { -"use strict"; - -load('jstests/multiVersion/libs/multi_rs.js'); - -const nodes = { - // We want the 6.0 node to be the primary. - n1: {binVersion: "6.0", rsConfig: {priority: 1}}, - n2: {binVersion: "latest", rsConfig: {priority: 0}}, -}; - -const rst = new ReplSetTest({nodes: nodes}); -rst.startSet(); -rst.initiate(); - -const dbName = "test"; -const collName = jsTestName(); - -const primary = rst.getPrimary(); -const primaryDB = primary.getDB(dbName); -const coll = primaryDB[collName]; - -assert.commandWorked(coll.insert({a: 1})); - -// The 6.0 node will replicate the dbCheck oplog entry with the 'snapshotRead:false' option. This is -// not supported in recent versions and should be ignored, but not cause the node to crash. -assert.commandWorked(primaryDB.runCommand({"dbCheck": 1, snapshotRead: false})); - -rst.awaitReplication(); - -function dbCheckCompleted(db) { - return db.currentOp().inprog.filter(x => x["desc"] == "dbCheck")[0] === undefined; -} - -function forEachNode(f) { - f(rst.getPrimary()); - f(rst.getSecondary()); -} - -function awaitDbCheckCompletion(db) { - assert.soon(() => dbCheckCompleted(db), "dbCheck timed out"); - rst.awaitSecondaryNodes(); - rst.awaitReplication(); - - forEachNode(function(node) { - const healthlog = node.getDB('local').system.healthlog; - assert.soon(function() { - return (healthlog.find({"operation": "dbCheckStop"}).itcount() == 1); - }, "dbCheck command didn't complete"); - }); -} - -awaitDbCheckCompletion(primaryDB); - -{ - // The 6.0 primary should not report any errors. - const healthlog = primary.getDB('local').system.healthlog; - assert.eq(0, healthlog.find({severity: "error"}).itcount()); - assert.eq(0, healthlog.find({severity: "warning"}).itcount()); -} - -{ - // The latest secondary should log an error in the health log. - const secondary = rst.getSecondary(); - const healthlog = secondary.getDB('local').system.healthlog; - assert.eq(1, healthlog.find({severity: "error"}).itcount()); - assert.eq(0, healthlog.find({severity: "warning"}).itcount()); - const errorEntry = healthlog.findOne({severity: "error"}); - assert(errorEntry.hasOwnProperty('data'), tojson(errorEntry)); - assert.eq(false, errorEntry.data.success, tojson(errorEntry)); - assert(errorEntry.data.error.startsWith("Location6769502"), tojson(errorEntry)); -} - -rst.stopSet(); -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/fle2_range_downgrade.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/fle2_range_downgrade.js deleted file mode 100644 index c8928789d2d..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/fle2_range_downgrade.js +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Tests that the cluster cannot be downgraded when range encrypted fields present - * - * @tags: [ - * requires_fcv_61 - * ] - */ - -load("jstests/fle2/libs/encrypted_client_util.js"); - -(function() { -"use strict"; - -const rst = new ReplSetTest({nodes: 1}); -rst.startSet(); -rst.initiate(); -rst.awaitReplication(); - -let conn = rst.getPrimary(); -let db = conn.getDB("admin"); - -function runTest(targetFCV) { - assert.commandWorked(db.createCollection("basic", { - encryptedFields: { - "fields": [ - { - "path": "first", - "keyId": UUID("11d58b8a-0c6c-4d69-a0bd-70c6d9befae9"), - "bsonType": "int", - "queries": {"queryType": "rangePreview", "min": 1, "max": 2, "sparsity": 1} - }, - ] - } - })); - - let res = assert.commandFailedWithCode( - db.adminCommand({setFeatureCompatibilityVersion: targetFCV}), ErrorCodes.CannotDowngrade); - - assert(db.basic.drop()); - - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: targetFCV})); - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: latestFCV})); -} - -runTest(lastLTSFCV); -runTest(lastContinuousFCV); - -rst.stopSet(); -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/invalid_index_options.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/invalid_index_options.js deleted file mode 100644 index 8abc86d65ac..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/invalid_index_options.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Tests that in 6.1 version listIndexes can parse invalid index specs created before 5.0 version. - * - * @tags: [requires_replication] - */ -(function() { -"use strict"; - -load('jstests/multiVersion/libs/multi_rs.js'); - -var nodes = { - n1: {binVersion: "4.4"}, - n2: {binVersion: "4.4"}, -}; - -var rst = new ReplSetTest({nodes: nodes}); -rst.startSet(); -rst.initiate(); - -const dbName = "test"; -const collName = jsTestName(); - -let primaryDB = rst.getPrimary().getDB(dbName); -let primaryColl = primaryDB.getCollection(collName); - -// In earlier versions, users were able to add invalid index options when creating an index. The -// option could still be interpreted accordingly. -assert.commandWorked(primaryColl.createIndex({x: 1}, {sparse: "yes"})); - -// Upgrades from 4.4 to 5.0. -jsTestLog("Upgrading to version 5.0"); -rst.upgradeSet({binVersion: "5.0"}); -assert.commandWorked(rst.getPrimary().adminCommand({setFeatureCompatibilityVersion: "5.0"})); - -// Upgrades from 5.0 to 6.0. -jsTestLog("Upgrading to version last-lts"); -rst.upgradeSet({binVersion: "last-lts"}); -assert.commandWorked(rst.getPrimary().adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - -// Upgrades from 6.0 to latest. -jsTestLog("Upgrading to version latest"); -rst.upgradeSet({binVersion: "latest"}); -const primary = rst.getPrimary(); -assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - -primaryDB = primary.getDB(dbName); - -// Verify listIndexes command can correctly output the repaired index specs. -assert.commandWorked(primaryDB.runCommand({listIndexes: collName})); - -// Add a new node to make sure the initial sync works correctly with the invalid index specs. -jsTestLog("Bringing up a new node"); -rst.add(); -rst.reInitiate(); - -jsTestLog("Waiting for new node to be synced."); -rst.awaitReplication(); -rst.awaitSecondaryNodes(); - -const [secondary1, secondary2] = rst.getSecondaries(); -const secondaryDB1 = secondary1.getDB(dbName); -const secondaryDB2 = secondary2.getDB(dbName); - -// Verify that the existing nodes detect invalid index options, but the new node has the repaired -// index spec. -let validateRes = assert.commandWorked(primaryDB.runCommand({validate: collName})); -assert(!validateRes.valid, "validate should fail: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB1.runCommand({validate: collName})); -assert(!validateRes.valid, "validate should fail: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB2.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); - -// Use collMod to fix the invalid index options in the collection. -assert.commandWorked(primaryDB.runCommand({collMod: collName})); - -// Fix the invalid fields from index spec. -checkLog.containsJson(primary, 6444400, {fieldName: "sparse"}); -checkLog.containsJson(secondary1, 6444400, {fieldName: "sparse"}); - -// Verify that the index no longer has invalid index options. -assert.commandWorked(primaryDB.runCommand({listIndexes: collName})); - -validateRes = assert.commandWorked(primaryDB.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB1.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB2.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); - -rst.stopSet(); -})(); \ No newline at end of file diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/partial_indexes_downgrade.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/partial_indexes_downgrade.js deleted file mode 100644 index 95eb03bfeb5..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/partial_indexes_downgrade.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Tests that we don't fail the FCV check for partial indexes on the admin database during startup. - */ - -(function() { -'use strict'; - -const dbpath = MongoRunner.dataPath + 'partial_indexes_downgrade'; -resetDbpath(dbpath); - -// If we have a partial index on the admin database, we want to make sure we can startup properly -// despite FCV not being initialized yet. It's possible to hit an invariant if featureFlag.isEnabled -// is called without checking fcv.isVersionInitialized (see SERVER-71068 for more details). -const dbName = 'admin'; -const collName = 'partial_indexes_downgrade'; - -// Startup with latest, create partial index, stop mongod. -{ - const conn = MongoRunner.runMongod({dbpath: dbpath, binVersion: 'latest', noCleanData: true}); - const db = conn.getDB(dbName); - const coll = db[collName]; - - assert.commandWorked(coll.createIndex( - {a: 1, b: 1}, {partialFilterExpression: {$or: [{a: {$lt: 20}}, {b: {$lt: 10}}]}})); - - assert.commandWorked(coll.insert({a: 1, b: 1})); - assert.commandWorked(coll.insert({a: 30, b: 20})); - - MongoRunner.stopMongod(conn); -} - -// Startup with latest again, to make sure we're not checking FCV for this index at startup. -{ - const conn = MongoRunner.runMongod({dbpath: dbpath, binVersion: 'latest', noCleanData: true}); - const db = conn.getDB(dbName); - const coll = db[collName]; - - // Make sure we are on the same db path as before. - assert.eq(coll.aggregate().toArray().length, 2); - - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - MongoRunner.stopMongod(conn); -} -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/recordPreImages_option_upgrade.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/recordPreImages_option_upgrade.js deleted file mode 100644 index 6f86dcb202c..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/recordPreImages_option_upgrade.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Verifies that the server ignores collection option "recordPreImages" on binary upgrade from the - * last LTS version to the current, as well as removes the option from collection attributes on - * FCV upgrade. - */ -(function() { -"use strict"; -load('jstests/multiVersion/libs/multi_rs.js'); - -const lastLTSVersion = "last-lts"; -const latestVersion = "latest"; - -// Setup a two-node replica set with last LTS binaries, so it is possible to create a collection -// with "recordPreImages" option. -const rst = new ReplSetTest( - {name: jsTestName(), nodes: [{binVersion: lastLTSVersion}, {binVersion: lastLTSVersion}]}); -rst.startSet(); -rst.initiate(); -const testDB = rst.getPrimary().getDB("test"); -const primaryNode = rst.getPrimary(); -const secondaryNode = rst.getSecondary(); - -// Create the collection. -const collectionName = "coll"; -assert.commandWorked(testDB.createCollection(collectionName, {recordPreImages: true})); -let coll = testDB[collectionName]; - -// Insert a test document which will be updated to trigger recording of change stream pre-images. -assert.commandWorked(coll.insert({_id: 1, a: 1})); -assert.commandWorked(coll.updateOne({_id: 1}, {$inc: {a: 1}})); -rst.awaitReplication(); - -// Upgrade the binary of the secondary node to the current version to setup a mixed binary cluster. -rst.upgradeMembers([secondaryNode], {binVersion: latestVersion}); - -// Make sure the primary node did not change. -rst.stepUp(primaryNode); - -// Verify that recording of change stream pre-images succeeds. -assert.commandWorked(coll.updateOne({_id: 1}, {$inc: {a: 1}})); -rst.awaitReplication(); - -// Finally upgrade the binary of the primary node to the current version. -rst.upgradePrimary(rst.getPrimary(), {binVersion: latestVersion}); - -// Update a document on the collection with inactive "recordPreImages" collection option. -coll = rst.getPrimary().getDB("test")[collectionName]; -assert.commandWorked(coll.updateOne({_id: 1}, {$inc: {a: 1}})); -rst.awaitReplication(); - -// Upgrade the FCV to the latest to trigger removal of "recordPreImages" collection option from -// persistent catalog entries. -assert.commandWorked(rst.getPrimary().adminCommand({setFeatureCompatibilityVersion: latestFCV})); - -// To check the collection options, downgrade FCV to later replace the binary of the server with -// the last LTS binary version. -assert.commandWorked(rst.getPrimary().adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); -rst.upgradeSet({binVersion: lastLTSVersion}); - -// Verify that collection option "recordPreImages" was removed. -const result = - assert.commandWorked(rst.getPrimary().getDB("test").runCommand({listCollections: 1})); -assert.eq(result.cursor.firstBatch[0].name, collectionName); -assert.docEq( - {}, - result.cursor.firstBatch[0].options, - `Collection option "recordPreImages" was not removed. Got response: ${tojson(result)}`); -rst.stopSet(); -})(); \ No newline at end of file diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_capped_collection.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_capped_collection.js deleted file mode 100644 index 2a921cfaf1c..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_capped_collection.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Test to ensure that: - * 1. The FCV cannot be downgraded to 6.0 if there are capped collections with a size - * that is non multiple of 256 bytes. - * 2. The FCV can be set back to upgraded if feature flag DowngradingToUpgrading is true. - * - * @tags: [requires_fcv_70] - */ -(function() { -"use strict"; - -load('jstests/libs/collection_drop_recreate.js'); -load("jstests/libs/feature_flag_util.js"); - -const latest = "latest"; -const dbName = "test_set_fcv_capped_collection"; -const collName = "capped_collection"; -const cappedCollOptions = { - capped: true, - size: 5242881, - max: 5000, -}; - -function checkFCVDowngradeUpgrade(db, adminDB) { - let runDowngradingToUpgrading = false; - if (FeatureFlagUtil.isEnabled(adminDB, "DowngradingToUpgrading")) { - runDowngradingToUpgrading = true; - } - - jsTest.log("Create a relaxed size capped collection and attempt to setFCV to lastLTS"); - checkFCV(adminDB, latestFCV); - assertCreateCollection(db, collName, cappedCollOptions); - assert.commandFailedWithCode(adminDB.runCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - - // Check FCV is in downgrading state. - checkFCV(adminDB, lastLTSFCV, lastLTSFCV); - - if (runDowngradingToUpgrading) { - jsTest.log("Set FCV back to latest"); - assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: latestFCV})); - checkFCV(adminDB, latestFCV); - - // Confirm the capped collection is not affected. - const res = db[collName].stats(); - assert.eq(res.capped, cappedCollOptions.capped); - assert.eq(res.maxSize, cappedCollOptions.size); - } - - assertDropCollection(db, collName); -} - -function runStandaloneTest() { - jsTest.log("Start Standalone test"); - const conn = MongoRunner.runMongod({binVersion: latest}); - const db = conn.getDB(dbName); - const adminDB = conn.getDB("admin"); - - checkFCVDowngradeUpgrade(db, adminDB); - - MongoRunner.stopMongod(conn); -} - -function runReplicaSetTest() { - jsTest.log("Start Replica Set test"); - const rst = new ReplSetTest({nodes: 2, nodeOpts: {binVersion: latest}}); - rst.startSet(); - rst.initiate(); - const db = rst.getPrimary().getDB(dbName); - const adminDB = rst.getPrimary().getDB("admin"); - - checkFCVDowngradeUpgrade(db, adminDB); - - rst.stopSet(); -} - -function runShardingTest() { - jsTest.log("Start Sharding test"); - const st = new ShardingTest({shards: 2, mongos: 1, config: 1}); - const db = st.s.getDB(dbName); - const adminDB = st.s.getDB("admin"); - - checkFCVDowngradeUpgrade(db, adminDB); - - st.stop(); -} - -runStandaloneTest(); -runReplicaSetTest(); -runShardingTest(); -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_encrypted_field_collection.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_encrypted_field_collection.js deleted file mode 100644 index 125e6c7dbd7..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_encrypted_field_collection.js +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Test to ensure that: - * 1. The FCV cannot be downgraded to 6.0 if there are queryable range encryption indexes. - * 2. The FCV can be set back to upgraded if feature flag DowngradingToUpgrading is true. - * - * @tags: [requires_fcv_70] - */ -(function() { -"use strict"; - -load('jstests/libs/collection_drop_recreate.js'); -load("jstests/libs/feature_flag_util.js"); - -const latest = "latest"; -const dbName = "test_set_fcv_encrypted_field"; -const collName = "encrypted"; -const encryptedFieldsOption = { - encryptedFields: { - fields: [{ - path: "firstName", - keyId: UUID("11d58b8a-0c6c-4d69-a0bd-70c6d9befae9"), - bsonType: "int", - queries: {queryType: "rangePreview", sparsity: 1, min: NumberInt(1), max: NumberInt(2)} - }] - } -}; - -function checkFCVDowngradeUpgrade(db, adminDB) { - let runDowngradingToUpgrading = false; - if (FeatureFlagUtil.isEnabled(adminDB, "DowngradingToUpgrading")) { - runDowngradingToUpgrading = true; - } - - jsTest.log("Create a encrypted field collection and attempt to setFCV to lastLTS"); - checkFCV(adminDB, latestFCV); - assertCreateCollection(db, collName, encryptedFieldsOption); - assert.commandFailedWithCode(adminDB.runCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - - // Check FCV is in downgrading state. - checkFCV(adminDB, lastLTSFCV, lastLTSFCV); - - if (runDowngradingToUpgrading) { - jsTest.log("Set FCV back to latest"); - assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: latestFCV})); - checkFCV(adminDB, latestFCV); - - // Check encryptedField is unaffected. - const res = db.getCollectionInfos({name: collName}); - assert.eq(res[0].options.encryptedFields.fields[0].queries.queryType, - encryptedFieldsOption.encryptedFields.fields[0].queries.queryType); - } - - assertDropCollection(db, collName); -} - -function runReplicaSetTest() { - jsTest.log("Start Replica Set test"); - const rst = new ReplSetTest({nodes: 2, nodeOpts: {binVersion: latest}}); - rst.startSet(); - rst.initiate(); - const db = rst.getPrimary().getDB(dbName); - const adminDB = rst.getPrimary().getDB("admin"); - - checkFCVDowngradeUpgrade(db, adminDB); - - rst.stopSet(); -} - -function runShardingTest() { - jsTest.log("Start Sharding test"); - const st = new ShardingTest({shards: 2, mongos: 1, config: 1}); - const db = st.s.getDB(dbName); - const adminDB = st.s.getDB("admin"); - - checkFCVDowngradeUpgrade(db, adminDB); - - st.stop(); -} - -runReplicaSetTest(); -runShardingTest(); -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_partial_ttl_index_on_timeseries.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_partial_ttl_index_on_timeseries.js deleted file mode 100644 index 1233db74785..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_downgrading_to_upgraded_with_partial_ttl_index_on_timeseries.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Test to ensure that: - * 1. The FCV cannot be downgraded to 6.0 if there are timeseries collections with - * partial TTL index. - * 2. The FCV can be set back to upgraded if feature flag DowngradingToUpgrading is true. - * - * @tags: [requires_fcv_70] - */ -(function() { -"use strict"; - -load('jstests/libs/collection_drop_recreate.js'); -load("jstests/libs/feature_flag_util.js"); - -const latest = "latest"; -const dbName = "test_set_fcv_partial_ttl_index"; -const collName = "timeseries"; -const timeFieldName = "tm"; -const metaFieldName = "mm"; -const timeseriesOptions = { - timeseries: { - timeField: timeFieldName, - metaField: metaFieldName, - } -}; -const ttlIndexSpec = { - [timeFieldName]: 1, -}; -const ttlIndexOptions = { - expireAfterSeconds: 3600, - partialFilterExpression: { - [metaFieldName]: { - $gt: 5, - } - } -}; - -function checkFCVDowngradeUpgrade(db, adminDB) { - let runDowngradingToUpgrading = false; - if (FeatureFlagUtil.isEnabled(adminDB, "DowngradingToUpgrading")) { - runDowngradingToUpgrading = true; - } - - jsTest.log( - "Create a partial TTL index on timeseries collection and attempt to setFCV to lastLTS"); - checkFCV(adminDB, latestFCV); - assertCreateCollection(db, collName, timeseriesOptions); - assert.commandWorked(db[collName].createIndex(ttlIndexSpec, ttlIndexOptions)); - assert.commandFailed(adminDB.runCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - - // Check FCV is in downgrading state. - checkFCV(adminDB, lastLTSFCV, lastLTSFCV); - - if (runDowngradingToUpgrading) { - jsTest.log("Set FCV back to latest"); - assert.commandWorked(adminDB.runCommand({setFeatureCompatibilityVersion: latestFCV})); - checkFCV(adminDB, latestFCV); - - // Confirm the partial TTL index is not affected. - const res = db[collName].getIndexes(); - assert.eq(res[1].expireAfterSeconds, ttlIndexOptions.expireAfterSeconds); - assert.eq(res[1].partialFilterExpression, ttlIndexOptions.partialFilterExpression); - } - - assertDropCollection(db, collName); -} - -function runStandaloneTest() { - jsTest.log("Start Standalone test"); - const conn = MongoRunner.runMongod({binVersion: latest}); - const db = conn.getDB(dbName); - const adminDB = conn.getDB("admin"); - - checkFCVDowngradeUpgrade(db, adminDB); - - MongoRunner.stopMongod(conn); -} - -function runReplicaSetTest() { - jsTest.log("Start Replica Set test"); - const rst = new ReplSetTest({nodes: 2, nodeOpts: {binVersion: latest}}); - rst.startSet(); - rst.initiate(); - const db = rst.getPrimary().getDB(dbName); - const adminDB = rst.getPrimary().getDB("admin"); - - checkFCVDowngradeUpgrade(db, adminDB); - - rst.stopSet(); -} - -function runShardingTest() { - jsTest.log("Start Sharding test"); - const st = new ShardingTest({shards: 2, mongos: 1, config: 1}); - const db = st.s.getDB(dbName); - const adminDB = st.s.getDB("admin"); - - checkFCVDowngradeUpgrade(db, adminDB); - - st.stop(); -} - -runStandaloneTest(); -runReplicaSetTest(); -runShardingTest(); -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_prevent_invalid_downgrade_with_catalog_shard.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_prevent_invalid_downgrade_with_catalog_shard.js deleted file mode 100644 index 10e08d3b98c..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/set_fcv_prevent_invalid_downgrade_with_catalog_shard.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Test to ensure that: - * 1. The FCV cannot be downgraded to a version that does not have catalog shards if catalog - * shard is enabled. - * 2. If the FCV does get downgraded to a version that does not support catalog shards, a - * catalog shard cannot be created (this can occur if an FCV downgrade happens concurrently - * with the creation of a catalog shard). - * - * @tags: [requires_fcv_70, featureFlagCatalogShard, featureFlagTransitionToCatalogShard] - */ -(function() { -"use strict"; - -// TODO (SERVER-74534): Enable the metadata consistency check when it will work with co-located -// configsvr. -TestData.skipCheckMetadataConsistency = true; - -load("jstests/libs/catalog_shard_util.js"); - -const shardedNs = "foo.bar"; -const unshardedNs = "unsharded_foo.unsharded_bar"; - -function basicCRUD(conn, ns) { - assert.commandWorked( - conn.getCollection(ns).insert([{_id: 1, x: 1, skey: -1000}, {_id: 2, skey: 1000}])); - assert.sameMembers(conn.getCollection(ns).find().toArray(), - [{_id: 1, x: 1, skey: -1000}, {_id: 2, skey: 1000}]); - assert.commandWorked(conn.getCollection(ns).remove({x: 1})); - assert.commandWorked(conn.getCollection(ns).remove({skey: 1000})); - assert.eq(conn.getCollection(ns).find().toArray().length, 0); -} - -let splitPoint = 0; -function basicShardedDDL(conn, ns) { - assert.commandWorked(conn.adminCommand({split: ns, middle: {skey: splitPoint}})); - splitPoint += 10; -} - -const st = new ShardingTest({shards: 2, catalogShard: true, other: {enableBalancer: true}}); -const mongosAdminDB = st.s.getDB("admin"); - -assert.commandWorked(st.s.adminCommand({shardCollection: shardedNs, key: {skey: 1}})); - -function runTest(targetFCV) { - jsTest.log("Downgrading FCV to an unsupported version when catalogShard is enabled."); - - const errRes = assert.commandFailedWithCode( - mongosAdminDB.runCommand({setFeatureCompatibilityVersion: targetFCV}), - ErrorCodes.CannotDowngrade); - assert.eq(errRes.errmsg, - `Cannot downgrade featureCompatibilityVersion to ${targetFCV} with a catalog shard as it is not supported in earlier versions. Please transition the config server to dedicated mode using the transitionToDedicatedConfigServer command.`); - - // The downgrade fails and should not start the downgrade process on any cluster node. - const configRes = - st.config0.getDB("admin").runCommand({getParameter: 1, featureCompatibilityVersion: 1}); - assert(configRes.featureCompatibilityVersion); - assert.eq(configRes.featureCompatibilityVersion.version, latestFCV); - - const shardRes = - st.shard1.getDB("admin").runCommand({getParameter: 1, featureCompatibilityVersion: 1}); - assert(shardRes.featureCompatibilityVersion); - assert.eq(shardRes.featureCompatibilityVersion.version, latestFCV); - - // The catalog shard's data can still be accessed. - basicCRUD(st.s, shardedNs); - basicShardedDDL(st.s, shardedNs); - basicCRUD(st.s, unshardedNs); - - // Remove the catalog shard and verify we can now downgrade. - CatalogShardUtil.transitionToDedicatedConfigServer(st); - assert.commandWorked(mongosAdminDB.runCommand({setFeatureCompatibilityVersion: targetFCV})); - - jsTest.log("Attempting to create a catalogShard on an unsupported FCV."); - - assert.commandWorked(mongosAdminDB.runCommand({setFeatureCompatibilityVersion: targetFCV})); - assert.commandFailedWithCode(mongosAdminDB.runCommand({transitionToCatalogShard: 1}), 7467202); - - // Upgrade and transition back to catalog shard mode for the next test. - assert.commandWorked(mongosAdminDB.runCommand({setFeatureCompatibilityVersion: latestFCV})); - assert.commandWorked(mongosAdminDB.runCommand({transitionToCatalogShard: 1})); - - basicCRUD(st.s, shardedNs); - basicShardedDDL(st.s, shardedNs); - basicCRUD(st.s, unshardedNs); -} - -runTest(lastLTSFCV); -runTest(lastContinuousFCV); - -st.stop(); -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/timeseries_index.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/timeseries_index.js deleted file mode 100644 index a6bca60df1a..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/timeseries_index.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Tests that time-series measurement indexes can be created in FCV 6.0. - */ -(function() { -"use strict"; - -const rst = new ReplSetTest({nodes: 1}); -rst.startSet(); -rst.initiate(); - -const primary = rst.getPrimary(); - -const dbName = "test"; -const collName = "coll"; - -const db = primary.getDB(dbName); - -assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); -assert.commandWorked(db.createCollection(collName, {timeseries: {timeField: "t", metaField: "m"}})); -assert.commandWorked(db.coll.insert({t: ISODate(), m: 1})); -assert.commandWorked(db.coll.createIndex({a: 1, t: 1})); - -rst.stopSet(); -}()); diff --git a/jstests/noPassthrough/capped_collections_downgrade.js b/jstests/noPassthrough/capped_collections_downgrade.js deleted file mode 100644 index 53a276f0c12..00000000000 --- a/jstests/noPassthrough/capped_collections_downgrade.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Tests that the cluster cannot be downgraded when there are capped collections with a size that - * is non multiple of 256 bytes. The user has to resize or drop the collection in order to - * downgrade. - */ -(function() { - -const conn = MongoRunner.runMongod(); -const testDB = conn.getDB(jsTestName()); -const cappedColl = testDB["capped_coll"]; -const options = Object.assign({}, {capped: true}, {size: 50 * 1023}); -testDB.createCollection(cappedColl.getName(), options); - -// We expect the server to be in a non-downgradable state initially and "command" is what we have to -// run to correct the state in order to successfully downgrade. -function checkCappedCollectionForDowngrade(command) { - assert.commandFailedWithCode(testDB.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - testDB.runCommand(command); - assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - assert.commandWorked(testDB.adminCommand({setFeatureCompatibilityVersion: latestFCV})); -} - -// We want to resize the collection to have a size multiple of 256 bytes in order to be able to -// downgrade. -const resizeCommand = Object.assign({}, {collMod: cappedColl.getName()}, {cappedSize: 50 * 1024}); -checkCappedCollectionForDowngrade(resizeCommand); - -// We reset the size of the collection to be a non multiple of 256 bytes. -const resetSizeCommand = - Object.assign({}, {collMod: cappedColl.getName()}, {cappedSize: 50 * 1023}); -testDB.runCommand(resetSizeCommand); - -// We want to drop the collection in order to be able to downgrade. -const dropCommand = Object.assign({}, {drop: cappedColl.getName()}); -checkCappedCollectionForDowngrade(dropCommand); - -MongoRunner.stopMongod(conn); -}()); diff --git a/jstests/noPassthrough/sharded_timeseries_bucketing_parameters_downgrade.js b/jstests/noPassthrough/sharded_timeseries_bucketing_parameters_downgrade.js deleted file mode 100644 index 0e1b77aff62..00000000000 --- a/jstests/noPassthrough/sharded_timeseries_bucketing_parameters_downgrade.js +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Tests that bucketing parameters are disallowed after downgrading to versions where the parameters - * are not supported. - */ -(function() { -'use strict'; - -load("jstests/core/timeseries/libs/timeseries.js"); -load("jstests/libs/catalog_shard_util.js"); -load("jstests/libs/fail_point_util.js"); - -const dbName = 'testDB'; -const collName = 'testColl'; -const timeField = 'tm'; -const metaField = 'mt'; - -const st = new ShardingTest({shards: 2}); -const mongos = st.s0; - -function useBucketingParametersOnLowerFCV() { - const db = mongos.getDB(dbName); - if (!TimeseriesTest.timeseriesScalabilityImprovementsEnabled(db)) { - jsTestLog( - "Skipped test as the featureFlagTimeseriesScalabilityImprovements feature flag is not enabled."); - return; - } - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - - const isCatalogShardEnabled = CatalogShardUtil.isEnabledIgnoringFCV(st); - - let coll = db.getCollection(collName); - coll.drop(); - assert.commandWorked(db.createCollection(collName, { - timeseries: { - timeField: timeField, - metaField: metaField, - bucketMaxSpanSeconds: 60, - bucketRoundingSeconds: 60 - } - })); - - const configDirectDb = st.configRS.getPrimary().getDB(dbName); - const configDirectColl = configDirectDb.getCollection(collName); - if (isCatalogShardEnabled) { - // Verify we cannot downgrade if the config server has a timeseries collection with - // bucketing. - assert.commandWorked(configDirectDb.createCollection(collName, { - timeseries: { - timeField: timeField, - metaField: metaField, - bucketMaxSpanSeconds: 60, - bucketRoundingSeconds: 60 - } - })); - } - - // On the latestFCV, we should not be able to use collMod with incomplete bucketing parameters. - assert.commandFailedWithCode( - db.runCommand({collMod: collName, timeseries: {bucketMaxSpanSeconds: 3600}}), - ErrorCodes.InvalidOptions); - - // We should fail to downgrade if we have a collection with custom bucketing parameters set. - assert.commandFailedWithCode(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - - coll = db.getCollection(collName); - coll.drop(); - - if (isCatalogShardEnabled) { - // We should still fail to downgrade if we have a collection on the config server with - // custom bucketing parameters set. - assert.commandFailedWithCode( - mongos.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - - configDirectColl.drop(); - } - - // Successfully downgrade to latest FCV. - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - - // On the latest FCV, we should not be able to create a collection with bucketing parameters. - assert.commandFailedWithCode(db.createCollection(collName, { - timeseries: { - timeField: timeField, - metaField: metaField, - bucketMaxSpanSeconds: 60, - bucketRoundingSeconds: 60 - } - }), - ErrorCodes.InvalidOptions); - - assert.commandWorked( - db.createCollection(collName, {timeseries: {timeField: timeField, metaField: metaField}})); - - // On the latest FCV we should not be able to use collMod with the bucketing parameters. - assert.commandFailedWithCode(db.runCommand({ - collMod: collName, - timeseries: {bucketMaxSpanSeconds: 3600, bucketRoundingSeconds: 3600} - }), - ErrorCodes.InvalidOptions); - assert.commandFailedWithCode( - db.runCommand({collMod: collName, timeseries: {bucketMaxSpanSeconds: 3600}}), - ErrorCodes.InvalidOptions); - assert.commandFailedWithCode( - db.runCommand({collMod: collName, timeseries: {bucketRoundingSeconds: 3600}}), - ErrorCodes.InvalidOptions); - - // Verify the time-series options are valid. - let collections = assert.commandWorked(db.runCommand({listCollections: 1})).cursor.firstBatch; - let collectionEntry = collections.find(entry => entry.name === 'system.buckets.' + collName); - assert(collectionEntry); - - assert.eq(collectionEntry.options.timeseries.granularity, "seconds"); - // Downgrading does not remove the 'bucketMaxSpanSeconds' parameter. It should correspond with - // the "seconds" granularity. - assert.eq(collectionEntry.options.timeseries.bucketMaxSpanSeconds, 3600); - assert.isnull(collectionEntry.options.timeseries.bucketRoundingSeconds); -} - -useBucketingParametersOnLowerFCV(); - -st.stop(); -})(); diff --git a/jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js b/jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js deleted file mode 100644 index 5a50f30c6d5..00000000000 --- a/jstests/noPassthrough/timeseries_bucketing_parameters_downgrade.js +++ /dev/null @@ -1,212 +0,0 @@ -/** - * Tests behavior with the bucketing parameters on time-series collections when downgrading. If we - * are using custom bucketing parameters we expect to fail the downgrade but if we use default - * granularity values the downgrade should succeed. - */ -(function() { -"use strict"; - -load("jstests/core/timeseries/libs/timeseries.js"); -load("jstests/libs/feature_flag_util.js"); // For isEnabled. - -const conn = MongoRunner.runMongod(); -const db = conn.getDB("test"); - -if (!TimeseriesTest.timeseriesScalabilityImprovementsEnabled(conn)) { - jsTestLog( - "Skipped test as the featureFlagTimeseriesScalabilityImprovements feature flag is not enabled."); - MongoRunner.stopMongod(conn); - return; -} - -const collName = "timeseries_bucketing_parameters"; -const coll = db.getCollection(collName); -const bucketsColl = db.getCollection("system.buckets." + collName); - -const timeFieldName = "tm"; -const metaFieldName = "mm"; - -const resetCollection = function(extraOptions = {}) { - coll.drop(); - - const tsOpts = {timeField: timeFieldName, metaField: metaFieldName}; - assert.commandWorked( - db.createCollection(coll.getName(), {timeseries: Object.merge(tsOpts, extraOptions)})); - assert.commandWorked(coll.insert({[timeFieldName]: ISODate(), [metaFieldName]: 1})); -}; - -const secondsMaxSpan = TimeseriesTest.getBucketMaxSpanSecondsFromGranularity('seconds'); -const secondsRoundingSeconds = TimeseriesTest.getBucketRoundingSecondsFromGranularity('seconds'); -const minutesMaxSpan = TimeseriesTest.getBucketMaxSpanSecondsFromGranularity('minutes'); -const minutesRoundingSeconds = TimeseriesTest.getBucketRoundingSecondsFromGranularity('minutes'); -const hoursMaxSpan = TimeseriesTest.getBucketMaxSpanSecondsFromGranularity('hours'); -const hoursRoundingSeconds = TimeseriesTest.getBucketRoundingSecondsFromGranularity('hours'); - -const getNearestGranularity = function(bucketingParams) { - assert(bucketingParams.hasOwnProperty('bucketMaxSpanSeconds') && - bucketingParams.hasOwnProperty('bucketRoundingSeconds')); - - if (bucketingParams.bucketMaxSpanSeconds <= secondsMaxSpan && - bucketingParams.bucketRoundingSeconds <= secondsRoundingSeconds) { - return 'seconds'; - } - - if (bucketingParams.bucketMaxSpanSeconds <= minutesMaxSpan && - bucketingParams.bucketRoundingSeconds <= minutesRoundingSeconds) { - return 'minutes'; - } - - if (bucketingParams.bucketMaxSpanSeconds <= hoursMaxSpan && - bucketingParams.bucketRoundingSeconds <= hoursRoundingSeconds) { - return 'hours'; - } - - return null; -}; - -// Checks if the downgrade command succeeds and reset the version to latestFCV. -function checkDowngradeSucceeds() { - // Verify that downgrade succeeds. - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - - // Check that the 'granularity' and 'bucketMaxSpanSeconds' are correctly set and that - // 'bucketRoundingSeconds' is not set to any value. - let collections = assert.commandWorked(db.runCommand({listCollections: 1})).cursor.firstBatch; - let collectionEntry = - collections.find(entry => entry.name === 'system.buckets.' + coll.getName()); - assert(collectionEntry); - - let granularity = collectionEntry.options.timeseries.granularity; - assert(granularity); - assert.isnull(collectionEntry.options.timeseries.bucketRoundingSeconds); - assert.eq(collectionEntry.options.timeseries.bucketMaxSpanSeconds, - TimeseriesTest.getBucketMaxSpanSecondsFromGranularity(granularity)); - - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: latestFCV})); -} - -// Checks that downgrade fails but tries again by using the collMod command to modify the collection -// into a downgradable state. Will drop the collection if there is no possible granularity to -// update. -function checkDowngradeFailsAndTryAgain(bucketingParams) { - assert.commandFailedWithCode(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - - let nextGranularity = getNearestGranularity(bucketingParams); - - if (nextGranularity) { - assert.commandWorked( - db.runCommand({collMod: collName, timeseries: {granularity: nextGranularity}})); - } else { - // If the bucketMaxSpanSeconds and bucketRoundingSeconds are both greater than the values - // corresponding to the 'hours' granularity, the only way to successfully downgrade is to - // drop the collection. - resetCollection(); - } - - checkDowngradeSucceeds(); -} - -const checkBucketCount = function(count = 1) { - let stats = assert.commandWorked(coll.stats()); - assert(stats.timeseries); - assert.eq(stats.timeseries['bucketCount'], count); -}; - -// 1. We expect downgrade to work seamlessly when a standard granularity is used. -{ - resetCollection(); - - // When we create collections with no granularity specified, we should default to 'seconds' - // meaning we should be able to downgrade successfully. - checkDowngradeSucceeds(); - - // If we explicitly set the granularity of a collection we expect to succesfully downgrade. - resetCollection({granularity: 'seconds'}); - checkDowngradeSucceeds(); - - // We expect to successfully downgrade with different granularity values. - assert.commandWorked(db.runCommand({collMod: collName, timeseries: {granularity: "seconds"}})); - checkDowngradeSucceeds(); - assert.commandWorked(db.runCommand({collMod: collName, timeseries: {granularity: "minutes"}})); - checkDowngradeSucceeds(); - assert.commandWorked(db.runCommand({collMod: collName, timeseries: {granularity: "hours"}})); - checkDowngradeSucceeds(); -} - -// 2. We expect to successfully downgrade if 'bucketMaxSpanSeconds' corresponds to a granularity. -{ - resetCollection({granularity: 'seconds', bucketMaxSpanSeconds: secondsMaxSpan}); - checkDowngradeSucceeds(); - - resetCollection({granularity: 'seconds', bucketMaxSpanSeconds: secondsMaxSpan}); - checkDowngradeSucceeds(); - - resetCollection({granularity: 'minutes', bucketMaxSpanSeconds: minutesMaxSpan}); - checkDowngradeSucceeds(); - - resetCollection({granularity: 'hours', bucketMaxSpanSeconds: hoursMaxSpan}); - checkDowngradeSucceeds(); -} - -// 3. When we set values for 'bucketMaxSpanSeconds' and 'bucketRoundingSeconds' we expect downgrade -// to fail. Changing the collection's granularity to the next possible granularity should allow -// downgrade to succeed. -{ - // Use custom bucketing parameters (less than the 'seconds' granularity). - let bucketingParams = { - bucketMaxSpanSeconds: secondsRoundingSeconds, - bucketRoundingSeconds: secondsRoundingSeconds - }; - resetCollection(bucketingParams); - - // Insert a few measurements to create a total of 3 buckets. - assert.commandWorked(coll.insert({[timeFieldName]: ISODate(), [metaFieldName]: 2})); - assert.commandWorked(coll.insert({[timeFieldName]: ISODate(), [metaFieldName]: 3})); - checkBucketCount(3); - - // Expect downgrade to fail but when the granularity is changed to 'seconds' we should - // successfully downgrade. - checkDowngradeFailsAndTryAgain(bucketingParams); - - // Use custom bucketing parameters (less than the 'minutes' granularity). - bucketingParams = {bucketMaxSpanSeconds: secondsMaxSpan, bucketRoundingSeconds: secondsMaxSpan}; - assert.commandWorked(db.runCommand({collMod: collName, timeseries: bucketingParams})); - - // Expect downgrade to fail but when the granularity is changed to 'minutes' we should - // successfully downgrade. - checkDowngradeFailsAndTryAgain(bucketingParams); - - // Use custom bucketing parameters (less than the 'hours' granularity). - bucketingParams = {bucketMaxSpanSeconds: minutesMaxSpan, bucketRoundingSeconds: minutesMaxSpan}; - assert.commandWorked(db.runCommand({collMod: collName, timeseries: bucketingParams})); - - // Expect downgrade to fail but when the granularity is changed to 'hours' we should - // successfully downgrade. - checkDowngradeFailsAndTryAgain(bucketingParams); - - // Make sure the collection did not get dropped in the process to successfully downgrade by - // checking the number of buckets in the collection. - checkBucketCount(3); -} - -// 4. In cases where the bucketing parameters are higher than the possible granularities, the only -// way to downgrade is to drop the collection. -{ - let bucketingParams = {bucketMaxSpanSeconds: hoursMaxSpan, bucketRoundingSeconds: hoursMaxSpan}; - resetCollection(bucketingParams); - - // Insert a few measurements to create a total of 3 buckets. - assert.commandWorked(coll.insert({[timeFieldName]: ISODate(), [metaFieldName]: 2})); - assert.commandWorked(coll.insert({[timeFieldName]: ISODate(), [metaFieldName]: 3})); - checkBucketCount(3); - - // Expect the downgrade to fail and drops the collection for the downgrade to succeed. - checkDowngradeFailsAndTryAgain(bucketingParams); - - // Verify the original collection had to be dropped in order to downgrade. - checkBucketCount(1); -} - -MongoRunner.stopMongod(conn); -}()); diff --git a/jstests/noPassthrough/timeseries_ttl_index_downgrade.js b/jstests/noPassthrough/timeseries_ttl_index_downgrade.js deleted file mode 100644 index 3f900741727..00000000000 --- a/jstests/noPassthrough/timeseries_ttl_index_downgrade.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Tests that the cluster cannot be downgraded when there are secondary TTL indexes with partial - * filters on time-series present. - */ -(function() { -"use strict"; - -load("jstests/core/timeseries/libs/timeseries.js"); -load("jstests/libs/feature_flag_util.js"); // For isEnabled. - -const conn = MongoRunner.runMongod(); -const db = conn.getDB("test"); - -if (!FeatureFlagUtil.isEnabled(db, "TimeseriesScalabilityImprovements")) { - jsTestLog( - "Skipped test as the featureFlagTimeseriesScalabilityImprovements feature flag is not enabled."); - MongoRunner.stopMongod(conn); - return; -} - -const collName = "timeseries_ttl_index_downgrade"; -const coll = db.getCollection(collName); -const bucketsColl = db.getCollection("system.buckets." + collName); - -const timeFieldName = "tm"; -const metaFieldName = "mm"; -const timeSpec = { - [timeFieldName]: 1 -}; - -assert.commandWorked(db.createCollection( - coll.getName(), {timeseries: {timeField: timeFieldName, metaField: metaFieldName}})); - -function checkIndexForDowngrade(isCompatible) { - if (!isCompatible) { - assert.commandFailedWithCode(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - assert.commandWorked(coll.dropIndexes("*")); - } - - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: latestFCV})); -} - -// Verify that downgrading succeeds on a time-series collection without any indexes. -checkIndexForDowngrade(true); - -// Verify that downgrading succeeds on a time-series collection with a partial index. -const options = { - name: "partialIndexOnMeta", - partialFilterExpression: {[metaFieldName]: {$gt: 5}} -}; -assert.commandWorked(coll.createIndex(timeSpec, options)); -checkIndexForDowngrade(true); - -// Verify that downgrading succeeds on a time-series collection created with expireAfterSeconds -// value. -coll.drop(); -assert.commandWorked(db.createCollection( - coll.getName(), - {timeseries: {timeField: timeFieldName, metaField: metaFieldName}, expireAfterSeconds: 3600})); -checkIndexForDowngrade(true); - -// Verify that downgrading fails on a time-series collection with a partial, TTL index. -assert.commandWorked(coll.createIndex(timeSpec, Object.merge(options, {expireAfterSeconds: 400}))); -checkIndexForDowngrade(false); - -MongoRunner.stopMongod(conn); -}()); diff --git a/jstests/replsets/all_commands_downgrading_to_upgraded.js b/jstests/replsets/all_commands_downgrading_to_upgraded.js index 9460d090927..9313ff903a5 100644 --- a/jstests/replsets/all_commands_downgrading_to_upgraded.js +++ b/jstests/replsets/all_commands_downgrading_to_upgraded.js @@ -29,6 +29,7 @@ const isAnInternalCommand = "internal command"; const isDeprecated = "deprecated command"; const commandIsDisabledOnLastLTS = "skip command on downgrading fcv"; const requiresParallelShell = "requires parallel shell"; +const cannotRunWhileDowngrading = "cannot run command while downgrading"; const allCommands = { _addShard: {skip: isAnInternalCommand}, @@ -1091,13 +1092,7 @@ const allCommands = { }, }, movePrimary: { - isShardedOnly: true, - fullScenario: function(conn, fixture) { - assert.commandWorked(conn.getDB(dbName).runCommand({create: collName})); - assert.commandWorked(conn.getDB('admin').runCommand( - {movePrimary: dbName, to: fixture.shard0.shardName})); - assert.commandWorked(conn.getDB(dbName).runCommand({drop: collName})); - } + skip: cannotRunWhileDowngrading, }, moveRange: { isShardedOnly: true, diff --git a/jstests/sharding/config_settings_schema_upgrade_downgrade.js b/jstests/sharding/config_settings_schema_upgrade_downgrade.js deleted file mode 100644 index 83a033d482e..00000000000 --- a/jstests/sharding/config_settings_schema_upgrade_downgrade.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * TODO (SERVER-70763) remove this test after 7.0 becomes lastLTS - * - * Tests that a schema is added to the config.settings collection on upgrade and removed on - * downgrade. - * - * Incompatible with a catalog shard because catalog shards can't downgrade FCV below 7.0, and this - * test is only for that particular transition. - * @tags: [ - * multiversion_incompatible, - * featureFlagConfigSettingsSchema, - * does_not_support_stepdowns, - * catalog_shard_incompatible, - * ] - */ -(function() { -'use strict'; - -load("jstests/libs/feature_flag_util.js"); - -var st = new ShardingTest({shards: 1, config: 2}); - -// Validator should be created for new clusters in 6.2 -let validatorDoc = st.config.getCollectionInfos({name: "settings"})[0].options.validator; -assert(validatorDoc); - -// Validator should be removed on downgrade -st.s.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}); -validatorDoc = st.config.getCollectionInfos({name: "settings"})[0].options.validator; -assert(!validatorDoc); - -// Validator should be added in on upgrade -st.s.adminCommand({setFeatureCompatibilityVersion: latestFCV}); -validatorDoc = st.config.getCollectionInfos({name: "settings"})[0].options.validator; -assert(validatorDoc); - -st.stop(); -})();