diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-05-31 16:50:51 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-05-31 16:50:51 +0000 |
commit | d1716100a992bdbf96793369cfc961af1c56b19a (patch) | |
tree | c81e0efdea028dfd1e8492ebb642f2941bda301c | |
parent | e351f4412c2dc944ef0db80d27ab6e24c515a6e3 (diff) | |
parent | 044cf85ef562da1cea696fc047277297c6ee7bf4 (diff) | |
download | oslo-db-d1716100a992bdbf96793369cfc961af1c56b19a.tar.gz |
Merge "Allow testing of MySQL and PostgreSQL scenario locally"
-rw-r--r-- | CONTRIBUTING.rst | 27 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rwxr-xr-x | tools/run-pifpaf-tests.sh | 7 | ||||
-rw-r--r-- | tox.ini | 26 |
4 files changed, 61 insertions, 1 deletions
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 019004c..aa704f9 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -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 @@ -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 = diff --git a/tools/run-pifpaf-tests.sh b/tools/run-pifpaf-tests.sh new file mode 100755 index 0000000..687b6bb --- /dev/null +++ b/tools/run-pifpaf-tests.sh @@ -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 $* @@ -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 = |