@cryptotaxi247 / kubo / commits / b2da27547

sharness/lib: fix daemon startup check

Go back to test_run_repeat_10_sec to make sure the API is there. I think this is also clearer on the reader.

Juan Batiz-Benet committed Feb 1, 2015 at 20:53 UTC b2da275475ee804dd39f6983379bf0a6dba84f2d
1 file changed +7 -23
test/sharness/lib/test-lib.sh
+7 -23
@@ -142,10 +142,10 @@ test_init_ipfs() {
142 }
143
144 test_config_ipfs_gateway_readonly() {
145 - GWAY_ADDR=$1
145 + ADDR_GWAY=$1
146 test_expect_success "prepare config -- gateway address" '
147 - test "$GWAY_ADDR" != "" &&
148 - test_config_set "Addresses.Gateway" "$GWAY_ADDR"
147 + test "$ADDR_GWAY" != "" &&
148 + test_config_set "Addresses.Gateway" "$ADDR_GWAY"
149 '
150
151 # tell the user what's going on if they messed up the call.
@@ -168,38 +168,22 @@ test_config_ipfs_gateway_writable() {
168
169 test_launch_ipfs_daemon() {
170
171 - ADDR_API="/ip4/127.0.0.1/tcp/5001"
172 - NLINES="2"
173 -
174 - # ADDR_GWAY will be set if the test_config_ipfs_gateway_* funcs were called.
175 - if test "$ADDR_GWAY" != ""; then
176 - NLINES="3"
177 - fi
178 -
171 test_expect_success "'ipfs daemon' succeeds" '
172 ipfs daemon >actual_daemon 2>daemon_err &
173 '
174
175 # we say the daemon is ready when the API server is ready.
184 - # and we make sure there are no errors
176 + ADDR_API="/ip4/127.0.0.1/tcp/5001"
177 test_expect_success "'ipfs daemon' is ready" '
178 IPFS_PID=$! &&
187 - test_wait_output_n_lines_60_sec actual_daemon $NLINES ||
179 + test_wait_output_n_lines_60_sec actual_daemon 2 &&
180 + test_run_repeat_10_sec "cat actual_daemon | grep \"API server listening on $ADDR_API\"" ||
181 fsh cat actual_daemon || fsh cat daemon_err
182 '
183
191 - test_expect_success "'ipfs daemon' output includes API address" '
192 - cat actual_daemon | grep "API server listening on $ADDR_API" ||
193 - fsh cat actual_daemon ||
194 - fsh "cat actual_daemon | grep \"API server listening on $ADDR_API\"" ||
195 - fsh cat daemon_err
196 - '
197 -
184 if test "$ADDR_GWAY" != ""; then
185 test_expect_success "'ipfs daemon' output includes Gateway address" '
200 - cat actual_daemon | grep "Gateway server listening on $ADDR_GWAY" ||
201 - fsh cat actual_daemon ||
202 - fsh "cat actual_daemon | grep \"Gateway server listening on $ADDR_GWAY\"" ||
186 + test_run_repeat_10_sec "cat actual_daemon | grep \"Gateway server listening on $ADDR_GWAY\"" ||
187 fsh cat daemon_err
188 '
189 fi