@@ -327,13 +327,15 @@ wait_for_ready "/ping"
327327curl -s -k -X POST -d " banana" https://localhost:8443/ping > /dev/null
328328
329329# There should be 3 lines, the "listening on...", the /ping ready test, and the /ping POST test.
330- if [[ " $( docker logs http-echo-tests | wc -l) " == 3 ]] && \
331- ! docker logs http-echo-tests | grep -q banana
330+ LOG_OUTPUT=" $( docker logs http-echo-tests 2>&1 ) "
331+ LINE_COUNT=$(( $(wc - l <<< "$LOG_OUTPUT ") ))
332+ if [[ " $LINE_COUNT " == 3 ]] && \
333+ ! grep -q banana <<< " $LOG_OUTPUT"
332334then
333335 passed " LOG_IGNORE_PATH ignored the /ping path"
334336else
335337 failed " LOG_IGNORE_PATH failed"
336- docker logs http- echo-tests
338+ echo " $LOG_OUTPUT "
337339 exit 1
338340fi
339341
@@ -347,25 +349,28 @@ wait_for_ready "/health"
347349curl -s -k -X POST -d " banana" https://localhost:8443/metrics > /dev/null
348350
349351# There should be 3 lines, the "listening on...", the /health ready test, and the /metrics POST test.
350- if [[ " $( docker logs http-echo-tests | wc -l) " == 3 ]] && \
351- ! docker logs http-echo-tests | grep -q banana
352+ LOG_OUTPUT=" $( docker logs http-echo-tests 2>&1 ) "
353+ LINE_COUNT=$(( $(wc - l <<< "$LOG_OUTPUT ") ))
354+ if [[ " $LINE_COUNT " == 3 ]] && \
355+ ! grep -q banana <<< " $LOG_OUTPUT"
352356then
353357 passed " LOG_IGNORE_PATH ignored the /metrics path"
354358else
355359 failed " LOG_IGNORE_PATH failed"
356- docker logs http- echo-tests
360+ echo " $LOG_OUTPUT "
357361 exit 1
358362fi
359363
360364# Test a positive case where the path is not ignored
361365curl -s -k -X POST -d " strawberry" https://localhost:8443/veryvisible > /dev/null
362366
363- if docker logs http-echo-tests | grep -q strawberry
367+ LOG_OUTPUT=" $( docker logs http-echo-tests 2>&1 ) "
368+ if grep -q strawberry <<< " $LOG_OUTPUT"
364369then
365370 passed " LOG_IGNORE_PATH didn't ignore the /veryvisible path"
366371else
367372 failed " LOG_IGNORE_PATH failed, it should not ignore the /veryvisible path"
368- docker logs http- echo-tests
373+ echo " $LOG_OUTPUT "
369374 exit 1
370375fi
371376
@@ -380,13 +385,15 @@ wait_for_ready "/hello"
380385curl -s -k -X POST -d " banana" https://localhost:8443/ > /dev/null
381386
382387# There should be 3 lines, the "listening on", the "/hello" ready test, and the POST banana test.
383- if [[ " $( docker logs http-echo-tests | wc -l) " == 3 ]] && \
384- ! docker logs http-echo-tests | grep -q banana
388+ LOG_OUTPUT=" $( docker logs http-echo-tests 2>&1 ) "
389+ LINE_COUNT=$(( $(wc - l <<< "$LOG_OUTPUT ") ))
390+ if [[ " $LINE_COUNT " == 3 ]] && \
391+ ! grep -q banana <<< " $LOG_OUTPUT"
385392then
386393 passed " LOG_IGNORE_PATH ignored all paths"
387394else
388395 failed " LOG_IGNORE_PATH failed"
389- docker logs http- echo-tests
396+ echo " $LOG_OUTPUT "
390397 exit 1
391398fi
392399
@@ -399,12 +406,13 @@ docker run -d --rm -e DISABLE_REQUEST_LOGS=true --name http-echo-tests -p 8080:8
399406wait_for_ready " /healthy"
400407
401408curl -s -k -X GET https://localhost:8443/strawberry > /dev/null
402- if [[ " $( docker logs http-echo-tests | grep -c " GET /strawberry HTTP/1.1" ) " -eq 0 ]]
409+ LOG_OUTPUT=" $( docker logs http-echo-tests 2>&1 ) "
410+ if [[ " $( grep -c " GET /strawberry HTTP/1.1" <<< " $LOG_OUTPUT" ) " -eq 0 ]]
403411then
404412 passed " DISABLE_REQUEST_LOGS disabled Express HTTP logging"
405413else
406414 failed " DISABLE_REQUEST_LOGS failed"
407- docker logs http- echo-tests
415+ echo " $LOG_OUTPUT "
408416 exit 1
409417fi
410418
@@ -439,13 +447,15 @@ wait_for_ready
439447curl -s -k -X POST -d " tiramisu" https://localhost:8443/ > /dev/null
440448
441449# There will be 4 lines, the Listening on, the / ready test and response, the POST test and response
442- if [[ " $( docker logs http-echo-tests | wc -l) " == 5 ]] && \
443- docker logs http-echo-tests | grep -q tiramisu
450+ LOG_OUTPUT=" $( docker logs http-echo-tests 2>&1 ) "
451+ LINE_COUNT=$(( $(wc - l <<< "$LOG_OUTPUT ") ))
452+ if [[ " $LINE_COUNT " == 5 ]] && \
453+ grep -q tiramisu <<< " $LOG_OUTPUT"
444454then
445455 passed " LOG_WITHOUT_NEWLINE logged output in single line"
446456else
447457 failed " LOG_WITHOUT_NEWLINE failed"
448- docker logs http- echo-tests
458+ echo " $LOG_OUTPUT "
449459 exit 1
450460fi
451461
0 commit comments