blob: 0786ebf408785840fd87b993a46589dbb0a4ea67 [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
14More 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 Keatingda819532017-03-01 13:17:59 -080020As 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. Blair9ab86622013-07-02 11:23:46 -070030Run The Tests
31-------------
32
33*Navigate to the project's root directory and execute*::
34
35 tox
36Note: completing this command may take a long time (depends on system resources)
37also, you might not see any output until tox is complete.
38
39Information about tox can be found here: http://testrun.org/tox/latest/
40
41
42Run The Tests in One Environment
43--------------------------------
44
45Tox 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
51To run the test suite in just one of the environments in envlist execute::
52
53 tox -e <env>
54so for example, *run the test suite in py26*::
55
56 tox -e py26
57
58Run One Test
59------------
60
61To run individual tests with tox::
62
63 tox -e <env> -- path.to.module.Class.test
64
65For example, to *run the basic Zuul test*::
66
Paul Belanger174a8272017-03-14 13:20:10 -040067 tox -e py27 -- tests.unit.test_scheduler.TestScheduler.test_jobs_executed
James E. Blair9ab86622013-07-02 11:23:46 -070068
69To *run one test in the foreground* (after previously having run tox
70to set up the virtualenv)::
71
Paul Belanger174a8272017-03-14 13:20:10 -040072 .tox/py27/bin/python -m testtools.run tests.unit.test_scheduler.TestScheduler.test_jobs_executed
James E. Blair9ab86622013-07-02 11:23:46 -070073
James E. Blairdda6c912013-07-29 14:12:12 -070074List Failing Tests
75------------------
76
77 .tox/py27/bin/activate
78 testr failing --list
79
James E. Blair6c358e72013-07-29 17:06:47 -070080Hanging Tests
81-------------
82
83The following will run each test in turn and print the name of the
84test as it is run::
85
86 . .tox/py27/bin/activate
87 testr run --subunit | subunit2pyunit
88
89You can compare the output of that to::
90
91 python -m testtools.run discover --list
92
James E. Blair9ab86622013-07-02 11:23:46 -070093Need More Info?
94---------------
95
96More information about testr: https://wiki.openstack.org/wiki/Testr
97
98More information about nose: https://nose.readthedocs.org/en/latest/
99
100
101More information about testing OpenStack code can be found here:
102https://wiki.openstack.org/wiki/Testing