Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Fix up tests for DNS changes
Browse files Browse the repository at this point in the history
Now that `weave dns-args` doesn't parse any flags we need to
call it or not call it, which `start_container` will do for us.

Also add back the part of the test where we run weaver with and
without DNS, which had become lost in 8b061fd

Also change a couple of tests to use proxy to start containers,
again to avoid needing `dns-args` to parse flags.
  • Loading branch information
bboreham committed Jul 31, 2020
1 parent 5b2311b commit 9ffd0e3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
6 changes: 3 additions & 3 deletions test/225_dns_subdomain_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ start_suite "Resolve names in custom domain with subdomains"

weave_on $HOST1 launch --log-level=debug --dns-domain $DOMAIN.

start_container_with_dns $HOST1 $C1/24 --name=c1 -h foo.$SUBDOMAIN1
start_container_with_dns $HOST1 $C2/24 --name=c2 -h foo.$SUBDOMAIN2
start_container_with_dns $HOST1 $C3/24 --name=c3 -h tre.$SUBDOMAIN1 --dns-search=$SUBDOMAIN2
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C1/24 --name=c1 -h foo.$SUBDOMAIN1
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C2/24 --name=c2 -h foo.$SUBDOMAIN2
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C3/24 --name=c3 -h tre.$SUBDOMAIN1 --dns-search=$SUBDOMAIN2

assert_dns_record $HOST1 c1 foo.$SUBDOMAIN2 $C2
assert_dns_a_record $HOST1 c3 foo $C2 foo.$SUBDOMAIN2
Expand Down
6 changes: 3 additions & 3 deletions test/230_dns_unqualified_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ start_suite "Resolve unqualified names"

weave_on $HOST1 launch

start_container $HOST1 $C1/24 --name=c1 -h $NAME
start_container_with_dns $HOST1 $C2/24 --name=c2 -h seetwo.$DOMAIN
start_container_with_dns $HOST1 $C3/24 --name=c3 --dns-search=$DOMAIN
proxy_start_container $HOST1 -e WEAVE_CIDR=$C1/24 --name=c1 -h $NAME
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C2/24 --name=c2 -h seetwo.$DOMAIN
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C3/24 --name=c3 --dns-search=$DOMAIN
container=$(start_container_with_dns $HOST1 $C4/24)

assert_dns_a_record $HOST1 c2 seeone $C1 $NAME
Expand Down
15 changes: 12 additions & 3 deletions test/280_with_or_without_dns_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,34 @@ TARGET=seetwo.weave.local
TARGET_IP=10.2.0.78
STATIC=static.name
STATIC_IP=10.9.9.9
ATTACH_ARGS="--rewrite-hosts --add-host=$STATIC:$STATIC_IP"

check_dns() {
chk=$1
shift

container=$(docker_on $HOST1 run $(dns_args $HOST1 "$@") -dt $DNS_IMAGE /bin/sh)
weave_on $HOST1 attach $IP/24 "$@" --rewrite-hosts --add-host=$STATIC:$STATIC_IP $container
container=$(start_container_with_dns $HOST1 "$@" $IP/24)
$chk $HOST1 $container $TARGET
# --add-host adds to /etc/hosts so should work even when DNS is off.
assert_dns_record $HOST1 $container $STATIC $STATIC_IP
rm_containers $HOST1 $container
}

start_suite "With or without DNS test"

# Assert behaviour without weaveDNS running
weave_on $HOST1 launch
weave_on $HOST1 launch --no-dns

start_container $HOST1 $TARGET_IP/24 --name c2 -h $TARGET

check_dns assert_no_dns_record --without-dns
check_dns assert_no_dns_record

weave_on $HOST1 stop

# Assert behaviour with weaveDNS
weave_on $HOST1 launch

check_dns assert_no_dns_record --without-dns
check_dns assert_dns_record

Expand Down
2 changes: 1 addition & 1 deletion test/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ start_container_image() {
fi
is_cidr "$1" && { cidr=$1; shift; }
container=$(docker_on $host run $weave_dns_args $name_args "$@" -dt $image /bin/sh)
if ! weave_on $host attach $cidr $container >/dev/null ; then
if ! weave_on $host attach $cidr $ATTACH_ARGS $container >/dev/null ; then
docker_on $host rm -f $container
return 1
fi
Expand Down

0 comments on commit 9ffd0e3

Please sign in to comment.