Peer list persistence smoke test

This commit is contained in:
Adam Harrison committed 2016-06-03 13:53:07 +01:00
1 parent 4b758dd130
commit f9dd763774
3 files changed
+55 -18

No files matched your search

-18
View File
@@ -4,24 +4,6 @@
start_suite "Test docker restart policy"
check_restart() {
OLD_PID=$(container_pid $1 $2)
run_on $1 sudo kill $OLD_PID
for i in $(seq 1 10); do
NEW_PID=$(container_pid $1 $2)
if [ $NEW_PID != 0 -a $NEW_PID != $OLD_PID ] ; then
return 0
fi
sleep 1
done
return 1
}
weave_on $HOST1 launch
assert "docker_on $HOST1 inspect -f '{{.HostConfig.RestartPolicy.Name}}' weave weaveproxy weaveplugin" "always\nalways\nalways"
+36
View File
@@ -0,0 +1,36 @@
#! /bin/bash
. ./config.sh
assert_targets() {
HOST=$1
shift
EXPECTED=$(for TARGET in $@; do echo $TARGET; done | sort)
assert "weave_on $HOST report | jq -r '.Router.Targets[] | tostring' | sort" "$EXPECTED"
}
start_suite "Check Docker restart uses persisted peer list"
# Launch router and modify initial peer list
weave_on $HOST1 launch $HOST1 $HOST2
weave_on $HOST1 forget $HOST1
weave_on $HOST1 connect $HOST3
# Ensure modified peer list is still in effect after restart
check_restart $HOST1 weave
assert_targets $HOST1 $HOST2 $HOST3
# Ensure persisted peer changes are still in effect after --resume
weave_on $HOST1 stop
weave_on $HOST1 launch --resume
assert_targets $HOST1 $HOST2 $HOST3
# Ensure persisted peer changes are ignored after stop and subsequent restart
weave_on $HOST1 stop
weave_on $HOST1 launch $HOST1 $HOST2
assert_targets $HOST1 $HOST1 $HOST2
check_restart $HOST1 weave
assert_targets $HOST1 $HOST1 $HOST2
end_suite
+19
View File
@@ -249,6 +249,25 @@ assert_dns_ptr_record() {
assert "exec_on $1 $2 getent hosts $4 | tr -s ' '" "$4 $3"
}
# Kill a container process and make sure it's restarted by Docker
check_restart() {
OLD_PID=$(container_pid $1 $2)
run_on $1 sudo kill $OLD_PID
for i in $(seq 1 10); do
NEW_PID=$(container_pid $1 $2)
if [ $NEW_PID != 0 -a $NEW_PID != $OLD_PID ] ; then
return 0
fi
sleep 1
done
return 1
}
start_suite() {
for host in $HOSTS; do
[ -z "$DEBUG" ] || echo "Cleaning up on $host: removing all containers and resetting weave"