summaryrefslogtreecommitdiff
path: root/jstests/disk/wt_table_checks_read_only.js
blob: 6d6519f2c857e5c1028667492e870e7aa60350c6 (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
/**
 * Tests that the table logging settings are not changed during read only mode.
 *
 * @tags: [requires_wiredtiger]
 */
(function() {

load('jstests/disk/libs/wt_file_helper.js');

// Create a bunch of collections under various database names.
let conn = MongoRunner.runMongod({});
const dbpath = conn.dbpath;

for (let i = 0; i < 10; i++) {
    assert.commandWorked(conn.getDB(i.toString()).createCollection(i.toString()));
}

MongoRunner.stopMongod(conn);

// Option for read only mode.
let options = {queryableBackupMode: ""};

// Verifies that setTableLogging() does not get called in read only mode, otherwise the invariant
// would fire.
conn = startMongodOnExistingPath(dbpath, options);
assert(conn);
MongoRunner.stopMongod(conn);

// Create the '_wt_table_checks' file in the dbpath and ensure it doesn't get removed while in read
// only mode.
let files = listFiles(dbpath);
for (f in files) {
    assert(!files[f].name.includes("_wt_table_checks"));
}

writeFile(dbpath + "/_wt_table_checks", "");

conn = startMongodOnExistingPath(dbpath, options);
assert(conn);
MongoRunner.stopMongod(conn);

let hasWTTableChecksFile = false;
files = listFiles(dbpath);
for (f in files) {
    if (files[f].name.includes("_wt_table_checks")) {
        hasWTTableChecksFile = true;
    }
}

assert(hasWTTableChecksFile);
}());