diff options
Diffstat (limited to 'jstests/multiVersion/targetedTestsLastLtsFeatures')
10 files changed, 12 insertions, 676 deletions
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} |
