tests: hold off until daemon is available
The postgresql container initializes DB files e.a. in these tests, this can take a couple of seconds. Try contacting it for up to 20 seconds, and only then run the tests: create a table, store something in it and retrieve it again.
This commit is contained in:
parent
f3e435ec35
commit
fcb7466f35
1 changed files with 20 additions and 8 deletions
|
|
@ -43,11 +43,23 @@ test:
|
|||
done
|
||||
test "$up" -ne 0
|
||||
testhost:
|
||||
selfcheck:
|
||||
- 'env PGPASSWORD=mtftest psql -h localhost -U mtftest -f test.sql | egrep "anything|something"'
|
||||
#- 'echo errr | nc localhost 11211'
|
||||
#- 'echo set AAA 0 4 2 | nc localhost 11211'
|
||||
#- 'echo get AAA | nc localhost 11211'
|
||||
#selcheckError:
|
||||
#- 'echo errr | nc localhost 11211 |grep ERROR'
|
||||
|
||||
db_usable:
|
||||
- |
|
||||
export PGPASSWORD=mtftest
|
||||
PSQL="psql -h localhost -U mtftest -q"
|
||||
up=0
|
||||
for i in `seq 20`; do
|
||||
echo "Pinging PostgreSQL ($i)"
|
||||
if $PSQL -c "" >&/dev/null; then
|
||||
up=1
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
if [ "$up" -eq 1 ]; then
|
||||
$PSQL -f test.sql | egrep "anything|something"
|
||||
else
|
||||
echo "Unable to connect to database." >&2
|
||||
false
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue