mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-22 05:50:47 +02:00
Poll for the database to be up before running tests
This commit is contained in:
parent
9f65d809da
commit
49bc3eb0cd
2 changed files with 19 additions and 1 deletions
|
@ -7,6 +7,12 @@ function cleanup() {
|
||||||
$docker_compose down
|
$docker_compose down
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function die() {
|
||||||
|
echo $@
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
export RAILS_ENV=test
|
export RAILS_ENV=test
|
||||||
|
@ -16,7 +22,7 @@ cp config/site.yml.tmpl config/site.yml
|
||||||
|
|
||||||
$docker_compose build
|
$docker_compose build
|
||||||
$docker_compose up -d
|
$docker_compose up -d
|
||||||
sleep 5 # janky way of waiting for the database to be up
|
script/poll-for-db
|
||||||
|
|
||||||
# Leaving this in since it will be needed for Rails 5
|
# Leaving this in since it will be needed for Rails 5
|
||||||
# bin/rails db:environment:set RAILS_ENV=test || true
|
# bin/rails db:environment:set RAILS_ENV=test || true
|
||||||
|
|
12
script/poll-for-db
Executable file
12
script/poll-for-db
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
appdir=$(cd $(dirname "$0")/.. && pwd)
|
||||||
|
[ -f /etc/app-env ] || exec "$appdir/script/docker-environment" $0 $@
|
||||||
|
|
||||||
|
for i in {1..60}; do
|
||||||
|
curl -sf db:3306 >/dev/null && exit
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Unable to reach database!"
|
||||||
|
exit 1
|
Loading…
Add table
Add a link
Reference in a new issue