Skip to content

Commit

Permalink
show docker logs in case of test failure
Browse files Browse the repository at this point in the history
Inspired by fabric8io-images#212 and found this very useful for fabric8io-images#213
  • Loading branch information
vorburger committed Jan 16, 2019
1 parent 6468352 commit 5ece25c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ function test_app() {
local http_port="$(docker port ${container_id} ${port}|sed 's/0.0.0.0://')"
local http_reply=$(curl --silent --show-error http://localhost:$http_port)

docker rm -f "$container_id"

if [ "$http_reply" = 'hello, world' ]; then
echo "APP TEST PASSED"
docker rm -f ${container_id}
return 0
else
echo "APP TEST FAILED"
docker logs ${container_id}
docker rm -f ${container_id}
return -123
fi
}
Expand All @@ -40,15 +41,16 @@ function test_metrics() {
local metrics_port="$(docker port ${container_id} ${port}|sed 's/0.0.0.0://')"
local metrics_reply=$(curl --silent --show-error http://localhost:$metrics_port/metrics)

docker rm -f "$container_id"

case $metrics_reply in
*"jvm_threads_current"*)
echo "METRICS TEST PASSED"
docker rm -f ${container_id}
return 0
;;
*)
echo "METRICS TEST FAILED"
docker logs ${container_id}
docker rm -f ${container_id}
return -123
;;
esac
Expand Down

0 comments on commit 5ece25c

Please sign in to comment.