From 27b37e74732212ae6eff6616082b6699ff4209f7 Mon Sep 17 00:00:00 2001 From: Alessandro Boch Date: Wed, 9 Sep 2015 16:40:08 -0700 Subject: [PATCH] Remove possible stale containers first - So test will not fail because container is already there Prefer this to re-use the containers as it would contain states from last run - A stale consul or dnet container condition will happen in case the previous integ test run aborted Signed-off-by: Alessandro Boch --- libnetwork/test/integration/dnet/helpers.bash | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libnetwork/test/integration/dnet/helpers.bash b/libnetwork/test/integration/dnet/helpers.bash index 65533a15df..bb188d31ac 100644 --- a/libnetwork/test/integration/dnet/helpers.bash +++ b/libnetwork/test/integration/dnet/helpers.bash @@ -1,17 +1,19 @@ function start_consul() { + stop_consul docker run -d --name=pr_consul -p 8500:8500 -p 8300-8302:8300-8302/tcp -p 8300-8302:8300-8302/udp -h consul progrium/consul -server -bootstrap sleep 2 } function stop_consul() { - docker stop pr_consul + docker stop pr_consul || true # You cannot destroy a container in Circle CI. So do not attempt destroy in circleci if [ -z "$CIRCLECI" ]; then - docker rm pr_consul + docker rm -f pr_consul || true fi } function start_dnet() { + stop_dnet $1 name="dnet-$1" hport=$((41000+${1}-1)) @@ -38,11 +40,11 @@ EOF function stop_dnet() { name="dnet-$1" - rm -rf /tmp/dnet/${name} - docker stop ${name} + rm -rf /tmp/dnet/${name} || true + docker stop ${name} || true # You cannot destroy a container in Circle CI. So do not attempt destroy in circleci if [ -z "$CIRCLECI" ]; then - docker rm ${name} || true + docker rm -f ${name} || true fi }