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

38 lines
1.1 KiB
JavaScript

import {ReplSetTest} from "jstests/libs/replsettest.js";
let doTest = function(signal) {
// Test orphaned primary steps down
var replTest = new ReplSetTest({name: 'testSet', nodes: 3});
replTest.startSet();
replTest.initiate(null, null, {initiateWithDefaultElectionTimeout: true});
var primary = replTest.getPrimary();
// Kill both secondaries, simulating a network partition
var secondaries = replTest.getSecondaries();
for (var i = 0; i < secondaries.length; i++) {
var secondary_id = replTest.getNodeId(secondaries[i]);
replTest.stop(secondary_id);
}
print("replset4.js 1");
assert.soon(function() {
try {
var result = primary.getDB("admin").runCommand({hello: 1});
return (result['ok'] == 1 && result['isWritablePrimary'] == false);
} catch (e) {
print("replset4.js caught " + e);
return false;
}
}, "Primary fails to step down when orphaned.");
print("replset4.js worked, stopping");
replTest.stopSet(signal);
};
print("replset4.js");
doTest(15);
print("replset4.js SUCCESS");