blob: a6e4f5b07ff1cc5b9b9585e4d8bcec837ddcda5e (
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
52
53
54
55
|
/**
* This test is only for WiredTiger storageEngine
* Test nojournal and fsync with wiredTiger standalone.
* Add some data and kill -9, once after fsync, once without fsync
* If no fsync, data should go away after restart.
* If fsync, should recover and data should be present after restart.
*/
function writeDataAndRestart(doFsync) {
jsTestLog("add some data");
for (var i=0; i<100; i++) {
conn.getDB(name).foo.insert({x:i});
}
if (doFsync) {
jsTestLog("run fsync on the node");
assert.commandWorked(conn.getDB("admin").runCommand({fsync : 1}));
}
jsTestLog("kill -9");
MongoRunner.stopMongod(conn, /*signal*/ 9);
jsTestLog("restart node");
conn = MongoRunner.runMongod({restart: true,
port: conn.port,
cleanData: false,
storageEngine: "wiredTiger",
nojournal: ""});
return conn;
}
// This test can only be run if the storageEngine is wiredTiger
if (jsTest.options().storageEngine && jsTest.options().storageEngine !== "wiredTiger") {
jsTestLog("Skipping test because storageEngine is not wiredTiger");
}
else {
var name = "wt_nojournal_fsync";
jsTestLog("run mongod without journaling");
conn = MongoRunner.runMongod({storageEngine: "wiredTiger", nojournal: ""});
// restart node without fsync and --nojournal. Data should not be there after restart
conn = writeDataAndRestart(false);
jsTestLog("check data is not in collection foo");
assert.eq(conn.getDB(name).foo.count(), 0);
// restart node with fsync and --nojournal. Data should be there after restart
conn = writeDataAndRestart(true);
jsTestLog("check data is in collection foo");
assert.eq(conn.getDB(name).foo.count(), 100);
MongoRunner.stopMongod(conn);
jsTestLog("Success!");
}
|