summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/server_status.js
blob: d19621c07de987004869fa336ebbfdf49a96cb39 (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
// Checks storage-engine specific sections of db.severStatus() output.

(function() {
    'use strict';

    // 'backgroundFlushing' is mmapv1-specific.
    var mongo = MongoRunner.runMongod({smallfiles: ""});
    var testDB = mongo.getDB('test');
    var serverStatus = assert.commandWorked(testDB.serverStatus());
    if (serverStatus.storageEngine.name == 'mmapv1') {
        assert(serverStatus.backgroundFlushing,
               'mmapv1 db.serverStatus() result must contain backgroundFlushing document: ' +
                   tojson(serverStatus));
    } else {
        assert(!serverStatus.backgroundFlushing,
               'Unexpected backgroundFlushing document in non-mmapv1 db.serverStatus() result: ' +
                   tojson(serverStatus));
    }
    MongoRunner.stopMongod(mongo);

    // 'dur' is mmapv1-specific and should only be generated when journaling is enabled.
    mongo = MongoRunner.runMongod({smallfiles: "", journal: ""});
    testDB = mongo.getDB('test');
    serverStatus = assert.commandWorked(testDB.serverStatus());
    if (serverStatus.storageEngine.name == 'mmapv1') {
        assert(
            serverStatus.dur,
            'mmapv1 db.serverStatus() result must contain "dur" document: ' + tojson(serverStatus));
    } else {
        assert(!serverStatus.dur,
               'Unexpected "dur" document in non-mmapv1 db.serverStatus() result: ' +
                   tojson(serverStatus));
    }
    MongoRunner.stopMongod(mongo);
    mongo = MongoRunner.runMongod({smallfiles: "", nojournal: ""});
    testDB = mongo.getDB('test');
    serverStatus = assert.commandWorked(testDB.serverStatus());
    assert(!serverStatus.dur,
           'Unexpected "dur" document in db.serverStatus() result when journaling is disabled: ' +
               tojson(serverStatus));
    MongoRunner.stopMongod(mongo);
}());