exercises/euca.sh timing fixes
Adjust timing in the script for testing on slower systems,
such as VMs on laptops.
Change-Id: I657fe54c7a4b75169b84ae1af37c88e2941e918a
diff --git a/exercises/euca.sh b/exercises/euca.sh
index 67150e4..dc2d9ca 100755
--- a/exercises/euca.sh
+++ b/exercises/euca.sh
@@ -33,7 +33,7 @@
INSTANCE=`euca-run-instances -g $SECGROUP -t m1.tiny $IMAGE | grep INSTANCE | cut -f2`
# Assure it has booted within a reasonable time
-if ! timeout $RUNNING_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
+if ! timeout $RUNNING_TIMEOUT sh -c "while ! euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
echo "server didn't become active within $RUNNING_TIMEOUT seconds"
exit 1
fi
@@ -48,10 +48,10 @@
# Authorize pinging
euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP
-# Max time till the vm is bootable
-BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
-if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
- echo "Couldn't ping server"
+# Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
+ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-10}
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
+ echo "Couldn't ping server with floating ip"
exit 1
fi
@@ -67,5 +67,11 @@
# Release floating address
euca-release-address $FLOATING_IP
+# Wait just a tick for everything above to complete so terminate doesn't fail
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while euca-describe-addresses | grep -q $FLOATING_IP; do sleep 1; done"; then
+ echo "Floating ip $FLOATING_IP not released within $ASSOCIATE_TIMEOUT seconds"
+ exit 1
+fi
+
# Terminate instance
euca-terminate-instances $INSTANCE