diff options
author | Spencer T Brody <spencer@mongodb.com> | 2017-01-17 17:06:52 -0500 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2017-01-18 18:05:33 -0500 |
commit | 21948042b6da5fb5bf15897f9808a70551f5af09 (patch) | |
tree | fbbf09efa69efefc8b14cdb4d4ff9a7260f29e74 /jstests/libs/check_log.js | |
parent | fd6971a17400c37ea6bf6c54ef2c04c25201416d (diff) | |
download | mongo-21948042b6da5fb5bf15897f9808a70551f5af09.tar.gz |
SERVER-27680 Merge stopOplogFetcher and pauseRsBgSyncProducer failpoint into single stopReplProducer failpoint
Diffstat (limited to 'jstests/libs/check_log.js')
-rw-r--r-- | jstests/libs/check_log.js | 99 |
1 files changed, 55 insertions, 44 deletions
diff --git a/jstests/libs/check_log.js b/jstests/libs/check_log.js index 8cb064f9558..5a9ba10435a 100644 --- a/jstests/libs/check_log.js +++ b/jstests/libs/check_log.js @@ -1,53 +1,64 @@ -"use strict"; - /* * Helper functions which connect to a server, and check its logs for particular strings. */ -var checkLog = (function() { - /* - * Calls the 'getLog' function at regular intervals on the provided connection 'conn' until the - * provided 'msg' is found in the logs, or 5 minutes have elapsed. Throws an exception on - * timeout. - */ - var contains = function(conn, msg) { - assert.soon( - function() { - var logMessages = assert.commandWorked(conn.adminCommand({getLog: 'global'})).log; - for (var i = 0; i < logMessages.length; i++) { - if (logMessages[i].indexOf(msg) != -1) { - return true; +var checkLog; + +(function() { + "use strict"; + + if (checkLog) { + return; // Protect against this file being double-loaded. + } + + checkLog = (function() { + /* + * Calls the 'getLog' function at regular intervals on the provided connection 'conn' until + * the provided 'msg' is found in the logs, or 5 minutes have elapsed. Throws an exception + * on timeout. + */ + var contains = function(conn, msg) { + assert.soon( + function() { + var logMessages = + assert.commandWorked(conn.adminCommand({getLog: 'global'})).log; + for (var i = 0; i < logMessages.length; i++) { + if (logMessages[i].indexOf(msg) != -1) { + return true; + } } - } - return false; - }, - 'Could not find log entries containing the following message: ' + msg, - 5 * 60 * 1000, - 300); - }; + return false; + }, + 'Could not find log entries containing the following message: ' + msg, + 5 * 60 * 1000, + 300); + }; - /* - * Calls the 'getLog' function at regular intervals on the provided connection 'conn' until the - * provided 'msg' is found in the logs exactly 'expectedCount' times, or 5 minutes have elapsed. - * Throws an exception on timeout. - */ - var containsWithCount = function(conn, msg, expectedCount) { - var count = 0; - assert.soon( - function() { - var logMessages = assert.commandWorked(conn.adminCommand({getLog: 'global'})).log; - for (var i = 0; i < logMessages.length; i++) { - if (logMessages[i].indexOf(msg) != -1) { - count++; + /* + * Calls the 'getLog' function at regular intervals on the provided connection 'conn' until + * the provided 'msg' is found in the logs exactly 'expectedCount' times, or 5 minutes have + * elapsed. + * Throws an exception on timeout. + */ + var containsWithCount = function(conn, msg, expectedCount) { + var count = 0; + assert.soon( + function() { + var logMessages = + assert.commandWorked(conn.adminCommand({getLog: 'global'})).log; + for (var i = 0; i < logMessages.length; i++) { + if (logMessages[i].indexOf(msg) != -1) { + count++; + } } - } - return expectedCount === count; - }, - 'Expected ' + expectedCount + ', but instead saw ' + count + - ' log entries containing the following message: ' + msg, - 5 * 60 * 1000, - 300); - }; + return expectedCount === count; + }, + 'Expected ' + expectedCount + ', but instead saw ' + count + + ' log entries containing the following message: ' + msg, + 5 * 60 * 1000, + 300); + }; - return {contains: contains, containsWithCount: containsWithCount}; + return {contains: contains, containsWithCount: containsWithCount}; + })(); })(); |