diff --git a/private b/private index 3571adfd3f..1deed37471 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit 3571adfd3f2aa6a84ac9c6c2ca4a2fe4ec549a62 +Subproject commit 1deed37471dd6246fdec023fb388b082d44a5648 diff --git a/script/ci/init.sh b/script/ci/init.sh index 137b1155e7..fded42c2eb 100755 --- a/script/ci/init.sh +++ b/script/ci/init.sh @@ -1,9 +1,26 @@ #!/bin/bash +set -e + +DB_IP=${DB_IP:-localhost} +TIMEOUT_CONN=${TIMEOUT_CONN:-120} +MAX_RETRIES=${MAX_RETRIES:-10} +SLEEP_RETRY=$((TIMEOUT_CONN/MAX_RETRIES)) +SLEEP_DEBUGING=${SLEEP_DEBUGING:-120} + cd /cartodb mkdir -p log && chmod -R 777 log/ -createdb -T template0 -O postgres -h localhost -U postgres -E UTF8 template_postgis || true -psql -h localhost -U postgres template_postgis -c 'CREATE EXTENSION IF NOT EXISTS postgis;CREATE EXTENSION IF NOT EXISTS postgis_topology;' -REDIS_PORT=6335 RAILS_ENV=test bundle exec rake cartodb:test:prepare -cd - + +echo "Waiting for the database to be ready. Retrying every $SLEEP_RETRY seconds until it reaches a total of $MAX_RETRIES retries" +n=0 +until [[ $n -eq $MAX_RETRIES ]]; do + echo "Try $((n+1))..." + pg_isready -U postgres -h "$DB_IP" && break + n=$((n+1)) + sleep "$SLEEP_RETRY" +done + +createdb -T template0 -O postgres -h "${DB_IP}" -U postgres -E UTF8 template_postgis || true +psql -h "${DB_IP}" -U postgres -d template_postgis -c 'CREATE EXTENSION IF NOT EXISTS postgis;CREATE EXTENSION IF NOT EXISTS postgis_topology;CREATE EXTENSION IF NOT EXISTS postgis_raster;' +RAILS_ENV=test bundle exec rake cartodb:test:prepare