Nova contains a suite of unit tests, in the nova/tests directory.
Any proposed code change will be automatically rejected by the OpenStack Jenkins server [1] if the change causes unit test failures.
The preferred way to run the unit tests is using tox. See the unit testing section of the Testing wiki page and Nova’s HACKING.rst for more information. Following are some simple examples.
To run the style tests:
tox -e pep8
You can request multiple tests, separated by commas:
tox -e py27,pep8
Instead of running all tests, you can specify an individual directory, file, class, or method that contains test code.
To run the tests in the nova/tests/unit/scheduler directory:
tox -e py27 nova.tests.unit.scheduler
To run the tests in the nova/tests/unit/virt/libvirt/test_driver.py file:
tox -e py27 test_driver
To run the tests in the CacheConcurrencyTestCase class in nova/tests/unit/virt/libvirt/test_driver.py:
tox -e py27 test_driver.CacheConcurrencyTestCase
To run the ValidateIntegerTestCase.test_invalid_inputs test method in nova/tests/unit/test_utils.py:
tox -epy27 test_utils.ValidateIntegerTestCase.test_invalid_inputs
Things to try when there are odd test failures such as failure on jenkins but not locally.
The venv can get stale. Force a refresh by adding the -r flag:
tox -r -e pep8
Footnotes
[1] | See Continuous Integration with Jenkins. |