Allow skipping exercises.

- Catch a special exit signal 55 to notify that we want to skip an
  excercise.
- Move is_enabled_service to functions.
- Fix bug 928390.

Change-Id: Iebf7a6f30a0f305a2a70173fb6b988bc07e34292
This commit is contained in:
Chmouel Boudjnah 2012-03-15 23:21:55 +00:00
parent 17ff9763da
commit 408b009ccd
5 changed files with 34 additions and 26 deletions

View File

@ -136,6 +136,10 @@ These scripts are executed serially by ``exercise.sh`` in testing situations.
FLOATING_IP=`euca-allocate-address | cut -f2` FLOATING_IP=`euca-allocate-address | cut -f2`
die_if_not_set FLOATING_IP "Failure allocating floating IP" die_if_not_set FLOATING_IP "Failure allocating floating IP"
* If you want an exercise to be skipped when for example a service wasn't
enabled for the exercise to be run, you can exit your exercise with the
special exitcode 55 and it will be detected as skipped.
* The exercise scripts should only use the various OpenStack client binaries to * The exercise scripts should only use the various OpenStack client binaries to
interact with OpenStack. This specifically excludes any ``*-manage`` tools interact with OpenStack. This specifically excludes any ``*-manage`` tools
as those assume direct access to configuration and databases, as well as direct as those assume direct access to configuration and databases, as well as direct

View File

@ -32,7 +32,10 @@ for script in $basenames; do
echo Running $script echo Running $script
echo "=====================================================================" echo "====================================================================="
$EXERCISE_DIR/$script.sh $EXERCISE_DIR/$script.sh
if [[ $? -ne 0 ]] ; then exitcode=$?
if [[ $exitcode == 55 ]]; then
skips="$skips $script"
elif [[ $exitcode -ne 0 ]] ; then
failures="$failures $script" failures="$failures $script"
else else
passes="$passes $script" passes="$passes $script"

View File

@ -36,6 +36,9 @@ source $TOP_DIR/exerciserc
# Container name # Container name
CONTAINER=ex-swift CONTAINER=ex-swift
# If swift is not enabled we exit with exitcode 55 which mean
# exercise is skipped.
is_service_enabled swift || exit 55
# Testing Swift # Testing Swift
# ============= # =============

View File

@ -115,6 +115,28 @@ function git_clone {
} }
# is_service_enabled() checks if the service(s) specified as arguments are
# enabled by the user in **ENABLED_SERVICES**.
#
# If there are multiple services specified as arguments the test performs a
# boolean OR or if any of the services specified on the command line
# return true.
#
# There is a special cases for some 'catch-all' services::
# **nova** returns true if any service enabled start with **n-**
# **glance** returns true if any service enabled start with **g-**
# **quantum** returns true if any service enabled start with **q-**
function is_service_enabled() {
services=$@
for service in ${services}; do
[[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0
[[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
[[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
[[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
done
return 1
}
# Test if the named environment variable is set and not zero length # Test if the named environment variable is set and not zero length
# is_set env-var # is_set env-var
@ -151,4 +173,4 @@ function trueorfalse() {
} }
# Restore xtrace # Restore xtrace
$XTRACE $XTRACE

View File

@ -268,30 +268,6 @@ function read_password {
set -o xtrace set -o xtrace
} }
# is_service_enabled() checks if the service(s) specified as arguments are
# enabled by the user in **ENABLED_SERVICES**.
#
# If there are multiple services specified as arguments the test performs a
# boolean OR or if any of the services specified on the command line
# return true.
#
# There is a special cases for some 'catch-all' services::
# **nova** returns true if any service enabled start with **n-**
# **glance** returns true if any service enabled start with **g-**
# **quantum** returns true if any service enabled start with **q-**
function is_service_enabled() {
services=$@
for service in ${services}; do
[[ ,${ENABLED_SERVICES}, =~ ,${service}, ]] && return 0
[[ ${service} == "nova" && ${ENABLED_SERVICES} =~ "n-" ]] && return 0
[[ ${service} == "glance" && ${ENABLED_SERVICES} =~ "g-" ]] && return 0
[[ ${service} == "quantum" && ${ENABLED_SERVICES} =~ "q-" ]] && return 0
done
return 1
}
# Nova Network Configuration # Nova Network Configuration
# -------------------------- # --------------------------