Merge "Allow testing of MySQL and PostgreSQL scenario locally"

This commit is contained in:
Jenkins 2016-05-31 16:50:51 +00:00 committed by Gerrit Code Review
commit d1716100a9
4 changed files with 61 additions and 1 deletions

View File

@ -59,4 +59,31 @@ For MySQL you can use the following commands::
mysql> GRANT ALL PRIVILEGES ON * . * TO 'openstack_citest'@'localhost';
mysql> FLUSH PRIVILEGES;
Alternatively, you can use `pifpaf`_ to run the unit tests directly without
setting up the database yourself. You still need to have the database software
installed on your system. The following tox environments can be used::
tox -e py27-mysql
tox -e py27-postgresql
tox -e py34-mysql
tox -e py34-postgresql
tox -e py27-all
tox -e py34-all
The database will be set up for you locally and temporarily on each run.
Another way is to start `pifpaf` manually and use it to run the tests as you
wish::
$ eval `pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run postgresql`
$ echo $OS_TEST_DBAPI_ADMIN_CONNECTION
postgresql://localhost/postgres?host=/var/folders/7k/pwdhb_mj2cv4zyr0kyrlzjx40000gq/T/tmpMGqN8C&port=9824
$ tox -e py27
[…]
$ tox -e py34
[…]
# Kill pifpaf once you're done
$ kill $PIFPAF_PID
.. _wiki: https://wiki.openstack.org/wiki/Testing#Unit_Tests
.. _pifpaf: https://github.com/jd/pifpaf

View File

@ -48,6 +48,8 @@ test =
fixtures =
testresources>=0.2.4 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
pifpaf =
pifpaf>=0.1.0
[files]
packages =

7
tools/run-pifpaf-tests.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
# Replace mysql:// by mysql+pymysql:// and add sqlite
export OS_TEST_DBAPI_ADMIN_CONNECTION="${OS_TEST_DBAPI_ADMIN_CONNECTION/#mysql:/mysql+pymysql:};sqlite://"
echo $OS_TEST_DBAPI_ADMIN_CONNECTION
tools/pretty_tox.sh $*
TEST_EVENTLET=1 tools/pretty_tox.sh $*

26
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
minversion = 1.6
minversion = 1.8
envlist = py34,py27,pep8,pip-missing-reqs
[testenv]
@ -8,7 +8,9 @@ whitelist_externals = bash
setenv =
VIRTUAL_ENV={envdir}
deps = .[test,fixtures,mysql,postgresql]
py{27,34}-{postgresql,mysql,all}: .[pifpaf]
commands = bash tools/pretty_tox.sh '{posargs}'
passenv = OS_TEST_DBAPI_ADMIN_CONNECTION
[testenv:sqla_09]
commands = pip install SQLAlchemy>=0.9.0,!=0.9.5,<1.0.0
@ -19,6 +21,28 @@ commands =
env TEST_EVENTLET=0 bash tools/pretty_tox.sh '{posargs}'
env TEST_EVENTLET=1 bash tools/pretty_tox.sh '{posargs}'
[testenv:py27-all]
commands = pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run mysql -- pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run postgresql -- {toxinidir}/tools/run-pifpaf-tests.sh {posargs}
[testenv:py34-all]
commands = pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run mysql -- pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run postgresql -- {toxinidir}/tools/run-pifpaf-tests.sh {posargs}
[testenv:py27-mysql]
commands =
pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run mysql {toxinidir}/tools/run-pifpaf-tests.sh {posargs}
[testenv:py27-postgresql]
commands =
pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run postgresql {toxinidir}/tools/run-pifpaf-tests.sh {posargs}
[testenv:py34-mysql]
commands =
pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run mysql {toxinidir}/tools/run-pifpaf-tests.sh {posargs}
[testenv:py34-postgresql]
commands =
pifpaf -g OS_TEST_DBAPI_ADMIN_CONNECTION run postgresql {toxinidir}/tools/run-pifpaf-tests.sh {posargs}
[testenv:mysql-python]
deps = .[mysql-c,postgresql,test,fixtures]
setenv =