From af38f07d26feff5eb26bb5ce87b9e3aea183fd11 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Fri, 12 Jun 2015 16:50:01 +0100 Subject: [PATCH] refactoring proxy dns test --- test/280_with_or_without_dns_test.sh | 8 ++++---- test/630_proxy_dns_test.sh | 30 +++++++++++++++++----------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/test/280_with_or_without_dns_test.sh b/test/280_with_or_without_dns_test.sh index 5d6e0de5..f537b7dd 100755 --- a/test/280_with_or_without_dns_test.sh +++ b/test/280_with_or_without_dns_test.sh @@ -8,14 +8,14 @@ TARGET_IP=10.2.0.78 assert_no_resolution() { container=$(weave_on $HOST1 run "$@" $IP/24 -t $DNS_IMAGE /bin/sh) - assert_no_dns_record $HOST1 "$container" $TARGET - docker_on $HOST1 rm -f "$container" >/dev/null + assert_no_dns_record $HOST1 $container $TARGET + rm_containers $HOST1 $container } assert_resolution() { container=$(weave_on $HOST1 run "$@" $IP/24 -t $DNS_IMAGE /bin/sh) - assert_dns_record $HOST1 "$container" $TARGET $TARGET_IP - docker_on $HOST1 rm -f "$container" >/dev/null + assert_dns_record $HOST1 $container $TARGET $TARGET_IP + rm_containers $HOST1 $container } start_suite "With or without DNS test" diff --git a/test/630_proxy_dns_test.sh b/test/630_proxy_dns_test.sh index 6fcf4c79..f37e388b 100755 --- a/test/630_proxy_dns_test.sh +++ b/test/630_proxy_dns_test.sh @@ -13,33 +13,39 @@ boot_containers() { } kill_containers() { - docker_on $HOST1 kill c1 c2 - docker_on $HOST1 rm c1 c2 + rm_containers $HOST1 c1 c2 +} + +assert_no_resolution() { + boot_containers + assert_no_dns_record $HOST1 c1 $C2_NAME $C2 + assert_no_dns_record $HOST1 c2 $C1_NAME $C1 + kill_containers } start_suite "Proxy registers containers with dns" bridge_ip=$(weave_on $HOST1 docker-bridge-ip) +# Assert behaviour without weaveDNS running, but dns forced weave_on $HOST1 launch-proxy --with-dns -boot_containers -assert "exec_on $HOST1 c1 cat /etc/resolv.conf" "nameserver $bridge_ip" -assert "exec_on $HOST1 c2 cat /etc/resolv.conf" "nameserver $bridge_ip" +assert_no_resolution weave_on $HOST1 stop-proxy -kill_containers - -weave_on $HOST1 launch-dns 10.2.254.1/24 $WEAVEDNS_ARGS +# Assert behaviour without weaveDNS weave_on $HOST1 launch-proxy +assert_no_resolution + +# Assert behaviour with weaveDNS running +weave_on $HOST1 launch-dns 10.2.254.1/24 $WEAVEDNS_ARGS boot_containers assert_dns_record $HOST1 c1 $C2_NAME $C2 assert_dns_record $HOST1 c2 $C1_NAME $C1 -weave_on $HOST1 stop-proxy kill_containers +weave_on $HOST1 stop-proxy +# Assert behaviour with weaveDNS running, but dns forced off weave_on $HOST1 launch-proxy --without-dns -boot_containers -assert_no_dns_record $HOST1 c1 $C2_NAME -assert_no_dns_record $HOST1 c2 $C1_NAME +assert_no_resolution end_suite