aodh/run-tests.sh
Mehdi Abaakouk a8b4ff6b33 Ensure correct return code of run-tests.sh
If 'kill -9 mongodb_pid' failed, run-tests.sh exit with a
return code of 0.

This change ensure that the return code is the one of the failed
command.

Change-Id: Iad58dac3fa66d1ea688af706940511033c1d76f7
2013-07-16 00:19:40 +02:00

31 lines
779 B
Bash
Executable File

#!/bin/bash
set -e
function clean_exit(){
local error_code="$?"
rm -rf ${MONGO_DATA}
if [ "$MONGO_PID" ]; then
kill -9 ${MONGO_PID} || true
fi
return $error_code
}
if [ "$1" = "--coverage" ]; then
COVERAGE_ARG="$1"
shift
fi
if [ ! "$COVERAGE_ARGS" ]; then
# Nova notifier tests
bash tools/init_testr_if_needed.sh
python setup.py testr --slowest --testr-args="--concurrency=1 --here=nova_tests $*"
fi
# Main unit tests
MONGO_DATA=`mktemp -d`
trap "clean_exit" EXIT
mongod --maxConns 32 --smallfiles --quiet --noauth --port 29000 --dbpath "${MONGO_DATA}" --bind_ip localhost &
MONGO_PID=$!
export CEILOMETER_TEST_MONGODB_URL="mongodb://localhost:29000/ceilometer"
python setup.py testr --slowest --testr-args="--concurrency=1 $*" $COVERAGE_ARG