From f6705491868494fb3b78139dad23f35cd99f12c7 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 16:04:14 -0700 Subject: [PATCH 1/9] move from exercise.sh to exercises/.. --- exercises/euca.sh | 37 ++++++++++++++++++++++++ exercise.sh => exercises/floating_ips.sh | 5 ---- 2 files changed, 37 insertions(+), 5 deletions(-) create mode 100755 exercises/euca.sh rename exercise.sh => exercises/floating_ips.sh (97%) diff --git a/exercises/euca.sh b/exercises/euca.sh new file mode 100755 index 0000000..faeffcf --- /dev/null +++ b/exercises/euca.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# **exercise.sh** - using the cloud can be fun + +# we will use the ``nova`` cli tool provided by the ``python-novaclient`` +# package +# + + +# This script exits on an error so that errors don't compound and you see +# only the first error that occured. +set -o errexit + +# Print the commands being run so that we can see the command that triggers +# an error. It is also useful for following allowing as the install occurs. +set -o xtrace + + +# Settings +# ======== + +# Use openrc + stackrc + localrc for settings +source ./openrc + +# Max time till the vm is bootable +BOOT_TIMEOUT=${BOOT_TIMEOUT:-15} + +IMAGE=`euca-describe-images | grep machine | cut -f2` + +INSTANCE=`euca-run-instance $IMAGE | grep INSTANCE | cut -f2` + +if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then + echo "server didn't become active within $BOOT_TIMEOUT seconds" + exit 1 +fi + +euca-terminate-instances $INSTANCE diff --git a/exercise.sh b/exercises/floating_ips.sh similarity index 97% rename from exercise.sh rename to exercises/floating_ips.sh index 99b0f3b..06a2cd4 100755 --- a/exercise.sh +++ b/exercises/floating_ips.sh @@ -186,8 +186,3 @@ nova secgroup-delete $SECGROUP # FIXME: validate shutdown within 5 seconds # (nova show $NAME returns 1 or status != ACTIVE)? -# Testing Euca2ools -# ================== - -# make sure that we can describe instances -euca-describe-instances From 9f1863450e71e19bb8ff42e9a7c182c3f5f67c3d Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 16:05:40 -0700 Subject: [PATCH 2/9] docs --- exercises/euca.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/euca.sh b/exercises/euca.sh index faeffcf..fc81af8 100755 --- a/exercises/euca.sh +++ b/exercises/euca.sh @@ -1,12 +1,9 @@ #!/usr/bin/env bash -# **exercise.sh** - using the cloud can be fun - -# we will use the ``nova`` cli tool provided by the ``python-novaclient`` -# package +# we will use the ``euca2ools`` cli tool that wraps the python boto +# library to test ec2 compatibility # - # This script exits on an error so that errors don't compound and you see # only the first error that occured. set -o errexit @@ -25,10 +22,13 @@ source ./openrc # Max time till the vm is bootable BOOT_TIMEOUT=${BOOT_TIMEOUT:-15} +# find a machine image to boot IMAGE=`euca-describe-images | grep machine | cut -f2` +# launch it INSTANCE=`euca-run-instance $IMAGE | grep INSTANCE | cut -f2` +# assure it has booted within a reasonable time if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then echo "server didn't become active within $BOOT_TIMEOUT seconds" exit 1 From 787af01bddbaace8f83c65c273da6a62a9658a06 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Tue, 1 Nov 2011 16:44:19 -0700 Subject: [PATCH 3/9] fix sourcing of openrc --- exercises/euca.sh | 2 ++ exercises/floating_ips.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/exercises/euca.sh b/exercises/euca.sh index fc81af8..0cb5fea 100755 --- a/exercises/euca.sh +++ b/exercises/euca.sh @@ -17,7 +17,9 @@ set -o xtrace # ======== # Use openrc + stackrc + localrc for settings +pushd $(cd $(dirname "$0")/.. && pwd) source ./openrc +popd # Max time till the vm is bootable BOOT_TIMEOUT=${BOOT_TIMEOUT:-15} diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh index 06a2cd4..edf784c 100755 --- a/exercises/floating_ips.sh +++ b/exercises/floating_ips.sh @@ -20,7 +20,9 @@ set -o xtrace # ======== # Use openrc + stackrc + localrc for settings +pushd $(cd $(dirname "$0")/.. && pwd) source ./openrc +popd # Get a token for clients that don't support service catalog # ========================================================== From 2599b3165ad35c9c62b5bfa543c03f2a3aecb4cd Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Fri, 4 Nov 2011 10:31:37 -0400 Subject: [PATCH 4/9] Wrap exercises with master script, with logs, and move common variables. --- exercise.sh | 24 ++++++++++++++++++++++++ exercises/euca.sh | 3 --- exercises/floating_ips.sh | 9 --------- openrc | 8 ++++++++ 4 files changed, 32 insertions(+), 12 deletions(-) create mode 100755 exercise.sh diff --git a/exercise.sh b/exercise.sh new file mode 100755 index 0000000..de906f2 --- /dev/null +++ b/exercise.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Run everything in the exercises/ directory that isn't explicitly disabled + +# comma separated list of script basenames to skip +# to refrain from exercising euca.sh use SKIP_EXERCISES=euca +SKIP_EXERCISES=${SKIP_EXERCISES:-""} + +EXERCISE_DIR=$(dirname "$0")/exercises +basenames=$(for b in `ls $EXERCISE_DIR/*.sh` ; do basename $b .sh ; done) + +for script in $basenames ; do + if [[ "$SKIP_EXERCISES" =~ $script ]] ; then + echo SKIPPING $script + else + echo Running $script + $EXERCISE_DIR/$script.sh 2> $script.log + if [[ $? -ne 0 ]] ; then + echo FAILED. See $script.log + else + rm $script.log + fi + fi +done diff --git a/exercises/euca.sh b/exercises/euca.sh index 0cb5fea..0d48c93 100755 --- a/exercises/euca.sh +++ b/exercises/euca.sh @@ -21,9 +21,6 @@ pushd $(cd $(dirname "$0")/.. && pwd) source ./openrc popd -# Max time till the vm is bootable -BOOT_TIMEOUT=${BOOT_TIMEOUT:-15} - # find a machine image to boot IMAGE=`euca-describe-images | grep machine | cut -f2` diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh index edf784c..5c38430 100755 --- a/exercises/floating_ips.sh +++ b/exercises/floating_ips.sh @@ -84,15 +84,6 @@ nova boot --flavor $FLAVOR --image $IMAGE $NAME --security_groups=$SECGROUP # Waiting for boot # ---------------- -# Max time to wait while vm goes from build to active state -ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-10} - -# Max time till the vm is bootable -BOOT_TIMEOUT=${BOOT_TIMEOUT:-15} - -# Max time to wait for proper association and dis-association. -ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-10} - # check that the status is active within ACTIVE_TIMEOUT seconds if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $NAME | grep status | grep -q ACTIVE; do sleep 1; done"; then echo "server didn't become active!" diff --git a/openrc b/openrc index 324780b..db1a7d1 100644 --- a/openrc +++ b/openrc @@ -49,3 +49,11 @@ export EC2_SECRET_KEY=${ADMIN_PASSWORD:-secrete} # set log level to DEBUG (helps debug issues) # export NOVACLIENT_DEBUG=1 +# Max time till the vm is bootable +export BOOT_TIMEOUT=${BOOT_TIMEOUT:-15} + +# Max time to wait while vm goes from build to active state +export ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-10} + +# Max time to wait for proper IP association and dis-association. +export ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-10} From 9e9132ddaf77a4b858352e827da29ce214a6848d Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Fri, 4 Nov 2011 12:09:54 -0400 Subject: [PATCH 5/9] Exercises: euca bugfix, output cleanup. Don't log stderr per-exercise, because stdout is barfy anyway. Move the state of skip/pass/fail to the end of the exercise run. --- exercise.sh | 30 ++++++++++++++++++++++++++---- exercises/euca.sh | 2 +- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/exercise.sh b/exercise.sh index de906f2..d776385 100755 --- a/exercise.sh +++ b/exercise.sh @@ -6,19 +6,41 @@ # to refrain from exercising euca.sh use SKIP_EXERCISES=euca SKIP_EXERCISES=${SKIP_EXERCISES:-""} +# Locate the scripts we should run EXERCISE_DIR=$(dirname "$0")/exercises basenames=$(for b in `ls $EXERCISE_DIR/*.sh` ; do basename $b .sh ; done) +# Track the state of each script +passes="" +failures="" +skips="" + +# Loop over each possible script (by basename) for script in $basenames ; do if [[ "$SKIP_EXERCISES" =~ $script ]] ; then - echo SKIPPING $script + skips="$skips $script" else + echo ========================= echo Running $script - $EXERCISE_DIR/$script.sh 2> $script.log + echo ========================= + $EXERCISE_DIR/$script.sh if [[ $? -ne 0 ]] ; then - echo FAILED. See $script.log + failures="$failures $script" else - rm $script.log + passes="$passes $script" fi fi done + +# output status of exercise run +echo ========================= +echo ========================= +for script in $skips ; do + echo SKIP $script +done +for script in $passes ; do + echo PASS $script +done +for script in $failures ; do + echo FAILED $script +done diff --git a/exercises/euca.sh b/exercises/euca.sh index 0d48c93..bf6910d 100755 --- a/exercises/euca.sh +++ b/exercises/euca.sh @@ -25,7 +25,7 @@ popd IMAGE=`euca-describe-images | grep machine | cut -f2` # launch it -INSTANCE=`euca-run-instance $IMAGE | grep INSTANCE | cut -f2` +INSTANCE=`euca-run-instances $IMAGE | grep INSTANCE | cut -f2` # assure it has booted within a reasonable time if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then From 3e6ec236f01abaf80fe7dc8db73ecbfdf3532e89 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Fri, 4 Nov 2011 12:23:35 -0400 Subject: [PATCH 6/9] Pull in swift testing from master. --- exercises/swift.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 exercises/swift.sh diff --git a/exercises/swift.sh b/exercises/swift.sh new file mode 100644 index 0000000..f7be099 --- /dev/null +++ b/exercises/swift.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Test swift via the command line tools that ship with it. + +# This script exits on an error so that errors don't compound and you see +# only the first error that occured. +set -o errexit + +# Print the commands being run so that we can see the command that triggers +# an error. It is also useful for following allowing as the install occurs. +set -o xtrace + + +# Settings +# ======== + +# Use openrc + stackrc + localrc for settings +pushd $(cd $(dirname "$0")/.. && pwd) +source ./openrc +popd + + +# Testing Swift +# ============= + +# Check if we have to swift via keystone +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD stat + +# We start by creating a test container +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD post testcontainer + +# add some files into it. +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD upload testcontainer /etc/issue + +# list them +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD list testcontainer + +# And we may want to delete them now that we have tested that +# everything works. +swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete testcontainer From 0367cf1585eb7359a6bc741aab06dc3a3750575a Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Sat, 5 Nov 2011 10:46:56 -0400 Subject: [PATCH 7/9] remove spacicolons. --- exercise.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercise.sh b/exercise.sh index d776385..7703f40 100755 --- a/exercise.sh +++ b/exercise.sh @@ -8,7 +8,7 @@ SKIP_EXERCISES=${SKIP_EXERCISES:-""} # Locate the scripts we should run EXERCISE_DIR=$(dirname "$0")/exercises -basenames=$(for b in `ls $EXERCISE_DIR/*.sh` ; do basename $b .sh ; done) +basenames=$(for b in `ls $EXERCISE_DIR/*.sh`; do basename $b .sh; done) # Track the state of each script passes="" @@ -16,7 +16,7 @@ failures="" skips="" # Loop over each possible script (by basename) -for script in $basenames ; do +for script in $basenames; do if [[ "$SKIP_EXERCISES" =~ $script ]] ; then skips="$skips $script" else @@ -35,12 +35,12 @@ done # output status of exercise run echo ========================= echo ========================= -for script in $skips ; do +for script in $skips; do echo SKIP $script done -for script in $passes ; do +for script in $passes; do echo PASS $script done -for script in $failures ; do +for script in $failures; do echo FAILED $script done From 9a3066f9fd4efae4ec838a673fe1517554e0e531 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Sat, 5 Nov 2011 11:02:34 -0400 Subject: [PATCH 8/9] RUNNING_TIMEOUT = BOOT_TIMEOUT + ACTIVE_TIMEOUT --- exercises/euca.sh | 4 ++-- openrc | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/exercises/euca.sh b/exercises/euca.sh index bf6910d..9605ace 100755 --- a/exercises/euca.sh +++ b/exercises/euca.sh @@ -28,8 +28,8 @@ IMAGE=`euca-describe-images | grep machine | cut -f2` INSTANCE=`euca-run-instances $IMAGE | grep INSTANCE | cut -f2` # assure it has booted within a reasonable time -if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then - echo "server didn't become active within $BOOT_TIMEOUT seconds" +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 diff --git a/openrc b/openrc index db1a7d1..4b36112 100644 --- a/openrc +++ b/openrc @@ -55,5 +55,8 @@ export BOOT_TIMEOUT=${BOOT_TIMEOUT:-15} # Max time to wait while vm goes from build to active state export ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-10} +# Max time from run instance command until it is running +export RUNNING_TIMEOUT=${RUNNING_TIMEOUT:-$(($BOOT_TIMEOUT + $ACTIVE_TIMEOUT))} + # Max time to wait for proper IP association and dis-association. export ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-10} From b74b74a2b321adfc976590a58685b6a506e5db64 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Thu, 10 Nov 2011 11:47:34 -0800 Subject: [PATCH 9/9] permissions --- exercises/floating_ips.sh | 0 exercises/swift.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 exercises/floating_ips.sh mode change 100644 => 100755 exercises/swift.sh diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh old mode 100644 new mode 100755 diff --git a/exercises/swift.sh b/exercises/swift.sh old mode 100644 new mode 100755