2017-08-18 08:52:31 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-05-20 14:46:20 -04:00
|
|
|
# Script intended for running Deckhand functional tests via gabbi for
|
|
|
|
# developers. Dependencies include gabbi, pifpaf and uwsgi.
|
2018-05-29 10:45:40 -04:00
|
|
|
#
|
|
|
|
# Usage: pifpaf run postgresql -- tools/functional-tests.sh
|
2018-01-12 03:28:49 +00:00
|
|
|
|
2018-04-14 17:09:23 -04:00
|
|
|
set -xe
|
|
|
|
|
2018-05-20 14:46:20 -04:00
|
|
|
CURRENT_DIR="$(pwd)"
|
2017-08-18 08:52:31 -05:00
|
|
|
|
|
|
|
|
2018-04-14 17:09:23 -04:00
|
|
|
function cleanup_deckhand {
|
|
|
|
set +e
|
|
|
|
|
2018-05-20 14:46:20 -04:00
|
|
|
# Kill PostgreSQL if it is still running.
|
|
|
|
pifpaf_stop || deactive
|
2018-01-09 05:44:36 +00:00
|
|
|
|
2018-05-20 14:46:20 -04:00
|
|
|
# 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
|
2018-01-09 05:44:36 +00:00
|
|
|
fi
|
2017-12-12 19:56:15 +00:00
|
|
|
}
|
|
|
|
|
2018-01-09 05:44:36 +00:00
|
|
|
|
2018-04-14 17:09:23 -04:00
|
|
|
trap cleanup_deckhand EXIT
|
2018-01-09 03:16:35 +00:00
|
|
|
|
|
|
|
|
2018-04-14 17:09:23 -04:00
|
|
|
function deploy_deckhand {
|
2018-04-12 17:51:22 +05:30
|
|
|
gen_config true "127.0.0.1:9000"
|
2018-04-14 17:09:23 -04:00
|
|
|
gen_paste true
|
2017-08-18 08:52:31 -05:00
|
|
|
|
2018-05-20 14:46:20 -04:00
|
|
|
log_section "Running Deckhand via uwsgi."
|
|
|
|
|
2018-05-29 10:45:40 -04:00
|
|
|
source ${CURRENT_DIR}/entrypoint.sh alembic upgrade head &
|
|
|
|
# Give time for migrations to complete.
|
2018-05-31 04:37:24 +01:00
|
|
|
sleep 10
|
2017-09-21 18:22:03 +01:00
|
|
|
|
2018-05-29 10:45:40 -04:00
|
|
|
source ${CURRENT_DIR}/entrypoint.sh server &
|
2018-04-14 17:09:23 -04:00
|
|
|
# Give the server a chance to come up. Better to poll a health check.
|
2018-05-31 04:37:24 +01:00
|
|
|
sleep 10
|
2017-09-21 18:22:03 +01:00
|
|
|
}
|
|
|
|
|
2017-08-18 08:52:31 -05:00
|
|
|
|
2018-05-29 10:45:40 -04:00
|
|
|
export AIRSHIP_DECKHAND_DATABASE_URL=${PIFPAF_POSTGRESQL_URL}
|
|
|
|
|
2018-04-14 17:09:23 -04:00
|
|
|
# Deploy Deckhand and PostgreSQL and run tests.
|
2018-05-29 10:45:40 -04:00
|
|
|
source ${CURRENT_DIR}/tools/common-tests.sh
|
2018-04-14 17:09:23 -04:00
|
|
|
deploy_deckhand
|
2017-12-12 19:56:15 +00:00
|
|
|
|
2018-05-29 10:45:40 -04:00
|
|
|
log_section "Running tests."
|
2017-08-18 08:52:31 -05:00
|
|
|
|
2018-05-29 10:45:40 -04:00
|
|
|
export DECKHAND_TEST_DIR=${CURRENT_DIR}/deckhand/tests/functional/gabbits
|
2017-10-26 21:33:44 +01:00
|
|
|
|
2017-08-18 08:52:31 -05:00
|
|
|
set +e
|
2017-09-21 18:22:03 +01:00
|
|
|
posargs=$@
|
|
|
|
if [ ${#posargs} -ge 1 ]; then
|
2018-06-22 06:47:33 +01:00
|
|
|
stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color $1
|
2017-09-21 18:22:03 +01:00
|
|
|
else
|
2018-06-22 06:47:33 +01:00
|
|
|
stestr --test-path deckhand/tests/common/ run --serial --slowest --force-subunit-trace --color
|
2017-09-21 18:22:03 +01:00
|
|
|
fi
|
2017-08-18 08:52:31 -05:00
|
|
|
TEST_STATUS=$?
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "x$TEST_STATUS" = "x0" ]; then
|
|
|
|
log_section Done SUCCESS
|
|
|
|
else
|
|
|
|
log_section Deckhand Server Log
|
|
|
|
log_section Done FAILURE
|
2018-05-20 14:46:20 -04:00
|
|
|
exit ${TEST_STATUS}
|
2017-08-18 08:52:31 -05:00
|
|
|
fi
|