blob: c859ddd2f093e4476613daaafb7540e0a052cfbe [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
Sean Dagueb56052b2013-05-21 17:57:41 -04004This is a set of integration tests to be run against a live OpenStack
5cluster. Tempest has batteries of tests for OpenStack API validation,
6Scenarios, and other specific tests useful in validating an OpenStack
7deployment.
8
Sean Daguea26454d2013-11-01 18:09:55 -04009Design Principles
Matthew Treinish077a5632014-06-04 11:43:10 -040010-----------------
Sean Daguea26454d2013-11-01 18:09:55 -040011Tempest Design Principles that we strive to live by.
12
13- Tempest should be able to run against any OpenStack cloud, be it a
14 one node devstack install, a 20 node lxc cloud, or a 1000 node kvm
15 cloud.
16- Tempest should be explicit in testing features. It is easy to auto
17 discover features of a cloud incorrectly, and give people an
18 incorrect assessment of their cloud. Explicit is always better.
19- Tempest uses OpenStack public interfaces. Tests in Tempest should
20 only touch public interfaces, API calls (native or 3rd party),
Matthew Treinish464d2872015-04-29 12:23:01 -040021 or libraries.
Sean Daguea26454d2013-11-01 18:09:55 -040022- Tempest should not touch private or implementation specific
23 interfaces. This means not directly going to the database, not
24 directly hitting the hypervisors, not testing extensions not
OctopusZhang03b89002015-11-05 11:24:14 +080025 included in the OpenStack base. If there are some features of
26 OpenStack that are not verifiable through standard interfaces, this
Sean Daguea26454d2013-11-01 18:09:55 -040027 should be considered a possible enhancement.
28- Tempest strives for complete coverage of the OpenStack API and
29 common scenarios that demonstrate a working cloud.
30- Tempest drives load in an OpenStack cloud. By including a broad
31 array of API and scenario tests Tempest can be reused in whole or in
32 parts as load generation for an OpenStack cloud.
33- Tempest should attempt to clean up after itself, whenever possible
34 we should tear down resources when done.
zhangfengc53e4e12015-08-21 04:09:08 +000035- Tempest should be self-testing.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050036
37Quickstart
38----------
39
Matthew Treinish828734a2015-07-06 15:43:46 -040040To run Tempest, you first need to create a configuration file that will tell
41Tempest where to find the various OpenStack services and other testing behavior
42switches. Where the configuration file lives and how you interact with it
43depends on how you'll be running Tempest. There are 2 methods of using Tempest.
44The first, which is a newer and recommended workflow treats Tempest as a system
45installed program. The second older method is to run Tempest assuming your
46working dir is the actually Tempest source repo, and there are a number of
47assumptions related to that. For this section we'll only cover the newer method
48as it is simpler, and quicker to work with.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050049
OctopusZhang03b89002015-11-05 11:24:14 +080050#. You first need to install Tempest. This is done with pip after you check out
51 the Tempest repo::
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050052
OctopusZhang03b89002015-11-05 11:24:14 +080053 $ git clone https://github.com/openstack/tempest/
54 $ pip install tempest/
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050055
Matthew Treinish828734a2015-07-06 15:43:46 -040056 This can be done within a venv, but the assumption for this guide is that
57 the Tempest cli entry point will be in your shell's PATH.
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050058
Matthew Treinish828734a2015-07-06 15:43:46 -040059#. Installing Tempest will create a /etc/tempest dir which will contain the
60 sample config file packaged with Tempest. The contents of /etc/tempest will
61 be copied to all local working dirs, so if there is any common configuration
62 you'd like to be shared between anyone setting up local Tempest working dirs
63 it's recommended that you copy or rename tempest.conf.sample to tempest.conf
64 and make those changes to that file in /etc/tempest
Justin Shepherd0d9bbd12011-08-11 12:57:44 -050065
Matthew Treinish828734a2015-07-06 15:43:46 -040066#. Setup a local working Tempest dir. This is done using the tempest init
67 command::
Jay Pipes7f757632011-12-02 15:53:32 -050068
Matthew Treinish828734a2015-07-06 15:43:46 -040069 tempest init cloud-01
Matthew Treinisha970d652015-03-11 15:39:24 -040070
Matthew Treinish828734a2015-07-06 15:43:46 -040071 works the same as::
Attila Fazekas58d23302013-07-24 10:25:02 +020072
Matthew Treinish828734a2015-07-06 15:43:46 -040073 mkdir cloud-01 && cd cloud-01 && tempest init
Daryl Wallecke36f6232012-03-06 00:21:45 -060074
Matthew Treinish828734a2015-07-06 15:43:46 -040075 This will create a new directory for running a single Tempest configuration.
76 If you'd like to run Tempest against multiple OpenStack deployments the idea
77 is that you'll create a new working directory for each to maintain separate
78 configuration files and local artifact storage for each.
Attila Fazekas58d23302013-07-24 10:25:02 +020079
Matthew Treinish828734a2015-07-06 15:43:46 -040080#. Then cd into the newly created working dir and also modify the local
81 config files located in the etc/ subdir created by the ``tempest init``
82 command. Tempest is expecting a tempest.conf file in etc/ so if only a
83 sample exists you must rename or copy it to tempest.conf before making
84 any changes to it otherwise Tempest will not know how to load it.
Matthew Treinisha970d652015-03-11 15:39:24 -040085
Matthew Treinish828734a2015-07-06 15:43:46 -040086#. Once the configuration is done you're now ready to run Tempest. This can
87 be done with testr directly or any `testr`_ based test runner, like
88 `ostestr`_. For example, from the working dir running::
Matthew Treinishb17460e2013-09-17 17:04:03 +000089
Matthew Treinish42d69512015-09-11 14:46:21 -040090 $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario))'
Matthew Treinisha970d652015-03-11 15:39:24 -040091
Matthew Treinish828734a2015-07-06 15:43:46 -040092 will run the same set of tests as the default gate jobs.
Matthew Treinisha970d652015-03-11 15:39:24 -040093
Matthew Treinish828734a2015-07-06 15:43:46 -040094.. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html
95.. _ostestr: http://docs.openstack.org/developer/os-testr/
nayna-patelddb489c2012-11-13 22:06:45 +000096
Matthew Treinish55511d92016-02-23 10:55:53 -050097Library
98-------
99Tempest exposes a library interface. This interface is a stable interface and
100should be backwards compatible (including backwards compatibility with the
101old tempest-lib package, with the exception of the import). If you plan to
102directly consume tempest in your project you should only import code from the
103tempest library interface, other pieces of tempest do not have the same
104stable interface and there are no guarantees on the Python API unless otherwise
105stated.
106
107For more details refer to the library documentation here: :ref:`library`
108
109Release Versioning
110------------------
111Tempest's released versions are broken into 2 sets of information. Depending on
112how you intend to consume tempest you might need
113
114The version is a set of 3 numbers:
115
116X.Y.Z
117
118While this is almost `semver`_ like, the way versioning is handled is slightly
119different:
120
121X is used to represent the supported OpenStack releases for tempest tests
122in-tree, and to signify major feature changes to tempest. It's a monotonically
123increasing integer where each version either indicates a new supported OpenStack
124release, the drop of support for an OpenStack release (which will coincide with
125the upstream stable branch going EOL), or a major feature lands (or is removed)
126from tempest.
127
128Y.Z is used to represent library interface changes. This is treated the same
129way as minor and patch versions from `semver`_ but only for the library
130interface. When Y is incremented we've added functionality to the library
131interface and when Z is incremented it's a bug fix release for the library.
132Also note that both Y and Z are reset to 0 at each increment of X.
133
134.. _semver: http://semver.org/
135
Daryl Wallecke36f6232012-03-06 00:21:45 -0600136Configuration
137-------------
138
Joe H. Rahme00a75422015-03-16 17:46:24 +0100139Detailed configuration of Tempest is beyond the scope of this
Matthew Treinisha970d652015-03-11 15:39:24 -0400140document see :ref:`tempest-configuration` for more details on configuring
zhangfengc53e4e12015-08-21 04:09:08 +0000141Tempest. The etc/tempest.conf.sample attempts to be a self-documenting version
Matthew Treinisha970d652015-03-11 15:39:24 -0400142of the configuration.
Sean Dagueb56052b2013-05-21 17:57:41 -0400143
Matthew Treinisha970d652015-03-11 15:39:24 -0400144You can generate a new sample tempest.conf file, run the following
Joe H. Rahme00a75422015-03-16 17:46:24 +0100145command from the top level of the Tempest directory:
Masayuki Igawaac401c72014-11-18 15:28:46 +0900146
147 tox -egenconfig
Matthew Treinish6eb05852013-11-26 15:28:12 +0000148
Sean Dagueb56052b2013-05-21 17:57:41 -0400149The most important pieces that are needed are the user ids, openstack
Matthew Treinisha970d652015-03-11 15:39:24 -0400150endpoint, and basic flavors and images needed to run tests.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000151
152Unit Tests
153----------
154
Joe H. Rahme00a75422015-03-16 17:46:24 +0100155Tempest also has a set of unit tests which test the Tempest code itself. These
Atsushi SAKAI0a183b82015-07-28 21:52:17 +0900156tests can be run by specifying the test discovery path::
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000157
158 $> OS_TEST_PATH=./tempest/tests testr run --parallel
159
160By setting OS_TEST_PATH to ./tempest/tests it specifies that test discover
161should only be run on the unit test directory. The default value of OS_TEST_PATH
162is OS_TEST_PATH=./tempest/test_discover which will only run test discover on the
Joe H. Rahme00a75422015-03-16 17:46:24 +0100163Tempest suite.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000164
165Alternatively, you can use the run_tests.sh script which will create a venv and
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400166run the unit tests. There are also the py27 and py34 tox jobs which will run
167the unit tests with the corresponding version of python.
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500168
169Python 2.6
170----------
171
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500172Starting in the kilo release the OpenStack services dropped all support for
Joe H. Rahme00a75422015-03-16 17:46:24 +0100173python 2.6. This change has been mirrored in Tempest, starting after the
174tempest-2 tag. This means that proposed changes to Tempest which only fix
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500175python 2.6 compatibility will be rejected, and moving forward more features not
Joe H. Rahme00a75422015-03-16 17:46:24 +0100176present in python 2.6 will be used. If you're running your OpenStack services
177on an earlier release with python 2.6 you can easily run Tempest against it
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500178from a remote system running python 2.7. (or deploy a cloud guest in your cloud
179that has python 2.7)
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400180
181Python 3.4
182----------
183
184Starting during the Liberty release development cycle work began on enabling
185Tempest to run under both Python 2.7 and Python 3.4. Tempest strives to fully
186support running with Python 3.4. A gating unit test job was added to also run
187Tempest's unit tests under Python 3.4. This means that the Tempest code at
188least imports under Python 3.4 and things that have unit test coverage will
zhangfengc53e4e12015-08-21 04:09:08 +0000189work on Python 3.4. However, because large parts of Tempest are self-verifying
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400190there might be uncaught issues running on Python 3.4. So until there is a gating
191job which does a full Tempest run using Python 3.4 there isn't any guarantee
192that running Tempest under Python 3.4 is bug free.
Matthew Treinish828734a2015-07-06 15:43:46 -0400193
194Legacy run method
195-----------------
196
197The legacy method of running Tempest is to just treat the Tempest source code
198as a python unittest repository and run directly from the source repo. When
199running in this way you still start with a Tempest config file and the steps
200are basically the same except that it expects you know where the Tempest code
201lives on your system and requires a bit more manual interaction to get Tempest
202running. For example, when running Tempest this way things like a lock file
203directory do not get generated automatically and the burden is on the user to
204create and configure that.
205
206To start you need to create a configuration file. The easiest way to create a
207configuration file is to generate a sample in the ``etc/`` directory ::
208
209 $> cd $TEMPEST_ROOT_DIR
210 $> oslo-config-generator --config-file \
David Paterson0bf52d42015-04-13 21:55:58 -0400211 etc/config-generator.tempest.conf \
Matthew Treinish828734a2015-07-06 15:43:46 -0400212 --output-file etc/tempest.conf
213
214After that, open up the ``etc/tempest.conf`` file and edit the
215configuration variables to match valid data in your environment.
216This includes your Keystone endpoint, a valid user and credentials,
217and reference data to be used in testing.
218
219.. note::
220
221 If you have a running devstack environment, Tempest will be
222 automatically configured and placed in ``/opt/stack/tempest``. It
223 will have a configuration file already set up to work with your
224 devstack installation.
225
226Tempest is not tied to any single test runner, but `testr`_ is the most commonly
227used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
228
229After setting up your configuration file, you can execute the set of Tempest
230tests by using ``testr`` ::
231
232 $> testr run --parallel
233
Matthew Treinish828734a2015-07-06 15:43:46 -0400234To run one single test serially ::
235
236 $> testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
237
238Alternatively, you can use the run_tempest.sh script which will create a venv
239and run the tests or use tox to do the same. Tox also contains several existing
240job configurations. For example::
241
242 $> tox -efull
243
244which will run the same set of tests as the OpenStack gate. (it's exactly how
245the gate invokes Tempest) Or::
246
247 $> tox -esmoke
248
249to run the tests tagged as smoke.