summaryrefslogtreecommitdiff
path: root/jstests/slowNightly/command_line_parsing.js
blob: bb64e9b2e0677293f7bd439ed72559c51d902710 (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
// validate command line parameter parsing

port = allocatePorts( 1 )[ 0 ];
var baseName = "jstests_slowNightly_command_line_parsing";

// test notablescan
var m = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--notablescan" );
m.getDB( baseName ).getCollection( baseName ).save( {a:1} );
assert.throws( function() { m.getDB( baseName ).getCollection( baseName ).find( {a:1} ).toArray() } );

// test config file 
var m2 = startMongod( "--port", port+2, "--dbpath", MongoRunner.dataPath + baseName +"2", "--config", "jstests/libs/testconfig");

var m2expected = {
    "parsed" : {
        "config" : "jstests/libs/testconfig",
        "fastsync" : true,
        "storage" : {
            "dbPath" : MongoRunner.dataDir + "/jstests_slowNightly_command_line_parsing2",
        },
        "net" : {
            "port" : 31002
        }
    }
};
var m2result = m2.getDB("admin").runCommand( "getCmdLineOpts" );

//remove setParameter as it is variable depending on the way the test is started.
delete m2result.parsed.setParameter
assert.docEq( m2expected.parsed, m2result.parsed );

// test JSON config file
var m3 = startMongod("--port", port+4, "--dbpath", MongoRunner.dataPath + baseName +"4",
                     "--config", "jstests/libs/testconfig");

var m3expected = {
    "parsed" : {
        "config" : "jstests/libs/testconfig",
        "fastsync" : true,
        "storage" : {
            "dbPath" : MongoRunner.dataDir + "/jstests_slowNightly_command_line_parsing4",
        },
        "net" : {
            "port" : 31004
        }
    }
};
var m3result = m3.getDB("admin").runCommand( "getCmdLineOpts" );

//remove setParameter as it is variable depending on the way the test is started.
delete m3result.parsed.setParameter
assert.docEq( m3expected.parsed, m3result.parsed );