From 5eebd0be159aceb19b83dace91efb40cfa8caad4 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Thu, 19 Nov 2015 10:16:39 +0100 Subject: [PATCH 1/2] Cleaning up a few thing in the ITs script Signed-off-by: David Gageot --- test/integration/run-bats.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/test/integration/run-bats.sh b/test/integration/run-bats.sh index 6903069ac7..0d91c11e21 100755 --- a/test/integration/run-bats.sh +++ b/test/integration/run-bats.sh @@ -19,6 +19,12 @@ function cleanup_machines() { fi } +function cleanup_store() { + if [[ -d "$MACHINE_STORAGE_PATH" ]]; then + rm -r "$MACHINE_STORAGE_PATH" + fi +} + function machine() { export PATH="$MACHINE_ROOT"/bin:$PATH "$MACHINE_ROOT"/bin/"$MACHINE_BIN_NAME" "$@" @@ -30,13 +36,15 @@ function run_bats() { # BATS returns non-zero to indicate the tests have failed, we shouldn't # neccesarily bail in this case, so that's the reason for the e toggle. - set +e echo "=> $bats_file" + + set +e bats "$bats_file" if [[ $? -ne 0 ]]; then EXIT_STATUS=1 fi set -e + echo cleanup_machines done @@ -67,28 +75,23 @@ export MACHINE_ROOT="$BASE_TEST_DIR/../.." export MACHINE_STORAGE_PATH="/tmp/machine-bats-test-$DRIVER" export MACHINE_BIN_NAME=docker-machine export BATS_LOG="$MACHINE_ROOT/bats.log" -B2D_LOCATION=~/.docker/machine/cache/boot2docker.iso +export B2D_LOCATION=~/.docker/machine/cache/boot2docker.iso # This function gets used in the integration tests, so export it. export -f machine -touch "$BATS_LOG" -rm "$BATS_LOG" +> "$BATS_LOG" cleanup_machines -if [[ -d "$MACHINE_STORAGE_PATH" ]]; then - rm -r "$MACHINE_STORAGE_PATH" -fi +cleanup_store -if [[ "$b2dcache" == "1" ]] && [[ -f $B2D_LOCATION ]]; then +if [[ "$B2D_CACHE" == "1" ]] && [[ -f $B2D_LOCATION ]]; then mkdir -p "${MACHINE_STORAGE_PATH}/cache" cp $B2D_LOCATION "${MACHINE_STORAGE_PATH}/cache/boot2docker.iso" fi run_bats "$BATS_FILE" -if [[ -d "$MACHINE_STORAGE_PATH" ]]; then - rm -r "$MACHINE_STORAGE_PATH" -fi +cleanup_store exit ${EXIT_STATUS} From 5baab2fae5f1cd58af4fad9c4d817194c9ce9646 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Thu, 19 Nov 2015 10:18:58 +0100 Subject: [PATCH 2/2] This test seems more stable this way Otherwise it sometimes hangs Signed-off-by: David Gageot --- test/integration/core/arbitrary-engine-envs.bats | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/core/arbitrary-engine-envs.bats b/test/integration/core/arbitrary-engine-envs.bats index 5524c90abe..6e1accd20c 100644 --- a/test/integration/core/arbitrary-engine-envs.bats +++ b/test/integration/core/arbitrary-engine-envs.bats @@ -12,7 +12,8 @@ load ${BASE_TEST_DIR}/helpers.bash @test "$DRIVER: test docker process envs" { # get pid of docker process, check process envs for set Environment Variable from above test - run machine ssh $NAME 'pgrep -f "docker daemon" | xargs -I % sudo cat /proc/%/environ | grep -q "TEST=VALUE"' + run machine ssh $NAME 'sudo cat /proc/$(pgrep -f "docker [d]aemon")/environ' echo ${output} [ $status -eq 0 ] + [[ "${output}" =~ "TEST=VALUE" ]] }