Wating the AnkiConnect to be up to run the tests.
This commit is contained in:
parent
1642c48f0c
commit
a9dcea9674
@ -11,5 +11,5 @@ install:
|
|||||||
- docker build -f tests/docker/Dockerfile -t txgio/anki-connect .
|
- docker build -f tests/docker/Dockerfile -t txgio/anki-connect .
|
||||||
script:
|
script:
|
||||||
- docker run -ti -d --rm -p 8888:8765 -e ANKICONNECT_BIND_ADDRESS=0.0.0.0 txgio/anki-connect
|
- docker run -ti -d --rm -p 8888:8765 -e ANKICONNECT_BIND_ADDRESS=0.0.0.0 txgio/anki-connect
|
||||||
- sleep 5
|
- ./tests/scripts/wait-up.sh http://docker:8888
|
||||||
- python -m unittest discover -s tests
|
- python -m unittest discover -s tests -v
|
28
tests/scripts/wait-up.sh
Executable file
28
tests/scripts/wait-up.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
printf "First parameter URL required.\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
COUNTER=0
|
||||||
|
STEP_SIZE=1
|
||||||
|
MAX_SECONDS=${2:-10} # Wait 10 seconds if parameter not provided
|
||||||
|
MAX_RETRIES=$(( $MAX_SECONDS / $STEP_SIZE))
|
||||||
|
|
||||||
|
URL=$1
|
||||||
|
|
||||||
|
printf "Waiting URL: "$URL"\n"
|
||||||
|
|
||||||
|
until $(curl --insecure --output /dev/null --silent --fail $URL) || [ $COUNTER -eq $MAX_RETRIES ]; do
|
||||||
|
printf '.'
|
||||||
|
sleep $STEP_SIZE
|
||||||
|
COUNTER=$(($COUNTER + 1))
|
||||||
|
done
|
||||||
|
if [ $COUNTER -eq $MAX_RETRIES ]; then
|
||||||
|
printf "\nTimeout after "$(( $COUNTER * $STEP_SIZE))" second(s).\n"
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
|
printf "\nUp successfully after "$(( $COUNTER * $STEP_SIZE))" second(s).\n"
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user