2022-07-25 17:51:26 +01:00
|
|
|
#!/bin/bash -eu
|
|
|
|
export SYNCV3_BINDADDR=0.0.0.0:8844
|
2022-12-14 18:53:55 +00:00
|
|
|
export SYNCV3_ADDR='http://localhost:8844'
|
2022-08-16 11:04:23 +01:00
|
|
|
export SYNCV3_DEBUG=1
|
2022-07-25 17:51:26 +01:00
|
|
|
|
|
|
|
# Run the binary and stop it afterwards.
|
2023-03-16 14:57:41 +00:00
|
|
|
# Direct stderr into stdout, and optionally redirect both to a file.
|
|
|
|
../syncv3 &> "${E2E_TEST_SERVER_STDOUT:-/dev/stdout}" &
|
2022-07-25 17:51:26 +01:00
|
|
|
SYNCV3_PID=$!
|
|
|
|
trap "kill $SYNCV3_PID" EXIT
|
|
|
|
|
|
|
|
# wait for the server to be listening, we want this endpoint to 404 instead of connrefused
|
2023-09-20 11:12:23 +01:00
|
|
|
attempts=0
|
2022-07-25 17:51:26 +01:00
|
|
|
until [ \
|
|
|
|
"$(curl -s -w '%{http_code}' -o /dev/null "http://localhost:8844/idonotexist")" \
|
|
|
|
-eq 404 ]
|
|
|
|
do
|
2023-09-20 11:12:23 +01:00
|
|
|
if [ "$attempts" -gt 60 ]; then
|
2023-09-20 11:24:06 +01:00
|
|
|
echo "Server did not start after $attempts seconds"
|
2023-09-20 11:12:23 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2023-09-20 11:24:06 +01:00
|
|
|
echo "Waiting (total ${attempts}s) for server to start..."
|
2022-07-25 17:51:26 +01:00
|
|
|
sleep 1
|
2023-09-20 11:53:20 +01:00
|
|
|
attempts=$((attempts+1))
|
2022-07-25 17:51:26 +01:00
|
|
|
done
|
|
|
|
|
2022-07-29 16:04:12 +01:00
|
|
|
go test "$@"
|