Fix postgres CI test

This commit is contained in:
Sida Chen 2019-03-11 11:25:35 -04:00
parent da7413a92e
commit 8e830c0bff

View file

@ -12,6 +12,7 @@ IMAGE_TAR="${CACHE_DIR}/${IMAGE}-${IMAGE_TAG}.tar.gz"
MYSQL_IMAGE="mysql:5.7" MYSQL_IMAGE="mysql:5.7"
POSTGRES_IMAGE="postgres:9.6" POSTGRES_IMAGE="postgres:9.6"
POSTGRES_CONTAINER="test_postgres"
export MYSQL_ROOT_PASSWORD="quay" export MYSQL_ROOT_PASSWORD="quay"
export MYSQL_USER="quay" export MYSQL_USER="quay"
@ -110,13 +111,18 @@ postgres_ping() {
postgres_start() { postgres_start() {
docker run --net=host -d -e POSTGRES_USER -e POSTGRES_PASSWORD \ docker run --name="${POSTGRES_CONTAINER}" --net=host -d -e POSTGRES_USER -e POSTGRES_PASSWORD \
-e POSTGRES_DB "${POSTGRES_IMAGE}" -e POSTGRES_DB "${POSTGRES_IMAGE}"
if ! (sleep 10 && postgres_ping); then if ! (sleep 10 && postgres_ping); then
echo "PostgreSQL failed to respond in time." echo "PostgreSQL failed to respond in time."
exit 1 exit 1
fi fi
}
postgres_init() {
docker exec "${POSTGRES_CONTAINER}" psql -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" -c 'CREATE EXTENSION IF NOT EXISTS pg_trgm;'
} }
@ -129,6 +135,7 @@ postgres() {
load_image load_image
postgres_start postgres_start
postgres_init
quay_run make full-db-test quay_run make full-db-test
} }