deckhand/tools/functional-tests.sh
Felipe Monteiro 29894ee854 Move to stestr for functional/integration tests
This moves to stestr for functional/integration tests to
align with preferred OpenStack test runner and also because
py.test is causing issues here: [0].

[0] http://logs.openstack.org/45/573045/8/check/airship-deckhand-integration-uwsgi-py35/60bd7ae/job-output.txt.gz#_2018-06-22_03_00_51_267408

Change-Id: I701c71aef2a122b8f1fc64285cb799f71cfe520f
2018-07-21 15:32:26 -04:00

74 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Script intended for running Deckhand functional tests via gabbi for
# developers. Dependencies include gabbi, pifpaf and uwsgi.
#
# Usage: pifpaf run postgresql -- tools/functional-tests.sh
set -xe
CURRENT_DIR="$(pwd)"
function cleanup_deckhand {
set +e
# Kill PostgreSQL if it is still running.
pifpaf_stop || deactive
# Kill uwsgi service if it is still running.
PID=$( sudo netstat -tulpn | grep ":9000" | head -n 1 | awk '{print $NF}' )
if [ -n $PID ]; then
PID=${PID%/*}
sudo kill -9 $PID
fi
}
trap cleanup_deckhand EXIT
function deploy_deckhand {
gen_config true "127.0.0.1:9000"
gen_paste true
log_section "Running Deckhand via uwsgi."
source ${CURRENT_DIR}/entrypoint.sh alembic upgrade head &
# Give time for migrations to complete.
sleep 10
source ${CURRENT_DIR}/entrypoint.sh server &
# Give the server a chance to come up. Better to poll a health check.
sleep 10
}
export AIRSHIP_DECKHAND_DATABASE_URL=${PIFPAF_POSTGRESQL_URL}
# Deploy Deckhand and PostgreSQL and run tests.
source ${CURRENT_DIR}/tools/common-tests.sh
deploy_deckhand
log_section "Running tests."
export DECKHAND_TEST_DIR=${CURRENT_DIR}/deckhand/tests/functional/gabbits
set +e
posargs=$@
if [ ${#posargs} -ge 1 ]; then
stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color $1
else
stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color
fi
TEST_STATUS=$?
set -e
if [ "x$TEST_STATUS" = "x0" ]; then
log_section Done SUCCESS
else
log_section Deckhand Server Log
log_section Done FAILURE
exit ${TEST_STATUS}
fi