blob: 2f7bf2fbbdde958b0a4a248e84f49bb3d653d5f8 [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
davyyyac670dc2017-11-16 21:27:03 +080064 $ git clone https://git.openstack.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
114 There is also the option to use testr directly, or any `testr`_ based test
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400115 runner, like `ostestr`_. For example, from the workspace dir run::
Matthew Treinishb17460e2013-09-17 17:04:03 +0000116
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900117 $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario))'
Matthew Treinisha970d652015-03-11 15:39:24 -0400118
Matthew Treinish828734a2015-07-06 15:43:46 -0400119 will run the same set of tests as the default gate jobs.
Matthew Treinisha970d652015-03-11 15:39:24 -0400120
Matthew Treinish828734a2015-07-06 15:43:46 -0400121.. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html
chenxinge98720a2017-07-19 03:42:23 +0000122.. _ostestr: https://docs.openstack.org/os-testr/latest/
nayna-patelddb489c2012-11-13 22:06:45 +0000123
Matthew Treinish55511d92016-02-23 10:55:53 -0500124Library
125-------
126Tempest exposes a library interface. This interface is a stable interface and
127should be backwards compatible (including backwards compatibility with the
128old tempest-lib package, with the exception of the import). If you plan to
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200129directly consume Tempest in your project you should only import code from the
130Tempest library interface, other pieces of Tempest do not have the same
Matthew Treinish55511d92016-02-23 10:55:53 -0500131stable interface and there are no guarantees on the Python API unless otherwise
132stated.
133
ghanshyam36624992018-08-16 07:49:54 +0000134For more details refer to the library documentation here: `Library
135<https://docs.openstack.org/tempest/latest/library.html#library>`_
Matthew Treinish55511d92016-02-23 10:55:53 -0500136
137Release Versioning
138------------------
davyyyac670dc2017-11-16 21:27:03 +0800139`Tempest Release Notes <https://docs.openstack.org/releasenotes/tempest>`_
Ken'ichi Ohmichi7f5e1d72016-08-29 12:01:44 -0700140shows what changes have been released on each version.
141
Matthew Treinish55511d92016-02-23 10:55:53 -0500142Tempest's released versions are broken into 2 sets of information. Depending on
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200143how you intend to consume Tempest you might need
Matthew Treinish55511d92016-02-23 10:55:53 -0500144
145The version is a set of 3 numbers:
146
147X.Y.Z
148
149While this is almost `semver`_ like, the way versioning is handled is slightly
150different:
151
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200152X is used to represent the supported OpenStack releases for Tempest tests
153in-tree, and to signify major feature changes to Tempest. It's a monotonically
Matthew Treinish55511d92016-02-23 10:55:53 -0500154increasing integer where each version either indicates a new supported OpenStack
155release, the drop of support for an OpenStack release (which will coincide with
156the upstream stable branch going EOL), or a major feature lands (or is removed)
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200157from Tempest.
Matthew Treinish55511d92016-02-23 10:55:53 -0500158
159Y.Z is used to represent library interface changes. This is treated the same
160way as minor and patch versions from `semver`_ but only for the library
161interface. When Y is incremented we've added functionality to the library
162interface and when Z is incremented it's a bug fix release for the library.
163Also note that both Y and Z are reset to 0 at each increment of X.
164
165.. _semver: http://semver.org/
166
Daryl Wallecke36f6232012-03-06 00:21:45 -0600167Configuration
168-------------
169
Joe H. Rahme00a75422015-03-16 17:46:24 +0100170Detailed configuration of Tempest is beyond the scope of this
ghanshyam36624992018-08-16 07:49:54 +0000171document, see `Tempest Configuration Documentation
172<https://docs.openstack.org/tempest/latest/configuration.html#tempest-configuration>`_
173for more details on configuring Tempest.
174The ``etc/tempest.conf.sample`` attempts to be a self-documenting
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200175version of the configuration.
Sean Dagueb56052b2013-05-21 17:57:41 -0400176
Matthew Treinisha970d652015-03-11 15:39:24 -0400177You can generate a new sample tempest.conf file, run the following
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900178command from the top level of the Tempest directory::
Masayuki Igawaac401c72014-11-18 15:28:46 +0900179
Hai Shi6f52fc52017-04-03 21:17:37 +0800180 $ tox -e genconfig
Matthew Treinish6eb05852013-11-26 15:28:12 +0000181
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200182The most important pieces that are needed are the user ids, OpenStack
183endpoints, and basic flavors and images needed to run tests.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000184
185Unit Tests
186----------
187
Joe H. Rahme00a75422015-03-16 17:46:24 +0100188Tempest also has a set of unit tests which test the Tempest code itself. These
Atsushi SAKAI0a183b82015-07-28 21:52:17 +0900189tests can be run by specifying the test discovery path::
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000190
Masayuki Igawaebe46982017-09-14 16:38:40 -0600191 $ stestr --test-path ./tempest/tests run
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000192
Masayuki Igawaebe46982017-09-14 16:38:40 -0600193By setting ``--test-path`` option to ./tempest/tests it specifies that test discover
194should only be run on the unit test directory. The default value of ``test_path``
195is ``test_path=./tempest/test_discover`` which will only run test discover on the
Joe H. Rahme00a75422015-03-16 17:46:24 +0100196Tempest suite.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000197
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200198Alternatively, there are the py27 and py35 tox jobs which will run the unit
Masayuki Igawaafb11432016-06-02 16:09:50 +0900199tests with the corresponding version of python.
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500200
junboli9e25a572017-11-22 14:42:30 +0800201One common activity is to just run a single test, you can do this with tox
202simply by specifying to just run py27 or py35 tests against a single test::
203
204 $ tox -e py27 -- -n tempest.tests.test_microversions.TestMicroversionsTestsClass.test_config_version_none_23
205
206Or all tests in the test_microversions.py file::
207
208 $ tox -e py27 -- -n tempest.tests.test_microversions
209
210You may also use regular expressions to run any matching tests::
211
212 $ tox -e py27 -- test_microversions
213
214Additionally, when running a single test, or test-file, the ``-n/--no-discover``
215argument is no longer required, however it may perform faster if included.
216
217For more information on these options and details about stestr, please see the
218`stestr documentation <http://stestr.readthedocs.io/en/latest/MANUAL.html>`_.
219
Matthew Treinish315aa212016-10-13 17:35:47 -0400220Python 3.x
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400221----------
222
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200223Starting during the Pike cycle Tempest has a gating CI job that runs Tempest
224with Python 3. Any Tempest release after 15.0.0 should fully support running
Matthew Treinisha60fe382017-03-02 17:15:05 -0500225under Python 3 as well as Python 2.7.
Matthew Treinish828734a2015-07-06 15:43:46 -0400226
227Legacy run method
228-----------------
229
230The legacy method of running Tempest is to just treat the Tempest source code
231as a python unittest repository and run directly from the source repo. When
232running in this way you still start with a Tempest config file and the steps
233are basically the same except that it expects you know where the Tempest code
234lives on your system and requires a bit more manual interaction to get Tempest
235running. For example, when running Tempest this way things like a lock file
236directory do not get generated automatically and the burden is on the user to
237create and configure that.
238
239To start you need to create a configuration file. The easiest way to create a
240configuration file is to generate a sample in the ``etc/`` directory ::
241
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700242 $ cd $TEMPEST_ROOT_DIR
243 $ oslo-config-generator --config-file \
Erickson Santos7d274ed2016-07-26 14:16:57 +0000244 tempest/cmd/config-generator.tempest.conf \
Matthew Treinish828734a2015-07-06 15:43:46 -0400245 --output-file etc/tempest.conf
246
247After that, open up the ``etc/tempest.conf`` file and edit the
248configuration variables to match valid data in your environment.
249This includes your Keystone endpoint, a valid user and credentials,
250and reference data to be used in testing.
251
252.. note::
253
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200254 If you have a running DevStack environment, Tempest will be
Matthew Treinish828734a2015-07-06 15:43:46 -0400255 automatically configured and placed in ``/opt/stack/tempest``. It
256 will have a configuration file already set up to work with your
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200257 DevStack installation.
Matthew Treinish828734a2015-07-06 15:43:46 -0400258
259Tempest is not tied to any single test runner, but `testr`_ is the most commonly
260used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
261
262After setting up your configuration file, you can execute the set of Tempest
263tests by using ``testr`` ::
264
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700265 $ testr run --parallel
Matthew Treinish828734a2015-07-06 15:43:46 -0400266
Matthew Treinish828734a2015-07-06 15:43:46 -0400267To run one single test serially ::
268
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700269 $ testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
Matthew Treinish828734a2015-07-06 15:43:46 -0400270
Jordan Pittier27ca2512017-02-22 16:25:28 +0100271Tox also contains several existing job configurations. For example::
Matthew Treinish828734a2015-07-06 15:43:46 -0400272
Hai Shi6f52fc52017-04-03 21:17:37 +0800273 $ tox -e full
Matthew Treinish828734a2015-07-06 15:43:46 -0400274
275which will run the same set of tests as the OpenStack gate. (it's exactly how
276the gate invokes Tempest) Or::
277
Hai Shi6f52fc52017-04-03 21:17:37 +0800278 $ tox -e smoke
Matthew Treinish828734a2015-07-06 15:43:46 -0400279
280to run the tests tagged as smoke.