summaryrefslogtreecommitdiff
path: root/jstests/replsets/replset4.js
blob: e6df067d1ea7fbcd8acc87544bdde352e92f21c3 (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
29
30
31
32
33
34
35
36
doTest = function(signal) {

    // Test orphaned master steps down
    var replTest = new ReplSetTest({name: 'testSet', nodes: 3});

    replTest.startSet();
    replTest.initiate();

    var master = replTest.getPrimary();

    // Kill both slaves, simulating a network partition
    var slaves = replTest.liveNodes.slaves;
    for (var i = 0; i < slaves.length; i++) {
        var slave_id = replTest.getNodeId(slaves[i]);
        replTest.stop(slave_id);
    }

    print("replset4.js 1");

    assert.soon(function() {
        try {
            var result = master.getDB("admin").runCommand({ismaster: 1});
            return (result['ok'] == 1 && result['ismaster'] == false);
        } catch (e) {
            print("replset4.js caught " + e);
            return false;
        }
    }, "Master fails to step down when orphaned.");

    print("replset4.js worked, stopping");
    replTest.stopSet(signal);
};

print("replset4.js");
doTest(15);
print("replset4.js SUCCESS");