blob: e8206eea2f31f5787e4cb53d769c28dd0e837f37 [file] [log] [blame]
Flavio Percoco3d2dac72016-11-24 13:06:32 +01001========================
2Team and repository tags
3========================
4
melissamlfa64e6f2018-03-10 23:08:36 +08005.. image:: https://governance.openstack.org/tc/badges/tempest.svg
junboli477fd022017-09-06 17:25:11 +08006 :target: https://governance.openstack.org/tc/reference/tags/index.html
Flavio Percoco3d2dac72016-11-24 13:06:32 +01007
8.. Change things from this point on
9
Jay Pipes7f757632011-12-02 15:53:32 -050010Tempest - The OpenStack Integration Test Suite
11==============================================
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050012
Matthew Treinishdced4232016-07-05 11:20:12 -040013The documentation for Tempest is officially hosted at:
chenxinge98720a2017-07-19 03:42:23 +000014https://docs.openstack.org/tempest/latest/
Masayuki Igawab5d32932016-03-25 12:46:43 +090015
Sean Dagueb56052b2013-05-21 17:57:41 -040016This is a set of integration tests to be run against a live OpenStack
17cluster. Tempest has batteries of tests for OpenStack API validation,
Chang Liu98cf4672018-03-30 14:27:09 +080018scenarios, and other specific tests useful in validating an OpenStack
Sean Dagueb56052b2013-05-21 17:57:41 -040019deployment.
20
Sean Daguea26454d2013-11-01 18:09:55 -040021Design Principles
Matthew Treinish077a5632014-06-04 11:43:10 -040022-----------------
Sean Daguea26454d2013-11-01 18:09:55 -040023Tempest Design Principles that we strive to live by.
24
25- Tempest should be able to run against any OpenStack cloud, be it a
Jordan Pittier74a56ab2017-04-26 16:46:20 +020026 one node DevStack install, a 20 node LXC cloud, or a 1000 node KVM
Sean Daguea26454d2013-11-01 18:09:55 -040027 cloud.
28- Tempest should be explicit in testing features. It is easy to auto
29 discover features of a cloud incorrectly, and give people an
30 incorrect assessment of their cloud. Explicit is always better.
31- Tempest uses OpenStack public interfaces. Tests in Tempest should
Ken'ichi Ohmichib8249902016-06-01 17:11:04 -070032 only touch public OpenStack APIs.
Sean Daguea26454d2013-11-01 18:09:55 -040033- Tempest should not touch private or implementation specific
34 interfaces. This means not directly going to the database, not
35 directly hitting the hypervisors, not testing extensions not
OctopusZhang03b89002015-11-05 11:24:14 +080036 included in the OpenStack base. If there are some features of
37 OpenStack that are not verifiable through standard interfaces, this
Sean Daguea26454d2013-11-01 18:09:55 -040038 should be considered a possible enhancement.
39- Tempest strives for complete coverage of the OpenStack API and
40 common scenarios that demonstrate a working cloud.
41- Tempest drives load in an OpenStack cloud. By including a broad
42 array of API and scenario tests Tempest can be reused in whole or in
43 parts as load generation for an OpenStack cloud.
44- Tempest should attempt to clean up after itself, whenever possible
45 we should tear down resources when done.
zhangfengc53e4e12015-08-21 04:09:08 +000046- Tempest should be self-testing.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050047
48Quickstart
49----------
50
Matthew Treinish828734a2015-07-06 15:43:46 -040051To run Tempest, you first need to create a configuration file that will tell
52Tempest where to find the various OpenStack services and other testing behavior
53switches. Where the configuration file lives and how you interact with it
54depends on how you'll be running Tempest. There are 2 methods of using Tempest.
55The first, which is a newer and recommended workflow treats Tempest as a system
56installed program. The second older method is to run Tempest assuming your
57working dir is the actually Tempest source repo, and there are a number of
58assumptions related to that. For this section we'll only cover the newer method
59as it is simpler, and quicker to work with.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050060
OctopusZhang03b89002015-11-05 11:24:14 +080061#. You first need to install Tempest. This is done with pip after you check out
62 the Tempest repo::
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050063
caoyuan349ba752019-04-23 19:40:06 +080064 $ git clone https://opendev.org/openstack/tempest
OctopusZhang03b89002015-11-05 11:24:14 +080065 $ pip install tempest/
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050066
Matthew Treinish828734a2015-07-06 15:43:46 -040067 This can be done within a venv, but the assumption for this guide is that
Jordan Pittier74a56ab2017-04-26 16:46:20 +020068 the Tempest CLI entry point will be in your shell's PATH.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050069
Jordan Pittier74a56ab2017-04-26 16:46:20 +020070#. Installing Tempest may create a ``/etc/tempest dir``, however if one isn't
71 created you can create one or use ``~/.tempest/etc`` or ``~/.config/tempest`` in
72 place of ``/etc/tempest``. If none of these dirs are created Tempest will create
73 ``~/.tempest/etc`` when it's needed. The contents of this dir will always
74 automatically be copied to all ``etc/`` dirs in local workspaces as an initial
Matthew Treinish531b01c2016-07-05 10:22:52 -040075 setup step. So if there is any common configuration you'd like to be shared
76 between local Tempest workspaces it's recommended that you pre-populate it
77 before running ``tempest init``.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050078
Matthew Treinishab77cbf2016-07-01 13:55:05 -040079#. Setup a local Tempest workspace. This is done by using the tempest init
Matthew Treinish828734a2015-07-06 15:43:46 -040080 command::
Jay Pipes7f757632011-12-02 15:53:32 -050081
Ken'ichi Ohmichi9883ff22016-04-22 18:24:15 -070082 $ tempest init cloud-01
Matthew Treinisha970d652015-03-11 15:39:24 -040083
Matthew Treinishab77cbf2016-07-01 13:55:05 -040084 which also works the same as::
Attila Fazekas58d23302013-07-24 10:25:02 +020085
Ken'ichi Ohmichi9883ff22016-04-22 18:24:15 -070086 $ mkdir cloud-01 && cd cloud-01 && tempest init
Daryl Wallecke36f6232012-03-06 00:21:45 -060087
Matthew Treinish828734a2015-07-06 15:43:46 -040088 This will create a new directory for running a single Tempest configuration.
89 If you'd like to run Tempest against multiple OpenStack deployments the idea
90 is that you'll create a new working directory for each to maintain separate
91 configuration files and local artifact storage for each.
Attila Fazekas58d23302013-07-24 10:25:02 +020092
Jordan Pittier74a56ab2017-04-26 16:46:20 +020093#. Then ``cd`` into the newly created working dir and also modify the local
94 config files located in the ``etc/`` subdir created by the ``tempest init``
95 command. Tempest is expecting a ``tempest.conf`` file in etc/ so if only a
Matthew Treinish828734a2015-07-06 15:43:46 -040096 sample exists you must rename or copy it to tempest.conf before making
Matthew Treinishdced4232016-07-05 11:20:12 -040097 any changes to it otherwise Tempest will not know how to load it. For
ghanshyam36624992018-08-16 07:49:54 +000098 details on configuring Tempest refer to the
99 `Tempest Configuration <https://docs.openstack.org/tempest/latest/configuration.html#tempest-configuration>`_
Matthew Treinisha970d652015-03-11 15:39:24 -0400100
Matthew Treinish828734a2015-07-06 15:43:46 -0400101#. Once the configuration is done you're now ready to run Tempest. This can
ghanshyam36624992018-08-16 07:49:54 +0000102 be done using the `Tempest Run <https://docs.openstack.org/tempest/latest/run.html#tempest-run>`_
103 command. This can be done by either
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400104 running::
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400105
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900106 $ tempest run
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400107
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400108 from the Tempest workspace directory. Or you can use the ``--workspace``
zhufl5eccdf42017-03-16 10:08:18 +0800109 argument to run in the workspace you created regardless of your current
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400110 working directory. For example::
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400111
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900112 $ tempest run --workspace cloud-01
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400113
Masayuki Igawaac0b1712018-03-09 16:20:42 +0900114 There is also the option to use `stestr`_ directly. For example, from
115 the workspace dir run::
Matthew Treinishb17460e2013-09-17 17:04:03 +0000116
Masayuki Igawaac0b1712018-03-09 16:20:42 +0900117 $ stestr run --black-regex '\[.*\bslow\b.*\]' '^tempest\.(api|scenario)'
Matthew Treinisha970d652015-03-11 15:39:24 -0400118
Masayuki Igawaac0b1712018-03-09 16:20:42 +0900119 will run the same set of tests as the default gate jobs. Or you can
120 use `unittest`_ compatible test runners such as `testr`_, `pytest`_ etc.
Matthew Treinisha970d652015-03-11 15:39:24 -0400121
Masayuki Igawaac0b1712018-03-09 16:20:42 +0900122.. _unittest: https://docs.python.org/3/library/unittest.html
Matthew Treinish828734a2015-07-06 15:43:46 -0400123.. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html
Masayuki Igawaac0b1712018-03-09 16:20:42 +0900124.. _stestr: https://stestr.readthedocs.org/en/latest/MANUAL.html
125.. _pytest: https://docs.pytest.org/en/latest/
nayna-patelddb489c2012-11-13 22:06:45 +0000126
Matthew Treinish55511d92016-02-23 10:55:53 -0500127Library
128-------
129Tempest exposes a library interface. This interface is a stable interface and
130should be backwards compatible (including backwards compatibility with the
131old tempest-lib package, with the exception of the import). If you plan to
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200132directly consume Tempest in your project you should only import code from the
133Tempest library interface, other pieces of Tempest do not have the same
Matthew Treinish55511d92016-02-23 10:55:53 -0500134stable interface and there are no guarantees on the Python API unless otherwise
135stated.
136
ghanshyam8316f962018-08-16 12:13:02 +0000137For more details refer to the `library documentation
ghanshyam36624992018-08-16 07:49:54 +0000138<https://docs.openstack.org/tempest/latest/library.html#library>`_
Matthew Treinish55511d92016-02-23 10:55:53 -0500139
140Release Versioning
141------------------
davyyyac670dc2017-11-16 21:27:03 +0800142`Tempest Release Notes <https://docs.openstack.org/releasenotes/tempest>`_
Ken'ichi Ohmichi7f5e1d72016-08-29 12:01:44 -0700143shows what changes have been released on each version.
144
Matthew Treinish55511d92016-02-23 10:55:53 -0500145Tempest's released versions are broken into 2 sets of information. Depending on
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200146how you intend to consume Tempest you might need
Matthew Treinish55511d92016-02-23 10:55:53 -0500147
148The version is a set of 3 numbers:
149
150X.Y.Z
151
152While this is almost `semver`_ like, the way versioning is handled is slightly
153different:
154
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200155X is used to represent the supported OpenStack releases for Tempest tests
156in-tree, and to signify major feature changes to Tempest. It's a monotonically
Matthew Treinish55511d92016-02-23 10:55:53 -0500157increasing integer where each version either indicates a new supported OpenStack
158release, the drop of support for an OpenStack release (which will coincide with
159the upstream stable branch going EOL), or a major feature lands (or is removed)
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200160from Tempest.
Matthew Treinish55511d92016-02-23 10:55:53 -0500161
162Y.Z is used to represent library interface changes. This is treated the same
163way as minor and patch versions from `semver`_ but only for the library
164interface. When Y is incremented we've added functionality to the library
165interface and when Z is incremented it's a bug fix release for the library.
166Also note that both Y and Z are reset to 0 at each increment of X.
167
sunqingliang68606c832018-11-09 14:25:17 +0800168.. _semver: https://semver.org/
Matthew Treinish55511d92016-02-23 10:55:53 -0500169
Daryl Wallecke36f6232012-03-06 00:21:45 -0600170Configuration
171-------------
172
Joe H. Rahme00a75422015-03-16 17:46:24 +0100173Detailed configuration of Tempest is beyond the scope of this
ghanshyam36624992018-08-16 07:49:54 +0000174document, see `Tempest Configuration Documentation
175<https://docs.openstack.org/tempest/latest/configuration.html#tempest-configuration>`_
176for more details on configuring Tempest.
177The ``etc/tempest.conf.sample`` attempts to be a self-documenting
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200178version of the configuration.
Sean Dagueb56052b2013-05-21 17:57:41 -0400179
Matthew Treinisha970d652015-03-11 15:39:24 -0400180You can generate a new sample tempest.conf file, run the following
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900181command from the top level of the Tempest directory::
Masayuki Igawaac401c72014-11-18 15:28:46 +0900182
Hai Shi6f52fc52017-04-03 21:17:37 +0800183 $ tox -e genconfig
Matthew Treinish6eb05852013-11-26 15:28:12 +0000184
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200185The most important pieces that are needed are the user ids, OpenStack
186endpoints, and basic flavors and images needed to run tests.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000187
188Unit Tests
189----------
190
Joe H. Rahme00a75422015-03-16 17:46:24 +0100191Tempest also has a set of unit tests which test the Tempest code itself. These
Atsushi SAKAI0a183b82015-07-28 21:52:17 +0900192tests can be run by specifying the test discovery path::
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000193
Masayuki Igawaebe46982017-09-14 16:38:40 -0600194 $ stestr --test-path ./tempest/tests run
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000195
Masayuki Igawaebe46982017-09-14 16:38:40 -0600196By setting ``--test-path`` option to ./tempest/tests it specifies that test discover
197should only be run on the unit test directory. The default value of ``test_path``
198is ``test_path=./tempest/test_discover`` which will only run test discover on the
Joe H. Rahme00a75422015-03-16 17:46:24 +0100199Tempest suite.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000200
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900201Alternatively, there are the py27 and py36 tox jobs which will run the unit
Masayuki Igawaafb11432016-06-02 16:09:50 +0900202tests with the corresponding version of python.
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500203
junboli9e25a572017-11-22 14:42:30 +0800204One common activity is to just run a single test, you can do this with tox
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900205simply by specifying to just run py27 or py36 tests against a single test::
junboli9e25a572017-11-22 14:42:30 +0800206
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900207 $ tox -e py36 -- -n tempest.tests.test_microversions.TestMicroversionsTestsClass.test_config_version_none_23
junboli9e25a572017-11-22 14:42:30 +0800208
209Or all tests in the test_microversions.py file::
210
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900211 $ tox -e py36 -- -n tempest.tests.test_microversions
junboli9e25a572017-11-22 14:42:30 +0800212
213You may also use regular expressions to run any matching tests::
214
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900215 $ tox -e py36 -- test_microversions
junboli9e25a572017-11-22 14:42:30 +0800216
217Additionally, when running a single test, or test-file, the ``-n/--no-discover``
218argument is no longer required, however it may perform faster if included.
219
220For more information on these options and details about stestr, please see the
sunqingliang68606c832018-11-09 14:25:17 +0800221`stestr documentation <https://stestr.readthedocs.io/en/latest/MANUAL.html>`_.
junboli9e25a572017-11-22 14:42:30 +0800222
Matthew Treinish315aa212016-10-13 17:35:47 -0400223Python 3.x
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400224----------
225
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200226Starting during the Pike cycle Tempest has a gating CI job that runs Tempest
227with Python 3. Any Tempest release after 15.0.0 should fully support running
Matthew Treinisha60fe382017-03-02 17:15:05 -0500228under Python 3 as well as Python 2.7.
Matthew Treinish828734a2015-07-06 15:43:46 -0400229
230Legacy run method
231-----------------
232
233The legacy method of running Tempest is to just treat the Tempest source code
234as a python unittest repository and run directly from the source repo. When
235running in this way you still start with a Tempest config file and the steps
236are basically the same except that it expects you know where the Tempest code
237lives on your system and requires a bit more manual interaction to get Tempest
238running. For example, when running Tempest this way things like a lock file
239directory do not get generated automatically and the burden is on the user to
240create and configure that.
241
242To start you need to create a configuration file. The easiest way to create a
243configuration file is to generate a sample in the ``etc/`` directory ::
244
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700245 $ cd $TEMPEST_ROOT_DIR
246 $ oslo-config-generator --config-file \
Erickson Santos7d274ed2016-07-26 14:16:57 +0000247 tempest/cmd/config-generator.tempest.conf \
Matthew Treinish828734a2015-07-06 15:43:46 -0400248 --output-file etc/tempest.conf
249
250After that, open up the ``etc/tempest.conf`` file and edit the
251configuration variables to match valid data in your environment.
252This includes your Keystone endpoint, a valid user and credentials,
253and reference data to be used in testing.
254
255.. note::
256
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200257 If you have a running DevStack environment, Tempest will be
Matthew Treinish828734a2015-07-06 15:43:46 -0400258 automatically configured and placed in ``/opt/stack/tempest``. It
259 will have a configuration file already set up to work with your
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200260 DevStack installation.
Matthew Treinish828734a2015-07-06 15:43:46 -0400261
262Tempest is not tied to any single test runner, but `testr`_ is the most commonly
263used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
264
265After setting up your configuration file, you can execute the set of Tempest
266tests by using ``testr`` ::
267
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700268 $ testr run --parallel
Matthew Treinish828734a2015-07-06 15:43:46 -0400269
Matthew Treinish828734a2015-07-06 15:43:46 -0400270To run one single test serially ::
271
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700272 $ testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
Matthew Treinish828734a2015-07-06 15:43:46 -0400273
Jordan Pittier27ca2512017-02-22 16:25:28 +0100274Tox also contains several existing job configurations. For example::
Matthew Treinish828734a2015-07-06 15:43:46 -0400275
Hai Shi6f52fc52017-04-03 21:17:37 +0800276 $ tox -e full
Matthew Treinish828734a2015-07-06 15:43:46 -0400277
278which will run the same set of tests as the OpenStack gate. (it's exactly how
279the gate invokes Tempest) Or::
280
Hai Shi6f52fc52017-04-03 21:17:37 +0800281 $ tox -e smoke
Matthew Treinish828734a2015-07-06 15:43:46 -0400282
283to run the tests tagged as smoke.