File: arbiter.js

package info (click to toggle)
mongodb 1%3A3.2.11-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 196,404 kB
  • sloc: cpp: 1,412,793; ansic: 504,961; python: 78,522; perl: 5,837; sh: 5,661; java: 4,202; makefile: 1,784; pascal: 617; xml: 176; asm: 128
file content (39 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download
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
37
38
39
// Certain commands should be run-able from arbiters under localhost, but not from
// any other nodes in the replset.

var name = "arbiter_localhost_test";
var key = "jstests/libs/key1";
var replTest = new ReplSetTest({name: name, nodes: 3, keyFile: key});
var nodes = replTest.nodeList();

replTest.startSet();
replTest.initiate({
    _id: name,
    members: [
        {"_id": 0, "host": nodes[0], priority: 3},
        {"_id": 1, "host": nodes[1]},
        {"_id": 2, "host": nodes[2], arbiterOnly: true}
    ],
});

var primaryAdmin = replTest.nodes[0].getDB("admin");
var arbiterAdmin = replTest.nodes[2].getDB("admin");

var cmd0 = {
    getCmdLineOpts: 1
};
var cmd1 = {
    getParameter: 1,
    logLevel: 1
};
var cmd2 = {
    serverStatus: 1
};

assert.commandFailedWithCode(primaryAdmin.runCommand(cmd0), 13);
assert.commandFailedWithCode(primaryAdmin.runCommand(cmd1), 13);
assert.commandFailedWithCode(primaryAdmin.runCommand(cmd2), 13);

assert.commandWorked(arbiterAdmin.runCommand(cmd0));
assert.commandWorked(arbiterAdmin.runCommand(cmd1));
assert.commandWorked(arbiterAdmin.runCommand(cmd2));