summaryrefslogtreecommitdiff
path: root/jstests/multiVersion/genericBinVersion
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/multiVersion/genericBinVersion')
-rw-r--r--jstests/multiVersion/genericBinVersion/query_stats_key_hash_version_consistency.js56
-rw-r--r--jstests/multiVersion/genericBinVersion/remove_invalid_index_options.js13
-rw-r--r--jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js4
3 files changed, 70 insertions, 3 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
new file mode 100644
index 00000000000..1e61d5280fc
--- /dev/null
+++ b/jstests/multiVersion/genericBinVersion/query_stats_key_hash_version_consistency.js
@@ -0,0 +1,56 @@
+/**
+ * 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 c49422423c4..b9a9405c182 100644
--- a/jstests/multiVersion/genericBinVersion/remove_invalid_index_options.js
+++ b/jstests/multiVersion/genericBinVersion/remove_invalid_index_options.js
@@ -44,10 +44,15 @@ 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(validateRes.valid);
+assert.eq(validateRes.errors.length, 0);
+assert.eq(validateRes.warnings.length, 2);
validateRes = assert.commandWorked(secondaryDB.runCommand({validate: collName}));
-assert(!validateRes.valid);
+// TODO (SERVER-87985): Enable assertions.
+// assert(validateRes.valid);
+// assert.eq(validateRes.errors.length, 0);
+// assert.eq(validateRes.warnings.length, 2);
// Use collMod to remove the invalid index options in the collection.
assert.commandWorked(primaryDB.runCommand({collMod: collName}));
@@ -64,9 +69,13 @@ 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 4e94668a46f..85943e6c9d1 100644
--- a/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js
+++ b/jstests/multiVersion/genericBinVersion/timeseries_collection_mixed_type.js
@@ -17,7 +17,9 @@ const timeFieldName = "time";
* one bucket was created.
*/
function runTest(docs, query, results, path, bounds) {
- const oldVersion = "last-lts";
+ // 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 nodes = {
n1: {binVersion: oldVersion},
n2: {binVersion: oldVersion},