From 517339beecd8fc01b89fd41c5f1543961250aed4 Mon Sep 17 00:00:00 2001 From: John Bouchard Date: Tue, 29 Sep 2020 11:39:01 -0700 Subject: [PATCH 1/3] improve-line-filtering --- src/util/childProcess.js | 45 ++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/util/childProcess.js b/src/util/childProcess.js index e62776f..f721cbd 100644 --- a/src/util/childProcess.js +++ b/src/util/childProcess.js @@ -29,9 +29,14 @@ const ADDED_ERROR_MESSAGE_CONTEXT = "If running on saucelabs, perhaps " + // if the "this.handler.stdout" stream of the childprocess does not // include atleast one of these tokens then it will not be included in the "this.stdout" + +const NW_ERROR_TAG = "\x1B[1;33mERROR\x1B[0m"; +const NW_WARN_TAG = "\x1B[1;32m\x1B[40mWARN\x1B[0m"; +const NW_INFO_TAG = "\x1B[1;35m\x1B[40mINFO\x1B[0m"; + const STDOUT_WHITE_LIST = [ - "\x1B[1;33mERROR\x1B[0m", - "\x1B[1;32m\x1B[40mWARN\x1B[0m", + NW_ERROR_TAG, + NW_WARN_TAG, "Test Suite", "✖", "✔", @@ -40,7 +45,14 @@ const STDOUT_WHITE_LIST = [ ]; // we slice the VERBOSE nighwatch stdout stream on the purple INFO text that has black background -const SLICE_ON_TEXT = "\x1B[1;35m\x1B[40mINFO\x1B[0m"; +const SLICE_ON_TEXT = NW_INFO_TAG; + +const applyLineFilter = (text, lineFilter) => { + const lines = text.split("\n"); + const buff = []; + lines.forEach(line => lineFilter(line, buff)); + return buff.join("\n"); +}; module.exports = class ChildProcess { constructor(handler) { @@ -60,27 +72,34 @@ module.exports = class ChildProcess { const stdoutFilter = new Transform({ transform(data, encoding, callback) { let text = data.toString().trim(); + // ignore info chunks that are reporting a failed /timeouts/async_script request + // avoids cluttering the log because /timeouts/async_script is not well supported + if (text.includes(NW_ERROR_TAG) && text.includes("/timeouts/async_script")) { + // we are not losing any key information here, request and response payloads + // sit between nw_info_tags and we slice data on nw_info_tag + return callback(); + } if (text.length > 0 && self.isTextWhiteListed(text)) { - if (text.includes("✔") || text.includes("Running:") || text.includes("OK.")) { - // for successful chunks we really only want to keep specific lines - const lines = text.split("\n"); - const buff = []; + // slices that have any one of these indicators + // need-line-by-line filtering applied to them + const lineFilterIndicators = ["✔", "Running:", "OK.", "✖"]; + if (lineFilterIndicators.some(item => text.includes(item))) { + // apply some line by line filtering const maxLineLength = 512; - const processLine = (line) => { + const lineFilter = (line, buff) => { if (self.isTextWhiteListed(line)) { // limit the length of each line, goal here is to "limit" verbosity buff.push(line.substring(0, maxLineLength)); } }; - lines.forEach(line => processLine(line)); - text = buff.join("\n"); + text = applyLineFilter(text, lineFilter); } text = text .split("\n") .filter((line) => !_.isEmpty(line.trim())) - .map((line) => `\n${clc.yellowBright(logStamp())} ${line}`) - .join("\n"); - self.stdout += text + "\n"; + .map((line) => `${clc.yellowBright(logStamp())} ${line}`) + .join("\n") + "\n"; + self.stdout += text; self.addErrorMessageContext(); this.push(text); } From c351852c6d2541b77af1f4814c7c352a230aee9a Mon Sep 17 00:00:00 2001 From: John Bouchard Date: Tue, 29 Sep 2020 11:39:37 -0700 Subject: [PATCH 2/3] bump-version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4bb8e3d..a73a1c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "testarmada-magellan", - "version": "11.0.15", + "version": "11.0.16", "description": "Massively parallel automated testing", "main": "src/main", "directories": { From 9728a9b1f7aa150edcdb0b20a75d403b6fdf8491 Mon Sep 17 00:00:00 2001 From: John Bouchard Date: Tue, 29 Sep 2020 11:46:50 -0700 Subject: [PATCH 3/3] fix-typo --- src/util/childProcess.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/childProcess.js b/src/util/childProcess.js index f721cbd..96b958c 100644 --- a/src/util/childProcess.js +++ b/src/util/childProcess.js @@ -81,7 +81,7 @@ module.exports = class ChildProcess { } if (text.length > 0 && self.isTextWhiteListed(text)) { // slices that have any one of these indicators - // need-line-by-line filtering applied to them + // need line-by-line filtering applied to them const lineFilterIndicators = ["✔", "Running:", "OK.", "✖"]; if (lineFilterIndicators.some(item => text.includes(item))) { // apply some line by line filtering