-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·58 lines (48 loc) · 1.59 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·58 lines (48 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
run_dir="$(mktemp -d)"
berghain_pid=""
haproxy_pid=""
cleanup() {
status=$?
trap - EXIT
[[ -z "$haproxy_pid" ]] || kill "$haproxy_pid" 2>/dev/null || true
[[ -z "$berghain_pid" ]] || kill "$berghain_pid" 2>/dev/null || true
[[ -z "$haproxy_pid" ]] || wait "$haproxy_pid" 2>/dev/null || true
[[ -z "$berghain_pid" ]] || wait "$berghain_pid" 2>/dev/null || true
if [[ $status -ne 0 ]]; then
printf '\nBerghain log:\n' >&2
cat "$run_dir/berghain.log" >&2 2>/dev/null || true
printf '\nHAProxy log:\n' >&2
cat "$run_dir/haproxy.log" >&2 2>/dev/null || true
fi
rm -rf "$run_dir"
exit "$status"
}
trap cleanup EXIT
cd "$repo_root"
go build -o "$run_dir/berghain" ./cmd/spop
"$run_dir/berghain" -config test/e2e/spop.yaml >"$run_dir/berghain.log" 2>&1 &
berghain_pid=$!
haproxy -db -f test/e2e/haproxy.cfg >"$run_dir/haproxy.log" 2>&1 &
haproxy_pid=$!
for port in 18080 18081; do
ready=""
for _ in $(seq 1 30); do
status="$(curl --max-time 1 --silent --output /dev/null --write-out '%{http_code}' "http://localhost:$port/" || true)"
if [[ $status == 403 ]]; then
ready=1
break
fi
sleep 1
done
if [[ -z "$ready" ]]; then
echo "E2E stack did not serve the challenge page on port $port" >&2
exit 1
fi
done
export BERGHAIN_E2E_BASE_URL=http://localhost:18080
export BERGHAIN_E2E_TURNSTILE_URL=http://localhost:18081
cd test/e2e
go test -count=1 -tags=e2e -v .