summaryrefslogtreecommitdiff
path: root/jstests/multiVersion/genericSetFCVUsage
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /jstests/multiVersion/genericSetFCVUsage
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (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/genericSetFCVUsage')
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/1_test_launching_replset.js55
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/2_test_launching_cluster.js103
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js20
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/major_version_upgrade.js2
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/move_primary_setFCV.js84
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/setfcv_reshard_collection.js (renamed from jstests/multiVersion/genericSetFCVUsage/setfcv_aborts_reshard_collection.js)33
6 files changed, 94 insertions, 203 deletions
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();
}