blob: ee6ea5ebaec3d7e0bcce5748fa2a21a7d9d94d2b [file] [log] [blame]
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +09001Tempest - The OpenStack Integration Test Suite
2==============================================
3
4The documentation for Tempest is officially hosted at:
5https://docs.openstack.org/tempest/latest/
6
7This is a set of integration tests to be run against a live OpenStack
8cluster. Tempest has batteries of tests for OpenStack API validation,
9scenarios, and other specific tests useful in validating an OpenStack
10deployment.
11
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +090012Design Principles
13-----------------
Ivan Anfimovf6320532026-01-08 13:30:33 +000014
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +090015Tempest Design Principles that we strive to live by.
16
17- Tempest should be able to run against any OpenStack cloud, be it a
18 one node DevStack install, a 20 node LXC cloud, or a 1000 node KVM
19 cloud.
20- Tempest should be explicit in testing features. It is easy to auto
21 discover features of a cloud incorrectly, and give people an
22 incorrect assessment of their cloud. Explicit is always better.
23- Tempest uses OpenStack public interfaces. Tests in Tempest should
24 only touch public OpenStack APIs.
25- Tempest should not touch private or implementation specific
26 interfaces. This means not directly going to the database, not
27 directly hitting the hypervisors, not testing extensions not
28 included in the OpenStack base. If there are some features of
29 OpenStack that are not verifiable through standard interfaces, this
30 should be considered a possible enhancement.
31- Tempest strives for complete coverage of the OpenStack API and
32 common scenarios that demonstrate a working cloud.
33- Tempest drives load in an OpenStack cloud. By including a broad
34 array of API and scenario tests Tempest can be reused in whole or in
35 parts as load generation for an OpenStack cloud.
36- Tempest should attempt to clean up after itself, whenever possible
37 we should tear down resources when done.
38- Tempest should be self-testing.
39
40Quickstart
41----------
42
43To run Tempest, you first need to create a configuration file that will tell
44Tempest where to find the various OpenStack services and other testing behavior
45switches. Where the configuration file lives and how you interact with it
46depends on how you'll be running Tempest. There are 2 methods of using Tempest.
47The first, which is a newer and recommended workflow treats Tempest as a system
48installed program. The second older method is to run Tempest assuming your
49working dir is the actually Tempest source repo, and there are a number of
50assumptions related to that. For this section we'll only cover the newer method
51as it is simpler, and quicker to work with.
52
53#. You first need to install Tempest. This is done with pip after you check out
54 the Tempest repo::
55
56 $ git clone https://opendev.org/openstack/tempest
57 $ pip install tempest/
58
59 This can be done within a venv, but the assumption for this guide is that
60 the Tempest CLI entry point will be in your shell's PATH.
61
62#. Installing Tempest may create a ``/etc/tempest dir``, however if one isn't
63 created you can create one or use ``~/.tempest/etc`` or ``~/.config/tempest`` in
64 place of ``/etc/tempest``. If none of these dirs are created Tempest will create
65 ``~/.tempest/etc`` when it's needed. The contents of this dir will always
66 automatically be copied to all ``etc/`` dirs in local workspaces as an initial
67 setup step. So if there is any common configuration you'd like to be shared
68 between local Tempest workspaces it's recommended that you pre-populate it
69 before running ``tempest init``.
70
71#. Setup a local Tempest workspace. This is done by using the tempest init
72 command::
73
74 $ tempest init cloud-01
75
76 which also works the same as::
77
78 $ mkdir cloud-01 && cd cloud-01 && tempest init
79
80 This will create a new directory for running a single Tempest configuration.
81 If you'd like to run Tempest against multiple OpenStack deployments the idea
82 is that you'll create a new working directory for each to maintain separate
83 configuration files and local artifact storage for each.
84
85#. Then ``cd`` into the newly created working dir and also modify the local
86 config files located in the ``etc/`` subdir created by the ``tempest init``
87 command. Tempest is expecting a ``tempest.conf`` file in etc/ so if only a
88 sample exists you must rename or copy it to tempest.conf before making
89 any changes to it otherwise Tempest will not know how to load it. For
90 details on configuring Tempest refer to the
91 `Tempest Configuration <https://docs.openstack.org/tempest/latest/configuration.html#tempest-configuration>`_
92
93#. Once the configuration is done you're now ready to run Tempest. This can
94 be done using the `Tempest Run <https://docs.openstack.org/tempest/latest/run.html#tempest-run>`_
95 command. This can be done by either
96 running::
97
98 $ tempest run
99
100 from the Tempest workspace directory. Or you can use the ``--workspace``
101 argument to run in the workspace you created regardless of your current
102 working directory. For example::
103
104 $ tempest run --workspace cloud-01
105
106 There is also the option to use `stestr`_ directly. For example, from
107 the workspace dir run::
108
Martin Kopecdc844232020-12-24 15:57:53 +0000109 $ stestr run --exclude-regex '\[.*\bslow\b.*\]' '^tempest\.(api|scenario)'
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900110
111 will run the same set of tests as the default gate jobs. Or you can
Soniya Vyas6ed6fb52019-11-26 13:24:11 +0530112 use `unittest`_ compatible test runners such as `stestr`_, `pytest`_ etc.
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900113
114 Tox also contains several existing job configurations. For example::
115
116 $ tox -e full
117
118 which will run the same set of tests as the OpenStack gate. (it's exactly how
119 the gate invokes Tempest) Or::
120
121 $ tox -e smoke
122
123 to run the tests tagged as smoke.
124
125.. _unittest: https://docs.python.org/3/library/unittest.html
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900126.. _stestr: https://stestr.readthedocs.org/en/latest/MANUAL.html
127.. _pytest: https://docs.pytest.org/en/latest/
128
129Library
130-------
Ivan Anfimovf6320532026-01-08 13:30:33 +0000131
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900132Tempest exposes a library interface. This interface is a stable interface and
133should be backwards compatible (including backwards compatibility with the
134old tempest-lib package, with the exception of the import). If you plan to
135directly consume Tempest in your project you should only import code from the
136Tempest library interface, other pieces of Tempest do not have the same
137stable interface and there are no guarantees on the Python API unless otherwise
138stated.
139
140For more details refer to the `library documentation
141<https://docs.openstack.org/tempest/latest/library.html#library>`_
142
143Release Versioning
144------------------
Ivan Anfimovf6320532026-01-08 13:30:33 +0000145
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900146`Tempest Release Notes <https://docs.openstack.org/releasenotes/tempest>`_
147shows what changes have been released on each version.
148
149Tempest's released versions are broken into 2 sets of information. Depending on
150how you intend to consume Tempest you might need
151
152The version is a set of 3 numbers:
153
154X.Y.Z
155
156While this is almost `semver`_ like, the way versioning is handled is slightly
157different:
158
159X is used to represent the supported OpenStack releases for Tempest tests
160in-tree, and to signify major feature changes to Tempest. It's a monotonically
161increasing integer where each version either indicates a new supported OpenStack
162release, the drop of support for an OpenStack release (which will coincide with
163the upstream stable branch going EOL), or a major feature lands (or is removed)
164from Tempest.
165
166Y.Z is used to represent library interface changes. This is treated the same
167way as minor and patch versions from `semver`_ but only for the library
168interface. When Y is incremented we've added functionality to the library
169interface and when Z is incremented it's a bug fix release for the library.
170Also note that both Y and Z are reset to 0 at each increment of X.
171
172.. _semver: https://semver.org/
173
174Configuration
175-------------
176
177Detailed configuration of Tempest is beyond the scope of this
178document, see `Tempest Configuration Documentation
179<https://docs.openstack.org/tempest/latest/configuration.html#tempest-configuration>`_
180for more details on configuring Tempest.
181The ``etc/tempest.conf.sample`` attempts to be a self-documenting
182version of the configuration.
183
184You can generate a new sample tempest.conf file, run the following
185command from the top level of the Tempest directory::
186
187 $ tox -e genconfig
188
189The most important pieces that are needed are the user ids, OpenStack
190endpoints, and basic flavors and images needed to run tests.
191
192Unit Tests
193----------
194
195Tempest also has a set of unit tests which test the Tempest code itself. These
196tests can be run by specifying the test discovery path::
197
198 $ stestr --test-path ./tempest/tests run
199
200By setting ``--test-path`` option to ./tempest/tests it specifies that test discover
201should only be run on the unit test directory. The default value of ``test_path``
202is ``test_path=./tempest/test_discover`` which will only run test discover on the
203Tempest suite.
204
Masayuki Igawa5fbca522022-10-12 13:35:17 +0900205Alternatively, there is the py39 tox job which will run the unit tests with
206the corresponding version of python.
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900207
208One common activity is to just run a single test, you can do this with tox
Masayuki Igawa5fbca522022-10-12 13:35:17 +0900209simply by specifying to just run py39 tests against a single test::
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900210
Masayuki Igawa5fbca522022-10-12 13:35:17 +0900211 $ tox -e py39 -- -n tempest.tests.test_microversions.TestMicroversionsTestsClass.test_config_version_none_23
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900212
213Or all tests in the test_microversions.py file::
214
Masayuki Igawa5fbca522022-10-12 13:35:17 +0900215 $ tox -e py39 -- -n tempest.tests.test_microversions
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900216
217You may also use regular expressions to run any matching tests::
218
Masayuki Igawa5fbca522022-10-12 13:35:17 +0900219 $ tox -e py39 -- test_microversions
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900220
221Additionally, when running a single test, or test-file, the ``-n/--no-discover``
222argument is no longer required, however it may perform faster if included.
223
224For more information on these options and details about stestr, please see the
225`stestr documentation <https://stestr.readthedocs.io/en/latest/MANUAL.html>`_.
226
227Python 3.x
228----------
229
230Starting during the Pike cycle Tempest has a gating CI job that runs Tempest
231with Python 3. Any Tempest release after 15.0.0 should fully support running
232under Python 3 as well as Python 2.7.
233
234Legacy run method
235-----------------
236
237The legacy method of running Tempest is to just treat the Tempest source code
238as a python unittest repository and run directly from the source repo. When
239running in this way you still start with a Tempest config file and the steps
240are basically the same except that it expects you know where the Tempest code
241lives on your system and requires a bit more manual interaction to get Tempest
242running. For example, when running Tempest this way things like a lock file
243directory do not get generated automatically and the burden is on the user to
244create and configure that.
245
246To start you need to create a configuration file. The easiest way to create a
247configuration file is to generate a sample in the ``etc/`` directory ::
248
249 $ cd $TEMPEST_ROOT_DIR
250 $ oslo-config-generator --config-file \
251 tempest/cmd/config-generator.tempest.conf \
252 --output-file etc/tempest.conf
253
254After that, open up the ``etc/tempest.conf`` file and edit the
255configuration variables to match valid data in your environment.
256This includes your Keystone endpoint, a valid user and credentials,
257and reference data to be used in testing.
258
259.. note::
260
261 If you have a running DevStack environment, Tempest will be
262 automatically configured and placed in ``/opt/stack/tempest``. It
263 will have a configuration file already set up to work with your
264 DevStack installation.
265
Soniya Vyas6ed6fb52019-11-26 13:24:11 +0530266Tempest is not tied to any single test runner, but `stestr`_ is the most commonly
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900267used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
268
269After setting up your configuration file, you can execute the set of Tempest
Soniya Vyas6ed6fb52019-11-26 13:24:11 +0530270tests by using ``stestr``. By default, ``stestr`` runs tests in parallel ::
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900271
Soniya Vyas6ed6fb52019-11-26 13:24:11 +0530272 $ stestr run
Masayuki Igawa7e4ef4c2019-07-03 17:17:44 +0900273
274To run one single test serially ::
275
Soniya Vyas6ed6fb52019-11-26 13:24:11 +0530276 $ stestr run --serial tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server