Skip to content

Commit c384424

Browse files
author
Dean Troyer
committed
exercises/euca.sh timing fixes
Adjust timing in the script for testing on slower systems, such as VMs on laptops. Change-Id: I657fe54c7a4b75169b84ae1af37c88e2941e918a
1 parent 34694f1 commit c384424

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

exercises/euca.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ euca-add-group -d description $SECGROUP
3333
INSTANCE=`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
3939
fi
@@ -48,10 +48,10 @@ euca-associate-address -i $INSTANCE $FLOATING_IP
4848
# Authorize pinging
4949
euca-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
5656
fi
5757

@@ -67,5 +67,11 @@ euca-disassociate-address $FLOATING_IP
6767
# Release floating address
6868
euca-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
7177
euca-terminate-instances $INSTANCE

0 commit comments

Comments
 (0)