cloudron-e2e-test/parallel_test.sh

69 lines
1.6 KiB
Bash
Raw Normal View History

2015-11-14 03:59:43 +00:00
#!/bin/bash
set -eu
export DEBUG=superagent-sync,e2e:*
export DEBUG_COLORS=true
2015-11-19 16:55:21 +00:00
test_pids=()
test_logs=()
2015-11-14 03:59:43 +00:00
# cleanup
rm -f logs/*
echo "Cleaning up"
2016-01-27 16:42:51 +00:00
if ! ./node_modules/.bin/mocha --bail test/000-cleanup.js > "logs/000-cleanup.log" 2>&1; then
2016-01-14 21:47:35 +00:00
echo "Cleanup script failed"
cat "logs/000-cleanup.log"
exit 1
fi
2015-11-14 03:59:43 +00:00
# run tests
2016-02-03 17:22:58 +00:00
readonly tests=(app-flow-test cloudron-user-test new-user-test cloudron-backup-test custom-domain-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-14 04:32:02 +00:00
# update test modifies release file, so run it separately
sleep 20 # wait for the other tests to have created the cloudron
2016-01-27 16:42:51 +00:00
./node_modules/.bin/mocha --bail "test/cloudron-update-test.js" > "logs/cloudron-update-test.log" 2>&1 &
2015-11-19 16:55:21 +00:00
test_pids+=("$!")
2016-01-26 22:42:17 +00:00
echo "Starting test cloudron-update-test with pid ${test_pids[-1]}"
2015-11-19 16:55:21 +00:00
test_logs+=("logs/cloudron-update-test.log")
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}"
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