From 4da2501d7aff3adb47d079c7e03dfa7f48f70a45 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sat, 12 Oct 2019 09:33:00 +0000 Subject: [PATCH] Add sleeps in tests for topology gossip to propagate The new weaveworks/mesh version defers topology updates by up to 1 second, so we can't expect to connect two nodes and immediately ping between them. --- test/150_connect_forget_2_test.sh | 8 ++++++++ test/191_create_bridge_2_test.sh | 4 +++- test/210_dns_cross_hosts_3_test.sh | 2 ++ test/215_stale_dns_3_test.sh | 4 +++- test/380_ipam_seed_2_test.sh | 3 +++ test/800_plugin_cross_hosts_2_test.sh | 2 ++ 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/test/150_connect_forget_2_test.sh b/test/150_connect_forget_2_test.sh index 40b7922c..1a78136d 100755 --- a/test/150_connect_forget_2_test.sh +++ b/test/150_connect_forget_2_test.sh @@ -26,10 +26,15 @@ start_container $HOST2 $C2/24 --name=c2 assert_raises "weave_on $HOST2 connect 10.2.2.1 10.2.2.2" assert_peers $HOST2 "10.2.2.1\n10.2.2.2" +sleep 2 # Allow topology to propagate + # Replace bogus hosts with real hosts assert_raises "exec_on $HOST1 c1 sh -c '! $PING $C2'" assert_raises "weave_on $HOST2 connect --replace $HOST1 $HOST2" assert_peers $HOST2 "$HOST1\n$HOST2" + +sleep 2 # Allow topology to propagate + assert_raises "exec_on $HOST1 c1 $PING $C2" # Forget everyone and disconnect @@ -37,6 +42,9 @@ assert_raises "weave_on $HOST2 forget $HOST1 $HOST2" assert_raises "stop_weave_on $HOST1" assert_raises "weave_on $HOST1 launch" assert_peers $HOST2 "" + +sleep 2 # Allow topology to propagate + assert_raises "exec_on $HOST1 c1 sh -c '! $PING $C2'" end_suite diff --git a/test/191_create_bridge_2_test.sh b/test/191_create_bridge_2_test.sh index abca8a9b..cf294f56 100755 --- a/test/191_create_bridge_2_test.sh +++ b/test/191_create_bridge_2_test.sh @@ -9,7 +9,7 @@ kill_weaver() { run_on $HOST1 sudo ip link set weave down WEAVER_PID=$(container_pid $HOST1 weave) run_on $HOST1 sudo kill -9 $WEAVER_PID - sleep 3 + sleep 5 } start_suite "Re-create bridge after restart" @@ -20,6 +20,7 @@ WEAVE_NO_FASTDP=1 weave_on $HOST2 launch $HOST1 start_container $HOST1 $C1/24 --name=c1 start_container $HOST2 $C2/24 --name=c2 +sleep 2 # give topology gossip some time to propagate assert_raises "exec_on $HOST1 c1 $PING $C2" kill_weaver # should re-create the bridge @@ -30,6 +31,7 @@ assert_raises "exec_on $HOST1 c1 $PING $C2" weave_on $HOST1 reset weave_on $HOST1 launch $HOST2 weave_on $HOST1 attach $C1/24 c1 +sleep 2 # give topology gossip some time to propagate assert_raises "exec_on $HOST1 c1 $PING $C2" kill_weaver # should re-create the bridge diff --git a/test/210_dns_cross_hosts_3_test.sh b/test/210_dns_cross_hosts_3_test.sh index ee29fe9e..d6b9b1c2 100755 --- a/test/210_dns_cross_hosts_3_test.sh +++ b/test/210_dns_cross_hosts_3_test.sh @@ -16,6 +16,8 @@ for host in $HOSTS; do weave_on $host launch --ipalloc-range $UNIVERSE $HOSTS done +sleep 2 # Allow topology updates to propagate + # Basic test start_container $HOST2 $C2/24 --name=c2 -h $NAME2 start_container_with_dns $HOST1 $C1/24 --name=c1 diff --git a/test/215_stale_dns_3_test.sh b/test/215_stale_dns_3_test.sh index bfabb390..15647e2f 100755 --- a/test/215_stale_dns_3_test.sh +++ b/test/215_stale_dns_3_test.sh @@ -8,6 +8,8 @@ weave_on $HOST1 launch --no-discovery weave_on $HOST2 launch --no-discovery $HOST1 weave_on $HOST3 launch --no-discovery $HOST2 +sleep 2 # Allow topology updates to propagate + start_container $HOST1 --name=c1 C1=$(container_ip $HOST1 c1) start_container_with_dns $HOST3 --name=c3 @@ -25,7 +27,7 @@ weave_on $HOST1 launch --no-discovery $HOST3 # Now re-enable gossip from host2 to host3 run_on $HOST3 "sudo iptables -D INPUT -s $HOST2 -j DROP" -sleep 1 +sleep 2 # allow some time for connections to reform and updates to propagate assert_no_dns_record $HOST3 c3 c1.weave.local diff --git a/test/380_ipam_seed_2_test.sh b/test/380_ipam_seed_2_test.sh index 39e031b0..51ff964c 100755 --- a/test/380_ipam_seed_2_test.sh +++ b/test/380_ipam_seed_2_test.sh @@ -15,6 +15,9 @@ assert_raises "timeout 10 cat <( start_container $HOST2 --name c2)" # Connect routers weave_on $HOST2 connect $HOST1 +# Allow topology to propagate +sleep 2 + # Check connectivity assert_raises "exec_on $HOST1 c1 $PING c2" assert_raises "exec_on $HOST2 c2 $PING c1" diff --git a/test/800_plugin_cross_hosts_2_test.sh b/test/800_plugin_cross_hosts_2_test.sh index ac4fdf00..5f324949 100755 --- a/test/800_plugin_cross_hosts_2_test.sh +++ b/test/800_plugin_cross_hosts_2_test.sh @@ -15,6 +15,8 @@ weave_on $HOST2 launch $HOST1 start_container_local_plugin $HOST1 --name=c1 --hostname=$C1_NAME --dns=$DNS_IP start_container_local_plugin $HOST2 --name=c2 --hostname=$C2_NAME --dns=$DNS_IP +sleep 2 # Allow topology to propagate + assert_raises "exec_on $HOST1 c1 $PING $C2_NAME" assert_raises "exec_on $HOST2 c2 $PING $C1_NAME"