Excercise euca2ools volumes commands when
exercising the other euca2ools as well.
Change-Id: Ia43bd233c63224eac5e851b3b8a3dbdbf3b5e1f0
Signed-off-by: Chuck Short <chuck.short@canonical.com>
| ... | ... |
@@ -72,6 +72,48 @@ if ! timeout $RUNNING_TIMEOUT sh -c "while ! euca-describe-instances $INSTANCE | |
| 72 | 72 |
exit 1 |
| 73 | 73 |
fi |
| 74 | 74 |
|
| 75 |
+# Volumes |
|
| 76 |
+# ------- |
|
| 77 |
+if [[ "$ENABLED_SERVICES" =~ "n-vol" || "$ENABLED_SERVICES" =~ "c-vol" ]]; then |
|
| 78 |
+ VOLUME=`euca-create-volume -s 1 -z $VOLUME_ZONE | cut -f2` |
|
| 79 |
+ die_if_not_set VOLUME "Failure to create volume" |
|
| 80 |
+ |
|
| 81 |
+ # Test that volume has been created |
|
| 82 |
+ VOLUME=`euca-describe-volumes | cut -f2` |
|
| 83 |
+ |
|
| 84 |
+ # Test volume has become available |
|
| 85 |
+ if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q available; do sleep 1; done"; then |
|
| 86 |
+ echo "volume didnt become available within $RUNNING_TIMEOUT seconds" |
|
| 87 |
+ exit 1 |
|
| 88 |
+ fi |
|
| 89 |
+ |
|
| 90 |
+ # Attach volume to an instance |
|
| 91 |
+ euca-attach-volume -i $INSTANCE -d $ATTACH_DEVICE $VOLUME || \ |
|
| 92 |
+ die "Failure attaching volume $VOLUME to $INSTANCE" |
|
| 93 |
+ if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q in-use; do sleep 1; done"; then |
|
| 94 |
+ echo "Could not attach $VOLUME to $INSTANCE" |
|
| 95 |
+ exit 1 |
|
| 96 |
+ fi |
|
| 97 |
+ |
|
| 98 |
+ # Detach volume from an instance |
|
| 99 |
+ euca-detach-volume $VOLUME || \ |
|
| 100 |
+ die "Failure detaching volume $VOLUME to $INSTANCE" |
|
| 101 |
+ if ! timeout $ACTIVE_TIMEOUT sh -c "while ! euca-describe-volumes $VOLUME | grep -q available; do sleep 1; done"; then |
|
| 102 |
+ echo "Could not detach $VOLUME to $INSTANCE" |
|
| 103 |
+ exit 1 |
|
| 104 |
+ fi |
|
| 105 |
+ |
|
| 106 |
+ # Remove volume |
|
| 107 |
+ euca-delete-volume $VOLUME || \ |
|
| 108 |
+ die "Failure to delete volume" |
|
| 109 |
+ if ! timeout $ACTIVE_TIMEOUT sh -c "while euca-describe-volumes | grep $VOLUME; do sleep 1; done"; then |
|
| 110 |
+ echo "Could not delete $VOLUME" |
|
| 111 |
+ exit 1 |
|
| 112 |
+ fi |
|
| 113 |
+else |
|
| 114 |
+ echo "Volume Tests Skipped" |
|
| 115 |
+fi |
|
| 116 |
+ |
|
| 75 | 117 |
# Allocate floating address |
| 76 | 118 |
FLOATING_IP=`euca-allocate-address | cut -f2` |
| 77 | 119 |
die_if_not_set FLOATING_IP "Failure allocating floating IP" |