summaryrefslogtreecommitdiff
path: root/jstests/replsets/get_status.js
blob: 31a49dc130046363598efcfb331185215cb7cfb9 (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
/*
 * Sanity check that get_status works as expected. There are C++ unit tests for most of the
 * functionality, so we'll just check that it succeeds and fails when it's supposed to.
 */

(function() {
    "use strict";
    var name = "getstatus";
    var numNodes = 4;
    var replTest = new ReplSetTest({name: name, nodes: numNodes});
    var nodes = replTest.startSet();

    var config = replTest.getReplSetConfig();
    config.members[numNodes - 1].arbiterOnly = true;
    // An invalid time to get status
    var statusBeforeInitCode = 94;
    assert.commandFailedWithCode(nodes[0].getDB("admin").runCommand({replSetGetStatus: 1}),
                                 statusBeforeInitCode,
                                 "replSetGetStatus should fail before initializing.");
    replTest.initiate(config);
    replTest.awaitSecondaryNodes();

    // A valid status
    var primary = replTest.getPrimary();
    assert.commandWorked(primary.getDB("admin").runCommand({replSetGetStatus: 1}));

    replTest.stopSet();
}());