From d0d8144ef96c7188ff386a81f83ca845084aca03 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Fri, 24 Apr 2015 11:38:16 +0100 Subject: [PATCH] Factor out test fixture teardown --- test/100_cross_hosts_test.sh | 6 ------ test/110_encryption_test.sh | 6 ------ test/200_dns_test.sh | 4 ---- test/210_dns_multicast_test.sh | 6 ------ test/220_dns_custom_test.sh | 4 ---- test/230_dns_unqualified_test.sh | 4 ---- test/300_fallback_dns_test.sh | 2 -- test/400_weave_local_test.sh | 4 ---- test/500_weave_multi_cidr_test.sh | 5 ----- test/config.sh | 6 ++++++ 10 files changed, 6 insertions(+), 41 deletions(-) diff --git a/test/100_cross_hosts_test.sh b/test/100_cross_hosts_test.sh index faa445e5..7c8502da 100755 --- a/test/100_cross_hosts_test.sh +++ b/test/100_cross_hosts_test.sh @@ -7,12 +7,6 @@ C2=10.2.1.7 start_suite "Ping over cross-host weave network" -for HOST in $HOST1 $HOST2; do - weave_on $HOST stop || true - weave_on $HOST stop-dns || true - docker_on $HOST rm -f c1 c2 || true -done - weave_on $HOST1 launch weave_on $HOST2 launch $HOST1 diff --git a/test/110_encryption_test.sh b/test/110_encryption_test.sh index 2e604984..7ba2ebb3 100755 --- a/test/110_encryption_test.sh +++ b/test/110_encryption_test.sh @@ -7,12 +7,6 @@ C2=10.2.1.7 start_suite "Ping over encrypted cross-host weave network" -for HOST in $HOST1 $HOST2; do - weave_on $HOST stop || true - weave_on $HOST stop-dns || true - docker_on $HOST rm -f c1 c2 || true -done - weave_on $HOST1 launch -password notverysecure weave_on $HOST2 launch -password notverysecure $HOST1 diff --git a/test/200_dns_test.sh b/test/200_dns_test.sh index 3a04ef45..e90a173f 100755 --- a/test/200_dns_test.sh +++ b/test/200_dns_test.sh @@ -8,12 +8,8 @@ NAME=seetwo.weave.local start_suite "Resolve names on a single host" -weave_on $HOST1 stop || true -weave_on $HOST1 stop-dns || true weave_on $HOST1 launch-dns 10.2.254.1/24 -docker_on $HOST1 rm -f c1 c2 || true - weave_on $HOST1 run $C2/24 -t --name=c2 -h $NAME ubuntu weave_on $HOST1 run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh diff --git a/test/210_dns_multicast_test.sh b/test/210_dns_multicast_test.sh index 9629c12f..91235c53 100755 --- a/test/210_dns_multicast_test.sh +++ b/test/210_dns_multicast_test.sh @@ -8,12 +8,6 @@ NAME=seetwo.weave.local start_suite "Resolve names across hosts" -for host in $HOST1 $HOST2; do - weave_on $host stop || true - weave_on $host stop-dns || true - docker_on $host rm -f c1 c2 || true -done - weave_on $HOST1 launch weave_on $HOST2 launch $HOST1 diff --git a/test/220_dns_custom_test.sh b/test/220_dns_custom_test.sh index 94388f12..6603d555 100755 --- a/test/220_dns_custom_test.sh +++ b/test/220_dns_custom_test.sh @@ -9,12 +9,8 @@ NAME=seetwo.$DOMAIN start_suite "Resolve names in custom domain" -weave_on $HOST1 stop || true -weave_on $HOST1 stop-dns || true weave_on $HOST1 launch-dns 10.2.254.1/24 --domain $DOMAIN. -docker_on $HOST1 rm -f c1 c2 || true - weave_on $HOST1 run $C2/24 -t --name=c2 -h $NAME ubuntu weave_on $HOST1 run --with-dns $C1/24 -t --name=c1 aanand/docker-dnsutils /bin/sh diff --git a/test/230_dns_unqualified_test.sh b/test/230_dns_unqualified_test.sh index df2d8635..525c48d7 100755 --- a/test/230_dns_unqualified_test.sh +++ b/test/230_dns_unqualified_test.sh @@ -10,12 +10,8 @@ NAME=seeone.$DOMAIN start_suite "Resolve unqualified names" -weave_on $HOST1 stop || true -weave_on $HOST1 stop-dns || true weave_on $HOST1 launch-dns 10.2.254.1/24 -docker_on $HOST1 rm -f c1 c2 c3 || true - weave_on $HOST1 run $C1/24 -t --name=c1 -h $NAME ubuntu weave_on $HOST1 run --with-dns $C2/24 -t --name=c2 -h seetwo.$DOMAIN aanand/docker-dnsutils /bin/sh weave_on $HOST1 run --with-dns $C3/24 -t --name=c3 --dns-search=weave.local aanand/docker-dnsutils /bin/sh diff --git a/test/300_fallback_dns_test.sh b/test/300_fallback_dns_test.sh index 8e665efb..c9f94b94 100755 --- a/test/300_fallback_dns_test.sh +++ b/test/300_fallback_dns_test.sh @@ -4,9 +4,7 @@ start_suite "Resolve a non-weave address" -weave_on $HOST1 stop-dns || true weave_on $HOST1 launch-dns 10.2.254.1/24 -debug -docker_on $HOST1 rm -f c1 || true weave_on $HOST1 run --with-dns 10.2.1.5/24 --name=c1 -t aanand/docker-dnsutils /bin/sh diff --git a/test/400_weave_local_test.sh b/test/400_weave_local_test.sh index 0b198951..007c10e6 100755 --- a/test/400_weave_local_test.sh +++ b/test/400_weave_local_test.sh @@ -9,11 +9,7 @@ run_on $HOST1 sudo ./weave --local reset run_on $HOST1 sudo ./weave --local launch assert_raises "docker_on $HOST1 ps | grep weave" 0 -docker_on $HOST1 rm -f c1 || true run_on $HOST1 sudo ./weave --local run 10.2.6.5/24 -ti --name=c1 ubuntu - assert_raises "exec_on $HOST1 c1 ifconfig | grep ethwe" -docker_on $HOST1 rm -f c1 || true - end_suite diff --git a/test/500_weave_multi_cidr_test.sh b/test/500_weave_multi_cidr_test.sh index 9bfdf218..eb8e3ddc 100755 --- a/test/500_weave_multi_cidr_test.sh +++ b/test/500_weave_multi_cidr_test.sh @@ -4,11 +4,6 @@ start_suite "Weave run/start/attach/detach with multiple cidr arguments" -# Cleanup from previous run -weave_on $HOST1 stop || true -weave_on $HOST1 stop-dns || true -docker_on $HOST1 rm -f multicidr || true - weave_on $HOST1 launch weave_on $HOST1 launch-dns 10.254.254.254/24 diff --git a/test/config.sh b/test/config.sh index 02656018..4076845c 100644 --- a/test/config.sh +++ b/test/config.sh @@ -95,6 +95,12 @@ assert_dns_record() { } start_suite() { + for HOST in $HOST1 $HOST2; do + echo "Cleaning up on $HOST: removing all containers and resetting weave" + CONTAINERS=$(docker -H tcp://$HOST:2375 ps -aq) + [ -n "$CONTAINERS" ] && docker -H tcp://$HOST:2375 rm -f $CONTAINERS > /dev/null + weave_on $HOST reset > /dev/null + done whitely echo $@ }