diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /jstests/multiVersion | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'jstests/multiVersion')
20 files changed, 113 insertions, 956 deletions
diff --git a/jstests/multiVersion/genericBinVersion/query_stats_key_hash_version_consistency.js b/jstests/multiVersion/genericBinVersion/query_stats_key_hash_version_consistency.js deleted file mode 100644 index 1e61d5280fc..00000000000 --- a/jstests/multiVersion/genericBinVersion/query_stats_key_hash_version_consistency.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Tests that query stats key hashes are consistent across versions. - * @tags: [requires_fcv_60] - */ -(function() { -'use strict'; - -load("jstests/multiVersion/libs/multi_rs.js"); -load("jstests/libs/query_stats_utils.js"); // For getQueryStatsFindCmd and getQueryStatsKeyHashes. - -// TODO SERVER-87729 Start from the previous version. -const rst = new ReplSetTest( - {nodes: {n1: {binVersion: "latest"}, n2: {binVersion: "latest"}, n3: {binVersion: "latest"}}}); - -// Turn on the collecting of query stats metrics. -rst.startSet({setParameter: {internalQueryStatsRateLimit: -1}}); -rst.initiate(); - -let conn = rst.getPrimary(); -const collName = jsTestName(); -let coll = conn.getDB("test")[collName]; -coll.drop(); -coll.insert({x: 5}); - -// Run a few unique queries so that they generate different query stats entries. -function runQueries() { - coll.find({x: 5}).toArray(); - coll.find({y: 5}).toArray(); - coll.find({y: 5}).sort({x: -1}).toArray(); - coll.find({y: 5}).maxTimeMS(123).toArray(); -} - -// First, collect and save query stats entries on the older version. -runQueries(); -const preUpgradeEntries = getQueryStatsFindCmd(conn, {collName, transformIdentifiers: false}); -assert.eq(preUpgradeEntries.length, 4, tojson(preUpgradeEntries)); -const preUpgradeKeyHashes = getQueryStatsKeyHashes(preUpgradeEntries); - -// Upgrade to the latest. -rst.upgradeSet({binVersion: 'latest'}); -conn = rst.getPrimary(); -coll = conn.getDB("test")[collName]; - -// Run the same queries again and check that we got the same query stats key hash values as we did -// on the old version. -runQueries(); -const postUpgradeEntries = getQueryStatsFindCmd(conn, {collName, transformIdentifiers: false}); -assert.eq(postUpgradeEntries.length, 4, tojson(postUpgradeEntries)); -const postUpgradeKeyHashes = getQueryStatsKeyHashes(postUpgradeEntries); -assert.sameMembers(postUpgradeKeyHashes, - preUpgradeKeyHashes, - `preUpgradeEntries = ${tojson(preUpgradeEntries)}, postUpgradeEntries = ${ - tojson(postUpgradeEntries)}`); - -rst.stopSet(); -})();
\ No newline at end of file diff --git a/jstests/multiVersion/genericBinVersion/remove_invalid_index_options.js b/jstests/multiVersion/genericBinVersion/remove_invalid_index_options.js index b9a9405c182..c49422423c4 100644 --- a/jstests/multiVersion/genericBinVersion/remove_invalid_index_options.js +++ b/jstests/multiVersion/genericBinVersion/remove_invalid_index_options.js @@ -44,15 +44,10 @@ fpSecondary.off(); // Verify that the primary (latest) and secondary (last-lts) detect invalid index options. let validateRes = assert.commandWorked(primaryDB.runCommand({validate: collName})); -assert(validateRes.valid); -assert.eq(validateRes.errors.length, 0); -assert.eq(validateRes.warnings.length, 2); +assert(!validateRes.valid); validateRes = assert.commandWorked(secondaryDB.runCommand({validate: collName})); -// TODO (SERVER-87985): Enable assertions. -// assert(validateRes.valid); -// assert.eq(validateRes.errors.length, 0); -// assert.eq(validateRes.warnings.length, 2); +assert(!validateRes.valid); // Use collMod to remove the invalid index options in the collection. assert.commandWorked(primaryDB.runCommand({collMod: collName})); @@ -69,13 +64,9 @@ checkLog.containsJson(secondary, 23878, {fieldName: "xyz"}); // Verify that the index no longer has invalid index options. validateRes = assert.commandWorked(primaryDB.runCommand({validate: collName})); assert(validateRes.valid); -assert.eq(validateRes.errors.length, 0); -assert.eq(validateRes.warnings.length, 0); validateRes = assert.commandWorked(secondaryDB.runCommand({validate: collName})); assert(validateRes.valid); -assert.eq(validateRes.errors.length, 0); -assert.eq(validateRes.warnings.length, 0); rst.stopSet(); })(); diff --git a/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js b/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js index 85943e6c9d1..4e94668a46f 100644 --- a/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js +++ b/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js @@ -17,9 +17,7 @@ const timeFieldName = "time"; * one bucket was created. */ function runTest(docs, query, results, path, bounds) { - // Since v5.0 no longer supports writing mixed schema buckets as of 5.0.29, pin the version - // to 5.0.28 to retain coverage as v5.0 still supports the presence of mixed schema data. - const oldVersion = "5.0.28"; + const oldVersion = "last-lts"; const nodes = { n1: {binVersion: oldVersion}, n2: {binVersion: oldVersion}, diff --git a/jstests/multiVersion/genericSetFCVUsage/1_test_launching_replset.js b/jstests/multiVersion/genericSetFCVUsage/1_test_launching_replset.js index 69c110df30f..2d2fcbe85ae 100644 --- a/jstests/multiVersion/genericSetFCVUsage/1_test_launching_replset.js +++ b/jstests/multiVersion/genericSetFCVUsage/1_test_launching_replset.js @@ -45,42 +45,41 @@ for (let versions of [["last-lts", "latest"], ["last-continuous", "latest"]]) { rst.stopSet(); } -if (MongoRunner.areBinVersionsTheSame("last-continuous", "last-lts")) { - jsTest.log("Skipping test because 'last-continuous' == 'last-lts'"); +// TODO(SERVER-61100): Re-enable this test. +if (true) { + jsTestLog("Skipping test as it is currently disabled."); return; } for (let versions of [["last-lts", "last-continuous"], ["last-continuous", "last-lts"]]) { jsTestLog("Testing mixed versions: " + tojson(versions)); - var rst = new ReplSetTest({nodes: 2}); - rst.startSet({binVersion: versions}); - let err = assert.throws(() => rst.initiate()); - assert(err.message.includes( - "Can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both."), - err); - rst.stopSet(); -} + try { + var rst = new ReplSetTest({nodes: 2}); + rst.startSet({binVersion: versions}); + rst.initiate(); + } catch (e) { + if (e instanceof Error) { + if (e.message.includes( + "Can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both.")) { + continue; + } + } + throw e; + } + assert( + MongoRunner.areBinVersionsTheSame("last-continuous", "last-lts"), + "Should have thrown error in creating ReplSetTest because can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both."); -for (let versions of [["last-lts", "last-continuous"], ["last-continuous", "last-lts"]]) { - jsTestLog("Testing mixed versions: " + tojson(versions)); + var nodes = rst.nodes; + + // Make sure we have hosts of all the different versions + var versionsFound = []; + for (var j = 0; j < nodes.length; j++) + versionsFound.push(nodes[j].getBinVersion()); + + assert.allBinVersions(versions, versionsFound); - const rst = new ReplSetTest({ - nodes: [ - { - binVersion: versions[0], - }, - { - binVersion: versions[1], - }, - ] - }); - rst.startSet(); - - let err = assert.throws(() => rst.initiate()); - assert(err.message.includes( - "Can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both."), - err); rst.stopSet(); } diff --git a/jstests/multiVersion/genericSetFCVUsage/2_test_launching_cluster.js b/jstests/multiVersion/genericSetFCVUsage/2_test_launching_cluster.js index 00e025e910d..69f228875cc 100644 --- a/jstests/multiVersion/genericSetFCVUsage/2_test_launching_cluster.js +++ b/jstests/multiVersion/genericSetFCVUsage/2_test_launching_cluster.js @@ -8,60 +8,71 @@ load('./jstests/multiVersion/libs/verify_versions.js'); (function() { "use strict"; -function checkEquivalent(testConfig, st) { - var expectedVersions = [testConfig.other.mongosOptions.binVersion]; - var expectedNodes = [...testConfig.shards.rs0.nodes, ...testConfig.shards.rs1.nodes]; - for (j = 0; j < expectedNodes.length; j++) { - expectedVersions.push(expectedNodes[j].binVersion); - } - - var versionsFound = [st.s0.getBinVersion()]; - var nodes = [...st._rs[0].test.nodes, ...st._rs[1].test.nodes]; - for (var j = 0; j < nodes.length; j++) { - versionsFound.push(nodes[j].getBinVersion()); - } - assert.allBinVersions(expectedVersions, versionsFound); -} - -if (MongoRunner.areBinVersionsTheSame("last-continuous", "last-lts")) { - jsTest.log("Skipping test because 'last-continuous' == 'last-lts'"); +// TODO(SERVER-61100): Re-enable this test. +if (true) { + jsTestLog("Skipping test as it is currently disabled."); return; } -const invalidMixedVersionsToCheck = [ - { - shards: { - rs0: {nodes: [{binVersion: "last-continuous"}, {binVersion: "last-lts"}]}, - rs1: {nodes: [{binVersion: "last-lts"}]} - }, - other: {mongosOptions: {binVersion: "last-lts"}} - }, +// Sharded cluster upgrade order: config servers -> shards -> mongos. +const mixedVersionsToCheck = [ + {config: ["latest"], shard: ["last-lts", "latest"], mongos: ["last-lts"]}, + {config: ["latest"], shard: ["last-continuous", "latest"], mongos: ["last-continuous"]}, + {config: ["latest"], shard: ["last-continuous", "last-lts"], mongos: ["last-continuous"]}, + {config: ["latest"], shard: ["last-lts", "last-continuous"], mongos: ["last-lts"]}, ]; -for (let config of invalidMixedVersionsToCheck) { - jsTest.log("Testing invalid mixed versions: " + tojson(config)); +for (let versions of mixedVersionsToCheck) { + jsTest.log("Testing mixed versions: " + tojson(versions)); + try { + // Set up a multi-version cluster + var st = new ShardingTest({ + shards: 2, + mongos: 2, + other: { + mongosOptions: {binVersion: versions.mongos}, + configOptions: {binVersion: versions.config}, + shardOptions: {binVersion: versions.shard}, + enableBalancer: true + } + }); + } catch (e) { + if (e instanceof Error) { + if (e.message.includes( + "Can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both.")) { + continue; + } + } + throw e; + } + if ((versions.shard[0] === "last-continuous" && versions.shard[1] === "last-lts") || + (versions.shard[1] === "last-continuous" && versions.shard[0] === "last-lts")) { + assert( + MongoRunner.areBinVersionsTheSame("last-continuous", "last-lts"), + "Should have thrown error in creating ShardingTest because can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both."); + } + var shards = [st.shard0, st.shard1]; + var mongoses = [st.s0, st.s1]; + var configs = [st.config0, st.config1, st.config2]; + + // Make sure we have hosts of all the different versions + var versionsFound = []; + for (var j = 0; j < shards.length; j++) + versionsFound.push(shards[j].getBinVersion()); - let err = assert.throws( - () => new ShardingTest({shouldFailInit: true, shards: config.shards, other: config.other})); - assert.eq( - true, - err.message.includes( - "Can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both."), - "Unexpected Error"); -} + assert.allBinVersions(versions.shard, versionsFound); -const validMixedVersionsToCheck = [ - { - shards: {rs0: {nodes: [{binVersion: "latest"}]}, rs1: {nodes: [{binVersion: "last-lts"}]}}, - other: {mongosOptions: {binVersion: "last-lts"}} - }, -]; + versionsFound = []; + for (var j = 0; j < mongoses.length; j++) + versionsFound.push(mongoses[j].getBinVersion()); -for (let config of validMixedVersionsToCheck) { - jsTest.log("Testing valid mixed versions: " + tojson(config)); - var st = new ShardingTest({shards: config.shards, other: config.other}); - var configs = [st.config0, st.config1, st.config2]; - checkEquivalent(config, st); + assert.allBinVersions(versions.mongos, versionsFound); + + versionsFound = []; + for (var j = 0; j < configs.length; j++) + versionsFound.push(configs[j].getBinVersion()); + + assert.allBinVersions(versions.config, versionsFound); st.stop(); } diff --git a/jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js b/jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js index 352a16e882c..0e4d2fde530 100644 --- a/jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js +++ b/jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js @@ -1,29 +1,19 @@ /* - * Tests that an arbiter will always be on the latest FCV regardless of the FCV of the replica set. + * Tests that an arbiter will default to the latest FCV regardless of the FCV of the replica set. */ (function() { "use strict"; function runTest(FCV) { - let rst = new ReplSetTest({nodes: [{}, {rsConfig: {arbiterOnly: true}}]}); + let rst = new ReplSetTest( + {nodes: [{}, {rsConfig: {arbiterOnly: true}}], nodeOpts: {binVersion: FCV}}); rst.startSet(); rst.initiate(); - const primary = rst.getPrimary(); - if (FCV != latestFCV) { - assert.commandWorked( - primary.getDB("admin").runCommand({setFeatureCompatibilityVersion: FCV})); - } - - const primaryFCV = assert.commandWorked( - primary.getDB("admin").runCommand({getParameter: 1, featureCompatibilityVersion: 1})); - assert.eq(primaryFCV.featureCompatibilityVersion.version, FCV, tojson(primaryFCV)); - - // The arbiter should always have an FCV matching kLatest. const arbiter = rst.getArbiter(); - const arbiterFCV = assert.commandWorked( + const res = assert.commandWorked( arbiter.getDB("admin").runCommand({getParameter: 1, featureCompatibilityVersion: 1})); - assert.eq(arbiterFCV.featureCompatibilityVersion.version, latestFCV, tojson(arbiterFCV)); + assert.eq(res.featureCompatibilityVersion.version, latestFCV, tojson(res)); rst.stopSet(); } diff --git a/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js b/jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js index 9b8f9978f11..e2c9ba0feab 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] */ (function() { diff --git a/jstests/multiVersion/genericSetFCVUsage/move_primary_setFCV.js b/jstests/multiVersion/genericSetFCVUsage/move_primary_setFCV.js deleted file mode 100644 index 34eea8fedb9..00000000000 --- a/jstests/multiVersion/genericSetFCVUsage/move_primary_setFCV.js +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Test that `movePrimary` works for databases created under a different FCV - */ -(function() { - -"use strict"; - -let st = new ShardingTest({shards: 2, mongos: 1, rs: {nodes: 1}}); - -const mongos = st.s; -const kBeforeDowngradingDbName = 'createdBeforeDowngrading'; -const kBeforeUpgradingDbName = 'createdBeforeUpgrading'; -const shard0 = st.shard0.shardName; -const shard1 = st.shard1.shardName; - -const createdBeforeDowngradingDB = mongos.getDB(kBeforeDowngradingDbName); -const createdBeforeUpgradingDB = mongos.getDB(kBeforeUpgradingDbName); -const fcvValues = [lastLTSFCV, lastContinuousFCV]; - -function testMovePrimary(db) { - const dbName = db.getName(); - // The following pipeline update modifies the config.databases entry to simulate its database - // version field order as having come from running {setFeatureCompatibility: "5.0"} as part of - // upgrading from MongoDB 4.4. See SERVER-68511 for more details of the original issue. - mongos.getDB('config').databases.update({_id: dbName}, [{ - $replaceWith: { - $mergeObjects: [ - "$$ROOT", - { - version: { - uuid: "$version.uuid", - lastMod: "$version.lastMod", - timestamp: "$version.timestamp" - } - } - ] - } - }]); - - const currentPrimary = mongos.getDB('config').databases.findOne({_id: dbName}).primary; - const newPrimary = currentPrimary == shard0 ? shard1 : shard0; - assert.eq(db.coll.countDocuments({}), 1); - assert.commandWorked(mongos.adminCommand({movePrimary: dbName, to: newPrimary})); - assert.eq(newPrimary, mongos.getDB('config').databases.findOne({_id: dbName}).primary); - assert.eq(db.coll.countDocuments({}), 1); -} - -for (var i = 0; i < fcvValues.length; i++) { - // Latest FCV - assert.commandWorked(mongos.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - - // Create database `createdBeforeDowngrading` under latest FCV - assert.commandWorked( - mongos.adminCommand({enableSharding: kBeforeDowngradingDbName, primaryShard: shard0})); - assert.commandWorked(createdBeforeDowngradingDB.coll.insert({_id: 'foo'})); - - // Downgrade FCV - assert.commandWorked(mongos.adminCommand({setFeatureCompatibilityVersion: fcvValues[i]})); - - // Make sure movePrimary works for `createdBeforeDowngrading` - testMovePrimary(createdBeforeDowngradingDB); - - // Create database `createdBeforeUpgrading` under downgraded FCV - assert.commandWorked(mongos.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - assert.commandWorked( - mongos.adminCommand({enableSharding: kBeforeUpgradingDbName, primaryShard: shard0})); - assert.commandWorked(createdBeforeUpgradingDB.coll.insert({_id: 'foo'})); - - // Upgrade FCV - assert.commandWorked(mongos.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - - // Make sure movePrimary works (again) for `createdBeforeDowngrading` - testMovePrimary(createdBeforeDowngradingDB); - - // Make sure movePrimary works for `createdBeforeUpgrading` - testMovePrimary(createdBeforeUpgradingDB); - - // Drop databases for next round - assert.commandWorked(createdBeforeDowngradingDB.dropDatabase()); - assert.commandWorked(createdBeforeUpgradingDB.dropDatabase()); -} - -st.stop(); -})(); diff --git a/jstests/multiVersion/genericSetFCVUsage/setfcv_aborts_reshard_collection.js b/jstests/multiVersion/genericSetFCVUsage/setfcv_reshard_collection.js index 82d7d62b8f7..7fa818f7f99 100644 --- a/jstests/multiVersion/genericSetFCVUsage/setfcv_aborts_reshard_collection.js +++ b/jstests/multiVersion/genericSetFCVUsage/setfcv_reshard_collection.js @@ -1,10 +1,6 @@ -/** - * Tests that setFeatureCompatibilityVersion command aborts an ongoing reshardCollection command - */ (function() { "use strict"; -load("jstests/libs/parallel_shell_helpers.js"); load("jstests/sharding/libs/resharding_test_fixture.js"); load('jstests/libs/discover_topology.js'); load('jstests/libs/fail_point_util.js'); @@ -25,8 +21,6 @@ function runTest(forcePooledConnectionsDropped) { ], }); - const sourceNamespace = inputCollection.getFullName(); - let mongos = inputCollection.getMongo(); for (let x = 0; x < 1000; x++) { @@ -43,17 +37,7 @@ function runTest(forcePooledConnectionsDropped) { pauseBeforeCloseCxns = configureFailPoint(config, "pauseBeforeCloseCxns"); } - function checkCoordinatorDoc() { - assert.soon(() => { - const coordinatorDoc = - mongos.getCollection("config.reshardingOperations").findOne({ns: sourceNamespace}); - - return coordinatorDoc === null || coordinatorDoc.state === "aborting"; - }); - } - const recipientShardNames = reshardingTest.recipientShardNames; - let awaitShell; reshardingTest.withReshardingInBackground( { newShardKeyPattern: {newKey: 1}, @@ -79,7 +63,7 @@ function runTest(forcePooledConnectionsDropped) { assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); }`; - awaitShell = startParallelShell(codeToRunInParallelShell, mongos.port); + let awaitShell = startParallelShell(codeToRunInParallelShell, mongos.port); if (forcePooledConnectionsDropped) { pauseBeforeCloseCxns.wait(); @@ -104,7 +88,8 @@ function runTest(forcePooledConnectionsDropped) { jsTestLog("Turn off pause before pauseBeforeMarkKeepOpen failpoint"); pauseBeforeMarkKeepOpen.off(); } - checkCoordinatorDoc(); + + awaitShell(); }, { expectedErrorCode: [ @@ -113,8 +98,6 @@ function runTest(forcePooledConnectionsDropped) { ] }); - awaitShell(); - reshardingTest.withReshardingInBackground( { newShardKeyPattern: {newKey: 1}, @@ -124,14 +107,7 @@ function runTest(forcePooledConnectionsDropped) { ], }, () => { - assert.soon(() => { - return mongos.getDB('config').reshardingOperations.findOne() != null; - }, "timed out waiting for coordinator doc to be written", 30 * 1000); - awaitShell = startParallelShell(funWithArgs(function(latestFCV) { - assert.commandWorked(db.adminCommand( - {setFeatureCompatibilityVersion: latestFCV})); - }, latestFCV), mongos.port); - checkCoordinatorDoc(); + assert.commandWorked(mongos.adminCommand({setFeatureCompatibilityVersion: latestFCV})); }, { expectedErrorCode: [ @@ -141,7 +117,6 @@ function runTest(forcePooledConnectionsDropped) { ] }); - awaitShell(); reshardingTest.teardown(); } diff --git a/jstests/multiVersion/targetedTestsLastContinuousFeatures/accumulator_fix_last_continuous.js b/jstests/multiVersion/targetedTestsLastContinuousFeatures/accumulator_fix_last_continuous.js index 8e7117dbab4..75699597ffa 100644 --- a/jstests/multiVersion/targetedTestsLastContinuousFeatures/accumulator_fix_last_continuous.js +++ b/jstests/multiVersion/targetedTestsLastContinuousFeatures/accumulator_fix_last_continuous.js @@ -83,14 +83,11 @@ load('jstests/multiVersion/libs/multi_cluster.js'); // For upgradeCluster() let hashShardedColl = shardCollectionByHashing(db.partial_sum); for (let i = 0; i < 10; ++i) { - // We set predetermined values for _id so that our data can be distributed across shards - // deterministically. - const idStart = i * 4; const docs = [ - {_id: idStart, k: i, n: 1e+34}, - {_id: idStart + 1, k: i, n: NumberDecimal("0.1")}, - {_id: idStart + 2, k: i, n: NumberDecimal("0.01")}, - {_id: idStart + 3, k: i, n: -1e+34} + {k: i, n: 1e+34}, + {k: i, n: NumberDecimal("0.1")}, + {k: i, n: NumberDecimal("0.01")}, + {k: i, n: -1e+34} ]; assert.commandWorked(hashShardedColl.insert(docs)); } diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/accumulator_fix_last_lts.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/accumulator_fix_last_lts.js index eaed4f64587..8fba11955aa 100644 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/accumulator_fix_last_lts.js +++ b/jstests/multiVersion/targetedTestsLastLtsFeatures/accumulator_fix_last_lts.js @@ -94,14 +94,11 @@ load('jstests/multiVersion/libs/multi_cluster.js'); // For upgradeCluster() let hashShardedColl = shardCollectionByHashing(db.partial_sum); for (let i = 0; i < 10; ++i) { - // We set predetermined values for _id so that our data can be distributed across shards - // deterministically. - const idStart = i * 4; const docs = [ - {_id: idStart, k: i, n: 1e+34}, - {_id: idStart + 1, k: i, n: NumberDecimal("0.1")}, - {_id: idStart + 2, k: i, n: NumberDecimal("0.01")}, - {_id: idStart + 3, k: i, n: -1e+34} + {k: i, n: 1e+34}, + {k: i, n: NumberDecimal("0.1")}, + {k: i, n: NumberDecimal("0.01")}, + {k: i, n: -1e+34} ]; assert.commandWorked(hashShardedColl.insert(docs)); } diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/change_streams_split_event_v1_v2_tokens.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/change_streams_split_event_v1_v2_tokens.js deleted file mode 100644 index 40040a8f82e..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/change_streams_split_event_v1_v2_tokens.js +++ /dev/null @@ -1,217 +0,0 @@ -/** - * Tests the compatibility of v1 and v2 resume tokens across server version upgrade / downgrade. - * @tags: [uses_change_streams] - */ - -load("jstests/multiVersion/libs/multi_cluster.js"); // For - // 'ShardingTest.[upgrade|downgrade]Cluster(). -load("jstests/libs/collection_drop_recreate.js"); // For 'assert[Drop|Create]Collection()'. - -const kLargeStringSize = 15 * 1024 * 1024; - -const st = new ShardingTest({ - shards: 2, - config: 1, - other: { - mongosOptions: {binVersion: "last-lts"}, - configOptions: { - binVersion: "last-lts", - }, - rsOptions: { - binVersion: "last-lts", - }, - rs: { - nodes: 2, - // Reserving enough of oplog space to accommodate 4 nearly 16MB-large changes. - oplogSize: 16 * 5 - } - } -}); - -let testDB = st.s.getDB(jsTestName()); -let testColl = testDB["test"]; - -// Helper function to retrieve high-watermark change stream tokens. -function getHighWaterMarkToken(collection, pipeline = [], options = {}) { - const csCursor = collection.watch(pipeline, Object.assign({batchSize: 0}, options)); - const result = csCursor.getResumeToken(); - csCursor.close(); - return result; -} - -// Record a high-watermark resume token marking the start point of the test. -const testStartV1HWMToken = getHighWaterMarkToken(testColl, []); - -// An array which will list the expected sequence of change events generated by the test. -const expectedEvents = []; - -// -// Below, we generate one of each type of change event so that we can later test resuming from a v1 -// token representing each such event. -// - -// Produces no events on v5.0. -testColl = assertCreateCollection(testDB, testColl.getName()); - -// Produces no events on v5.0. -assert.commandWorked(testColl.createIndexes([{shard: 1}, {shard: 1, _id: 1}, {largeField: 1}])); - -// Shard the test collection and split it into two chunks: one that contains all {shard: 1} -// documents and one that contains all {shard: 2} documents. -// Produces no events on v5.0. -st.shardColl(testColl, {shard: 1} /* shard key */, {shard: 2} /* split at */); - -assert.commandWorked(testColl.insertMany([ - {_id: "a", shard: 1, largeField: ""}, - {_id: "b", shard: 2, largeField: ""}, - {_id: "c", shard: 2, largeField: ""} -])); -expectedEvents.push({operationType: "insert", documentKey: {_id: "a"}}, - {operationType: "insert", documentKey: {_id: "b"}}, - {operationType: "insert", documentKey: {_id: "c"}}); - -// This high watermark token will be at the same clusterTime as the subsequent update event that -// needs to be split. -const v1HwmTokenBeforeUpdate = getHighWaterMarkToken(testColl); - -assert.commandWorked( - testColl.update({_id: "a", shard: 1}, {$set: {largeField: "x".repeat(kLargeStringSize)}})); -expectedEvents.push({operationType: "update", documentKey: {_id: "a", shard: 1}}); - -assert.commandWorked( - testColl.update({_id: "b", shard: 2}, {$set: {largeField: "x".repeat(kLargeStringSize)}})); -expectedEvents.push({operationType: "update", documentKey: {_id: "b", shard: 2}}); - -assert.commandWorked(testColl.replaceOne( - {_id: "a", shard: 1}, {_id: "a", shard: 1, largeField: "y".repeat(kLargeStringSize)})); -expectedEvents.push({operationType: "replace", documentKey: {_id: "a", shard: 1}}); - -assert.commandWorked(testColl.replaceOne( - {_id: "b", shard: 2}, {_id: "b", shard: 2, largeField: "y".repeat(kLargeStringSize)})); -expectedEvents.push({operationType: "replace", documentKey: {_id: "b", shard: 2}}); - -assert.commandWorked(testColl.remove({_id: "a"})); -expectedEvents.push({operationType: "delete", documentKey: {_id: "a", shard: 1}}); - -assert.commandWorked(testColl.remove({_id: "b"})); -expectedEvents.push({operationType: "delete", documentKey: {_id: "b", shard: 2}}); - -// Produces no events on v5.0. -assert.commandWorked( - st.s.adminCommand({refineCollectionShardKey: testColl.getFullName(), key: {shard: 1, _id: 1}})); - -// Produces no events on v5.0. -assert.commandWorked(st.s.adminCommand({reshardCollection: testColl.getFullName(), key: {_id: 1}})); - -// Produces no events on v5.0. -assert.commandWorked(testColl.dropIndex({largeField: 1})); - -const newTestCollectionName = "test_"; -assert.commandWorked(testColl.renameCollection(newTestCollectionName)); -expectedEvents.push({operationType: "rename"}, {operationType: "rename"}); - -assertDropCollection(testDB, newTestCollectionName); -expectedEvents.push({operationType: "drop"}, {operationType: "drop"}); - -assert.commandWorked(testDB.dropDatabase()); -// A whole-DB stream will be invalidated by the dropDatabase event. We include a second dropDatabase -// event because one such event is generated on each shard, and will be reported if we resume after -// the invalidate. This second dropDatabase acts as a sentinel here, signifying that we have reached -// the end of the test stream. -expectedEvents.push({operationType: "dropDatabase"}, - {operationType: "invalidate"}, - {operationType: "dropDatabase"}); - -// Leave only the last of the events with identical resume tokens, because the previous events will -// be skipped when resuming from such a token. -// TODO SERVER-90266: Remove this workaround when no longer needed. -{ - const csCursor = testDB.watch([], {startAfter: testStartV1HWMToken}); - - // The 'drop' and 'rename' events coming from different shards are likely to get identical - // resume tokens in v5.0. - for (let prevEvent = csCursor.next(), nextEvent; csCursor.hasNext(); prevEvent = nextEvent) { - nextEvent = csCursor.next(); - if (bsonWoCompare(nextEvent._id, prevEvent._id) === 0) { - // If two or more consecutive events have identical resume tokens, remove all but the - // last from the expected events. - expectedEvents.splice(expectedEvents.findIndex( - (event) => (event.operationType === prevEvent.operationType)), - 1); - } - } - - csCursor.close(); -} - -// Helper function to assert on the given event fields. -function assertEventMatches(event, expectedEvent, errorMsg) { - for (const k in expectedEvent) { - assert.docEq(expectedEvent[k], event[k], errorMsg + `: value mismatch for field '${k}'`); - } -} - -// Asserts the next change event with the given pipeline and options matches the expected event. -// Returns the resume token of the matched event on success. -function assertNextChangeEvent(expectedEvent, pipeline, options) { - const csCursor = testDB.watch([...pipeline], options); - const errorMsg = "could not retrieve the expected event matching " + tojson(expectedEvent); - let event; - assert.doesNotThrow(() => assert.soon(() => csCursor.hasNext()), [], errorMsg); - event = csCursor.next(); - assertEventMatches(event, expectedEvent, errorMsg); - csCursor.close(); - return event._id; -} - -// Helper function to retrieve change event tokens for all events referred by 'expectedEvents'. -function getTokensForExpectedEvents(expectedEvents, startToken, pipeline = [], options = {}) { - return expectedEvents - .reduce( - (result, expectedEvent) => { - const lastToken = result[result.length - 1]; - result.push(assertNextChangeEvent( - expectedEvent, pipeline, Object.assign({startAfter: lastToken}, options))); - return result; - }, - [startToken]) - .slice(1); -} - -// Generate v1 resume tokens for all expected events on 'last-lts'. -const resumeTokensLastLTS = getTokensForExpectedEvents(expectedEvents, testStartV1HWMToken, []); -// TODO SERVER-82330: Validate that these tokens are indeed all v1 tokens. - -// Upgrade the cluster to 'latest' to allow testing v1 - v2 resume behaviour. -st.upgradeCluster("latest", {waitUntilStable: true}); -assert.commandWorked(st.s.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - -testDB = st.s.getDB(jsTestName()); - -// Verify that we can resume from each of the v1 tokens on the new binary version and with the -// $changeStreamSplitLargeEvent stage in the pipeline. When resuming from (i-1)-th event's token we -// expect to get the i-th event. We do not need to test the last token, because it is simply a -// sentinel value that signifies the end of the test. -for (let i = 1; i < expectedEvents.length; ++i) { - assertNextChangeEvent(expectedEvents[i], - [{$changeStreamSplitLargeEvent: {}}], - {startAfter: resumeTokensLastLTS[i - 1]}); -} - -// Test that we can split the update events after 'v1HwmTokenBeforeUpdate'. -const expectedSplitEvents = [ - {operationType: "update", splitEvent: {fragment: 1, of: 2}}, - {splitEvent: {fragment: 2, of: 2}}, - {operationType: "update", splitEvent: {fragment: 1, of: 2}}, - {splitEvent: {fragment: 2, of: 2}}, - {operationType: "replace"} -]; -// Confirm that resuming after v1HwmTokenBeforeUpdate generates the expected series of split events. -// We artificially add a large field into the pipeline because we were unable to record pre-images -// on 5.0 and we cannot look up the current post-image because the collection has been dropped. -getTokensForExpectedEvents(expectedSplitEvents, v1HwmTokenBeforeUpdate, [ - {$addFields: {largeField2: "x".repeat(kLargeStringSize)}}, - {$changeStreamSplitLargeEvent: {}} -]); - -st.stop(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/fix_invalid_index_options.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/fix_invalid_index_options.js deleted file mode 100644 index a18683b2956..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/fix_invalid_index_options.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Tests that in 6.0 version collMod fixes 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); - -let secondaryDB = rst.getSecondary().getDB(dbName); - -// In earlier versions, users were able to add invalid index options when creating an index. -assert.commandWorked(primaryColl.createIndex({x: 1}, {sparse: "yes"})); - -// Upgrades from 4.4 to 5.0. -jsTestLog("Upgrading to version last-lts"); -rst.upgradeSet({binVersion: "last-lts"}); -assert.commandWorked(rst.getPrimary().adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - -// Upgrades from 5.0 to 6.0. -jsTestLog("Upgrading to version latest"); -rst.upgradeSet({binVersion: "latest"}); -const primary = rst.getPrimary(); -const secondary = rst.getSecondary(); -assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - -primaryDB = primary.getDB(dbName); -secondaryDB = secondary.getDB(dbName); - -// Verify that the primary and secondary in 6.0 detect invalid index options. -let validateRes = assert.commandWorked(primaryDB.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 1, "validate should warn: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 1, "validate should warn: " + tojson(validateRes)); - -// Use collMod to fix the invalid index options in the collection. -assert.commandWorked(primaryDB.runCommand({collMod: collName})); - -// Fix invalid field from index spec. -checkLog.containsJson(primary, 6444400, {fieldName: "sparse"}); -checkLog.containsJson(secondary, 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)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 0, "validate should not warn: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 0, "validate should not warn: " + tojson(validateRes)); - -rst.stopSet(); -})(); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/fle2_downgrade.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/fle2_downgrade.js index e0c21a49a85..670d8afa572 100644 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/fle2_downgrade.js +++ b/jstests/multiVersion/targetedTestsLastLtsFeatures/fle2_downgrade.js @@ -35,9 +35,9 @@ function runTest(targetFCV) { let res = assert.commandFailedWithCode( db.adminCommand({setFeatureCompatibilityVersion: targetFCV}), ErrorCodes.CannotDowngrade); - assert(client.getDB().enxcol_.basic.ecoc.drop()); - assert(client.getDB().enxcol_.basic.ecc.drop()); - assert(client.getDB().enxcol_.basic.esc.drop()); + assert(client.getDB().fle2.basic.ecoc.drop()); + assert(client.getDB().fle2.basic.ecc.drop()); + assert(client.getDB().fle2.basic.esc.drop()); assert(client.getDB().basic.drop()); assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: targetFCV})); diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/invalid_index_options.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/invalid_index_options.js index c4c23061617..7905f32ccc8 100644 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/invalid_index_options.js +++ b/jstests/multiVersion/targetedTestsLastLtsFeatures/invalid_index_options.js @@ -52,51 +52,5 @@ 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 succeed: " + tojson(validateRes)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 1, "validate should warn: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB1.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 1, "validate should warn: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB2.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 0, "validate should not warn: " + 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)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 0, "validate should not warn: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB1.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 0, "validate should not warn: " + tojson(validateRes)); - -validateRes = assert.commandWorked(secondaryDB2.runCommand({validate: collName})); -assert(validateRes.valid, "validate should succeed: " + tojson(validateRes)); -assert.eq(validateRes.errors.length, 0, "validate should not error: " + tojson(validateRes)); -assert.eq(validateRes.warnings.length, 0, "validate should not warn: " + 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 bc2346aee45..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/partial_indexes_downgrade.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Tests that we cannot downgrade FCV when we have partial indexes with $or/$in/$geoWithin. - */ - -(function() { -'use strict'; - -const dbpath = MongoRunner.dataPath + 'partial_indexes_downgrade'; -resetDbpath(dbpath); - -// Start with 6.0, create a partial index with an $or, then make sure we fail to downgrade FCV -// to 5.0. Drop the index, then actually downgrade to 5.0. -{ - const conn = MongoRunner.runMongod({dbpath: dbpath, binVersion: 'latest', noCleanData: true}); - - const db = conn.getDB('test'); - const coll = db['partial_indexes_downgrade']; - assert.commandWorked(coll.createIndex( - {a: 1, b: 1}, {partialFilterExpression: {$or: [{a: {$lt: 20}}, {b: {$lt: 10}}]}})); - - coll.insert({a: 1, b: 1}); - coll.insert({a: 30, b: 20}); - - assert.commandFailedWithCode(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - ErrorCodes.CannotDowngrade); - coll.dropIndexes(); - assert.commandWorked(db.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - - MongoRunner.stopMongod(conn); -} - -// Startup with 5.0 binary, with FCV set to 5.0. -{ - const conn = MongoRunner.runMongod({dbpath: dbpath, binVersion: lastLTSFCV, noCleanData: true}); - - const db = conn.getDB('test'); - const coll = db['partial_indexes_downgrade']; - // Make sure we are on the same db path as before. - assert.eq(coll.aggregate().toArray().length, 2); - - MongoRunner.stopMongod(conn); -} -})();
\ No newline at end of file diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/query_stats_upgrade_downgrade.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/query_stats_upgrade_downgrade.js deleted file mode 100644 index 20ff7add9cd..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/query_stats_upgrade_downgrade.js +++ /dev/null @@ -1,272 +0,0 @@ -/** - * Verifies that $queryStats operates correctly when upgrading and downgrading. - */ - -load("jstests/multiVersion/libs/multi_rs.js"); -load("jstests/multiVersion/libs/multi_cluster.js"); -load("jstests/libs/collection_drop_recreate.js"); -load("jstests/libs/query_stats_utils.js"); - -(function() { -"use strict"; - -const lastLTSVersion = "last-lts"; - -class UpgradeDowngradeTestFixture { - constructor() { - this.collectionName = "coll"; - } - - getTestDB() { - return this.rst.getPrimary().getDB(jsTestName()); - } - - createAndPopulateTestCollection() { - let testDB = this.getTestDB(); - let coll = assertDropAndRecreateCollection(testDB, "coll"); - assert.commandWorked(coll.insertMany([{x: 0}, {x: 1}, {x: 2}])); - } - - setup() { - jsTestLog("Starting ReplicaSet Upgrade/Downgrade Test!"); - - this.rst = new ReplSetTest({ - name: jsTestName(), - nodes: [{binVersion: lastLTSVersion}, {binVersion: lastLTSVersion}] - }); - this.rst.startSet(); - this.rst.initiate(); - this.createAndPopulateTestCollection(); - } - - teardown() { - jsTestLog("Teardown ReplicaSet Upgrade/Downgrade Test!"); - - this.rst.stopSet(); - } - - getTestCollection() { - return this.getTestDB().getCollection(this.collectionName); - } - - adminCommand(command) { - return this.rst.getPrimary().getDB("admin").runCommand(command); - } - - upgradeBinaries() { - this.rst.upgradeSet({binVersion: "latest"}); - } - - upgradeFCV() { - assert.commandWorked(this.adminCommand({setFeatureCompatibilityVersion: latestFCV})); - } - - downgradeFCV() { - // Downgrade FCV (without restarting) and check that $queryStats returns an error. - assert.commandWorked(this.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - } - - testQueryStatsParam(expectedResult) { - if (expectedResult === true) { - assert.commandWorked( - this.adminCommand({setParameter: 1, internalQueryStatsRateLimit: -1})); - } else { - // Check that $queryStats related parameter does not work. - assert.commandFailed( - this.adminCommand({setParameter: 1, internalQueryStatsRateLimit: -1})); - } - } - - testQueryStatsCommandFailure() { - assert.commandFailedWithCode( - this.adminCommand({aggregate: 1, pipeline: [{$queryStats: {}}], cursor: {}}), - [ErrorCodes.QueryFeatureNotAllowed, 40324]); - } - - isShardedCluster() { - return false; - } - - verifyQueryStatsOutput({expectedNShapes}) { - const queryStats = getQueryStats(this, {collName: this.collectionName}); - assert.eq(expectedNShapes, queryStats.length, queryStats); - verifyMetrics(queryStats); - } -} - -class ShardedClusterUpgradeDowngradeTestFixture extends UpgradeDowngradeTestFixture { - setup() { - jsTestLog("Starting Sharded Upgrade/Downgrade Test!"); - this.shardedTest = new ShardingTest({ - name: jsTestName(), - shards: 1, - mongos: 1, - config: 1, - rs: {nodes: [{binVersion: lastLTSVersion}, {binVersion: lastLTSVersion}]}, - mongosOptions: {binVersion: lastLTSVersion}, - }); - this.createAndPopulateTestCollection(); - } - - isShardedCluster() { - return true; - } - - adminCommand(command) { - return this.shardedTest.s.adminCommand(command); - } - - getTestDB() { - return this.shardedTest.s.getDB(jsTestName()); - } - - upgradeBinaries() { - this.shardedTest.upgradeCluster('latest'); - } - - teardown() { - jsTestLog("Teardown ReplicaSet Upgrade/Downgrade Test!"); - this.shardedTest.stop(); - } -} - -function runTest(fixture) { - // 0. Initialize the fixture, we begin with a binary version that doesn't support queryStats. - fixture.setup(); - - // 1. Test that queryStats related features don't work in the base binary. - // 1.a. Verify queryStats is disabled by checking that setting queryStats related parameters and - // running the $queryStats stage both fail. - fixture.testQueryStatsParam(false); - fixture.testQueryStatsCommandFailure(); - - // 1.b. Run some queries while running base binary. We don't expect these queries to be - // collected by queryStats. - { - let coll = fixture.getTestCollection(); - let res = coll.aggregate([{$match: {x: 2}}]).toArray(); - assert.eq(1, res.length, res); - - res = coll.find({x: 2}).toArray(); - assert.eq(1, res.length, res); - } - - // 2. Upgrade both the binaries and FCV. After the upgrade we expect query stats features - // to work. Further, we verify that the previously executed queries were not collected by - // checking the results from the $queryStats stage. - fixture.upgradeBinaries(); - fixture.upgradeFCV(); - - // 2.a. Verify that queryStats parameters can be set after the upgrade, and that previously - // executed queries were not collected. - fixture.testQueryStatsParam(true); - fixture.verifyQueryStatsOutput({expectedNShapes: 0}); - - // 2.b. Execute two new queries (i.e new query shapes) and check that they are collected. - { - let coll = fixture.getTestCollection(); - let res = coll.aggregate([{$match: {x: 2}}, {$sort: {x: -1}}]).toArray(); - assert.eq(1, res.length, res); - - res = coll.find({x: 2}, {noCursorTimeout: true}).toArray(); - assert.eq(1, res.length, res); - - fixture.verifyQueryStatsOutput({ - expectedNShapes: 2 /* 1 each for the above. $queryStats is not included because we - filter on the collection name. */ - }); - } - - // 3. Downgrade FCV (without restarting). Without restarting the server, we expect the - // queryStatsStore to keep existing entries, but to not collect any more statistics while an FCV - // that doesn't support queryStats is in place. - fixture.downgradeFCV(); - - // 3.a. Run additional queries (new query shapes) after the downgrade. - { - let coll = fixture.getTestCollection(); - let res = coll.aggregate([{$match: {x: 2}}]).toArray(); - assert.eq(1, res.length, res); - - res = coll.find({x: 2}).toArray(); - assert.eq(1, res.length, res); - } - - // 3.b. If we are testing a sharded cluster, we don't expect queryStats to be disabled after the - // FCV downgrade. This is because in a sharded cluster, query stats resides on mongos, and - // mongos doesn't have a concept of its own in memory FCV settings. When a sharded cluster has - // its FCV downgraded, it forwards the downgrade request to the shards and the config - // servers. However, the router itself bases its FCV on its binaries. In our case, once we - // upgrade the binary on the mongos, we can no longer downgrade the FCV to "disable" queryStats. - // As a result, in the sharded scenario we expect the two queries run after the downgrade to - // have been collected by query stats. - if (fixture.isShardedCluster()) { - fixture.verifyQueryStatsOutput({ - expectedNShapes: 4 /* 2 from the previous queries + the two additional ones captured - after the downgrade. */ - }); - fixture.teardown(); - return; - } - - // 3.c. After the FCV downgrade (i.e FCV v5.0), running $queryStats should return an error. - fixture.testQueryStatsCommandFailure(); - - // 3.d. Upgrade the FCV without restart. QueryStatsStore should not have been cleared. Previous - // stats collected should be returned. The queries made during the downgrade should not - // have been collected. Note that getQueryStats() uses the same query to collect the statistics, - // so running $queryStats doesn't result in additional entries. - fixture.upgradeFCV(); - fixture.verifyQueryStatsOutput({expectedNShapes: 2}); - - // 4. Test query stats during a failed FCV downgrade. During the failed FCV downgrade, the FCV - // reverts back to the lastLTSFCV which doesn't support queryStats. - jsTestLog("Turning the failpoint on."); - assert.commandWorked( - fixture.adminCommand({configureFailPoint: 'failDowngrading', mode: "alwaysOn"})); - - assert.commandFailedWithCode(fixture.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}), - 549181); - - // 4.a. Current FCV is lower than the FCV necessary (7.2) for queryStats to run. These queries - // should not be collected. - { - let coll = fixture.getTestCollection(); - let res = coll.aggregate([{$match: {x: 2}}]).toArray(); - assert.eq(1, res.length, res); - - res = coll.find({x: 2}).toArray(); - assert.eq(1, res.length, res); - } - // 4.b. Running $queryStats should return an error. - fixture.testQueryStatsCommandFailure(ErrorCodes.QueryFeatureNotAllowed); - - // 4.c. Complete the downgrade, then successfully upgrade FCV. Check that the queries run during - // the failed downgrade were not collected. - assert.commandWorked( - fixture.adminCommand({configureFailPoint: 'failDowngrading', mode: "off"})); - assert.commandWorked(fixture.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV})); - - fixture.upgradeFCV(); - fixture.verifyQueryStatsOutput({expectedNShapes: 2}); - - // 4.d. Execute two new queries (new query shapes), these should result in new entries. - { - let coll = fixture.getTestCollection(); - let res = coll.aggregate([{$match: {x: 2}}], {allowDiskUse: false}).toArray(); - assert.eq(1, res.length, res); - - res = coll.find({x: 2}, {allowPartialResults: true}).toArray(); - assert.eq(1, res.length, res); - - fixture.verifyQueryStatsOutput({expectedNShapes: 4}); - } - - fixture.teardown(); -} - -// Perform Upgrade/Downgrade test on replica set. -runTest(new UpgradeDowngradeTestFixture()); -// Perform Upgrade/Downgrade test on sharded cluster. -runTest(new ShardedClusterUpgradeDowngradeTestFixture()); -})();
\ No newline at end of file diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/sharded_timeseries_collmod_mixed_version.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/sharded_timeseries_collmod_mixed_version.js index ae9b843e445..12c0f4bf6ef 100644 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/sharded_timeseries_collmod_mixed_version.js +++ b/jstests/multiVersion/targetedTestsLastLtsFeatures/sharded_timeseries_collmod_mixed_version.js @@ -32,12 +32,11 @@ assert.commandWorked(mongos.adminCommand({ assert.commandWorked(mongos.adminCommand({setFeatureCompatibilityVersion: '5.0'})); const oldDb = st.s1.getDB(dbName); - -assert.commandWorked(db[collName].createIndex({[timeField]: 1})); // Assert that collMod works with matching versions of mongos and mongod. -assert.commandWorked(db.runCommand({collMod: collName, index: {name: 'tm_1', hidden: true}})); +assert.commandWorked(db.runCommand({collMod: collName, index: {name: indexName, hidden: true}})); // Assert that collMod still works with old version of mongos. -assert.commandWorked(oldDb.runCommand({collMod: collName, index: {name: 'tm_1', hidden: false}})); +assert.commandWorked( + oldDb.runCommand({collMod: collName, index: {name: indexName, hidden: false}})); // Assert that collMod with granularity update fails with matching versions of mongos and mongod. assert.commandFailedWithCode(db.runCommand({collMod: collName, timeseries: {granularity: 'hours'}}), diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/timeseries_collection_mixed_schema_index_build_stepdown.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/timeseries_collection_mixed_schema_index_build_stepdown.js index b66de0c43f0..7575c514c20 100644 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/timeseries_collection_mixed_schema_index_build_stepdown.js +++ b/jstests/multiVersion/targetedTestsLastLtsFeatures/timeseries_collection_mixed_schema_index_build_stepdown.js @@ -13,9 +13,7 @@ load("jstests/libs/fail_point_util.js"); load("jstests/multiVersion/libs/multi_rs.js"); load('jstests/noPassthrough/libs/index_build.js'); -// Since v5.0 no longer supports writing mixed schema buckets as of 5.0.29, pin the version -// to 5.0.28 to retain coverage as v5.0 still supports the presence of mixed schema data. -const oldVersion = "5.0.28"; +const oldVersion = "last-lts"; const nodes = { n1: {binVersion: oldVersion}, n2: {binVersion: oldVersion} diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/upgrade_downgrade_timeseries_collection_from_last_lts.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/upgrade_downgrade_timeseries_collection_from_last_lts.js index d2fc1d83f3c..e714a38d698 100644 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/upgrade_downgrade_timeseries_collection_from_last_lts.js +++ b/jstests/multiVersion/targetedTestsLastLtsFeatures/upgrade_downgrade_timeseries_collection_from_last_lts.js @@ -13,9 +13,7 @@ load("jstests/core/timeseries/libs/timeseries.js"); load("jstests/multiVersion/libs/multi_rs.js"); -// Since v5.0 no longer supports writing mixed schema buckets as of 5.0.29, pin the version -// to 5.0.28 to retain coverage as v5.0 still supports the presence of mixed schema data. -const oldVersion = "5.0.28"; +const oldVersion = "last-lts"; const nodes = { n1: {binVersion: oldVersion}, n2: {binVersion: oldVersion} |
