From a2146ca5b004516db28daaa8638dc945d5017f56 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Fri, 12 Jun 2015 09:06:56 +0100 Subject: [PATCH] add tests for launching DNS with various ways of obtaining an IP As a side effect this also tests repopulation on restart, so we can remove the separate test for that. --- test/210_dns_multicast_test.sh | 60 ++++++++++++++++++++++++---------- test/250_dns_restart_test.sh | 18 ---------- 2 files changed, 42 insertions(+), 36 deletions(-) delete mode 100755 test/250_dns_restart_test.sh diff --git a/test/210_dns_multicast_test.sh b/test/210_dns_multicast_test.sh index f16d2eeb..bbb323fb 100755 --- a/test/210_dns_multicast_test.sh +++ b/test/210_dns_multicast_test.sh @@ -3,35 +3,59 @@ . ./config.sh C1=10.2.3.78 -C2_1=10.2.3.34 -C2_2=10.2.3.35 -C2_3=10.2.3.36 +C2=10.2.3.34 +C2a=10.2.3.35 +C2b=10.2.3.36 UNIVERSE=10.2.4.0/24 NAME2=seetwo.weave.local NAME4=seefour.weave.local -start_suite "Resolve names across hosts (with and without IPAM)" +start() { + weave_on $HOST1 launch-dns $1 >/dev/null + weave_on $HOST2 launch-dns $2 >/dev/null +} + +stop() { + weave_on $HOST1 stop-dns + weave_on $HOST2 stop-dns +} + +check() { + start $1 $2 + assert_dns_record $HOST1 c1 $NAME2 $C2 + assert_raises "exec_on $HOST1 c1 getent hosts 8.8.8.8 | grep google" + stop +} + +start_suite "Resolve names across hosts (with and without IPAM), and repopulate on restart" weave_on $HOST1 launch -iprange $UNIVERSE weave_on $HOST2 launch -iprange $UNIVERSE $HOST1 -weave_on $HOST1 launch-dns 10.2.254.1/24 -weave_on $HOST2 launch-dns 10.2.254.2/24 - -start_container $HOST2 $C2_1/24 --name=c2 -h $NAME2 -start_container $HOST2 --name=c4 -h $NAME4 - -weave_on $HOST2 dns-add $C2_2 c2 -h $NAME2 -weave_on $HOST2 dns-add $C2_3 c2 -h $NAME2 - +start_container $HOST2 $C2/24 --name=c2 -h $NAME2 start_container_with_dns $HOST1 $C1/24 --name=c1 -start_container_with_dns $HOST1 --name=c3 + +# resolution when DNS is launched with various ways of obtaining an IP +# NB: this also tests re-population on DNS restart +check ip:10.2.254.1/24 ip:10.2.254.2/24 +check net:10.2.4.128/25 net:10.2.4.128/25 +check net:default net:default +check + +start 10.2.254.1/24 10.2.254.2/24 + +# resolution for names mapped to multiple addresses +weave_on $HOST2 dns-add $C2a c2 -h $NAME2 +weave_on $HOST2 dns-add $C2b c2 -h $NAME2 +assert_dns_record $HOST1 c1 $NAME2 $C2 $C2a $C2b + +# resolution when containers addresses come from IPAM +start_container $HOST2 --name=c4 -h $NAME4 +start_container_with_dns $HOST1 --name=c3 C4=$(container_ip $HOST2 c4) - -assert_dns_record $HOST1 c1 $NAME2 $C2_1 $C2_2 $C2_3 assert_dns_record $HOST1 c3 $NAME4 $C4 - -assert_raises "exec_on $HOST1 c1 getent hosts 8.8.8.8 | grep google" assert_raises "exec_on $HOST1 c3 getent hosts 8.8.8.8 | grep google" +stop + end_suite diff --git a/test/250_dns_restart_test.sh b/test/250_dns_restart_test.sh deleted file mode 100755 index 24df8e78..00000000 --- a/test/250_dns_restart_test.sh +++ /dev/null @@ -1,18 +0,0 @@ -#! /bin/bash - -. ./config.sh - -C1=10.2.0.78 -C2=10.2.0.34 -NAME=seetwo.weave.local - -start_suite "Repopulation on weaveDNS restart" - -start_container $HOST1 $C2/24 --name=c2 -h $NAME -start_container_with_dns $HOST1 $C1/24 --name=c1 - -weave_on $HOST1 launch-dns 10.2.254.1/24 - -assert_dns_record $HOST1 c1 $NAME $C2 - -end_suite