From c18fdc37042dc7fb041475a524fe7abb0bd7afdc Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 13 Jan 2015 21:09:11 -0700 Subject: [PATCH] Properly fix "daemon kill" on test failure Signed-off-by: Andrew "Tianon" Page --- project/make/test-docker-py | 25 +++++++++++++++++-------- project/make/test-integration-cli | 18 ++++++++++++++---- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/project/make/test-docker-py b/project/make/test-docker-py index 6047eec1b9..104842a423 100644 --- a/project/make/test-docker-py +++ b/project/make/test-docker-py @@ -7,15 +7,24 @@ DEST=$1 ( source "$(dirname "$BASH_SOURCE")/.integration-daemon-start" - dockerPy='/docker-py' - [ -d "$dockerPy" ] || { - dockerPy="$DEST/docker-py" - git clone https://github.com/docker/docker-py.git "$dockerPy" - } + # we need to wrap up everything in between integration-daemon-start and + # integration-daemon-stop to make sure we kill the daemon and don't hang, + # even and especially on test failures + didFail= + if ! { + dockerPy='/docker-py' + [ -d "$dockerPy" ] || { + dockerPy="$DEST/docker-py" + git clone https://github.com/docker/docker-py.git "$dockerPy" + } - cd "$dockerPy" - export PYTHONPATH=. # import "docker" from "." - python tests/integration_test.py + export PYTHONPATH="$dockerPy" # import "docker" from our local docker-py + python "$dockerPy/tests/integration_test.py" + }; then + didFail=1 + fi source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop" + + [ -z "$didFail" ] # "set -e" ftw ) 2>&1 | tee -a $DEST/test.log diff --git a/project/make/test-integration-cli b/project/make/test-integration-cli index 0aaa298be9..5dc7c42976 100644 --- a/project/make/test-integration-cli +++ b/project/make/test-integration-cli @@ -11,12 +11,22 @@ bundle_test_integration_cli() { ( source "$(dirname "$BASH_SOURCE")/.integration-daemon-start" - # pull the busybox image before running the tests - sleep 2 + # we need to wrap up everything in between integration-daemon-start and + # integration-daemon-stop to make sure we kill the daemon and don't hang, + # even and especially on test failures + didFail= + if ! { + # pull the busybox image before running the tests + sleep 2 - source "$(dirname "$BASH_SOURCE")/.ensure-busybox" + source "$(dirname "$BASH_SOURCE")/.ensure-busybox" - bundle_test_integration_cli + bundle_test_integration_cli + }; then + didFail=1 + fi source "$(dirname "$BASH_SOURCE")/.integration-daemon-stop" + + [ -z "$didFail" ] # "set -e" ftw ) 2>&1 | tee -a $DEST/test.log