complement/cmd/homerunner/test/test.sh
kegsay 51b49035f6
Add homerunner integration tests (#408)
* Add homerunner integration tests

Uses homerunner-client which also serves to make sure the client works.

* Be in the right working directory

* Again with the working directories

* Poll a non-existent endpoint to 404 rather than sleeping for an arbitrary amount of time; more robust on slow GHA boxes

* Use env vars

* Purposefully break the test to ensure things fail

* Fix test

* Update cmd/homerunner/test/test.mjs

Co-authored-by: Will Hunt <will@half-shot.uk>

Co-authored-by: Will Hunt <will@half-shot.uk>
2022-07-11 12:18:41 +01:00

26 lines
613 B
Bash
Executable file

#!/bin/bash -eu
export HOMERUNNER_PORT=5544
export HOMERUNNER_SPAWN_HS_TIMEOUT_SECS=30
# build and run homerunner
go build ..
echo 'Running homerunner'
./homerunner &
HOMERUNNER_PID=$!
# knife homerunner when this script finishes
trap "kill $HOMERUNNER_PID" EXIT
# wait for homerunner to be listening, we want this endpoint to 404 instead of connrefused
until [ \
"$(curl -s -w '%{http_code}' -o /dev/null "http://localhost:${HOMERUNNER_PORT}/idonotexist")" \
-eq 404 ]
do
echo 'Waiting for homerunner to start...'
sleep 1
done
# build and run the test
echo 'Running tests'
yarn install
node test.mjs