Files
mongo/jstests/multiVersion/genericSetFCVUsage/2_test_launching_cluster.js
Steve McClure 1ffbc6c2e9 SERVER-109432: Autofix JS var usage to favor let (#40637)
GitOrigin-RevId: 9674b7db36a0f3f650d39c1e3fb2ad6ff2141cfb
2025-08-28 19:21:01 +00:00

63 lines
2.1 KiB
JavaScript

import "jstests/multiVersion/libs/verify_versions.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
function checkEquivalent(testConfig, st) {
let expectedVersions = [testConfig.other.mongosOptions.binVersion];
let expectedNodes = [...testConfig.shards.rs0.nodes, ...testConfig.shards.rs1.nodes];
for (j = 0; j < expectedNodes.length; j++) {
expectedVersions.push(expectedNodes[j].binVersion);
}
let versionsFound = [st.s0.getBinVersion()];
let 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'");
quit();
}
const invalidMixedVersionsToCheck = [
{
shards: {
rs0: {nodes: [{binVersion: "last-continuous"}, {binVersion: "last-lts"}]},
rs1: {nodes: [{binVersion: "last-lts"}]},
},
other: {mongosOptions: {binVersion: "last-lts"}},
},
];
for (let config of invalidMixedVersionsToCheck) {
jsTest.log("Testing invalid mixed versions: " + tojson(config));
let err = assert.throws(() => new ShardingTest({shouldFailInit: true, shards: config.shards, other: config.other}));
assert.eq(
true,
formatErrorMsg(err.message, err.extraAttr).includes(
"Can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both.",
),
"Unexpected Error",
);
}
const validMixedVersionsToCheck = [
{
shards: {rs0: {nodes: [{binVersion: "latest"}]}, rs1: {nodes: [{binVersion: "last-lts"}]}},
other: {mongosOptions: {binVersion: "last-lts"}},
},
];
for (let config of validMixedVersionsToCheck) {
jsTest.log("Testing valid mixed versions: " + tojson(config));
let st = new ShardingTest({shards: config.shards, other: config.other});
let configs = [st.config0, st.config1, st.config2];
checkEquivalent(config, st);
st.stop();
}