0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-13429 Update exit_logging.js to also test mongos exit logging.

This commit is contained in:
Andy Schwerin 2014-04-01 19:34:57 -04:00
parent ad91eb0f75
commit 9e041ccf43

View File

@ -19,41 +19,81 @@
function makeRegExMatchFn(pattern) {
return function (text) {
if (!pattern.test(text)) {
print("--- LOG CONTENTS ---");
print(text);
print("--- END LOG CONTENTS ---");
doassert("Log contents did not match " + pattern);
}
}
}
function testShutdownLogging(crashFn, matchFn) {
function testShutdownLogging(launcher, crashFn, matchFn) {
var logFileName = MongoRunner.dataPath + "mongod.log";
var opts = { logpath: logFileName, nojournal: "" };
var conn = MongoRunner.runMongod(opts);
var opts = { logpath: logFileName };
var conn = launcher.start(opts);
try {
crashFn(conn);
}
finally {
MongoRunner.stopMongod(conn);
launcher.stop(conn);
}
var logContents = cat(logFileName);
matchFn(logContents);
}
function runAllTests(launcher) {
testShutdownLogging(
launcher,
function (conn) { conn.getDB('admin').shutdownServer() },
makeRegExMatchFn(/shutdown command received[\s\S]*dbexit:/));
testShutdownLogging(
launcher,
makeShutdownByCrashFn('fault'),
makeRegExMatchFn(/Invalid access at address[\s\S]*printStackTrace/));
testShutdownLogging(
launcher,
makeShutdownByCrashFn('abort'),
makeRegExMatchFn(/Got signal[\s\S]*printStackTrace/));
}
if (_isWindows()) {
print("SKIPPING TEST ON WINDOWS");
return;
}
testShutdownLogging(
function (conn) { conn.getDB('admin').shutdownServer() },
makeRegExMatchFn(/shutdown command received[\s\S]*dbexit: really exiting now/));
(function testMongod() {
print("********************\nTesting exit logging in mongod\n********************");
testShutdownLogging(
makeShutdownByCrashFn('fault'),
makeRegExMatchFn(/Invalid access at address[\s\S]*printStackTrace/));
runAllTests({
start: function (opts) {
var actualOpts = { nojournal: "" };
Object.extend(actualOpts, opts);
return MongoRunner.runMongod(actualOpts);
},
stop: MongoRunner.stopMongod
});
}());
testShutdownLogging(
makeShutdownByCrashFn('abort'),
makeRegExMatchFn(/Got signal[\s\S]*printStackTrace/));
(function testMongos() {
print("********************\nTesting exit logging in mongos\n********************");
var st = new ShardingTest({
shards: 1,
other: { shardOptions: { nojournal: "" } }
});
var mongosLauncher = {
start: function (opts) {
var actualOpts = { configdb: st._configNames[0] }
Object.extend(actualOpts, opts);
return MongoRunner.runMongos(actualOpts);
},
stop: MongoRunner.stopMongos
};
runAllTests(mongosLauncher);
}());
}());