devstack/exercise.sh
Dean Troyer 05530caf2c Source functions before stackrc
The enable_service() and disable_service() functions in
https://review.openstack.org/9407 require the functions
file be sourced before stackrc.

* exercise.sh
* samples/local.sh (this will require manual addition to the user's
  local.sh if they based it on the sample)
* tools/build_bm.sh

Change-Id: I1bed687867e870bef5748289d712376435a776af
2012-08-01 20:03:01 -05:00

65 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# **exercise.sh**
# Keep track of the current devstack directory.
TOP_DIR=$(cd $(dirname "$0") && pwd)
# Import common functions
source $TOP_DIR/functions
# Load local configuration
source $TOP_DIR/stackrc
# 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:-""}
# 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
skips="$skips $script"
else
echo "====================================================================="
echo Running $script
echo "====================================================================="
$EXERCISE_DIR/$script.sh
exitcode=$?
if [[ $exitcode == 55 ]]; then
skips="$skips $script"
elif [[ $exitcode -ne 0 ]] ; then
failures="$failures $script"
else
passes="$passes $script"
fi
fi
done
# output status of exercise run
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
echo "====================================================================="
if [ -n "$failures" ] ; then
exit 1
fi