Close and dispose test database setup connections

Without explicitly closing and disposing the connections can linger in a
non-deterministic fashion and cause intermittent "too many connection"
errors in the tests.

These changes were diagnosed and then tested by lowering test
concurrency to 1 and lowering available postgres connections to 10
and forcing the problem early in the test run.

Change-Id: I8badf2a3094f2d27d381bd178c6d579f2a5c5ffe
This commit is contained in:
Chris Dent 2015-07-23 15:41:01 +00:00
parent 81cf431926
commit c9a8c0b957
2 changed files with 5 additions and 1 deletions

View File

@ -84,6 +84,8 @@ class PgSQLManager(SQLManager):
self._conn.execute(
'CREATE DATABASE %s WITH TEMPLATE template0;' % self._db_name)
self._conn.connection.set_isolation_level(1)
self._conn.close()
self._engine.dispose()
class MySQLManager(SQLManager):
@ -95,6 +97,8 @@ class MySQLManager(SQLManager):
self._url.replace('template1', ''))
self._conn = self._engine.connect()
self._conn.execute('CREATE DATABASE %s;' % self._db_name)
self._conn.close()
self._engine.dispose()
class HBaseManager(fixtures.Fixture):

View File

@ -27,7 +27,7 @@ PGSQL_PORT=9823
${PGSQL_PATH}/initdb -E UTF8 ${PGSQL_DATA}
trap "clean_exit_pgsql ${PGSQL_PATH} ${PGSQL_DATA} ${PGSQL_PORT}" EXIT
LANGUAGE=C ${PGSQL_PATH}/pg_ctl -w -D ${PGSQL_DATA} -o "-N 100 -F -k ${PGSQL_DATA} -p ${PGSQL_PORT}" start
LANGUAGE=C ${PGSQL_PATH}/pg_ctl -w -D ${PGSQL_DATA} -o "-F -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