blob: 841fae684c967d2ee21131bf823e147a2c263824 [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 Igawa80105b72019-06-05 19:04:59 +0900122 Tox also contains several existing job configurations. For example::
123
124 $ tox -e full
125
126 which will run the same set of tests as the OpenStack gate. (it's exactly how
127 the gate invokes Tempest) Or::
128
129 $ tox -e smoke
130
131 to run the tests tagged as smoke.
132
Masayuki Igawaac0b1712018-03-09 16:20:42 +0900133.. _unittest: https://docs.python.org/3/library/unittest.html
Matthew Treinish828734a2015-07-06 15:43:46 -0400134.. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html
Masayuki Igawaac0b1712018-03-09 16:20:42 +0900135.. _stestr: https://stestr.readthedocs.org/en/latest/MANUAL.html
136.. _pytest: https://docs.pytest.org/en/latest/
nayna-patelddb489c2012-11-13 22:06:45 +0000137
Matthew Treinish55511d92016-02-23 10:55:53 -0500138Library
139-------
140Tempest exposes a library interface. This interface is a stable interface and
141should be backwards compatible (including backwards compatibility with the
142old tempest-lib package, with the exception of the import). If you plan to
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200143directly consume Tempest in your project you should only import code from the
144Tempest library interface, other pieces of Tempest do not have the same
Matthew Treinish55511d92016-02-23 10:55:53 -0500145stable interface and there are no guarantees on the Python API unless otherwise
146stated.
147
ghanshyam8316f962018-08-16 12:13:02 +0000148For more details refer to the `library documentation
ghanshyam36624992018-08-16 07:49:54 +0000149<https://docs.openstack.org/tempest/latest/library.html#library>`_
Matthew Treinish55511d92016-02-23 10:55:53 -0500150
151Release Versioning
152------------------
davyyyac670dc2017-11-16 21:27:03 +0800153`Tempest Release Notes <https://docs.openstack.org/releasenotes/tempest>`_
Ken'ichi Ohmichi7f5e1d72016-08-29 12:01:44 -0700154shows what changes have been released on each version.
155
Matthew Treinish55511d92016-02-23 10:55:53 -0500156Tempest's released versions are broken into 2 sets of information. Depending on
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200157how you intend to consume Tempest you might need
Matthew Treinish55511d92016-02-23 10:55:53 -0500158
159The version is a set of 3 numbers:
160
161X.Y.Z
162
163While this is almost `semver`_ like, the way versioning is handled is slightly
164different:
165
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200166X is used to represent the supported OpenStack releases for Tempest tests
167in-tree, and to signify major feature changes to Tempest. It's a monotonically
Matthew Treinish55511d92016-02-23 10:55:53 -0500168increasing integer where each version either indicates a new supported OpenStack
169release, the drop of support for an OpenStack release (which will coincide with
170the upstream stable branch going EOL), or a major feature lands (or is removed)
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200171from Tempest.
Matthew Treinish55511d92016-02-23 10:55:53 -0500172
173Y.Z is used to represent library interface changes. This is treated the same
174way as minor and patch versions from `semver`_ but only for the library
175interface. When Y is incremented we've added functionality to the library
176interface and when Z is incremented it's a bug fix release for the library.
177Also note that both Y and Z are reset to 0 at each increment of X.
178
sunqingliang68606c832018-11-09 14:25:17 +0800179.. _semver: https://semver.org/
Matthew Treinish55511d92016-02-23 10:55:53 -0500180
Daryl Wallecke36f6232012-03-06 00:21:45 -0600181Configuration
182-------------
183
Joe H. Rahme00a75422015-03-16 17:46:24 +0100184Detailed configuration of Tempest is beyond the scope of this
ghanshyam36624992018-08-16 07:49:54 +0000185document, see `Tempest Configuration Documentation
186<https://docs.openstack.org/tempest/latest/configuration.html#tempest-configuration>`_
187for more details on configuring Tempest.
188The ``etc/tempest.conf.sample`` attempts to be a self-documenting
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200189version of the configuration.
Sean Dagueb56052b2013-05-21 17:57:41 -0400190
Matthew Treinisha970d652015-03-11 15:39:24 -0400191You can generate a new sample tempest.conf file, run the following
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900192command from the top level of the Tempest directory::
Masayuki Igawaac401c72014-11-18 15:28:46 +0900193
Hai Shi6f52fc52017-04-03 21:17:37 +0800194 $ tox -e genconfig
Matthew Treinish6eb05852013-11-26 15:28:12 +0000195
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200196The most important pieces that are needed are the user ids, OpenStack
197endpoints, and basic flavors and images needed to run tests.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000198
199Unit Tests
200----------
201
Joe H. Rahme00a75422015-03-16 17:46:24 +0100202Tempest also has a set of unit tests which test the Tempest code itself. These
Atsushi SAKAI0a183b82015-07-28 21:52:17 +0900203tests can be run by specifying the test discovery path::
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000204
Masayuki Igawaebe46982017-09-14 16:38:40 -0600205 $ stestr --test-path ./tempest/tests run
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000206
Masayuki Igawaebe46982017-09-14 16:38:40 -0600207By setting ``--test-path`` option to ./tempest/tests it specifies that test discover
208should only be run on the unit test directory. The default value of ``test_path``
209is ``test_path=./tempest/test_discover`` which will only run test discover on the
Joe H. Rahme00a75422015-03-16 17:46:24 +0100210Tempest suite.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000211
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900212Alternatively, there are the py27 and py36 tox jobs which will run the unit
Masayuki Igawaafb11432016-06-02 16:09:50 +0900213tests with the corresponding version of python.
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500214
junboli9e25a572017-11-22 14:42:30 +0800215One common activity is to just run a single test, you can do this with tox
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900216simply by specifying to just run py27 or py36 tests against a single test::
junboli9e25a572017-11-22 14:42:30 +0800217
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900218 $ tox -e py36 -- -n tempest.tests.test_microversions.TestMicroversionsTestsClass.test_config_version_none_23
junboli9e25a572017-11-22 14:42:30 +0800219
220Or all tests in the test_microversions.py file::
221
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900222 $ tox -e py36 -- -n tempest.tests.test_microversions
junboli9e25a572017-11-22 14:42:30 +0800223
224You may also use regular expressions to run any matching tests::
225
Masayuki Igawa80d30b82018-09-03 17:25:49 +0900226 $ tox -e py36 -- test_microversions
junboli9e25a572017-11-22 14:42:30 +0800227
228Additionally, when running a single test, or test-file, the ``-n/--no-discover``
229argument is no longer required, however it may perform faster if included.
230
231For more information on these options and details about stestr, please see the
sunqingliang68606c832018-11-09 14:25:17 +0800232`stestr documentation <https://stestr.readthedocs.io/en/latest/MANUAL.html>`_.
junboli9e25a572017-11-22 14:42:30 +0800233
Matthew Treinish315aa212016-10-13 17:35:47 -0400234Python 3.x
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400235----------
236
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200237Starting during the Pike cycle Tempest has a gating CI job that runs Tempest
238with Python 3. Any Tempest release after 15.0.0 should fully support running
Matthew Treinisha60fe382017-03-02 17:15:05 -0500239under Python 3 as well as Python 2.7.
Matthew Treinish828734a2015-07-06 15:43:46 -0400240
241Legacy run method
242-----------------
243
244The legacy method of running Tempest is to just treat the Tempest source code
245as a python unittest repository and run directly from the source repo. When
246running in this way you still start with a Tempest config file and the steps
247are basically the same except that it expects you know where the Tempest code
248lives on your system and requires a bit more manual interaction to get Tempest
249running. For example, when running Tempest this way things like a lock file
250directory do not get generated automatically and the burden is on the user to
251create and configure that.
252
253To start you need to create a configuration file. The easiest way to create a
254configuration file is to generate a sample in the ``etc/`` directory ::
255
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700256 $ cd $TEMPEST_ROOT_DIR
257 $ oslo-config-generator --config-file \
Erickson Santos7d274ed2016-07-26 14:16:57 +0000258 tempest/cmd/config-generator.tempest.conf \
Matthew Treinish828734a2015-07-06 15:43:46 -0400259 --output-file etc/tempest.conf
260
261After that, open up the ``etc/tempest.conf`` file and edit the
262configuration variables to match valid data in your environment.
263This includes your Keystone endpoint, a valid user and credentials,
264and reference data to be used in testing.
265
266.. note::
267
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200268 If you have a running DevStack environment, Tempest will be
Matthew Treinish828734a2015-07-06 15:43:46 -0400269 automatically configured and placed in ``/opt/stack/tempest``. It
270 will have a configuration file already set up to work with your
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200271 DevStack installation.
Matthew Treinish828734a2015-07-06 15:43:46 -0400272
273Tempest is not tied to any single test runner, but `testr`_ is the most commonly
274used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
275
276After setting up your configuration file, you can execute the set of Tempest
277tests by using ``testr`` ::
278
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700279 $ testr run --parallel
Matthew Treinish828734a2015-07-06 15:43:46 -0400280
Matthew Treinish828734a2015-07-06 15:43:46 -0400281To run one single test serially ::
282
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700283 $ testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server