Factor out 'wait_for_x' loop to reduce duplication

This commit is contained in:
Bryan Boreham committed 2017-05-19 11:47:57 +00:00
1 parent 1e60cff2ef
commit 66293e8caa
2 files changed
+23 -27

No files matched your search

+3 -11
View File
@@ -44,19 +44,11 @@ sed -e "s%imagePullPolicy: Always%imagePullPolicy: Never$COVERAGE_ARGS%" "$(dirn
sleep 5
wait_for_connections() {
for i in $(seq 1 45); do
if run_on $HOST1 "curl -sS http://127.0.0.1:6784/status | grep \"$SUCCESS\"" ; then
return
fi
echo "Waiting for connections"
sleep 1
done
echo "Timed out waiting for connections to establish" >&2
exit 1
check_connections() {
run_on $HOST1 "curl -sS http://127.0.0.1:6784/status | grep \"$SUCCESS\""
}
assert_raises wait_for_connections
assert_raises 'wait_for_x check_connections "connections to establish"'
# Check we can ping between the Weave bridg IPs on each host
HOST1EXPIP=$($SSH $HOST1 "weave expose" || true)
+20 -16
View File
@@ -218,18 +218,28 @@ proxy_start_container_with_dns() {
proxy docker_on $host run "$@" -dt $DNS_IMAGE /bin/sh
}
wait_for_proxy() {
for i in $(seq 1 120); do
echo "Waiting for proxy to start"
if proxy docker_on $1 info > /dev/null 2>&1 ; then
# Execute command $1 repeatedly until it returns true; description in $2, optional repeat limit in $3
wait_for_x() {
reps=${3:-45}
for i in $(seq 1 $reps); do
echo "Waiting for $2"
if $1 ; then
return
fi
sleep 1
done
echo "Timed out waiting for proxy to start" >&2
echo "Timed out waiting for $2" >&2
exit 1
}
check_proxy() {
proxy docker_on $1 info >/dev/null 2>&1
}
wait_for_proxy() {
wait_for_x check_proxy "proxy to start" 120
}
rm_containers() {
host=$1
shift
@@ -244,18 +254,12 @@ container_pid() {
docker_on $1 inspect -f '{{.State.Pid}}' $2
}
check_attached() {
exec_on $1 $2 $CHECK_ETHWE_UP >/dev/null 2>&1
}
wait_for_attached() {
host=$1
container=$2
for i in $(seq 1 10); do
echo "Waiting for $container on $host to be attached"
if exec_on $host $container $CHECK_ETHWE_UP > /dev/null 2>&1 ; then
return
fi
sleep 1
done
echo "Timed out waiting for $container on $host to be attached" >&2
exit 1
wait_for_x "check_attached $1 $2" "$2 on $1 to be attached"
}
# assert_dns_record <host> <container> <name> [<ip> ...]