blob: 9d19c234df979fdf71feec2c54ba28cda79ee8cb [file] [log] [blame]
Flavio Percoco3d2dac72016-11-24 13:06:32 +01001========================
2Team and repository tags
3========================
4
5.. image:: http://governance.openstack.org/badges/tempest.svg
6 :target: http://governance.openstack.org/reference/tags/index.html
Jordan Pittier63746da2016-12-09 17:16:51 +01007 :remote:
Flavio Percoco3d2dac72016-11-24 13:06:32 +01008
9.. Change things from this point on
10
Jay Pipes7f757632011-12-02 15:53:32 -050011Tempest - The OpenStack Integration Test Suite
12==============================================
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050013
Matthew Treinishdced4232016-07-05 11:20:12 -040014The documentation for Tempest is officially hosted at:
15http://docs.openstack.org/developer/tempest/
Masayuki Igawab5d32932016-03-25 12:46:43 +090016
Sean Dagueb56052b2013-05-21 17:57:41 -040017This is a set of integration tests to be run against a live OpenStack
18cluster. Tempest has batteries of tests for OpenStack API validation,
19Scenarios, and other specific tests useful in validating an OpenStack
20deployment.
21
Sean Daguea26454d2013-11-01 18:09:55 -040022Design Principles
Matthew Treinish077a5632014-06-04 11:43:10 -040023-----------------
Sean Daguea26454d2013-11-01 18:09:55 -040024Tempest Design Principles that we strive to live by.
25
26- Tempest should be able to run against any OpenStack cloud, be it a
27 one node devstack install, a 20 node lxc cloud, or a 1000 node kvm
28 cloud.
29- Tempest should be explicit in testing features. It is easy to auto
30 discover features of a cloud incorrectly, and give people an
31 incorrect assessment of their cloud. Explicit is always better.
32- Tempest uses OpenStack public interfaces. Tests in Tempest should
Ken'ichi Ohmichib8249902016-06-01 17:11:04 -070033 only touch public OpenStack APIs.
Sean Daguea26454d2013-11-01 18:09:55 -040034- Tempest should not touch private or implementation specific
35 interfaces. This means not directly going to the database, not
36 directly hitting the hypervisors, not testing extensions not
OctopusZhang03b89002015-11-05 11:24:14 +080037 included in the OpenStack base. If there are some features of
38 OpenStack that are not verifiable through standard interfaces, this
Sean Daguea26454d2013-11-01 18:09:55 -040039 should be considered a possible enhancement.
40- Tempest strives for complete coverage of the OpenStack API and
41 common scenarios that demonstrate a working cloud.
42- Tempest drives load in an OpenStack cloud. By including a broad
43 array of API and scenario tests Tempest can be reused in whole or in
44 parts as load generation for an OpenStack cloud.
45- Tempest should attempt to clean up after itself, whenever possible
46 we should tear down resources when done.
zhangfengc53e4e12015-08-21 04:09:08 +000047- Tempest should be self-testing.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050048
49Quickstart
50----------
51
Matthew Treinish828734a2015-07-06 15:43:46 -040052To run Tempest, you first need to create a configuration file that will tell
53Tempest where to find the various OpenStack services and other testing behavior
54switches. Where the configuration file lives and how you interact with it
55depends on how you'll be running Tempest. There are 2 methods of using Tempest.
56The first, which is a newer and recommended workflow treats Tempest as a system
57installed program. The second older method is to run Tempest assuming your
58working dir is the actually Tempest source repo, and there are a number of
59assumptions related to that. For this section we'll only cover the newer method
60as it is simpler, and quicker to work with.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050061
OctopusZhang03b89002015-11-05 11:24:14 +080062#. You first need to install Tempest. This is done with pip after you check out
63 the Tempest repo::
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050064
Ken'ichi Ohmichi9883ff22016-04-22 18:24:15 -070065 $ git clone http://git.openstack.org/openstack/tempest
OctopusZhang03b89002015-11-05 11:24:14 +080066 $ pip install tempest/
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050067
Matthew Treinish828734a2015-07-06 15:43:46 -040068 This can be done within a venv, but the assumption for this guide is that
69 the Tempest cli entry point will be in your shell's PATH.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050070
Matthew Treinish531b01c2016-07-05 10:22:52 -040071#. Installing Tempest may create a /etc/tempest dir, however if one isn't
72 created you can create one or use ~/.tempest/etc or ~/.config/tempest in
73 place of /etc/tempest. If none of these dirs are created tempest will create
74 ~/.tempest/etc when it's needed. The contents of this dir will always
75 automatically be copied to all etc/ dirs in local workspaces as an initial
76 setup step. So if there is any common configuration you'd like to be shared
77 between local Tempest workspaces it's recommended that you pre-populate it
78 before running ``tempest init``.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050079
Matthew Treinishab77cbf2016-07-01 13:55:05 -040080#. Setup a local Tempest workspace. This is done by using the tempest init
Matthew Treinish828734a2015-07-06 15:43:46 -040081 command::
Jay Pipes7f757632011-12-02 15:53:32 -050082
Ken'ichi Ohmichi9883ff22016-04-22 18:24:15 -070083 $ tempest init cloud-01
Matthew Treinisha970d652015-03-11 15:39:24 -040084
Matthew Treinishab77cbf2016-07-01 13:55:05 -040085 which also works the same as::
Attila Fazekas58d23302013-07-24 10:25:02 +020086
Ken'ichi Ohmichi9883ff22016-04-22 18:24:15 -070087 $ mkdir cloud-01 && cd cloud-01 && tempest init
Daryl Wallecke36f6232012-03-06 00:21:45 -060088
Matthew Treinish828734a2015-07-06 15:43:46 -040089 This will create a new directory for running a single Tempest configuration.
90 If you'd like to run Tempest against multiple OpenStack deployments the idea
91 is that you'll create a new working directory for each to maintain separate
92 configuration files and local artifact storage for each.
Attila Fazekas58d23302013-07-24 10:25:02 +020093
Matthew Treinish828734a2015-07-06 15:43:46 -040094#. Then cd into the newly created working dir and also modify the local
95 config files located in the etc/ subdir created by the ``tempest init``
96 command. Tempest is expecting a tempest.conf file in etc/ so if only a
97 sample exists you must rename or copy it to tempest.conf before making
Matthew Treinishdced4232016-07-05 11:20:12 -040098 any changes to it otherwise Tempest will not know how to load it. For
99 details on configuring tempest refer to the :ref:`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
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400102 be done using the :ref:`tempest_run` command. This can be done by either
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400103 running::
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400104
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900105 $ tempest run
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400106
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400107 from the Tempest workspace directory. Or you can use the ``--workspace``
108 argument to run in the workspace you created regarless of your current
109 working directory. For example::
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400110
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900111 $ tempest run --workspace cloud-01
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400112
113 There is also the option to use testr directly, or any `testr`_ based test
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400114 runner, like `ostestr`_. For example, from the workspace dir run::
Matthew Treinishb17460e2013-09-17 17:04:03 +0000115
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900116 $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario))'
Matthew Treinisha970d652015-03-11 15:39:24 -0400117
Matthew Treinish828734a2015-07-06 15:43:46 -0400118 will run the same set of tests as the default gate jobs.
Matthew Treinisha970d652015-03-11 15:39:24 -0400119
Matthew Treinish828734a2015-07-06 15:43:46 -0400120.. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html
121.. _ostestr: http://docs.openstack.org/developer/os-testr/
nayna-patelddb489c2012-11-13 22:06:45 +0000122
Matthew Treinish55511d92016-02-23 10:55:53 -0500123Library
124-------
125Tempest exposes a library interface. This interface is a stable interface and
126should be backwards compatible (including backwards compatibility with the
127old tempest-lib package, with the exception of the import). If you plan to
128directly consume tempest in your project you should only import code from the
129tempest library interface, other pieces of tempest do not have the same
130stable interface and there are no guarantees on the Python API unless otherwise
131stated.
132
133For more details refer to the library documentation here: :ref:`library`
134
135Release Versioning
136------------------
Ken'ichi Ohmichi7f5e1d72016-08-29 12:01:44 -0700137`Tempest Release Notes <http://docs.openstack.org/releasenotes/tempest>`_
138shows what changes have been released on each version.
139
Matthew Treinish55511d92016-02-23 10:55:53 -0500140Tempest's released versions are broken into 2 sets of information. Depending on
141how you intend to consume tempest you might need
142
143The version is a set of 3 numbers:
144
145X.Y.Z
146
147While this is almost `semver`_ like, the way versioning is handled is slightly
148different:
149
150X is used to represent the supported OpenStack releases for tempest tests
151in-tree, and to signify major feature changes to tempest. It's a monotonically
152increasing integer where each version either indicates a new supported OpenStack
153release, the drop of support for an OpenStack release (which will coincide with
154the upstream stable branch going EOL), or a major feature lands (or is removed)
155from tempest.
156
157Y.Z is used to represent library interface changes. This is treated the same
158way as minor and patch versions from `semver`_ but only for the library
159interface. When Y is incremented we've added functionality to the library
160interface and when Z is incremented it's a bug fix release for the library.
161Also note that both Y and Z are reset to 0 at each increment of X.
162
163.. _semver: http://semver.org/
164
Daryl Wallecke36f6232012-03-06 00:21:45 -0600165Configuration
166-------------
167
Joe H. Rahme00a75422015-03-16 17:46:24 +0100168Detailed configuration of Tempest is beyond the scope of this
Matthew Treinisha970d652015-03-11 15:39:24 -0400169document see :ref:`tempest-configuration` for more details on configuring
zhangfengc53e4e12015-08-21 04:09:08 +0000170Tempest. The etc/tempest.conf.sample attempts to be a self-documenting version
Matthew Treinisha970d652015-03-11 15:39:24 -0400171of the configuration.
Sean Dagueb56052b2013-05-21 17:57:41 -0400172
Matthew Treinisha970d652015-03-11 15:39:24 -0400173You can generate a new sample tempest.conf file, run the following
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900174command from the top level of the Tempest directory::
Masayuki Igawaac401c72014-11-18 15:28:46 +0900175
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900176 $ tox -egenconfig
Matthew Treinish6eb05852013-11-26 15:28:12 +0000177
Sean Dagueb56052b2013-05-21 17:57:41 -0400178The most important pieces that are needed are the user ids, openstack
Matthew Treinisha970d652015-03-11 15:39:24 -0400179endpoint, and basic flavors and images needed to run tests.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000180
181Unit Tests
182----------
183
Joe H. Rahme00a75422015-03-16 17:46:24 +0100184Tempest also has a set of unit tests which test the Tempest code itself. These
Atsushi SAKAI0a183b82015-07-28 21:52:17 +0900185tests can be run by specifying the test discovery path::
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000186
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700187 $ OS_TEST_PATH=./tempest/tests testr run --parallel
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000188
189By setting OS_TEST_PATH to ./tempest/tests it specifies that test discover
190should only be run on the unit test directory. The default value of OS_TEST_PATH
191is OS_TEST_PATH=./tempest/test_discover which will only run test discover on the
Joe H. Rahme00a75422015-03-16 17:46:24 +0100192Tempest suite.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000193
Masayuki Igawaafb11432016-06-02 16:09:50 +0900194Alternatively, there are the py27 and py34 tox jobs which will run the unit
195tests with the corresponding version of python.
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500196
197Python 2.6
198----------
199
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500200Starting in the kilo release the OpenStack services dropped all support for
Joe H. Rahme00a75422015-03-16 17:46:24 +0100201python 2.6. This change has been mirrored in Tempest, starting after the
202tempest-2 tag. This means that proposed changes to Tempest which only fix
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500203python 2.6 compatibility will be rejected, and moving forward more features not
Joe H. Rahme00a75422015-03-16 17:46:24 +0100204present in python 2.6 will be used. If you're running your OpenStack services
205on an earlier release with python 2.6 you can easily run Tempest against it
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500206from a remote system running python 2.7. (or deploy a cloud guest in your cloud
207that has python 2.7)
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400208
Matthew Treinish315aa212016-10-13 17:35:47 -0400209Python 3.x
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400210----------
211
212Starting during the Liberty release development cycle work began on enabling
213Tempest to run under both Python 2.7 and Python 3.4. Tempest strives to fully
Matthew Treinish315aa212016-10-13 17:35:47 -0400214support running with Python 3.4 and newer. A gating unit test job was added to
215also run Tempest's unit tests under Python 3. This means that the Tempest
216code at least imports under Python 3.4 and things that have unit test coverage
217will work on Python 3.4. However, because large parts of Tempest are
218self-verifying there might be uncaught issues running on Python 3. So until
219there is a gating job which does a full Tempest run using Python 3 there
220isn't any guarantee that running Tempest under Python 3 is bug free.
Matthew Treinish828734a2015-07-06 15:43:46 -0400221
222Legacy run method
223-----------------
224
225The legacy method of running Tempest is to just treat the Tempest source code
226as a python unittest repository and run directly from the source repo. When
227running in this way you still start with a Tempest config file and the steps
228are basically the same except that it expects you know where the Tempest code
229lives on your system and requires a bit more manual interaction to get Tempest
230running. For example, when running Tempest this way things like a lock file
231directory do not get generated automatically and the burden is on the user to
232create and configure that.
233
234To start you need to create a configuration file. The easiest way to create a
235configuration file is to generate a sample in the ``etc/`` directory ::
236
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700237 $ cd $TEMPEST_ROOT_DIR
238 $ oslo-config-generator --config-file \
Erickson Santos7d274ed2016-07-26 14:16:57 +0000239 tempest/cmd/config-generator.tempest.conf \
Matthew Treinish828734a2015-07-06 15:43:46 -0400240 --output-file etc/tempest.conf
241
242After that, open up the ``etc/tempest.conf`` file and edit the
243configuration variables to match valid data in your environment.
244This includes your Keystone endpoint, a valid user and credentials,
245and reference data to be used in testing.
246
247.. note::
248
249 If you have a running devstack environment, Tempest will be
250 automatically configured and placed in ``/opt/stack/tempest``. It
251 will have a configuration file already set up to work with your
252 devstack installation.
253
254Tempest is not tied to any single test runner, but `testr`_ is the most commonly
255used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
256
257After setting up your configuration file, you can execute the set of Tempest
258tests by using ``testr`` ::
259
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700260 $ testr run --parallel
Matthew Treinish828734a2015-07-06 15:43:46 -0400261
Matthew Treinish828734a2015-07-06 15:43:46 -0400262To run one single test serially ::
263
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700264 $ testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
Matthew Treinish828734a2015-07-06 15:43:46 -0400265
Jordan Pittier27ca2512017-02-22 16:25:28 +0100266Tox also contains several existing job configurations. For example::
Matthew Treinish828734a2015-07-06 15:43:46 -0400267
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900268 $ tox -efull
Matthew Treinish828734a2015-07-06 15:43:46 -0400269
270which will run the same set of tests as the OpenStack gate. (it's exactly how
271the gate invokes Tempest) Or::
272
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900273 $ tox -esmoke
Matthew Treinish828734a2015-07-06 15:43:46 -0400274
275to run the tests tagged as smoke.