blob: f1dac1cfb2a09068c1a85e85999511ac08dafb36 [file] [log] [blame]
Jay Pipes7f757632011-12-02 15:53:32 -05001Tempest - The OpenStack Integration Test Suite
2==============================================
Justin Shepherd0d9bbd12011-08-11 12:57:44 -05003
Matthew Treinishdced4232016-07-05 11:20:12 -04004The documentation for Tempest is officially hosted at:
5http://docs.openstack.org/developer/tempest/
Masayuki Igawab5d32932016-03-25 12:46:43 +09006
Sean Dagueb56052b2013-05-21 17:57:41 -04007This 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
Sean Daguea26454d2013-11-01 18:09:55 -040012Design Principles
Matthew Treinish077a5632014-06-04 11:43:10 -040013-----------------
Sean Daguea26454d2013-11-01 18:09:55 -040014Tempest Design Principles that we strive to live by.
15
16- Tempest should be able to run against any OpenStack cloud, be it a
17 one node devstack install, a 20 node lxc cloud, or a 1000 node kvm
18 cloud.
19- Tempest should be explicit in testing features. It is easy to auto
20 discover features of a cloud incorrectly, and give people an
21 incorrect assessment of their cloud. Explicit is always better.
22- Tempest uses OpenStack public interfaces. Tests in Tempest should
Ken'ichi Ohmichib8249902016-06-01 17:11:04 -070023 only touch public OpenStack APIs.
Sean Daguea26454d2013-11-01 18:09:55 -040024- Tempest should not touch private or implementation specific
25 interfaces. This means not directly going to the database, not
26 directly hitting the hypervisors, not testing extensions not
OctopusZhang03b89002015-11-05 11:24:14 +080027 included in the OpenStack base. If there are some features of
28 OpenStack that are not verifiable through standard interfaces, this
Sean Daguea26454d2013-11-01 18:09:55 -040029 should be considered a possible enhancement.
30- Tempest strives for complete coverage of the OpenStack API and
31 common scenarios that demonstrate a working cloud.
32- Tempest drives load in an OpenStack cloud. By including a broad
33 array of API and scenario tests Tempest can be reused in whole or in
34 parts as load generation for an OpenStack cloud.
35- Tempest should attempt to clean up after itself, whenever possible
36 we should tear down resources when done.
zhangfengc53e4e12015-08-21 04:09:08 +000037- Tempest should be self-testing.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050038
39Quickstart
40----------
41
Matthew Treinish828734a2015-07-06 15:43:46 -040042To run Tempest, you first need to create a configuration file that will tell
43Tempest where to find the various OpenStack services and other testing behavior
44switches. Where the configuration file lives and how you interact with it
45depends on how you'll be running Tempest. There are 2 methods of using Tempest.
46The first, which is a newer and recommended workflow treats Tempest as a system
47installed program. The second older method is to run Tempest assuming your
48working dir is the actually Tempest source repo, and there are a number of
49assumptions related to that. For this section we'll only cover the newer method
50as it is simpler, and quicker to work with.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050051
OctopusZhang03b89002015-11-05 11:24:14 +080052#. You first need to install Tempest. This is done with pip after you check out
53 the Tempest repo::
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050054
Ken'ichi Ohmichi9883ff22016-04-22 18:24:15 -070055 $ git clone http://git.openstack.org/openstack/tempest
OctopusZhang03b89002015-11-05 11:24:14 +080056 $ pip install tempest/
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050057
Matthew Treinish828734a2015-07-06 15:43:46 -040058 This can be done within a venv, but the assumption for this guide is that
59 the Tempest cli entry point will be in your shell's PATH.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050060
Matthew Treinish531b01c2016-07-05 10:22:52 -040061#. Installing Tempest may create a /etc/tempest dir, however if one isn't
62 created you can create one or use ~/.tempest/etc or ~/.config/tempest in
63 place of /etc/tempest. If none of these dirs are created tempest will create
64 ~/.tempest/etc when it's needed. The contents of this dir will always
65 automatically be copied to all etc/ dirs in local workspaces as an initial
66 setup step. So if there is any common configuration you'd like to be shared
67 between local Tempest workspaces it's recommended that you pre-populate it
68 before running ``tempest init``.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050069
Matthew Treinishab77cbf2016-07-01 13:55:05 -040070#. Setup a local Tempest workspace. This is done by using the tempest init
Matthew Treinish828734a2015-07-06 15:43:46 -040071 command::
Jay Pipes7f757632011-12-02 15:53:32 -050072
Ken'ichi Ohmichi9883ff22016-04-22 18:24:15 -070073 $ tempest init cloud-01
Matthew Treinisha970d652015-03-11 15:39:24 -040074
Matthew Treinishab77cbf2016-07-01 13:55:05 -040075 which also works the same as::
Attila Fazekas58d23302013-07-24 10:25:02 +020076
Ken'ichi Ohmichi9883ff22016-04-22 18:24:15 -070077 $ mkdir cloud-01 && cd cloud-01 && tempest init
Daryl Wallecke36f6232012-03-06 00:21:45 -060078
Matthew Treinish828734a2015-07-06 15:43:46 -040079 This will create a new directory for running a single Tempest configuration.
80 If you'd like to run Tempest against multiple OpenStack deployments the idea
81 is that you'll create a new working directory for each to maintain separate
82 configuration files and local artifact storage for each.
Attila Fazekas58d23302013-07-24 10:25:02 +020083
Matthew Treinish828734a2015-07-06 15:43:46 -040084#. Then cd into the newly created working dir and also modify the local
85 config files located in the etc/ subdir created by the ``tempest init``
86 command. Tempest is expecting a tempest.conf file in etc/ so if only a
87 sample exists you must rename or copy it to tempest.conf before making
Matthew Treinishdced4232016-07-05 11:20:12 -040088 any changes to it otherwise Tempest will not know how to load it. For
89 details on configuring tempest refer to the :ref:`tempest-configuration`.
Matthew Treinisha970d652015-03-11 15:39:24 -040090
Matthew Treinish828734a2015-07-06 15:43:46 -040091#. Once the configuration is done you're now ready to run Tempest. This can
Matthew Treinish85c8e3e2016-06-30 19:28:04 -040092 be done using the :ref:`tempest_run` command. This can be done by either
Matthew Treinishab77cbf2016-07-01 13:55:05 -040093 running::
Matthew Treinish85c8e3e2016-06-30 19:28:04 -040094
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +090095 $ tempest run
Matthew Treinish85c8e3e2016-06-30 19:28:04 -040096
Matthew Treinishab77cbf2016-07-01 13:55:05 -040097 from the Tempest workspace directory. Or you can use the ``--workspace``
98 argument to run in the workspace you created regarless of your current
99 working directory. For example::
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400100
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900101 $ tempest run --workspace cloud-01
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400102
103 There is also the option to use testr directly, or any `testr`_ based test
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400104 runner, like `ostestr`_. For example, from the workspace dir run::
Matthew Treinishb17460e2013-09-17 17:04:03 +0000105
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900106 $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario))'
Matthew Treinisha970d652015-03-11 15:39:24 -0400107
Matthew Treinish828734a2015-07-06 15:43:46 -0400108 will run the same set of tests as the default gate jobs.
Matthew Treinisha970d652015-03-11 15:39:24 -0400109
Matthew Treinish828734a2015-07-06 15:43:46 -0400110.. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html
111.. _ostestr: http://docs.openstack.org/developer/os-testr/
nayna-patelddb489c2012-11-13 22:06:45 +0000112
Matthew Treinish55511d92016-02-23 10:55:53 -0500113Library
114-------
115Tempest exposes a library interface. This interface is a stable interface and
116should be backwards compatible (including backwards compatibility with the
117old tempest-lib package, with the exception of the import). If you plan to
118directly consume tempest in your project you should only import code from the
119tempest library interface, other pieces of tempest do not have the same
120stable interface and there are no guarantees on the Python API unless otherwise
121stated.
122
123For more details refer to the library documentation here: :ref:`library`
124
125Release Versioning
126------------------
Ken'ichi Ohmichi7f5e1d72016-08-29 12:01:44 -0700127`Tempest Release Notes <http://docs.openstack.org/releasenotes/tempest>`_
128shows what changes have been released on each version.
129
Matthew Treinish55511d92016-02-23 10:55:53 -0500130Tempest's released versions are broken into 2 sets of information. Depending on
131how you intend to consume tempest you might need
132
133The version is a set of 3 numbers:
134
135X.Y.Z
136
137While this is almost `semver`_ like, the way versioning is handled is slightly
138different:
139
140X is used to represent the supported OpenStack releases for tempest tests
141in-tree, and to signify major feature changes to tempest. It's a monotonically
142increasing integer where each version either indicates a new supported OpenStack
143release, the drop of support for an OpenStack release (which will coincide with
144the upstream stable branch going EOL), or a major feature lands (or is removed)
145from tempest.
146
147Y.Z is used to represent library interface changes. This is treated the same
148way as minor and patch versions from `semver`_ but only for the library
149interface. When Y is incremented we've added functionality to the library
150interface and when Z is incremented it's a bug fix release for the library.
151Also note that both Y and Z are reset to 0 at each increment of X.
152
153.. _semver: http://semver.org/
154
Daryl Wallecke36f6232012-03-06 00:21:45 -0600155Configuration
156-------------
157
Joe H. Rahme00a75422015-03-16 17:46:24 +0100158Detailed configuration of Tempest is beyond the scope of this
Matthew Treinisha970d652015-03-11 15:39:24 -0400159document see :ref:`tempest-configuration` for more details on configuring
zhangfengc53e4e12015-08-21 04:09:08 +0000160Tempest. The etc/tempest.conf.sample attempts to be a self-documenting version
Matthew Treinisha970d652015-03-11 15:39:24 -0400161of the configuration.
Sean Dagueb56052b2013-05-21 17:57:41 -0400162
Matthew Treinisha970d652015-03-11 15:39:24 -0400163You can generate a new sample tempest.conf file, run the following
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900164command from the top level of the Tempest directory::
Masayuki Igawaac401c72014-11-18 15:28:46 +0900165
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900166 $ tox -egenconfig
Matthew Treinish6eb05852013-11-26 15:28:12 +0000167
Sean Dagueb56052b2013-05-21 17:57:41 -0400168The most important pieces that are needed are the user ids, openstack
Matthew Treinisha970d652015-03-11 15:39:24 -0400169endpoint, and basic flavors and images needed to run tests.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000170
171Unit Tests
172----------
173
Joe H. Rahme00a75422015-03-16 17:46:24 +0100174Tempest also has a set of unit tests which test the Tempest code itself. These
Atsushi SAKAI0a183b82015-07-28 21:52:17 +0900175tests can be run by specifying the test discovery path::
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000176
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700177 $ OS_TEST_PATH=./tempest/tests testr run --parallel
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000178
179By setting OS_TEST_PATH to ./tempest/tests it specifies that test discover
180should only be run on the unit test directory. The default value of OS_TEST_PATH
181is OS_TEST_PATH=./tempest/test_discover which will only run test discover on the
Joe H. Rahme00a75422015-03-16 17:46:24 +0100182Tempest suite.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000183
Masayuki Igawaafb11432016-06-02 16:09:50 +0900184Alternatively, there are the py27 and py34 tox jobs which will run the unit
185tests with the corresponding version of python.
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500186
187Python 2.6
188----------
189
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500190Starting in the kilo release the OpenStack services dropped all support for
Joe H. Rahme00a75422015-03-16 17:46:24 +0100191python 2.6. This change has been mirrored in Tempest, starting after the
192tempest-2 tag. This means that proposed changes to Tempest which only fix
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500193python 2.6 compatibility will be rejected, and moving forward more features not
Joe H. Rahme00a75422015-03-16 17:46:24 +0100194present in python 2.6 will be used. If you're running your OpenStack services
195on an earlier release with python 2.6 you can easily run Tempest against it
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500196from a remote system running python 2.7. (or deploy a cloud guest in your cloud
197that has python 2.7)
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400198
199Python 3.4
200----------
201
202Starting during the Liberty release development cycle work began on enabling
203Tempest to run under both Python 2.7 and Python 3.4. Tempest strives to fully
204support running with Python 3.4. A gating unit test job was added to also run
205Tempest's unit tests under Python 3.4. This means that the Tempest code at
206least imports under Python 3.4 and things that have unit test coverage will
zhangfengc53e4e12015-08-21 04:09:08 +0000207work on Python 3.4. However, because large parts of Tempest are self-verifying
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400208there might be uncaught issues running on Python 3.4. So until there is a gating
209job which does a full Tempest run using Python 3.4 there isn't any guarantee
210that running Tempest under Python 3.4 is bug free.
Matthew Treinish828734a2015-07-06 15:43:46 -0400211
212Legacy run method
213-----------------
214
215The legacy method of running Tempest is to just treat the Tempest source code
216as a python unittest repository and run directly from the source repo. When
217running in this way you still start with a Tempest config file and the steps
218are basically the same except that it expects you know where the Tempest code
219lives on your system and requires a bit more manual interaction to get Tempest
220running. For example, when running Tempest this way things like a lock file
221directory do not get generated automatically and the burden is on the user to
222create and configure that.
223
224To start you need to create a configuration file. The easiest way to create a
225configuration file is to generate a sample in the ``etc/`` directory ::
226
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700227 $ cd $TEMPEST_ROOT_DIR
228 $ oslo-config-generator --config-file \
Erickson Santos7d274ed2016-07-26 14:16:57 +0000229 tempest/cmd/config-generator.tempest.conf \
Matthew Treinish828734a2015-07-06 15:43:46 -0400230 --output-file etc/tempest.conf
231
232After that, open up the ``etc/tempest.conf`` file and edit the
233configuration variables to match valid data in your environment.
234This includes your Keystone endpoint, a valid user and credentials,
235and reference data to be used in testing.
236
237.. note::
238
239 If you have a running devstack environment, Tempest will be
240 automatically configured and placed in ``/opt/stack/tempest``. It
241 will have a configuration file already set up to work with your
242 devstack installation.
243
244Tempest is not tied to any single test runner, but `testr`_ is the most commonly
245used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
246
247After setting up your configuration file, you can execute the set of Tempest
248tests by using ``testr`` ::
249
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700250 $ testr run --parallel
Matthew Treinish828734a2015-07-06 15:43:46 -0400251
Matthew Treinish828734a2015-07-06 15:43:46 -0400252To run one single test serially ::
253
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700254 $ testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
Matthew Treinish828734a2015-07-06 15:43:46 -0400255
256Alternatively, you can use the run_tempest.sh script which will create a venv
257and run the tests or use tox to do the same. Tox also contains several existing
258job configurations. For example::
259
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900260 $ tox -efull
Matthew Treinish828734a2015-07-06 15:43:46 -0400261
262which will run the same set of tests as the OpenStack gate. (it's exactly how
263the gate invokes Tempest) Or::
264
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900265 $ tox -esmoke
Matthew Treinish828734a2015-07-06 15:43:46 -0400266
267to run the tests tagged as smoke.