summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/log_component_helpers.js
blob: 405b2bdaca3ed99020a2888eb1efa1e82c9e1cde (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
// 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(function() {
        mongo.setLogLevel(2, 24);
    });
    assert.throws(function() {
        db.setLogLevel(2, ["array", "not.allowed"]);
    });

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