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