Files
mongo/jstests/replsets/isself_failure_restart.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

39 lines
1.2 KiB
JavaScript

/**
* Tests that a replica retries on each heartbeat if isSelf fails due to temporary DNS outage during
* startup.
*
* @tags: [
* requires_persistence,
* ]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
import {waitForState} from "jstests/replsets/rslib.js";
const rst = new ReplSetTest({
nodes: [{}, {rsConfig: {priority: 0, votes: 0}}],
nodeOptions: {setParameter: {logComponentVerbosity: tojson({replication: 3})}}
});
rst.startSet();
rst.initiate();
const restartNode =
rst.restart(1, {setParameter: "failpoint.failIsSelfCheck=" + tojson({mode: "alwaysOn"})});
// "Locally stored replica set configuration does not have a valid entry for the current node".
checkLog.containsJson(restartNode, 21405);
waitForState(restartNode, ReplSetTest.State.REMOVED);
// "Received response to heartbeat".
checkLog.containsJson(rst.getPrimary(), 4615620, {
response: (response) => {
return response.codeName === "InvalidReplicaSetConfig";
}
});
assert.commandWorked(
restartNode.adminCommand({configureFailPoint: "failIsSelfCheck", mode: "off"}));
// Node 1 re-checks isSelf on next heartbeat and succeeds.
waitForState(restartNode, ReplSetTest.State.SECONDARY);
rst.stopSet();