@@ -33,7 +33,7 @@ euca-add-group -d description $SECGROUP
3333INSTANCE=` euca-run-instances -g $SECGROUP -t m1.tiny $IMAGE | grep INSTANCE | cut -f2`
3434
3535# Assure it has booted within a reasonable time
36- if ! timeout $RUNNING_TIMEOUT sh -c " while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done" ; then
36+ if ! timeout $RUNNING_TIMEOUT sh -c " while ! euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done" ; then
3737 echo " server didn't become active within $RUNNING_TIMEOUT seconds"
3838 exit 1
3939fi
@@ -48,10 +48,10 @@ euca-associate-address -i $INSTANCE $FLOATING_IP
4848# Authorize pinging
4949euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP
5050
51- # Max time till the vm is bootable
52- BOOT_TIMEOUT =${BOOT_TIMEOUT :- 15 }
53- if ! timeout $BOOT_TIMEOUT sh -c " while ! ping -c1 -w1 $FLOATING_IP ; do sleep 1; done" ; then
54- echo " Couldn't ping server"
51+ # Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
52+ ASSOCIATE_TIMEOUT =${ASSOCIATE_TIMEOUT :- 10 }
53+ if ! timeout $ASSOCIATE_TIMEOUT sh -c " while ! ping -c1 -w1 $FLOATING_IP ; do sleep 1; done" ; then
54+ echo " Couldn't ping server with floating ip "
5555 exit 1
5656fi
5757
@@ -67,5 +67,11 @@ euca-disassociate-address $FLOATING_IP
6767# Release floating address
6868euca-release-address $FLOATING_IP
6969
70+ # Wait just a tick for everything above to complete so terminate doesn't fail
71+ if ! timeout $ASSOCIATE_TIMEOUT sh -c " while euca-describe-addresses | grep -q $FLOATING_IP ; do sleep 1; done" ; then
72+ echo " Floating ip $FLOATING_IP not released within $ASSOCIATE_TIMEOUT seconds"
73+ exit 1
74+ fi
75+
7076# Terminate instance
7177euca-terminate-instances $INSTANCE
0 commit comments