diff options
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/shell_cmd_assertions.js | 9 | ||||
-rw-r--r-- | jstests/resmoke_selftest/shell_hang_analyzer.js | 21 |
2 files changed, 21 insertions, 9 deletions
diff --git a/jstests/noPassthrough/shell_cmd_assertions.js b/jstests/noPassthrough/shell_cmd_assertions.js index 5167947a832..207ac40fa12 100644 --- a/jstests/noPassthrough/shell_cmd_assertions.js +++ b/jstests/noPassthrough/shell_cmd_assertions.js @@ -412,7 +412,14 @@ tests.push(function assertCallsHangAnalyzer() { tests.forEach((test) => { jsTest.log(`Starting test '${test.name}'`); setup(); - test(); + const oldMongoRunner = MongoRunner; + try { + // We shouldn't actually run the hang-analyzer for these tests. + MongoRunner.runHangAnalyzer = Function.prototype; + test(); + } finally { + MongoRunner = oldMongoRunner; + } }); /* cleanup */ diff --git a/jstests/resmoke_selftest/shell_hang_analyzer.js b/jstests/resmoke_selftest/shell_hang_analyzer.js index 9fc58b628cd..189f6fe1bba 100644 --- a/jstests/resmoke_selftest/shell_hang_analyzer.js +++ b/jstests/resmoke_selftest/shell_hang_analyzer.js @@ -17,17 +17,21 @@ const anyLineMatches = function(lines, rex) { */ const child = MongoRunner.runMongod(); -try { - clearRawMongoProgramOutput(); +clearRawMongoProgramOutput(); - // drive-by test for enable(). Separate test for disable() below. - MongoRunner.runHangAnalyzer.disable(); - MongoRunner.runHangAnalyzer.enable(); +// drive-by test for enable(). Separate test for disable() below. +MongoRunner.runHangAnalyzer.disable(); +MongoRunner.runHangAnalyzer.enable(); - MongoRunner.runHangAnalyzer([child.pid]); +MongoRunner.runHangAnalyzer([child.pid]); - const lines = rawMongoProgramOutput().split('\n'); +if (TestData && TestData.inEvergreen) { + assert.soon(() => { + // Ensure the hang-analyzer has killed the process. + return !checkProgram(child.pid).alive; + }); + const lines = rawMongoProgramOutput().split('\n'); if (_isAddressSanitizerActive()) { assert.soon(() => { // On ASAN builds, we never dump the core during hang analyzer runs, @@ -42,7 +46,8 @@ try { return anyLineMatches(lines, /Dumping core/); }); } -} finally { +} else { + // When running locally the hang-analyzer is not run. MongoRunner.stopMongod(child); } })(); |