deb-aodh/setup-test-env-postgresql.sh
Chris Dent e57d5d2aaa Correct database functional tests
The database related functional tests would not work. Several
changes were required to fix them:

* Clean up permissions in function post_test_hook

  Without this tox can't create its .tox directories. We want to be
  running as user stack against a directory owned by user stack.

  We need to check for a directory named 'devstack' not a file in
  order to get the permissions changes to happen.

* Call pg_ctl initdb, not initdb to create the postgresql database.

* Add a DRIVER_MANAGER for mysql+pymysql (without this all mysql
  tests are skipped, even in the unit tests).

* Change get_connection so it doesn't split on + when looking up
  storage extensions, as we do want to use pymysql.

* Make sure AODH_BACKEND is set and exported in gate_hook.sh

* Mysql requires a database exist when we name it in a sql
  create_engine, replace the placeholder with '' when in mysql.

* Move keystonemiddleware config to the correct section of the paste
  file, temporarily.

Change-Id: I001e34e28353a35148e2101ab90cb3d238bd53cb
2015-08-10 17:12:52 +00:00

35 lines
778 B
Bash
Executable File

#!/bin/bash
set -e
source functions.sh
if [ "$1" = "--coverage" ]; then
COVERAGE_ARG="$1"
shift
fi
function clean_exit_pgsql(){
ret=$?
${1}/pg_ctl -w -D ${2} -o "-p ${3}" stop
rm -rf ${2}
return ${ret}
}
#export PATH=${PATH:+$PATH:}/sbin:/usr/sbin
check_for_cmd pg_config
# Start PostgreSQL process for tests
PGSQL_DATA=`mktemp -d /tmp/AODH-PGSQL-XXXXX`
PGSQL_PATH=`pg_config --bindir`
PGSQL_PORT=9823
${PGSQL_PATH}/pg_ctl initdb -D ${PGSQL_DATA}
trap "clean_exit_pgsql ${PGSQL_PATH} ${PGSQL_DATA} ${PGSQL_PORT}" EXIT
LANGUAGE=C ${PGSQL_PATH}/pg_ctl -w -D ${PGSQL_DATA} -o "-k ${PGSQL_DATA} -p ${PGSQL_PORT}" start
export AODH_TEST_PGSQL_URL="postgresql:///?host=${PGSQL_DATA}&port=${PGSQL_PORT}&dbname=template1"
# Yield execution to venv command
$*