mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 16:46:00 +01:00
9f7577b97d
GitOrigin-RevId: 42525651804c854ceab9fad1c553685713433e89
27 lines
1.0 KiB
JavaScript
27 lines
1.0 KiB
JavaScript
// The mongod process should always create a mongod.lock file in the data directory
|
|
// containing the process ID regardless of the storage engine requested.
|
|
|
|
// Ensures that mongod.lock exists and returns size of file.
|
|
function getMongodLockFileSize(dir) {
|
|
var files = listFiles(dir);
|
|
for (var i in files) {
|
|
var file = files[i];
|
|
if (!file.isDirectory && file.baseName == 'mongod.lock') {
|
|
return file.size;
|
|
}
|
|
}
|
|
assert(false, 'mongod.lock not found in data directory ' + dir);
|
|
}
|
|
|
|
var baseName = jsTestName();
|
|
var dbpath = MongoRunner.dataPath + baseName + '/';
|
|
|
|
// Test framework will append --storageEngine command line option.
|
|
var mongod = MongoRunner.runMongod({dbpath: dbpath});
|
|
assert.neq(
|
|
0, getMongodLockFileSize(dbpath), 'mongod.lock should not be empty while server is running');
|
|
|
|
MongoRunner.stopMongod(mongod);
|
|
|
|
// mongod.lock must be empty after shutting server down.
|
|
assert.eq(0, getMongodLockFileSize(dbpath), 'mongod.lock not truncated after shutting server down'); |