cloudron-e2e-test/parallel_test.sh
Girish Ramakrishnan bf1dbfe84b Test ams3 updates
2016-04-01 21:43:51 -07:00

70 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -eu
export DEBUG=superagent-sync,e2e:*
export DEBUG_COLORS=true
test_pids=()
test_logs=()
# before
rm -f logs/*
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"
exit 1
fi
# run tests
readonly tests=(app-flow-test cloudron-user-test new-user-test cloudron-backup-test custom-domain-test cloudron-update-sfo1-test cloudron-update-ams3-test)
for t in "${tests[@]}"; do
./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")
done
# stream all the logs (to stderr so that it's not in email but in deploy logs)
sleep 10 # wait for cloudron-update-test.log to get created (since it's a background subshell)
tail -f ${test_logs[*]} >&2 &
tail_pid=$!
# wait for tests to finish
fail=0
echo "Waiting for jobs to finish"
for pid in "${test_pids[@]}"; do
if ! wait $pid; then
let "fail+=1"
echo "$pid failed"
fi
done
kill -9 "${tail_pid}"
# 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
echo
echo
for log_file in "${test_logs[@]}"; do
echo "=========== ${log_file} =============="
cat "${log_file}"
echo
echo
done
if [ "$fail" == "0" ]; then
exit 0
else
echo "Fail count: ${fail}"
exit 1
fi