From 37258958ce7550c0662cf104b007b79e3dc76003 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Tue, 7 Aug 2012 10:38:44 -0500 Subject: [PATCH] Add volume tests to exercises/euca.sh Excercise euca2ools volumes commands when exercising the other euca2ools as well. Change-Id: Ia43bd233c63224eac5e851b3b8a3dbdbf3b5e1f0 Signed-off-by: Chuck Short --- exercises/euca.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/exercises/euca.sh b/exercises/euca.sh index fb052dd5aa..79405c2079 100755 --- a/exercises/euca.sh +++ b/exercises/euca.sh @@ -72,6 +72,48 @@ if ! timeout $RUNNING_TIMEOUT sh -c "while ! euca-describe-instances $INSTANCE | exit 1 fi +# Volumes +# ------- +if [[ "$ENABLED_SERVICES" =~ "n-vol" || "$ENABLED_SERVICES" =~ "c-vol" ]]; then + VOLUME=`euca-create-volume -s 1 -z $VOLUME_ZONE | cut -f2` + die_if_not_set VOLUME "Failure to create volume" + + # Test that volume has been created + VOLUME=`euca-describe-volumes | cut -f2` + + # Test volume has become available + if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q available; do sleep 1; done"; then + echo "volume didnt become available within $RUNNING_TIMEOUT seconds" + exit 1 + fi + + # Attach volume to an instance + euca-attach-volume -i $INSTANCE -d $ATTACH_DEVICE $VOLUME || \ + die "Failure attaching volume $VOLUME to $INSTANCE" + if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q in-use; do sleep 1; done"; then + echo "Could not attach $VOLUME to $INSTANCE" + exit 1 + fi + + # Detach volume from an instance + euca-detach-volume $VOLUME || \ + die "Failure detaching volume $VOLUME to $INSTANCE" + if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q available; do sleep 1; done"; then + echo "Could not detach $VOLUME to $INSTANCE" + exit 1 + fi + + # Remove volume + euca-delete-volume $VOLUME || \ + die "Failure to delete volume" + if ! timeout $ACTIVE_TIMEOUT sh -c "while euca-describe-volumes | grep $VOLUME; do sleep 1; done"; then + echo "Could not delete $VOLUME" + exit 1 + fi +else + echo "Volume Tests Skipped" +fi + # Allocate floating address FLOATING_IP=`euca-allocate-address | cut -f2` die_if_not_set FLOATING_IP "Failure allocating floating IP"