File: filesize.js

package info (click to toggle)
mongodb 1%3A3.2.11-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 196,404 kB
  • sloc: cpp: 1,412,793; ansic: 504,961; python: 78,522; perl: 5,837; sh: 5,661; java: 4,202; makefile: 1,784; pascal: 617; xml: 176; asm: 128
file content (39 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download
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
// Test for SERVER-7430: Warning about smallfiles should include filename
var baseName = "filesize";

// Start mongod with --smallfiles
var m = MongoRunner.runMongod({nojournal: "", smallfiles: ""});

var db = m.getDB(baseName);

// Skip on 32 bits, since 32-bit servers don't warn about small files
if (db.serverBuildInfo().bits == 32) {
    print("Skip on 32-bit");
} else {
    // Restart mongod without --smallFiles
    MongoRunner.stopMongod(m);
    m = MongoRunner.runMongod({
        restart: true,
        cleanData: false,
        dbpath: m.dbpath,
        port: m.port,
        nojournal: "",
    });

    db = m.getDB(baseName);
    var log = db.adminCommand({getLog: "global"}).log;

    // Find log message like:
    // "openExisting file size 16777216 but
    // mmapv1GlobalOptions.smallfiles=false: /data/db/filesize/local.0"
    var found = false, logline = '';
    for (i = log.length - 1; i >= 0; i--) {
        logline = log[i];
        if (logline.indexOf("openExisting file") >= 0 && logline.indexOf("local.0") >= 0) {
            found = true;
            break;
        }
    }

    assert(found);
}