summaryrefslogtreecommitdiff
path: root/jstests/libs/check_log.js
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2017-01-23 11:54:49 -0500
committerMathias Stearn <mathias@10gen.com>2017-01-24 11:53:10 -0500
commitc54d665229604e6fd6bfc0e73c171524604e296b (patch)
tree69ff63be98643f0ac3c99419cb61b57d8f21fc73 /jstests/libs/check_log.js
parent7dd4b02a58c757343e421ed9c04fc6fa20dbfc33 (diff)
downloadmongo-c54d665229604e6fd6bfc0e73c171524604e296b.tar.gz
SERVER-27050 jstest that rollback detects upstream node rolling back
Diffstat (limited to 'jstests/libs/check_log.js')
-rw-r--r--jstests/libs/check_log.js25
1 files changed, 21 insertions, 4 deletions
diff --git a/jstests/libs/check_log.js b/jstests/libs/check_log.js
index 5a9ba10435a..094fc63ecf8 100644
--- a/jstests/libs/check_log.js
+++ b/jstests/libs/check_log.js
@@ -11,6 +11,19 @@ var checkLog;
}
checkLog = (function() {
+ var getGlobalLog = function(conn) {
+ var cmdRes;
+ try {
+ cmdRes = conn.adminCommand({getLog: 'global'});
+ } catch (e) {
+ // Retry with network errors.
+ print("checkLog ignoring failure: " + e);
+ return null;
+ }
+
+ return assert.commandWorked(cmdRes).log;
+ };
+
/*
* 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
@@ -19,8 +32,10 @@ var checkLog;
var contains = function(conn, msg) {
assert.soon(
function() {
- var logMessages =
- assert.commandWorked(conn.adminCommand({getLog: 'global'})).log;
+ var logMessages = getGlobalLog(conn);
+ if (logMessages === null) {
+ return false;
+ }
for (var i = 0; i < logMessages.length; i++) {
if (logMessages[i].indexOf(msg) != -1) {
return true;
@@ -43,8 +58,10 @@ var checkLog;
var count = 0;
assert.soon(
function() {
- var logMessages =
- assert.commandWorked(conn.adminCommand({getLog: 'global'})).log;
+ var logMessages = getGlobalLog(conn);
+ if (logMessages === null) {
+ return false;
+ }
for (var i = 0; i < logMessages.length; i++) {
if (logMessages[i].indexOf(msg) != -1) {
count++;