James E. Blair | 9ab8662 | 2013-07-02 11:23:46 -0700 | [diff] [blame] | 1 | =========================== |
| 2 | Testing Your OpenStack Code |
| 3 | =========================== |
| 4 | ------------ |
| 5 | A Quickstart |
| 6 | ------------ |
| 7 | |
| 8 | This is designed to be enough information for you to run your first tests. |
| 9 | Detailed information on testing can be found here: https://wiki.openstack.org/wiki/Testing |
| 10 | |
| 11 | *Install pip*:: |
| 12 | |
| 13 | [apt-get | yum] install python-pip |
| 14 | More information on pip here: http://www.pip-installer.org/en/latest/ |
| 15 | |
| 16 | *Use pip to install tox*:: |
| 17 | |
| 18 | pip install tox |
| 19 | |
Jesse Keating | da81953 | 2017-03-01 13:17:59 -0800 | [diff] [blame] | 20 | As of zuul v3, a running zookeeper is required to execute tests. |
| 21 | |
| 22 | *Install zookeeper*:: |
| 23 | |
| 24 | [apt-get | yum] install zookeeperd |
| 25 | |
| 26 | *Start zookeeper*:: |
| 27 | |
| 28 | service zookeeper start |
| 29 | |
James E. Blair | 9ab8662 | 2013-07-02 11:23:46 -0700 | [diff] [blame] | 30 | Run The Tests |
| 31 | ------------- |
| 32 | |
| 33 | *Navigate to the project's root directory and execute*:: |
| 34 | |
| 35 | tox |
| 36 | Note: completing this command may take a long time (depends on system resources) |
| 37 | also, you might not see any output until tox is complete. |
| 38 | |
| 39 | Information about tox can be found here: http://testrun.org/tox/latest/ |
| 40 | |
| 41 | |
| 42 | Run The Tests in One Environment |
| 43 | -------------------------------- |
| 44 | |
| 45 | Tox will run your entire test suite in the environments specified in the project tox.ini:: |
| 46 | |
| 47 | [tox] |
| 48 | |
| 49 | envlist = <list of available environments> |
| 50 | |
| 51 | To run the test suite in just one of the environments in envlist execute:: |
| 52 | |
| 53 | tox -e <env> |
| 54 | so for example, *run the test suite in py26*:: |
| 55 | |
| 56 | tox -e py26 |
| 57 | |
| 58 | Run One Test |
| 59 | ------------ |
| 60 | |
| 61 | To run individual tests with tox:: |
| 62 | |
| 63 | tox -e <env> -- path.to.module.Class.test |
| 64 | |
| 65 | For example, to *run the basic Zuul test*:: |
| 66 | |
| 67 | tox -e py27 -- tests.test_scheduler.TestScheduler.test_jobs_launched |
| 68 | |
| 69 | To *run one test in the foreground* (after previously having run tox |
| 70 | to set up the virtualenv):: |
| 71 | |
| 72 | .tox/py27/bin/python -m testtools.run tests.test_scheduler.TestScheduler.test_jobs_launched |
| 73 | |
James E. Blair | dda6c91 | 2013-07-29 14:12:12 -0700 | [diff] [blame] | 74 | List Failing Tests |
| 75 | ------------------ |
| 76 | |
| 77 | .tox/py27/bin/activate |
| 78 | testr failing --list |
| 79 | |
James E. Blair | 6c358e7 | 2013-07-29 17:06:47 -0700 | [diff] [blame] | 80 | Hanging Tests |
| 81 | ------------- |
| 82 | |
| 83 | The following will run each test in turn and print the name of the |
| 84 | test as it is run:: |
| 85 | |
| 86 | . .tox/py27/bin/activate |
| 87 | testr run --subunit | subunit2pyunit |
| 88 | |
| 89 | You can compare the output of that to:: |
| 90 | |
| 91 | python -m testtools.run discover --list |
| 92 | |
James E. Blair | 9ab8662 | 2013-07-02 11:23:46 -0700 | [diff] [blame] | 93 | Need More Info? |
| 94 | --------------- |
| 95 | |
| 96 | More information about testr: https://wiki.openstack.org/wiki/Testr |
| 97 | |
| 98 | More information about nose: https://nose.readthedocs.org/en/latest/ |
| 99 | |
| 100 | |
| 101 | More information about testing OpenStack code can be found here: |
| 102 | https://wiki.openstack.org/wiki/Testing |