Test we respect --add-host when rewriting /etc/hosts

Simplify some tests
This commit is contained in:
Alvaro Saurin committed 2015-10-16 11:47:07 +02:00
1 parent 91f27ddd66
commit 5d2892f6fc
3 files changed
+38 -34

No files matched your search

+14 -2
View File
@@ -6,13 +6,25 @@ C1=10.2.0.78
C2=10.2.0.34
NAME=seetwo.weave.local
STATIC1=10.9.9.9
STATIC1_NAME=static1.name
STATIC2=10.10.10.10
STATIC2_NAME=static2.name
STATICS_ARGS="--add-host=$STATIC1_NAME:$STATIC1 --add-host $STATIC2_NAME:$STATIC2"
start_suite "Resolve names on a single host"
weave_on $HOST1 launch
start_container $HOST1 $C2/24 --name=c2 -h $NAME
start_container_with_dns $HOST1 $C1/24 --name=c1
start_container $HOST1 $C2/24 --name=c2 $STATICS_ARGS -h $NAME
start_container_with_dns $HOST1 $C1/24 --name=c1 $STATICS_ARGS
assert_dns_record $HOST1 c1 $NAME $C2
# check we respect the --add-host arguments
for C in c1 c2 ; do
assert_dns_a_record $HOST1 $C $STATIC1_NAME $STATIC1
assert_dns_a_record $HOST1 $C $STATIC2_NAME $STATIC2
done
end_suite
+11 -12
View File
@@ -5,16 +5,16 @@
IP=10.2.0.34
TARGET=seetwo.weave.local
TARGET_IP=10.2.0.78
STATIC=static.name
STATIC_IP=10.9.9.9
assert_no_resolution() {
container=$(weave_on $HOST1 run "$@" $IP/24 -t $DNS_IMAGE /bin/sh)
assert_no_dns_record $HOST1 $container $TARGET
rm_containers $HOST1 $container
}
check_dns() {
chk=$1
shift
assert_resolution() {
container=$(weave_on $HOST1 run "$@" $IP/24 -t $DNS_IMAGE /bin/sh)
assert_dns_record $HOST1 $container $TARGET $TARGET_IP
container=$(weave_on $HOST1 run $@ $IP/24 -t --add-host=$STATIC:$STATIC_IP $DNS_IMAGE /bin/sh)
$chk $HOST1 $container $TARGET
assert_dns_record $HOST1 $container $STATIC $STATIC_IP
rm_containers $HOST1 $container
}
@@ -24,10 +24,9 @@ start_suite "With or without DNS test"
weave_on $HOST1 launch-router
start_container $HOST1 $TARGET_IP/24 --name c2 -h $TARGET
DNS_IP=$(weave_on $HOST1 docker-bridge-ip)
assert_no_resolution --without-dns
assert_resolution
assert_resolution --with-dns
check_dns assert_no_dns_record --without-dns
check_dns assert_dns_record
check_dns assert_dns_record --with-dns
end_suite
+13 -20
View File
@@ -6,46 +6,39 @@ C1=10.2.0.78
C2=10.2.0.34
C1_NAME=c1.weave.local
C2_NAME=seetwo.weave.local
STATIC=static.name
STATIC_IP=10.9.9.9
boot_containers() {
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C2/24 -dt --name=c2 -h $C2_NAME
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C1/24 -dt --name=c1
}
kill_containers() {
do_assert_resolution() {
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C2/24 -dt --name=c2 --add-host $STATIC:$STATIC_IP -h $C2_NAME
proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C1/24 -dt --name=c1 --add-host $STATIC:$STATIC_IP
$1 $HOST1 c1 $C2_NAME $C2
assert_dns_record $HOST1 c1 $STATIC $STATIC_IP
$1 $HOST1 c2 $C1_NAME $C1
assert_dns_record $HOST1 c2 $STATIC $STATIC_IP
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
assert_no_resolution
do_assert_resolution assert_no_dns_record
weave_on $HOST1 stop-proxy
# Assert behaviour without weaveDNS
weave_on $HOST1 launch-proxy
assert_no_resolution
do_assert_resolution assert_no_dns_record
# Assert behaviour with weaveDNS running
weave_on $HOST1 launch-router
boot_containers
assert_dns_record $HOST1 c1 $C2_NAME $C2
assert_dns_record $HOST1 c2 $C1_NAME $C1
kill_containers
do_assert_resolution assert_dns_record
weave_on $HOST1 stop-proxy
# Assert behaviour with weaveDNS running, but dns forced off
weave_on $HOST1 launch-proxy --without-dns
assert_no_resolution
do_assert_resolution assert_no_dns_record
end_suite