summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/command_line_parsing.js
blob: bd1b1ff0e8bea576964fd0fd013cd4d3afcf7d13 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// validate command line parameter parsing

var baseName = "jstests_slowNightly_command_line_parsing";

// test notablescan
var m = MongoRunner.runMongod({notablescan: ""});
m.getDB(baseName).getCollection(baseName).save({a: 1});
assert.throws(function() {
    m.getDB(baseName).getCollection(baseName).find({a: 1}).toArray();
});
MongoRunner.stopMongod(m);

// test config file
var m2 = MongoRunner.runMongod({config: "jstests/libs/testconfig"});

var m2expected = {
    "parsed": {
        "config": "jstests/libs/testconfig",
        "storage": {"dbPath": m2.dbpath},
        "net": {"bindIp": "0.0.0.0", "port": m2.port},
        "help": false,
        "version": false,
        "sysinfo": false
    }
};
var m2result = m2.getDB("admin").runCommand("getCmdLineOpts");
MongoRunner.stopMongod(m2);

// remove variables that depend on the way the test is started.
delete m2result.parsed.net.serviceExecutor;
delete m2result.parsed.net.transportLayer;
delete m2result.parsed.storage.mmapv1;
delete m2result.parsed.setParameter;
delete m2result.parsed.storage.engine;
delete m2result.parsed.storage.journal;
delete m2result.parsed.storage.rocksdb;
delete m2result.parsed.storage.wiredTiger;
assert.docEq(m2expected.parsed, m2result.parsed);

// test JSON config file
var m3 = MongoRunner.runMongod({config: "jstests/libs/testconfig"});

var m3expected = {
    "parsed": {
        "config": "jstests/libs/testconfig",
        "storage": {"dbPath": m3.dbpath},
        "net": {"bindIp": "0.0.0.0", "port": m3.port},
        "help": false,
        "version": false,
        "sysinfo": false
    }
};
var m3result = m3.getDB("admin").runCommand("getCmdLineOpts");
MongoRunner.stopMongod(m3);

// remove variables that depend on the way the test is started.
delete m3result.parsed.net.serviceExecutor;
delete m3result.parsed.net.transportLayer;
delete m3result.parsed.storage.mmapv1;
delete m3result.parsed.setParameter;
delete m3result.parsed.storage.engine;
delete m3result.parsed.storage.journal;
delete m3result.parsed.storage.rocksdb;
delete m3result.parsed.storage.wiredTiger;
assert.docEq(m3expected.parsed, m3result.parsed);