summaryrefslogtreecommitdiff
path: root/jstests/replsets/isself_failure_initiate.js
blob: d9821c15bfc3747c950c6f4cd381ef19f088b2a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
 * Tests that replSetInitiate eventually succeeds despite temporary DNS outage.
 *
 * @tags: [
 *   multiversion_incompatible
 * ]
 */

(function() {
'use strict';

load("jstests/libs/fail_point_util.js");
load("jstests/replsets/rslib.js");

const rst = new ReplSetTest({nodes: [{}, {rsConfig: {priority: 0, votes: 0}}]});
const nodes = rst.startSet();
// Node 1 will fail to find itself in the config.
const failPoint = configureFailPoint(nodes[1], "failIsSelfCheck");
const config = rst.getReplSetConfig();
assert.commandWorked(nodes[0].adminCommand({replSetInitiate: config}));
failPoint.wait();
assert.commandFailedWithCode(nodes[1].adminCommand({replSetGetStatus: 1}),
                             ErrorCodes.NotYetInitialized);
failPoint.off();
// Node 1 re-checks isSelf on next heartbeat and succeeds.
waitForState(nodes[1], ReplSetTest.State.SECONDARY);
rst.stopSet();
})();