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

31 lines
1.1 KiB
JavaScript

/**
* Tests that if chaining is disabled, electing a new primary will cause nodes to start syncing from
* the new primary.
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
const replSet = new ReplSetTest({
nodes: 3,
settings: {chainingAllowed: false},
// We will turn on the noop writer after newPrimary is elected to ensure that newPrimary will
// eventually be an eligible sync source for the secondary. We don't turn it on at the start of
// the test because the noop writer could cause newPrimary to lose the election.
nodeOptions: {setParameter: {writePeriodicNoops: false, periodicNoopIntervalSecs: 1}}
});
replSet.startSet();
replSet.initiate();
const oldPrimary = replSet.getPrimary();
const [newPrimary, secondary] = replSet.getSecondaries();
replSet.awaitSyncSource(secondary, oldPrimary);
replSet.stepUp(newPrimary);
// Enable periodic noops so that the secondary can sync from newPrimary.
assert.commandWorked(newPrimary.adminCommand({setParameter: 1, writePeriodicNoops: true}));
replSet.awaitSyncSource(secondary, newPrimary);
replSet.stopSet();