From f6aed0c9cb9dca3022fd971edf1cac03791e28ba Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Tue, 10 Nov 2020 06:59:50 +0100 Subject: [PATCH] Fix truncation in travis (#4479) * log to travis every five seconds * travis: kill etherpad process after tests --- .travis.yml | 4 ++-- tests/frontend/travis/remote_runner.js | 29 ++++++++++++++++++++------ tests/frontend/travis/runner.sh | 2 ++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index f18288045..b9d330cc8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ jobs: - "bin/installDeps.sh" - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" script: - - "travis_wait 15 tests/frontend/travis/runner.sh" + - "./tests/frontend/travis/runner.sh" - name: "Run the Backend tests without Plugins" install: - "sudo add-apt-repository -y ppa:libreoffice/ppa" @@ -78,7 +78,7 @@ jobs: - *install_plugins - "export GIT_HASH=$(git rev-parse --verify --short HEAD)" script: - - "travis_wait 15 tests/frontend/travis/runner.sh" + - "./tests/frontend/travis/runner.sh" - name: "Lint test package-lock.json" install: - "npm install lockfile-lint" diff --git a/tests/frontend/travis/remote_runner.js b/tests/frontend/travis/remote_runner.js index 3fb98ccca..86273df98 100644 --- a/tests/frontend/travis/remote_runner.js +++ b/tests/frontend/travis/remote_runner.js @@ -40,13 +40,8 @@ var sauceTestWorker = async.queue(function (testSettings, callback) { // if stopSauce is called via timeout (in contrast to via getStatusInterval) than the log of up to the last // five seconds may not be available here. It's an error anyway, so don't care about it. - var testResult = knownConsoleText.replace(/\[red\]/g,'\x1B[31m').replace(/\[yellow\]/g,'\x1B[33m') - .replace(/\[green\]/g,'\x1B[32m').replace(/\[clear\]/g, '\x1B[39m'); - testResult = testResult.split("\\n").map(function(line){ - return "[" + testSettings.browserName + " " + testSettings.platform + (testSettings.version === "" ? '' : (" " + testSettings.version)) + "] " + line; - }).join("\n"); + printLog(logIndex); - console.log(testResult); if (timesup) { console.log("[" + testSettings.browserName + " " + testSettings.platform + (testSettings.version === "" ? '' : (" " + testSettings.version)) + "] \x1B[31mFAILED\x1B[39m allowed test duration exceeded"); } @@ -66,6 +61,8 @@ var sauceTestWorker = async.queue(function (testSettings, callback) { }, 870000); // travis timeout is 15 minutes, set this to a slightly lower value var knownConsoleText = ""; + // how many characters of the log have been sent to travis + let logIndex = 0; var getStatusInterval = setInterval(function(){ browser.eval("$('#console').text()", function(err, consoleText){ if(!consoleText || err){ @@ -83,9 +80,29 @@ var sauceTestWorker = async.queue(function (testSettings, callback) { } else { stopSauce(false); } + } else { + // not finished yet + printLog(logIndex); + logIndex = knownConsoleText.length; } }); }, 5000); + + /** + * Replaces color codes in the test runners log, appends + * browser name, platform etc. to every line and prints them. + * + * @param {number} index offset from where to start + */ + function printLog(index){ + let testResult = knownConsoleText.substring(index).replace(/\[red\]/g,'\x1B[31m').replace(/\[yellow\]/g,'\x1B[33m') + .replace(/\[green\]/g,'\x1B[32m').replace(/\[clear\]/g, '\x1B[39m'); + testResult = testResult.split("\\n").map(function(line){ + return "[" + testSettings.browserName + " " + testSettings.platform + (testSettings.version === "" ? '' : (" " + testSettings.version)) + "] " + line; + }).join("\n"); + + console.log(testResult); + } }); }, 6); //run 6 tests in parrallel diff --git a/tests/frontend/travis/runner.sh b/tests/frontend/travis/runner.sh index bbb4680d1..3dc372792 100755 --- a/tests/frontend/travis/runner.sh +++ b/tests/frontend/travis/runner.sh @@ -17,6 +17,7 @@ cd "${MY_DIR}/../../../" # a call to bin/installDeps.sh echo "Running Etherpad directly, assuming bin/installDeps.sh has already been run" node node_modules/ep_etherpad-lite/node/server.js --experimental-worker "${@}" & +ep_pid=$! echo "Now I will try for 15 seconds to connect to Etherpad on http://localhost:9001" @@ -44,5 +45,6 @@ node remote_runner.js exit_code=$? kill $(cat /tmp/sauce.pid) +kill $ep_pid exit $exit_code