summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/log_component_helpers.js
blob: dfe6523ac3533db402a5d94721cf6dfd88ae2e32 (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
// Basic sanity check of log component helpers

(function(db) {
    "use strict";
    var mongo = db.getMongo();

    // Get current log component setttings. We will reset to these later.
    var originalSettings =
        assert.commandWorked(db.adminCommand({getParameter: 1, logComponentVerbosity: 1}))
            .logComponentVerbosity;

    // getLogComponents
    var components1 = mongo.getLogComponents();
    assert.docEq(components1, originalSettings);

    // getLogComponents via db
    var components2 = db.getLogComponents();
    assert.docEq(components2, originalSettings);

    // setLogLevel - default component
    mongo.setLogLevel(2);
    assert.eq(mongo.getLogComponents().verbosity, 2);

    db.setLogLevel(0);
    assert.eq(mongo.getLogComponents().verbosity, 0);

    // setLogLevel - valid log component
    mongo.setLogLevel(2, "storage.journal");
    assert.eq(mongo.getLogComponents().storage.journal.verbosity, 2);

    db.setLogLevel(1, "storage.journal");
    assert.eq(mongo.getLogComponents().storage.journal.verbosity, 1);

    // setLogLevel - invalid argument
    assert.throws(mongo.setLogLevel, [2, 24]);
    assert.throws(db.setLogLevel, [2, ["array", "not.allowed"]]);

    // Restore originalSettings
    assert.commandWorked(
        db.adminCommand({setParameter: 1, logComponentVerbosity: originalSettings}));
}(db));