Factor out 'wait_for_x' loop to reduce duplication
This commit is contained in:
1 parent
1e60cff2ef
commit
66293e8caa
2 files changed
+23
-27
No files matched your search
@@ -44,19 +44,11 @@ sed -e "s%imagePullPolicy: Always%imagePullPolicy: Never$COVERAGE_ARGS%" "$(dirn
|
|||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
wait_for_connections() {
|
check_connections() {
|
||||||
for i in $(seq 1 45); do
|
run_on $HOST1 "curl -sS http://127.0.0.1:6784/status | grep \"$SUCCESS\""
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
# Check we can ping between the Weave bridg IPs on each host
|
||||||
HOST1EXPIP=$($SSH $HOST1 "weave expose" || true)
|
HOST1EXPIP=$($SSH $HOST1 "weave expose" || true)
|
||||||
|
|||||||
+20
-16
@@ -218,18 +218,28 @@ proxy_start_container_with_dns() {
|
|||||||
proxy docker_on $host run "$@" -dt $DNS_IMAGE /bin/sh
|
proxy docker_on $host run "$@" -dt $DNS_IMAGE /bin/sh
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_proxy() {
|
# Execute command $1 repeatedly until it returns true; description in $2, optional repeat limit in $3
|
||||||
for i in $(seq 1 120); do
|
wait_for_x() {
|
||||||
echo "Waiting for proxy to start"
|
reps=${3:-45}
|
||||||
if proxy docker_on $1 info > /dev/null 2>&1 ; then
|
for i in $(seq 1 $reps); do
|
||||||
|
echo "Waiting for $2"
|
||||||
|
if $1 ; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
echo "Timed out waiting for proxy to start" >&2
|
echo "Timed out waiting for $2" >&2
|
||||||
exit 1
|
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() {
|
rm_containers() {
|
||||||
host=$1
|
host=$1
|
||||||
shift
|
shift
|
||||||
@@ -244,18 +254,12 @@ container_pid() {
|
|||||||
docker_on $1 inspect -f '{{.State.Pid}}' $2
|
docker_on $1 inspect -f '{{.State.Pid}}' $2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_attached() {
|
||||||
|
exec_on $1 $2 $CHECK_ETHWE_UP >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
wait_for_attached() {
|
wait_for_attached() {
|
||||||
host=$1
|
wait_for_x "check_attached $1 $2" "$2 on $1 to be attached"
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# assert_dns_record <host> <container> <name> [<ip> ...]
|
# assert_dns_record <host> <container> <name> [<ip> ...]
|
||||||
|
|||||||
Reference in new issue
Block a user