@@ -35,19 +35,28 @@ sudo docker run \
35
35
--detach \
36
36
postgres:" ${POSTGRES_VERSION} " -alpine
37
37
38
+ check_database_readiness (){
39
+ sudo docker exec dblab_pg_initdb psql -U postgres -c ' select' > /dev/null 2>&1
40
+ return $?
41
+ }
42
+
38
43
for 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"
40
45
sleep 1
41
46
done
42
47
48
+ check_database_readiness || (echo " test database is not ready" && exit 1)
49
+
43
50
# Restart container explicitly after initdb to make sure that the server will not receive a shutdown request and queries will not be interrupted.
44
51
sudo docker restart dblab_pg_initdb
45
52
46
53
for 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"
48
55
sleep 1
49
56
done
50
57
58
+ check_database_readiness || (echo " test database is not ready" && exit 1)
59
+
51
60
# Create the test database
52
61
sudo docker exec dblab_pg_initdb psql -U postgres -c ' create database test'
53
62
@@ -109,12 +118,18 @@ sudo docker run \
109
118
# Check the Database Lab Engine logs
110
119
sudo docker logs ${DLE_SERVER_NAME} -f 2>&1 | awk ' {print "[CONTAINER ${DLE_SERVER_PORT}]: "$0}' &
111
120
121
+ check_dle_readiness (){
122
+ curl http://localhost:${DLE_SERVER_PORT} > /dev/null 2>&1
123
+ return $?
124
+ }
125
+
112
126
# ## Waiting for the Database Lab Engine initialization.
113
127
for 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"
115
129
sleep 1
116
130
done
117
131
132
+ check_dle_readiness || (echo " Database Lab Engine is not ready" && exit 1)
118
133
119
134
# ## Step 3. Start cloning
120
135
@@ -168,12 +183,14 @@ PGPASSWORD=secret_password psql \
168
183
# # Restart DLE.
169
184
sudo docker restart ${DLE_SERVER_NAME}
170
185
171
- # ## Waiting for the Database Lab Engine to start .
186
+ # ## Waiting for the Database Lab Engine initialization .
172
187
for 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"
174
189
sleep 1
175
190
done
176
191
192
+ check_dle_readiness || (echo " Database Lab Engine is not ready" && exit 1)
193
+
177
194
# # Reset clone.
178
195
dblab clone reset testclone
179
196
0 commit comments