blob: 7da83cdb5cc037d681df7ce8346a63b3671017fb [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
Masayuki Igawab5d32932016-03-25 12:46:43 +09004.. image:: https://img.shields.io/pypi/v/tempest.svg
5 :target: https://pypi.python.org/pypi/tempest/
6 :alt: Latest Version
7
8.. image:: https://img.shields.io/pypi/dm/tempest.svg
9 :target: https://pypi.python.org/pypi/tempest/
10 :alt: Downloads
11
Sean Dagueb56052b2013-05-21 17:57:41 -040012This is a set of integration tests to be run against a live OpenStack
13cluster. Tempest has batteries of tests for OpenStack API validation,
14Scenarios, and other specific tests useful in validating an OpenStack
15deployment.
16
Sean Daguea26454d2013-11-01 18:09:55 -040017Design Principles
Matthew Treinish077a5632014-06-04 11:43:10 -040018-----------------
Sean Daguea26454d2013-11-01 18:09:55 -040019Tempest Design Principles that we strive to live by.
20
21- Tempest should be able to run against any OpenStack cloud, be it a
22 one node devstack install, a 20 node lxc cloud, or a 1000 node kvm
23 cloud.
24- Tempest should be explicit in testing features. It is easy to auto
25 discover features of a cloud incorrectly, and give people an
26 incorrect assessment of their cloud. Explicit is always better.
27- Tempest uses OpenStack public interfaces. Tests in Tempest should
28 only touch public interfaces, API calls (native or 3rd party),
Matthew Treinish464d2872015-04-29 12:23:01 -040029 or libraries.
Sean Daguea26454d2013-11-01 18:09:55 -040030- Tempest should not touch private or implementation specific
31 interfaces. This means not directly going to the database, not
32 directly hitting the hypervisors, not testing extensions not
OctopusZhang03b89002015-11-05 11:24:14 +080033 included in the OpenStack base. If there are some features of
34 OpenStack that are not verifiable through standard interfaces, this
Sean Daguea26454d2013-11-01 18:09:55 -040035 should be considered a possible enhancement.
36- Tempest strives for complete coverage of the OpenStack API and
37 common scenarios that demonstrate a working cloud.
38- Tempest drives load in an OpenStack cloud. By including a broad
39 array of API and scenario tests Tempest can be reused in whole or in
40 parts as load generation for an OpenStack cloud.
41- Tempest should attempt to clean up after itself, whenever possible
42 we should tear down resources when done.
zhangfengc53e4e12015-08-21 04:09:08 +000043- Tempest should be self-testing.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050044
45Quickstart
46----------
47
Matthew Treinish828734a2015-07-06 15:43:46 -040048To run Tempest, you first need to create a configuration file that will tell
49Tempest where to find the various OpenStack services and other testing behavior
50switches. Where the configuration file lives and how you interact with it
51depends on how you'll be running Tempest. There are 2 methods of using Tempest.
52The first, which is a newer and recommended workflow treats Tempest as a system
53installed program. The second older method is to run Tempest assuming your
54working dir is the actually Tempest source repo, and there are a number of
55assumptions related to that. For this section we'll only cover the newer method
56as it is simpler, and quicker to work with.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050057
OctopusZhang03b89002015-11-05 11:24:14 +080058#. You first need to install Tempest. This is done with pip after you check out
59 the Tempest repo::
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050060
OctopusZhang03b89002015-11-05 11:24:14 +080061 $ git clone https://github.com/openstack/tempest/
62 $ pip install tempest/
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050063
Matthew Treinish828734a2015-07-06 15:43:46 -040064 This can be done within a venv, but the assumption for this guide is that
65 the Tempest cli entry point will be in your shell's PATH.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050066
Matthew Treinish828734a2015-07-06 15:43:46 -040067#. Installing Tempest will create a /etc/tempest dir which will contain the
68 sample config file packaged with Tempest. The contents of /etc/tempest will
69 be copied to all local working dirs, so if there is any common configuration
70 you'd like to be shared between anyone setting up local Tempest working dirs
71 it's recommended that you copy or rename tempest.conf.sample to tempest.conf
72 and make those changes to that file in /etc/tempest
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050073
Matthew Treinish828734a2015-07-06 15:43:46 -040074#. Setup a local working Tempest dir. This is done using the tempest init
75 command::
Jay Pipes7f757632011-12-02 15:53:32 -050076
Matthew Treinish828734a2015-07-06 15:43:46 -040077 tempest init cloud-01
Matthew Treinisha970d652015-03-11 15:39:24 -040078
Matthew Treinish828734a2015-07-06 15:43:46 -040079 works the same as::
Attila Fazekas58d23302013-07-24 10:25:02 +020080
Matthew Treinish828734a2015-07-06 15:43:46 -040081 mkdir cloud-01 && cd cloud-01 && tempest init
Daryl Wallecke36f6232012-03-06 00:21:45 -060082
Matthew Treinish828734a2015-07-06 15:43:46 -040083 This will create a new directory for running a single Tempest configuration.
84 If you'd like to run Tempest against multiple OpenStack deployments the idea
85 is that you'll create a new working directory for each to maintain separate
86 configuration files and local artifact storage for each.
Attila Fazekas58d23302013-07-24 10:25:02 +020087
Matthew Treinish828734a2015-07-06 15:43:46 -040088#. Then cd into the newly created working dir and also modify the local
89 config files located in the etc/ subdir created by the ``tempest init``
90 command. Tempest is expecting a tempest.conf file in etc/ so if only a
91 sample exists you must rename or copy it to tempest.conf before making
92 any changes to it otherwise Tempest will not know how to load it.
Matthew Treinisha970d652015-03-11 15:39:24 -040093
Matthew Treinish828734a2015-07-06 15:43:46 -040094#. Once the configuration is done you're now ready to run Tempest. This can
95 be done with testr directly or any `testr`_ based test runner, like
96 `ostestr`_. For example, from the working dir running::
Matthew Treinishb17460e2013-09-17 17:04:03 +000097
Matthew Treinish42d69512015-09-11 14:46:21 -040098 $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario))'
Matthew Treinisha970d652015-03-11 15:39:24 -040099
Matthew Treinish828734a2015-07-06 15:43:46 -0400100 will run the same set of tests as the default gate jobs.
Matthew Treinisha970d652015-03-11 15:39:24 -0400101
Matthew Treinish828734a2015-07-06 15:43:46 -0400102.. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html
103.. _ostestr: http://docs.openstack.org/developer/os-testr/
nayna-patelddb489c2012-11-13 22:06:45 +0000104
Matthew Treinish55511d92016-02-23 10:55:53 -0500105Library
106-------
107Tempest exposes a library interface. This interface is a stable interface and
108should be backwards compatible (including backwards compatibility with the
109old tempest-lib package, with the exception of the import). If you plan to
110directly consume tempest in your project you should only import code from the
111tempest library interface, other pieces of tempest do not have the same
112stable interface and there are no guarantees on the Python API unless otherwise
113stated.
114
115For more details refer to the library documentation here: :ref:`library`
116
117Release Versioning
118------------------
119Tempest's released versions are broken into 2 sets of information. Depending on
120how you intend to consume tempest you might need
121
122The version is a set of 3 numbers:
123
124X.Y.Z
125
126While this is almost `semver`_ like, the way versioning is handled is slightly
127different:
128
129X is used to represent the supported OpenStack releases for tempest tests
130in-tree, and to signify major feature changes to tempest. It's a monotonically
131increasing integer where each version either indicates a new supported OpenStack
132release, the drop of support for an OpenStack release (which will coincide with
133the upstream stable branch going EOL), or a major feature lands (or is removed)
134from tempest.
135
136Y.Z is used to represent library interface changes. This is treated the same
137way as minor and patch versions from `semver`_ but only for the library
138interface. When Y is incremented we've added functionality to the library
139interface and when Z is incremented it's a bug fix release for the library.
140Also note that both Y and Z are reset to 0 at each increment of X.
141
142.. _semver: http://semver.org/
143
Daryl Wallecke36f6232012-03-06 00:21:45 -0600144Configuration
145-------------
146
Joe H. Rahme00a75422015-03-16 17:46:24 +0100147Detailed configuration of Tempest is beyond the scope of this
Matthew Treinisha970d652015-03-11 15:39:24 -0400148document see :ref:`tempest-configuration` for more details on configuring
zhangfengc53e4e12015-08-21 04:09:08 +0000149Tempest. The etc/tempest.conf.sample attempts to be a self-documenting version
Matthew Treinisha970d652015-03-11 15:39:24 -0400150of the configuration.
Sean Dagueb56052b2013-05-21 17:57:41 -0400151
Matthew Treinisha970d652015-03-11 15:39:24 -0400152You can generate a new sample tempest.conf file, run the following
Joe H. Rahme00a75422015-03-16 17:46:24 +0100153command from the top level of the Tempest directory:
Masayuki Igawaac401c72014-11-18 15:28:46 +0900154
155 tox -egenconfig
Matthew Treinish6eb05852013-11-26 15:28:12 +0000156
Sean Dagueb56052b2013-05-21 17:57:41 -0400157The most important pieces that are needed are the user ids, openstack
Matthew Treinisha970d652015-03-11 15:39:24 -0400158endpoint, and basic flavors and images needed to run tests.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000159
160Unit Tests
161----------
162
Joe H. Rahme00a75422015-03-16 17:46:24 +0100163Tempest also has a set of unit tests which test the Tempest code itself. These
Atsushi SAKAI0a183b82015-07-28 21:52:17 +0900164tests can be run by specifying the test discovery path::
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000165
166 $> OS_TEST_PATH=./tempest/tests testr run --parallel
167
168By setting OS_TEST_PATH to ./tempest/tests it specifies that test discover
169should only be run on the unit test directory. The default value of OS_TEST_PATH
170is OS_TEST_PATH=./tempest/test_discover which will only run test discover on the
Joe H. Rahme00a75422015-03-16 17:46:24 +0100171Tempest suite.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000172
173Alternatively, you can use the run_tests.sh script which will create a venv and
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400174run the unit tests. There are also the py27 and py34 tox jobs which will run
175the unit tests with the corresponding version of python.
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500176
177Python 2.6
178----------
179
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500180Starting in the kilo release the OpenStack services dropped all support for
Joe H. Rahme00a75422015-03-16 17:46:24 +0100181python 2.6. This change has been mirrored in Tempest, starting after the
182tempest-2 tag. This means that proposed changes to Tempest which only fix
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500183python 2.6 compatibility will be rejected, and moving forward more features not
Joe H. Rahme00a75422015-03-16 17:46:24 +0100184present in python 2.6 will be used. If you're running your OpenStack services
185on an earlier release with python 2.6 you can easily run Tempest against it
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500186from a remote system running python 2.7. (or deploy a cloud guest in your cloud
187that has python 2.7)
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400188
189Python 3.4
190----------
191
192Starting during the Liberty release development cycle work began on enabling
193Tempest to run under both Python 2.7 and Python 3.4. Tempest strives to fully
194support running with Python 3.4. A gating unit test job was added to also run
195Tempest's unit tests under Python 3.4. This means that the Tempest code at
196least imports under Python 3.4 and things that have unit test coverage will
zhangfengc53e4e12015-08-21 04:09:08 +0000197work on Python 3.4. However, because large parts of Tempest are self-verifying
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400198there might be uncaught issues running on Python 3.4. So until there is a gating
199job which does a full Tempest run using Python 3.4 there isn't any guarantee
200that running Tempest under Python 3.4 is bug free.
Matthew Treinish828734a2015-07-06 15:43:46 -0400201
202Legacy run method
203-----------------
204
205The legacy method of running Tempest is to just treat the Tempest source code
206as a python unittest repository and run directly from the source repo. When
207running in this way you still start with a Tempest config file and the steps
208are basically the same except that it expects you know where the Tempest code
209lives on your system and requires a bit more manual interaction to get Tempest
210running. For example, when running Tempest this way things like a lock file
211directory do not get generated automatically and the burden is on the user to
212create and configure that.
213
214To start you need to create a configuration file. The easiest way to create a
215configuration file is to generate a sample in the ``etc/`` directory ::
216
217 $> cd $TEMPEST_ROOT_DIR
218 $> oslo-config-generator --config-file \
David Paterson0bf52d42015-04-13 21:55:58 -0400219 etc/config-generator.tempest.conf \
Matthew Treinish828734a2015-07-06 15:43:46 -0400220 --output-file etc/tempest.conf
221
222After that, open up the ``etc/tempest.conf`` file and edit the
223configuration variables to match valid data in your environment.
224This includes your Keystone endpoint, a valid user and credentials,
225and reference data to be used in testing.
226
227.. note::
228
229 If you have a running devstack environment, Tempest will be
230 automatically configured and placed in ``/opt/stack/tempest``. It
231 will have a configuration file already set up to work with your
232 devstack installation.
233
234Tempest is not tied to any single test runner, but `testr`_ is the most commonly
235used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
236
237After setting up your configuration file, you can execute the set of Tempest
238tests by using ``testr`` ::
239
240 $> testr run --parallel
241
Matthew Treinish828734a2015-07-06 15:43:46 -0400242To run one single test serially ::
243
244 $> testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
245
246Alternatively, you can use the run_tempest.sh script which will create a venv
247and run the tests or use tox to do the same. Tox also contains several existing
248job configurations. For example::
249
250 $> tox -efull
251
252which will run the same set of tests as the OpenStack gate. (it's exactly how
253the gate invokes Tempest) Or::
254
255 $> tox -esmoke
256
257to run the tests tagged as smoke.