Files
mongo/jstests/multiVersion/targetedTestsLastLtsFeatures/auto_bootstrap_upgrade_behavior.js
Moustafa Maher 2fd5f78d5a SERVER-95421 make initiateWithHighElectionTimeout the default in ReplSetTest (#28174)
GitOrigin-RevId: df168ee363c3f0e86526270437d3688ac4bb326d
2024-10-22 02:53:25 +00:00

55 lines
1.7 KiB
JavaScript

import "jstests/multiVersion/libs/multi_rs.js";
import {ReplSetTest} from "jstests/libs/replsettest.js";
function fetchShardIdentityDoc(conn) {
return conn.getDB('admin').system.version.findOne({_id: 'shardIdentity'});
}
(function() {
jsTest.log("Test auto-bootstrap doesn't happen for standalone in old fcv");
let oldStandalone = MongoRunner.runMongod({binVersion: 'last-lts'});
MongoRunner.stopMongod(oldStandalone, null, {noCleanData: true});
let newStandalone = MongoRunner.runMongod({
noCleanData: true,
dbpath: oldStandalone.dbpath,
port: oldStandalone.port,
setParameter: {featureFlagAllMongodsAreSharded: true}
});
assert.soon(() => {
return newStandalone.getDB('admin').hello().isWritablePrimary;
});
assert.eq(null, fetchShardIdentityDoc(newStandalone));
MongoRunner.stopMongod(newStandalone, null);
})();
(function() {
jsTest.log("Test auto-bootstrap doesn't happen for replSet in old fcv");
let nodeOption = {binVersion: 'last-lts'};
// Need at least 2 nodes because upgradeSet method needs to be able call step down
// with another primary eligible node available.
let replSet = new ReplSetTest({nodes: [nodeOption, nodeOption]});
replSet.startSet();
replSet.initiate(null, null, {initiateWithDefaultElectionTimeout: true});
replSet.upgradeSet({binVersion: 'latest', setParameter: {featureFlagAllMongodsAreSharded: true}});
let primary = replSet.getPrimary();
assert.eq(null, fetchShardIdentityDoc(primary));
assert.commandWorked(
primary.adminCommand({transitionToShardedCluster: 1, writeConcern: {w: 'majority'}}));
assert.neq(null, fetchShardIdentityDoc(primary));
assert.neq(null, primary.getDB('config').shards.findOne());
replSet.stopSet();
})();