Merge pull request #761 from inercia/weave-583-2

Background updates for names in the Zone database. Fixes #226.
This commit is contained in:
Adam Harrison committed 2015-05-28 10:00:32 +01:00
commit 037b6df385
30 files changed
+2510 -486

No files matched your search

+10 -4
View File
@@ -3,7 +3,9 @@
. ./config.sh
C1=10.2.3.78
C2=10.2.3.34
C2_1=10.2.3.34
C2_2=10.2.3.35
C2_3=10.2.3.36
UNIVERSE=10.2.4.0/24
NAME2=seetwo.weave.local
NAME4=seefour.weave.local
@@ -16,13 +18,17 @@ 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/24 --name=c2 -h $NAME2
start_container $HOST2 --name=c4 -h $NAME4
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_with_dns $HOST1 $C1/24 --name=c1
start_container_with_dns $HOST1 --name=c3
C4=$(container_ip $HOST2 c4)
assert_dns_record $HOST1 c1 $NAME2 $C2
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"
+2 -2
View File
@@ -9,7 +9,7 @@ NAME2=seetwo.weave.local
start_suite "Add and remove names on a single host"
weave_on $HOST1 launch-dns 10.2.254.1/24
weave_on $HOST1 launch-dns 10.2.254.1/24 --no-cache
start_container $HOST1 $C2/24 --name=c2
start_container_with_dns $HOST1 $C1/24 --name=c1
@@ -24,6 +24,6 @@ assert "exec_on $HOST1 c1 getent hosts $C1 | tr -s ' '" "$C1 $NAME1"
weave_on $HOST1 dns-remove $C1 c1
assert_raises "exec_on $HOST1 c1 getent hosts $NAME1" 2
assert_no_dns_record $HOST1 c1 $NAME1
end_suite
+1 -1
View File
@@ -4,7 +4,7 @@
start_suite "Resolve a non-weave address"
weave_on $HOST1 launch-dns 10.2.254.1/24
weave_on $HOST1 launch-dns 10.2.254.1/24 --no-cache
start_container_with_dns $HOST1 10.2.1.5/24 --name=c1
+2 -2
View File
@@ -21,11 +21,11 @@ assert_zone_records() {
FQDN=$1; shift
# Assert correct number of records exist
assert "weave_on $HOST status | grep \"^$CID\" | wc -l" $#
assert "weave_on $HOST status | grep \"^$CID\" | grep -oE \"\b([0-9]{1,3}\.){3}[0-9]{1,3}\b\" | wc -l" $#
# Assert correct records exist
for IP; do
assert_raises "weave_on $HOST status | grep \"^$CID $IP $FQDN$\""
assert_raises "weave_on $HOST status | grep \"$CID\" | grep \"$IP\" | grep \"$FQDN\""
done
}
+6
View File
@@ -34,6 +34,11 @@ def configure_docker(host, hostname, ip)
cleanup(host.vm)
end
def configure_resolv_conf(host)
# Fix the resolution errors by using 8.8.8.8
host.vm.provision :shell, :inline => "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@@ -48,6 +53,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
(1..n_machines).each do |i|
config.vm.define "host#{i}" do |host|
ip_suffix = ip_suffix_base + i
configure_resolv_conf(host)
configure_docker(host, "host#{i}", "#{ip_prefix}.#{ip_suffix}")
end
end
+25 -3
View File
@@ -115,10 +115,32 @@ container_ip() {
weave_on $1 ps $2 | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
}
# assert_dns_record <host> <container> <name> <ip>
# assert_dns_record <host> <container> <name> [<ip> ...]
assert_dns_record() {
assert "exec_on $1 $2 getent hosts $3 | tr -s ' '" "$4 $3"
assert "exec_on $1 $2 getent hosts $4 | tr -s ' '" "$4 $3"
host=$1
container=$2
name=$3
shift 3
exp_ips_regex=$(echo "$@" | sed -r 's/ /\\\|/g')
[[ -z "$DEBUG" ]] || greyly echo "Checking whether $name exists at $host:$container"
got_ip=$(exec_on $host $container getent hosts $name)
assert_raises "echo \"$got_ip\" | grep -q \"$exp_ips_regex\""
[[ -z "$DEBUG" ]] || greyly echo "Checking whether the IPs \"$@\" exists at $host:$container"
for ip in "$@" ; do
assert "exec_on $host $container getent hosts $ip | tr -s ' '" "$ip $name"
done
}
# assert_no_dns_record <host> <container> <name>
assert_no_dns_record() {
host=$1
container=$2
name=$3
[[ -z "$DEBUG" ]] || greyly echo "Checking if \"$name\" does not exist at $host:$container"
assert_raises "exec_on $host $container getent hosts $name" 2
}
start_suite() {