Skip to content

Commit

Permalink
Merge pull request #215 from vorburger/docker-logs
Browse files Browse the repository at this point in the history
show docker logs in case of test failure
  • Loading branch information
rhuss authored Jan 16, 2019
2 parents 11edaf0 + 5ece25c commit 41cf3ea
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 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 All @@ -75,7 +77,7 @@ function test_entrypoint() {
echo "APP TEST FAILED (with entrypoint ${entrypoint})"
docker logs ${container_id}
docker rm -f ${container_id}
return -123
return -123
fi
}

Expand Down Expand Up @@ -137,18 +139,18 @@ function test_image() {

test_container "${name}-binary-example"


# ----------------------------------------------------------------------------------
# Maven Wrapper
# ----------------------------------------------------------------------------------

s2i build --copy java/examples/maven-wrapper ${name} ${name}-maven-wrapper-example
s2i build --copy java/examples/maven-wrapper ${name} ${name}-maven-wrapper-example --incremental


# ----------------------------------------------------------------------------------
# Entrypoint Binary
# ----------------------------------------------------------------------------------
local dir=$1
local name=$2

curl https://repo.spring.io/release/org/springframework/cloud/spring-cloud-deployer-spi-test-app/1.3.4.RELEASE/spring-cloud-deployer-spi-test-app-1.3.4.RELEASE-exec.jar \
-o java/examples/binary/deployments/app.jar
Expand All @@ -159,7 +161,6 @@ function test_image() {
test_entrypoint "${name}-entrypoint-binary-example" "java -jar /deployments/app.jar" # works
test_entrypoint "${name}-entrypoint-binary-example" /opt/run-java/run-java.sh # will fail until https://github.com/fabric8io-images/run-java-sh/issues/75 is fixed
test_entrypoint "${name}-entrypoint-binary-example" /usr/local/s2i/run # will fail until https://github.com/fabric8io-images/run-java-sh/issues/75 is fixed

}

# ==================================================================================
Expand Down

0 comments on commit 41cf3ea

Please sign in to comment.