Files
mongo/jstests/multiVersion/libs/mixed_version_sharded_fixture_test.js
ppolato 45223429bc SERVER-97818 Clean up remaining usages of the ShardingTest.shardOptions setup field (#30055)
GitOrigin-RevId: 98cff3f8b65917e5c0e9ae34d91f0023095e8cdc
2024-12-09 19:49:19 +00:00

72 lines
2.0 KiB
JavaScript

import "jstests/multiVersion/libs/multi_cluster.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
export function testPerformUpgradeDowngradeSharded({
setupFn,
whenFullyDowngraded,
whenOnlyConfigIsLatestBinary,
whenSecondariesAndConfigAreLatestBinary,
whenFullyUpgraded,
whenBinariesAreLatestAndFCVIsLastLTS,
whenMongosBinaryIsLastLTS
}) {
const st = new ShardingTest({
shards: 2,
rs: {nodes: 2},
mongos: 1,
config: 1,
other: {
mongosOptions: {binVersion: "last-lts"},
configOptions: {binVersion: "last-lts"},
rsOptions: {binVersion: "last-lts"}
},
});
st.configRS.awaitReplication();
setupFn(st.s, st);
whenFullyDowngraded(st.s);
const justWaitForStable =
{upgradeShards: false, upgradeMongos: false, upgradeConfigs: false, waitUntilStable: true};
// Upgrade the configs.
st.upgradeCluster('latest', {...justWaitForStable, upgradeConfigs: true});
whenOnlyConfigIsLatestBinary(st.s);
// Upgrade the secondary shard.
st.upgradeCluster('latest', {...justWaitForStable, upgradeOneShard: st.rs1});
whenSecondariesAndConfigAreLatestBinary(st.s);
// Upgrade the rest of the cluster.
st.upgradeCluster('latest', {...justWaitForStable, upgradeShards: true});
whenMongosBinaryIsLastLTS(st.s);
// Upgrade mongos.
st.upgradeCluster('latest', {...justWaitForStable, upgradeMongos: true});
whenBinariesAreLatestAndFCVIsLastLTS(st.s);
// Upgrade the FCV.
assert.commandWorked(st.s.getDB(jsTestName()).adminCommand({
setFeatureCompatibilityVersion: latestFCV,
confirm: true
}));
whenFullyUpgraded(st.s);
// Downgrade the FCV without restarting.
assert.commandWorked(st.s.getDB(jsTestName()).adminCommand({
setFeatureCompatibilityVersion: lastLTSFCV,
confirm: true
}));
whenBinariesAreLatestAndFCVIsLastLTS(st.s);
st.stop();
}