summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/profile_options.js
blob: 0ba4a5b40c3b5c8a79c9bfc56e2dfba22a23a123 (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
66
67
68
69
70
71
72
73
74
75
var baseName = "jstests_core_profile_options";

function removeOptionsAddedByFramework(getCmdLineOptsResult) {
    // Remove options that we are not interested in checking, but that get set by the test
    delete getCmdLineOptsResult.parsed.setParameter
    delete getCmdLineOptsResult.parsed.storage
    delete getCmdLineOptsResult.parsed.net
    delete getCmdLineOptsResult.parsed.fastsync
    delete getCmdLineOptsResult.parsed.security
    return getCmdLineOptsResult;
}

function testGetCmdLineOpts(mongoRunnerConfig, expectedResult) {

    // Start mongod with options
    var mongod = MongoRunner.runMongod(mongoRunnerConfig);

    // Get the parsed options
    var getCmdLineOptsResult = mongod.adminCommand("getCmdLineOpts");
    printjson(getCmdLineOptsResult);

    // Remove options added by the test framework
    getCmdLineOptsResult = removeOptionsAddedByFramework(getCmdLineOptsResult);

    // Make sure the options are equal to what we expect
    assert.docEq(getCmdLineOptsResult.parsed, expectedResult.parsed);

    // Cleanup
    MongoRunner.stopMongod(mongod.port);
}

jsTest.log("Testing \"profile\" command line option with profiling off");
var expectedResult = {
    "parsed" : {
        "operationProfiling" : {
            "mode" : "off"
        }
    }
};
testGetCmdLineOpts({ profile : "0" }, expectedResult);

jsTest.log("Testing \"profile\" command line option with profiling slow operations on");
var expectedResult = {
    "parsed" : {
        "operationProfiling" : {
            "mode" : "slowOp"
        }
    }
};
testGetCmdLineOpts({ profile : "1" }, expectedResult);

jsTest.log("Testing \"profile\" command line option with profiling all on");
var expectedResult = {
    "parsed" : {
        "operationProfiling" : {
            "mode" : "all"
        }
    }
};
testGetCmdLineOpts({ profile : "2" }, expectedResult);

jsTest.log("Testing \"operationProfiling.mode\" config file option");
expectedResult = {
    "parsed" : {
        "config" : "jstests/libs/config_files/set_profiling.json",
        "operationProfiling" : {
            "mode" : "all"
        }
    }
};
testGetCmdLineOpts({ config : "jstests/libs/config_files/set_profiling.json" }, expectedResult);



print(baseName + " succeeded.");