Merge "Run unit tests against PostgreSQL"

This commit is contained in:
Jenkins 2014-10-06 08:53:37 +00:00 committed by Gerrit Code Review
commit 559018300c
4 changed files with 39 additions and 6 deletions

View File

@ -65,13 +65,13 @@ class MongoDbManager(fixtures.Fixture):
}
class MySQLDbManager(fixtures.Fixture):
class SQLManager(fixtures.Fixture):
def __init__(self, url):
self._url = url
def setUp(self):
super(MySQLDbManager, self).setUp()
super(SQLManager, self).setUp()
self.connection = storage.get_connection(
self.url, 'ceilometer.metering.storage')
self.alarm_connection = storage.get_connection(
@ -143,7 +143,8 @@ class TestBase(testscenarios.testcase.WithScenarios, test_base.BaseTestCase):
DRIVER_MANAGERS = {
'mongodb': MongoDbManager,
'mysql': MySQLDbManager,
'mysql': SQLManager,
'postgresql': SQLManager,
'db2': MongoDbManager,
'sqlite': SQLiteManager,
'hbase': HBaseManager,
@ -237,7 +238,7 @@ class MixinTestsWithBackendScenarios(object):
('sqlite', {'db_url': 'sqlite://'}),
]
for db in ('MONGODB', 'MYSQL', 'HBASE', 'DB2'):
for db in ('MONGODB', 'MYSQL', 'PGSQL', 'HBASE', 'DB2'):
if os.environ.get('CEILOMETER_TEST_%s_URL' % db):
scenarios.append(
(db.lower(), {'db_url': os.environ.get(

View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
source functions.sh
if [ "$1" = "--coverage" ]; then
COVERAGE_ARG="$1"
shift
fi
#export PATH=${PATH:+$PATH:}/sbin:/usr/sbin
check_for_cmd pg_config
# Start PostgreSQL process for tests
PGSQL_DATA=`mktemp -d /tmp/CEILO-PGSQL-XXXXX`
trap "clean_exit ${PGSQL_DATA}" EXIT
PGSQL_PATH=`pg_config --bindir`
${PGSQL_PATH}/initdb ${PGSQL_DATA}
mkfifo ${PGSQL_DATA}/out
${PGSQL_PATH}/postgres -N 100 -F -k ${PGSQL_DATA} -D ${PGSQL_DATA} -p 9823 &> ${PGSQL_DATA}/out &
# Wait for PostgreSQL to start listening to connections
wait_for_line "database system is ready to accept connections" ${PGSQL_DATA}/out
export CEILOMETER_TEST_PGSQL_URL="postgresql:///?host=${PGSQL_DATA}&port=9823&dbname=template1"
# Yield execution to venv command
$*

View File

@ -15,6 +15,7 @@ MySQL-python
# Docs Requirements
oslosphinx>=2.2.0 # Apache-2.0
oslotest>=1.1.0 # Apache-2.0
psycopg2
pymongo>=2.5
python-subunit>=0.0.18
sphinx>=1.1.2,!=1.2.0,<1.3

View File

@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = py26,py27,py27-mysql,py33,pep8
envlist = py26,py27,py33,py-mysql,py-pgsql,pep8
[testenv]
deps = -r{toxinidir}/requirements.txt
@ -16,10 +16,14 @@ commands =
downloadcache = {toxworkdir}/_download
whitelist_externals = bash
[testenv:py27-mysql]
[testenv:py-mysql]
commands =
bash -x {toxinidir}/setup-test-env-mysql.sh python setup.py testr --slowest --testr-args="{posargs}"
[testenv:py-pgsql]
commands =
bash -x {toxinidir}/setup-test-env-postgresql.sh python setup.py testr --slowest --testr-args="{posargs}"
[testenv:py33]
deps = -r{toxinidir}/requirements-py3.txt
-r{toxinidir}/test-requirements-py3.txt