@@ -35,19 +35,28 @@ sudo docker run \
3535 --detach \
3636 postgres:" ${POSTGRES_VERSION} " -alpine
3737
38+ check_database_readiness (){
39+ sudo docker exec dblab_pg_initdb psql -U postgres -c ' select' > /dev/null 2>&1
40+ return $?
41+ }
42+
3843for i in {1..300}; do
39- sudo docker exec dblab_pg_initdb psql -U postgres -c ' select ' > /dev/null 2>&1 && break || echo " test database is not ready yet"
44+ check_database_readiness && break || echo " test database is not ready yet"
4045 sleep 1
4146done
4247
48+ check_database_readiness || (echo " test database is not ready" && exit 1)
49+
4350# Restart container explicitly after initdb to make sure that the server will not receive a shutdown request and queries will not be interrupted.
4451sudo docker restart dblab_pg_initdb
4552
4653for i in {1..300}; do
47- sudo docker exec dblab_pg_initdb psql -U postgres -c ' select ' > /dev/null 2>&1 && break || echo " test database is not ready yet"
54+ check_database_readiness && break || echo " test database is not ready yet"
4855 sleep 1
4956done
5057
58+ check_database_readiness || (echo " test database is not ready" && exit 1)
59+
5160# Create the test database
5261sudo docker exec dblab_pg_initdb psql -U postgres -c ' create database test'
5362
@@ -109,12 +118,18 @@ sudo docker run \
109118# Check the Database Lab Engine logs
110119sudo docker logs ${DLE_SERVER_NAME} -f 2>&1 | awk ' {print "[CONTAINER ${DLE_SERVER_PORT}]: "$0}' &
111120
121+ check_dle_readiness (){
122+ curl http://localhost:${DLE_SERVER_PORT} > /dev/null 2>&1
123+ return $?
124+ }
125+
112126# ## Waiting for the Database Lab Engine initialization.
113127for i in {1..300}; do
114- curl http://localhost: ${DLE_SERVER_PORT} > /dev/null 2>&1 && break || echo " dblab is not ready yet"
128+ check_dle_readiness && break || echo " Database Lab Engine is not ready yet"
115129 sleep 1
116130done
117131
132+ check_dle_readiness || (echo " Database Lab Engine is not ready" && exit 1)
118133
119134# ## Step 3. Start cloning
120135
@@ -168,12 +183,14 @@ PGPASSWORD=secret_password psql \
168183# # Restart DLE.
169184sudo docker restart ${DLE_SERVER_NAME}
170185
171- # ## Waiting for the Database Lab Engine to start .
186+ # ## Waiting for the Database Lab Engine initialization .
172187for i in {1..300}; do
173- curl http://localhost: ${DLE_SERVER_PORT} > /dev/null 2>&1 && break || echo " dblab is not ready yet"
188+ check_dle_readiness && break || echo " Database Lab Engine is not ready yet"
174189 sleep 1
175190done
176191
192+ check_dle_readiness || (echo " Database Lab Engine is not ready" && exit 1)
193+
177194# # Reset clone.
178195dblab clone reset testclone
179196
0 commit comments