2020-08-04 14:26:49 -04:00
|
|
|
import "jstests/multiVersion/libs/verify_versions.js";
|
|
|
|
|
|
2024-08-20 17:54:15 -04:00
|
|
|
import {ShardingTest} from "jstests/libs/shardingtest.js";
|
|
|
|
|
|
2023-03-28 19:39:01 +00:00
|
|
|
function checkEquivalent(testConfig, st) {
|
2025-08-28 15:11:44 -04:00
|
|
|
let expectedVersions = [testConfig.other.mongosOptions.binVersion];
|
|
|
|
|
let expectedNodes = [...testConfig.shards.rs0.nodes, ...testConfig.shards.rs1.nodes];
|
2023-03-28 19:39:01 +00:00
|
|
|
for (j = 0; j < expectedNodes.length; j++) {
|
|
|
|
|
expectedVersions.push(expectedNodes[j].binVersion);
|
2021-10-09 00:46:36 +00:00
|
|
|
}
|
2023-03-28 19:39:01 +00:00
|
|
|
|
2025-08-28 15:11:44 -04:00
|
|
|
let versionsFound = [st.s0.getBinVersion()];
|
|
|
|
|
let nodes = [...st._rs[0].test.nodes, ...st._rs[1].test.nodes];
|
2023-03-28 19:39:01 +00:00
|
|
|
for (var j = 0; j < nodes.length; j++) {
|
|
|
|
|
versionsFound.push(nodes[j].getBinVersion());
|
2021-10-09 00:46:36 +00:00
|
|
|
}
|
2023-03-28 19:39:01 +00:00
|
|
|
assert.allBinVersions(expectedVersions, versionsFound);
|
|
|
|
|
}
|
2020-08-04 14:26:49 -04:00
|
|
|
|
2023-03-28 19:39:01 +00:00
|
|
|
if (MongoRunner.areBinVersionsTheSame("last-continuous", "last-lts")) {
|
|
|
|
|
jsTest.log("Skipping test because 'last-continuous' == 'last-lts'");
|
|
|
|
|
quit();
|
|
|
|
|
}
|
2020-08-04 14:26:49 -04:00
|
|
|
|
2023-03-28 19:39:01 +00:00
|
|
|
const invalidMixedVersionsToCheck = [
|
|
|
|
|
{
|
|
|
|
|
shards: {
|
|
|
|
|
rs0: {nodes: [{binVersion: "last-continuous"}, {binVersion: "last-lts"}]},
|
2025-08-21 10:17:44 -07:00
|
|
|
rs1: {nodes: [{binVersion: "last-lts"}]},
|
2023-03-28 19:39:01 +00:00
|
|
|
},
|
2025-08-21 10:17:44 -07:00
|
|
|
other: {mongosOptions: {binVersion: "last-lts"}},
|
2023-03-28 19:39:01 +00:00
|
|
|
},
|
|
|
|
|
];
|
2020-08-04 14:26:49 -04:00
|
|
|
|
2023-03-28 19:39:01 +00:00
|
|
|
for (let config of invalidMixedVersionsToCheck) {
|
|
|
|
|
jsTest.log("Testing invalid mixed versions: " + tojson(config));
|
2020-08-04 14:26:49 -04:00
|
|
|
|
2025-08-21 10:17:44 -07:00
|
|
|
let err = assert.throws(() => new ShardingTest({shouldFailInit: true, shards: config.shards, other: config.other}));
|
2023-03-28 19:39:01 +00:00
|
|
|
assert.eq(
|
|
|
|
|
true,
|
2025-08-21 10:17:44 -07:00
|
|
|
formatErrorMsg(err.message, err.extraAttr).includes(
|
|
|
|
|
"Can only specify one of 'last-lts' and 'last-continuous' in binVersion, not both.",
|
|
|
|
|
),
|
|
|
|
|
"Unexpected Error",
|
|
|
|
|
);
|
2023-03-28 19:39:01 +00:00
|
|
|
}
|
2020-08-04 14:26:49 -04:00
|
|
|
|
2023-03-28 19:39:01 +00:00
|
|
|
const validMixedVersionsToCheck = [
|
|
|
|
|
{
|
|
|
|
|
shards: {rs0: {nodes: [{binVersion: "latest"}]}, rs1: {nodes: [{binVersion: "last-lts"}]}},
|
2025-08-21 10:17:44 -07:00
|
|
|
other: {mongosOptions: {binVersion: "last-lts"}},
|
2023-03-28 19:39:01 +00:00
|
|
|
},
|
|
|
|
|
];
|
2020-08-04 14:26:49 -04:00
|
|
|
|
2023-03-28 19:39:01 +00:00
|
|
|
for (let config of validMixedVersionsToCheck) {
|
|
|
|
|
jsTest.log("Testing valid mixed versions: " + tojson(config));
|
2025-08-28 15:11:44 -04:00
|
|
|
let st = new ShardingTest({shards: config.shards, other: config.other});
|
|
|
|
|
let configs = [st.config0, st.config1, st.config2];
|
2023-03-28 19:39:01 +00:00
|
|
|
checkEquivalent(config, st);
|
2020-08-04 14:26:49 -04:00
|
|
|
|
|
|
|
|
st.stop();
|
|
|
|
|
}
|