cloudron-e2e-test/parallel_test.sh

70 lines
1.6 KiB
Bash
Raw Normal View History

2015-11-14 03:59:43 +00:00
#!/bin/bash
set -eu
2016-06-23 19:57:51 +00:00
export DEBUG=superagent-sync,e2e:*,imap-probe
2015-11-14 03:59:43 +00:00
export DEBUG_COLORS=true
2015-11-19 16:55:21 +00:00
test_pids=()
test_logs=()
2015-11-14 03:59:43 +00:00
2016-04-02 04:11:58 +00:00
# before
2015-11-14 03:59:43 +00:00
rm -f logs/*
2016-04-02 04:11:58 +00:00
echo "Before"
if ! ./node_modules/.bin/mocha --bail test/before.js > "logs/before.log" 2>&1; then
echo "Before script failed"
cat "logs/before.log"
2016-01-14 21:47:35 +00:00
exit 1
fi
2015-11-14 03:59:43 +00:00
# run tests
2016-09-09 08:04:38 +00:00
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)
2015-11-14 03:59:43 +00:00
for t in "${tests[@]}"; do
2016-01-27 16:42:51 +00:00
./node_modules/.bin/mocha --bail "test/${t}.js" > "logs/${t}.log" 2>&1 &
2015-11-19 16:55:21 +00:00
test_pids+=("$!")
2016-01-26 21:38:41 +00:00
echo "Starting test ${t} with pid ${test_pids[-1]}"
2015-11-19 16:55:21 +00:00
test_logs+=("logs/${t}.log")
2015-11-14 03:59:43 +00:00
done
2015-11-19 21:49:13 +00:00
# stream all the logs (to stderr so that it's not in email but in deploy logs)
2016-01-27 01:50:32 +00:00
sleep 10 # wait for cloudron-update-test.log to get created (since it's a background subshell)
2015-11-19 21:49:13 +00:00
tail -f ${test_logs[*]} >&2 &
2015-11-19 23:10:05 +00:00
tail_pid=$!
2015-11-14 04:32:02 +00:00
2015-11-14 03:59:43 +00:00
# wait for tests to finish
fail=0
echo "Waiting for jobs to finish"
2015-11-19 16:55:21 +00:00
for pid in "${test_pids[@]}"; do
2016-01-26 21:38:41 +00:00
if ! wait $pid; then
let "fail+=1"
echo "$pid failed"
fi
2015-11-14 03:59:43 +00:00
done
2015-11-19 23:10:05 +00:00
kill -9 "${tail_pid}"
2016-04-02 04:11:58 +00:00
# after
echo "After"
if ! ./node_modules/.bin/mocha --bail test/after.js > "logs/after.js" 2>&1; then
echo "After script failed"
cat "logs/after.log"
fi
# dump logs for email
2015-11-14 03:59:43 +00:00
echo
echo
2016-02-03 17:22:58 +00:00
for log_file in "${test_logs[@]}"; do
2016-03-28 18:54:08 +00:00
echo "=========== ${log_file} =============="
2016-02-03 17:22:58 +00:00
cat "${log_file}"
2015-11-14 03:59:43 +00:00
echo
echo
done
if [ "$fail" == "0" ]; then
exit 0
else
echo "Fail count: ${fail}"
exit 1
fi