summaryrefslogtreecommitdiff
path: root/jstests/rs/test_framework.js
blob: eb6e62871882dfb8ed7b69f663d459c6ad029ac4 (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
// test helpers
// load("test_framework.js")

DB.prototype.isMaster = function() { 
    return this.runCommand("isMaster");
}
DB.prototype.ismaster = function () { return this.isMaster().ismaster; }

function rs_mongod() {
    /* run mongod for a replica set member. wipes data dir! */
    var port = __nextPort++;
    var not_me = (port == 27000 ? port + 1 : port - 1);
    var f = startMongodEmpty;
    var dir = "" + port; // e.g., data/db/27000
    var conn = f.apply(null, [
        {
            port: port,
            dbpath: "/data/db/" + dir,
            noprealloc: "",
            smallfiles: "",
            oplogSize: "2",
            //nohttpinterface: ""
            rest: "", // --rest is best for replica set administration
            replSet: "asdf/" + hostname() + ":" + not_me
        }
    ]
    );
    conn.name = "localhost:" + port;
    return conn;
}