From ab8dbce751c3a514b71df89c31acf4c9bbdf7671 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 26 Oct 2011 21:23:20 -0700 Subject: [PATCH 1/4] 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 From 5a774839d73d4d9193e21acc71137f5397962317 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 26 Oct 2011 21:30:02 -0700 Subject: [PATCH 2/4] more converting sleep -> timeouts --- exercise.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/exercise.sh b/exercise.sh index feecfaf..b79dc3c 100755 --- a/exercise.sh +++ b/exercise.sh @@ -82,11 +82,11 @@ nova boot --flavor $FLAVOR --image $IMAGE $NAME --security_groups=$SECGROUP # Waiting for boot # ---------------- -# let's give it 5 seconds to launch -sleep 5 - -# check that the status is active -nova show $NAME | grep status | grep -q ACTIVE +# check that the status is active within 10 seconds +if ! timeout 10 sh -c "while ! nova show $NAME | grep status | grep -q ACTIVE; do sleep 1; done"; then + echo "server didn't become active!" + exit 1 +fi # get the IP of the server IP=`nova show $NAME | grep "private network" | cut -d"|" -f3` @@ -121,21 +121,21 @@ FLOATING_IP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed # add floating ip to our server nova add-floating-ip $NAME $FLOATING_IP -# sleep for a smidge -sleep 5 +# test we can ping our floating ip within 10 seconds +if ! timeout 10 sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then + echo "Couldn't ping server with floating ip" + exit 1 +fi -# ping our floating ip ping -c1 -w1 $FLOATING_IP # dis-allow icmp traffic (ping) nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 -# sleep for a smidge -sleep 5 - -# ping our floating ip -if ( ping -c1 -w1 $FLOATING_IP ); then +# test we can aren't able to ping our floating ip within 10 seconds +if ! timeout 10 sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then print "Security group failure - ping should not be allowed!" + echo "Couldn't ping server with floating ip" exit 1 fi From ac2e166e895eb52286e47ee51a95f0e3d8491932 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 26 Oct 2011 21:39:56 -0700 Subject: [PATCH 3/4] grammer --- exercise.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercise.sh b/exercise.sh index b79dc3c..8feda9f 100755 --- a/exercise.sh +++ b/exercise.sh @@ -95,7 +95,7 @@ IP=`nova show $NAME | grep "private network" | cut -d"|" -f3` MULTI_HOST=${MULTI_HOST:-0} if [ "$MULTI_HOST" = "0" ]; then # sometimes the first ping fails (10 seconds isn't enough time for the VM's - # network to respond?), so let's for 15 seconds pinging with a timeout + # network to respond?), so let's ping for 15 seconds 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" From 53d4a1db2b27ef8549c42d36cda2255bea6576a5 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Wed, 26 Oct 2011 21:46:47 -0700 Subject: [PATCH 4/4] missed removing this ping --- exercise.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/exercise.sh b/exercise.sh index 8feda9f..f512691 100755 --- a/exercise.sh +++ b/exercise.sh @@ -127,8 +127,6 @@ if ! timeout 10 sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; the exit 1 fi -ping -c1 -w1 $FLOATING_IP - # dis-allow icmp traffic (ping) nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0