summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/lock_file_fail_to_open.js
blob: 83df3ed80bd21e223fe11ac8bfda3b6f14f0831d (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
// Tests that MongoD fails to start with the correct error message if mongod.lock exists in the
// dbpath.
(function() {
"use strict";

var baseName = "jstests_lock_file_fail_to_open";

var dbPath = MongoRunner.dataPath + baseName + "/";

// Start a MongoD just to get a lockfile in place.
var mongo1 = MongoRunner.runMongod({dbpath: dbPath, waitForConnect: true});

clearRawMongoProgramOutput();
// Start another one which should fail to start as there is already a lockfile in its
// dbpath.
assert.throws(() => MongoRunner.runMongod({dbpath: dbPath, noCleanData: true}));

var logContents = rawMongoProgramOutput();
assert(logContents.indexOf("Unable to lock the lock file") > 0 ||
       // Windows error message is different.
       logContents.indexOf("Unable to create/open the lock file") > 0);

MongoRunner.stopMongod(mongo1);
})();