Browse Source

tox: Integrate tox-docker

This allows us to start a zookeeper instance via docker as part of the
standard tox process, avoiding issues like those described in [1]. It's
exposed as a separate target, to ensure users can use local
installations if necessary. This requires bumping the minimum version of
tox to 3.2 so we can make use of the 'requires' config option [2].

[1] https://review.openstack.org/#/c/648399/
[2] https://tox.readthedocs.io/en/latest/config.html#conf-requires

Change-Id: Ie848d409533b2a53523cd930299acf21ac10e13c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
tags/3.9.0
Stephen Finucane 7 months ago
parent
commit
390f071563
3 changed files with 26 additions and 6 deletions
  1. 5
    3
      TESTING.rst
  2. 14
    1
      tests/base.py
  3. 7
    2
      tox.ini

+ 5
- 3
TESTING.rst View File

@@ -14,11 +14,13 @@ Detailed information on testing can be found here: https://wiki.openstack.org/wi

More information on pip here: http://www.pip-installer.org/en/latest/

*Use pip to install tox*::
*Use pip to install tox and tox-docker*::

pip install tox
pip install tox tox-docker

As of zuul v3, a running zookeeper is required to execute tests.
As of zuul v3, a running zookeeper is required to execute tests. Using the
``-docker`` suffixed commands will ensure this is started automatically by tox,
but if you do not wish to use this:

*Install zookeeper*::


+ 14
- 1
tests/base.py View File

@@ -2047,7 +2047,20 @@ class ChrootedKazooFixture(fixtures.Fixture):
def __init__(self, test_id):
super(ChrootedKazooFixture, self).__init__()

zk_host = os.environ.get('NODEPOOL_ZK_HOST', 'localhost')
if 'ZOOKEEPER_2181_TCP' in os.environ:
# prevent any nasty hobbits^H^H^H suprises
if 'NODEPOOL_ZK_HOST' in os.environ:
raise Exception(
'Looks like tox-docker is being used but you have also '
'configured NODEPOOL_ZK_HOST. Either avoid using the '
'docker environment or unset NODEPOOL_ZK_HOST.')

zk_host = 'localhost:' + os.environ['ZOOKEEPER_2181_TCP']
elif 'NODEPOOL_ZK_HOST' in os.environ:
zk_host = os.environ['NODEPOOL_ZK_HOST']
else:
zk_host = 'localhost'

if ':' in zk_host:
host, port = zk_host.split(':')
else:

+ 7
- 2
tox.ini View File

@@ -1,8 +1,11 @@
[tox]
minversion = 3.1
minversion = 3.2
skipsdist = True
envlist = pep8,py35
envlist = pep8,py35{-docker}
ignore_basepython_conflict = True
# TODO(stephenfin): It would be good to set 'requires = tox-docker', but doing
# so borks the tools/pip.sh wrapper we're using here and probably isn't what
# we want in the gate :(

[testenv]
basepython = python3
@@ -28,6 +31,8 @@ whitelist_externals = bash
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
docker =
docker: zookeeper:3.4
commands =
stestr run {posargs}
stestr slowest

Loading…
Cancel
Save