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:03:54 -0400 |
commit | 9e041ccf433660008ed2ddb1c2ed58ba78ef5488 (patch) | |
tree | e076a4ce861234cc5adc7d26e3aa44b4ed06d37b /jstests/noPassthrough/exit_logging.js | |
parent | ad91eb0f75f39c1bb71b5e0ca4279b883cb9fe8d (diff) | |
download | mongo-9e041ccf433660008ed2ddb1c2ed58ba78ef5488.tar.gz |
SERVER-13429 Update exit_logging.js to also test mongos exit logging.
Diffstat (limited to 'jstests/noPassthrough/exit_logging.js')
-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); + }()); }()); |