Testing is and will always be an integral part of any software development. OpenStack is no exception. In OpenStack, unit testing is done using tox.
Installing tox,
Tox has various tests defined in the envlist. One can open tox.ini for a complete list of envs defined.
OpenStack defines, py27 and pep8 test. Former is for unittests and later for style checks.
To run all tests,
tox requires some elaborate environment setups which can sometimes be tricky. Here are some errors whcih I came across during my installation. For posterity, I'm documenting them in this blog,
ERROR:
Solution:
ERROR:
Solution:
Installing tox,
[apt-get | yum] install python-pip; pip install tox
Tox has various tests defined in the envlist. One can open tox.ini for a complete list of envs defined.
OpenStack defines, py27 and pep8 test. Former is for unittests and later for style checks.
How to run tox and testr
Tox can use used to list unit tests and execute all of them or any subset of them using regex.To run all tests,
tox -e py27 # you can chose any other environment like py26 if you likeTo run only selected tests,
tox -e py --One can get the test_name either from the source code of the project concerned or by asking tox to list them out. For example, the tests defined in nova.tests.compute.test_compute_cells.py are accessible by 'nova.tests.unit.compute.test_compute_cells.*'. Alternatively to list the tests using tox one has to go to tox shell after sourcing the virtual env.
source .tox/py27/bin/activate
testr list-testsWith the venv sourced we can run testr directly.
testr help
testr run --parallel
After tests have run you can view the failing tests then run only that list of tests.testr run --parallel
Errors and workaround
tox requires some elaborate environment setups which can sometimes be tricky. Here are some errors whcih I came across during my installation. For posterity, I'm documenting them in this blog,
ERROR:
Package libvirt was not found in the pkg-config search path.
Perhaps you should add the directory containing `libvirt.pc'
to the PKG_CONFIG_PATH environment variable
Solution:
sudo yum install libvirt-devel
ERROR:
fatal error: my_config.h: No such file or directory
Solution:
sudo yum install mysql-devel
Comments
Post a Comment