blob: 289af5c2bcf54b794d709fd84e187a43594eb843 [file] [log] [blame]
James E. Blair9ab86622013-07-02 11:23:46 -07001===========================
2Testing Your OpenStack Code
3===========================
4------------
5A Quickstart
6------------
7
8This is designed to be enough information for you to run your first tests.
9Detailed 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
Monty Taylor4a781a72017-07-25 07:28:04 -040014
James E. Blair9ab86622013-07-02 11:23:46 -070015More information on pip here: http://www.pip-installer.org/en/latest/
16
17*Use pip to install tox*::
18
19 pip install tox
20
Jesse Keatingda819532017-03-01 13:17:59 -080021As of zuul v3, a running zookeeper is required to execute tests.
22
23*Install zookeeper*::
24
25 [apt-get | yum] install zookeeperd
26
27*Start zookeeper*::
28
29 service zookeeper start
30
Monty Taylor4a781a72017-07-25 07:28:04 -040031.. note:: Installing and bulding javascript is not required, but tests that
32 depend on the javascript assets having been built will be skipped
33 if you don't.
34
35*Install javascript tools*::
36
37 tools/install-js-tools.sh
38
39*Install javascript dependencies*::
40
41 yarn install
42
43*Build javascript assets*::
44
45 npm run build:dev
46
James E. Blair9ab86622013-07-02 11:23:46 -070047Run The Tests
48-------------
49
50*Navigate to the project's root directory and execute*::
51
52 tox
53Note: completing this command may take a long time (depends on system resources)
54also, you might not see any output until tox is complete.
55
56Information about tox can be found here: http://testrun.org/tox/latest/
57
58
59Run The Tests in One Environment
60--------------------------------
61
62Tox will run your entire test suite in the environments specified in the project tox.ini::
63
64 [tox]
65
66 envlist = <list of available environments>
67
68To run the test suite in just one of the environments in envlist execute::
69
70 tox -e <env>
71so for example, *run the test suite in py26*::
72
73 tox -e py26
74
75Run One Test
76------------
77
78To run individual tests with tox::
79
80 tox -e <env> -- path.to.module.Class.test
81
82For example, to *run the basic Zuul test*::
83
Paul Belanger174a8272017-03-14 13:20:10 -040084 tox -e py27 -- tests.unit.test_scheduler.TestScheduler.test_jobs_executed
James E. Blair9ab86622013-07-02 11:23:46 -070085
86To *run one test in the foreground* (after previously having run tox
87to set up the virtualenv)::
88
Paul Belanger174a8272017-03-14 13:20:10 -040089 .tox/py27/bin/python -m testtools.run tests.unit.test_scheduler.TestScheduler.test_jobs_executed
James E. Blair9ab86622013-07-02 11:23:46 -070090
James E. Blairdda6c912013-07-29 14:12:12 -070091List Failing Tests
92------------------
93
94 .tox/py27/bin/activate
95 testr failing --list
96
James E. Blair6c358e72013-07-29 17:06:47 -070097Hanging Tests
98-------------
99
100The following will run each test in turn and print the name of the
101test as it is run::
102
103 . .tox/py27/bin/activate
104 testr run --subunit | subunit2pyunit
105
106You can compare the output of that to::
107
108 python -m testtools.run discover --list
109
James E. Blair9ab86622013-07-02 11:23:46 -0700110Need More Info?
111---------------
112
113More information about testr: https://wiki.openstack.org/wiki/Testr
114
115More information about nose: https://nose.readthedocs.org/en/latest/
116
117
118More information about testing OpenStack code can be found here:
119https://wiki.openstack.org/wiki/Testing