dump all logs in single dir and send it as attachment

This commit is contained in:
Girish Ramakrishnan 2016-09-21 10:39:09 -07:00
parent 2be8b6fb41
commit 2ceda75d5d
2 changed files with 6 additions and 12 deletions

View File

@ -5,18 +5,17 @@
require('supererror')({ splatchError: true });
var debug = require('debug')('e2e:runner'),
shell = require('./shell.js'),
semver = require('semver'),
mailer = require('./mailer.js'),
mkdirp = require('mkdirp'),
path = require('path'),
rimraf = require('rimraf'),
semver = require('semver'),
shell = require('./shell.js'),
superagent = require('superagent'),
terminate = require('terminate'),
util = require('util'),
_ = require('underscore');
var LOG_FILE_DIR = '/tmp/testlog/';
// override debug.log to print only as console.log
debug.log = console.log.bind(console);
@ -84,19 +83,14 @@ function getLatestBoxVersion(callback) {
function runTests(latestVersionInfo, callback) {
debug('Running tests for %j', latestVersionInfo);
// The selfhosting tests use a logfile for cli tool output, to avoid spamming the test results with script output
// These will be stored in /tmp/testlog/<testfilename>.log
rimraf.sync(LOG_FILE_DIR);
mkdirp.sync(LOG_FILE_DIR);
gNpmTest = shell.system('e2etestrunner', 'LOG_FILE_DIR=' + LOG_FILE_DIR + ' BOX_VERSION=' + latestVersionInfo.version + ' npm run-script parallel_test', function (error, stdout, stderr) {
gNpmTest = shell.system('e2etestrunner', 'BOX_VERSION=' + latestVersionInfo.version + ' npm run-script parallel_test', function (error, stdout, stderr) {
gNpmTest = null;
debug('Final test result', error);
var topic = util.format('E2E Test %s for box version: %s', error ? 'failed': 'passed', latestVersionInfo.version);
// do not send stderr in mail since it contains the tail log stream
mailer.sendEndToEndTestResult(topic, JSON.stringify(latestVersionInfo, null, 4), stdout ? stdout.toString('utf8') : '', '', LOG_FILE_DIR, function () { });
mailer.sendEndToEndTestResult(topic, JSON.stringify(latestVersionInfo, null, 4), stdout ? stdout.toString('utf8') : '', '', path.join(__dirname, 'logs'), function (error) { if (error) console.log(error); });
return callback(error);
});
}

View File

@ -20,7 +20,7 @@ fi
# readonly tests=(app-flow-test app-update-test alt-domain-test cloudron-button-test cloudron-user-test new-user-test cloudron-backup-test cloudron-migrate-test cloudron-autoupdate-sfo1-test cloudron-update-ams3-test selfhost-ec2-test selfhost-digitalocean-test)
readonly tests=(app-flow-test app-update-test alt-domain-test cloudron-button-test cloudron-user-test new-user-test cloudron-backup-test cloudron-migrate-test cloudron-autoupdate-sfo1-test cloudron-update-ams3-test)
for t in "${tests[@]}"; do
EXEC_LOG_FILE="${LOG_FILE_DIR}/${t}.log" ./node_modules/.bin/mocha --bail "test/${t}.js" > "logs/${t}.log" 2>&1 &
EXEC_LOG_FILE="logs/${t}-cloudron-cli.log" ./node_modules/.bin/mocha --bail "test/${t}.js" > "logs/${t}.log" 2>&1 &
test_pids+=("$!")
echo "Starting test ${t} with pid ${test_pids[-1]}"
test_logs+=("logs/${t}.log")