Browse code

exercises/euca.sh timing fixes

Adjust timing in the script for testing on slower systems,
such as VMs on laptops.

Change-Id: I657fe54c7a4b75169b84ae1af37c88e2941e918a

Dean Troyer authored on 2011/12/31 05:27:02
Showing 1 changed files
... ...
@@ -33,7 +33,7 @@ euca-add-group -d description $SECGROUP
33 33
 INSTANCE=`euca-run-instances -g $SECGROUP -t m1.tiny $IMAGE | grep INSTANCE | cut -f2`
34 34
 
35 35
 # 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
37 37
     echo "server didn't become active within $RUNNING_TIMEOUT seconds"
38 38
     exit 1
39 39
 fi
... ...
@@ -48,10 +48,10 @@ euca-associate-address -i $INSTANCE $FLOATING_IP
48 48
 # Authorize pinging
49 49
 euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP
50 50
 
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"
55 55
     exit 1
56 56
 fi
57 57
 
... ...
@@ -67,5 +67,11 @@ euca-disassociate-address $FLOATING_IP
67 67
 # Release floating address
68 68
 euca-release-address $FLOATING_IP
69 69
 
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
+
70 76
 # Terminate instance
71 77
 euca-terminate-instances $INSTANCE