From ab8dbce751c3a514b71df89c31acf4c9bbdf7671 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 26 Oct 2011 21:23:20 -0700 Subject: [PATCH] play with how ping tests/sleep works in exercise --- exercise.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/exercise.sh b/exercise.sh index 3f2c94e..feecfaf 100755 --- a/exercise.sh +++ b/exercise.sh @@ -82,8 +82,8 @@ nova boot --flavor $FLAVOR --image $IMAGE $NAME --security_groups=$SECGROUP # Waiting for boot # ---------------- -# let's give it 10 seconds to launch -sleep 10 +# let's give it 5 seconds to launch +sleep 5 # check that the status is active nova show $NAME | grep status | grep -q ACTIVE @@ -94,14 +94,13 @@ IP=`nova show $NAME | grep "private network" | cut -d"|" -f3` # for single node deployments, we can ping private ips MULTI_HOST=${MULTI_HOST:-0} if [ "$MULTI_HOST" = "0" ]; then - # ping it once (timeout of a second) - ping -c1 -w1 $IP || true - # sometimes the first ping fails (10 seconds isn't enough time for the VM's - # network to respond?), so let's wait 5 seconds and really test ping - sleep 5 - - ping -c1 -w1 $IP + # network to respond?), so let's for 15 seconds pinging with a timeout + # of a second. + if ! timeout 15 sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then + echo "Couldn't ping server" + exit 1 + fi fi # Security Groups & Floating IPs