diff --git a/test/240_dns_add_name_test.sh b/test/240_dns_add_name_test.sh index 59da781a..f29df2e4 100755 --- a/test/240_dns_add_name_test.sh +++ b/test/240_dns_add_name_test.sh @@ -6,6 +6,7 @@ C1=10.2.0.78 C2=10.2.0.34 NAME1=seeone.weave.local NAME2=seetwo.weave.local +NAME3=seethree.weave.local start_suite "Add and remove names on a single host" @@ -19,11 +20,14 @@ weave_on $HOST1 dns-add $C2 c2 -h $NAME2 assert_dns_record $HOST1 c1 $NAME2 $C2 weave_on $HOST1 dns-add $C1 c1 -h $NAME1 +weave_on $HOST1 dns-add $C1 c1 -h $NAME3 -assert "exec_on $HOST1 c1 getent hosts $C1 | tr -s ' '" "$C1 $NAME1" +assert_dns_a_record $HOST1 c1 $NAME1 $C1 +assert_dns_a_record $HOST1 c1 $NAME3 $C1 -weave_on $HOST1 dns-remove $C1 c1 +weave_on $HOST1 dns-remove $C1 c1 -h $NAME1 assert_no_dns_record $HOST1 c1 $NAME1 +assert_dns_a_record $HOST1 c1 $NAME3 $C1 end_suite diff --git a/test/250_dns_test_restart.sh b/test/250_dns_test_restart.sh new file mode 100755 index 00000000..24df8e78 --- /dev/null +++ b/test/250_dns_test_restart.sh @@ -0,0 +1,18 @@ +#! /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 diff --git a/test/config.sh b/test/config.sh index 190fb90e..ed19b057 100644 --- a/test/config.sh +++ b/test/config.sh @@ -143,6 +143,16 @@ assert_no_dns_record() { assert_raises "exec_on $host $container getent hosts $name" 2 } +# assert_dns_a_record +assert_dns_a_record() { + assert "exec_on $1 $2 getent hosts $3 | tr -s ' '" "$4 $3" +} + +# assert_dns_ptr_record +assert_dns_ptr_record() { + assert "exec_on $1 $2 getent hosts $4 | tr -s ' '" "$4 $3" +} + start_suite() { for host in $HOST1 $HOST2; do echo "Cleaning up on $host: removing all containers and resetting weave"