diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2014-04-01 19:34:57 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2014-04-01 20:04:12 -0400 |
commit | c7a673410edd0c9ff6a17ff333f72fb43c82fb2c (patch) | |
tree | 7ac3a8ae9c4612dd5e2d1593fd52e078d1682af0 | |
parent | 261233b6c11a8282b1f626d496a1743a0b48821d (diff) | |
download | mongo-c7a673410edd0c9ff6a17ff333f72fb43c82fb2c.tar.gz |
SERVER-13429 Update exit_logging.js to also test mongos exit logging.
(cherry picked from commit 9e041ccf433660008ed2ddb1c2ed58ba78ef5488)
-rw-r--r-- | jstests/noPassthrough/exit_logging.js | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/jstests/noPassthrough/exit_logging.js b/jstests/noPassthrough/exit_logging.js index 32e3dd2d3de..3a26b4a3108 100644 --- a/jstests/noPassthrough/exit_logging.js +++ b/jstests/noPassthrough/exit_logging.js @@ -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********************"); + + runAllTests({ + start: function (opts) { + var actualOpts = { nojournal: "" }; + Object.extend(actualOpts, opts); + return MongoRunner.runMongod(actualOpts); + }, + stop: MongoRunner.stopMongod + }); + }()); + + (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); + }, - testShutdownLogging( - makeShutdownByCrashFn('fault'), - makeRegExMatchFn(/Invalid access at address[\s\S]*printStackTrace/)); + stop: MongoRunner.stopMongos + }; - testShutdownLogging( - makeShutdownByCrashFn('abort'), - makeRegExMatchFn(/Got signal[\s\S]*printStackTrace/)); + runAllTests(mongosLauncher); + }()); }()); |