From b712ba1e04c7425edad0bdfb27be8049cf9ac631 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 23 Jul 2015 12:56:44 +0100 Subject: [PATCH] Extend test to cover containers restarting automatically --- test/640_proxy_restart_reattaches_test.sh | 25 ++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test/640_proxy_restart_reattaches_test.sh b/test/640_proxy_restart_reattaches_test.sh index a2c04ebd..428092f3 100755 --- a/test/640_proxy_restart_reattaches_test.sh +++ b/test/640_proxy_restart_reattaches_test.sh @@ -6,14 +6,29 @@ C1=10.2.0.78 C2=10.2.0.34 NAME=seetwo.weave.local +check_attached() { + assert_raises "proxy exec_on $HOST1 c2 $CHECK_ETHWE_UP" + assert_dns_record $HOST1 c1 $NAME $C2 +} + start_suite "Proxy restart reattaches networking to containers" weave_on $HOST1 launch -proxy_start_container $HOST1 -e WEAVE_CIDR=$C2/24 -dt --name=c2 -h $NAME -proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C1/24 -dt --name=c1 +proxy_start_container $HOST1 -e WEAVE_CIDR=$C2/24 -di --name=c2 --restart=always -h $NAME +proxy_start_container_with_dns $HOST1 -e WEAVE_CIDR=$C1/24 -di --name=c1 --restart=always -proxy docker_on $HOST1 restart c2 -assert_raises "proxy exec_on $HOST1 c2 $CHECK_ETHWE_UP" -assert_dns_record $HOST1 c1 $NAME $C2 +proxy docker_on $HOST1 restart -t=1 c2 +check_attached + +# Kill outside of Docker so Docker will restart it +run_on $HOST1 sudo kill -KILL $(docker_on $HOST1 inspect --format='{{.State.Pid}}' c2) +sleep 1 +check_attached + +# Restart docker itself, using different commands for systemd- and upstart-managed. +run_on $HOST1 sh -c "command -v systemctl >/dev/null && sudo systemctl restart docker || sudo service docker restart" +sleep 1 +weave_on $HOST1 launch +check_attached end_suite