From 60b0e8da5cefa4221a97c8659c5b9aaa375716a4 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Tue, 2 Jul 2019 16:51:42 +0800 Subject: [PATCH] Wait for Postgres to be running before starting the unit tests Fixes #1314 Signed-off-by: Chenxiong Qi --- contrib/run-unittests.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/run-unittests.sh b/contrib/run-unittests.sh index 10fa48d2..641ae7e8 100755 --- a/contrib/run-unittests.sh +++ b/contrib/run-unittests.sh @@ -64,6 +64,15 @@ if [ -n "$with_pgsql" ]; then -d \ $postgres_image ) + + # Waiting for postgres container to start completely in case tests start too fast. + while true + do + docker exec $db_bg_container psql -U postgres -c '\dp' $db_name >/dev/null 2>&1 + if [ $? == 0 ]; then + break + fi + done fi (cd "$source_dir" && docker run "${container_opts[@]}" $test_image "$@")