blob: 242f4d53581b0bd4c38bcc4799cbbcd4ae2a7aa4 [file] [log] [blame]
Flavio Percoco3d2dac72016-11-24 13:06:32 +01001========================
2Team and repository tags
3========================
4
davyyyac670dc2017-11-16 21:27:03 +08005.. image:: https://governance.openstack.org/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,
18Scenarios, and other specific tests useful in validating an OpenStack
19deployment.
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
Jordan Pittier74a56ab2017-04-26 16:46:20 +020098 details on configuring Tempest refer to the :ref:`tempest-configuration`.
Matthew Treinisha970d652015-03-11 15:39:24 -040099
Matthew Treinish828734a2015-07-06 15:43:46 -0400100#. Once the configuration is done you're now ready to run Tempest. This can
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400101 be done using the :ref:`tempest_run` command. This can be done by either
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400102 running::
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400103
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900104 $ tempest run
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400105
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400106 from the Tempest workspace directory. Or you can use the ``--workspace``
zhufl5eccdf42017-03-16 10:08:18 +0800107 argument to run in the workspace you created regardless of your current
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400108 working directory. For example::
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400109
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900110 $ tempest run --workspace cloud-01
Matthew Treinish85c8e3e2016-06-30 19:28:04 -0400111
112 There is also the option to use testr directly, or any `testr`_ based test
Matthew Treinishab77cbf2016-07-01 13:55:05 -0400113 runner, like `ostestr`_. For example, from the workspace dir run::
Matthew Treinishb17460e2013-09-17 17:04:03 +0000114
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900115 $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario))'
Matthew Treinisha970d652015-03-11 15:39:24 -0400116
Matthew Treinish828734a2015-07-06 15:43:46 -0400117 will run the same set of tests as the default gate jobs.
Matthew Treinisha970d652015-03-11 15:39:24 -0400118
Matthew Treinish828734a2015-07-06 15:43:46 -0400119.. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html
chenxinge98720a2017-07-19 03:42:23 +0000120.. _ostestr: https://docs.openstack.org/os-testr/latest/
nayna-patelddb489c2012-11-13 22:06:45 +0000121
Matthew Treinish55511d92016-02-23 10:55:53 -0500122Library
123-------
124Tempest exposes a library interface. This interface is a stable interface and
125should be backwards compatible (including backwards compatibility with the
126old tempest-lib package, with the exception of the import). If you plan to
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200127directly consume Tempest in your project you should only import code from the
128Tempest library interface, other pieces of Tempest do not have the same
Matthew Treinish55511d92016-02-23 10:55:53 -0500129stable interface and there are no guarantees on the Python API unless otherwise
130stated.
131
132For more details refer to the library documentation here: :ref:`library`
133
134Release Versioning
135------------------
davyyyac670dc2017-11-16 21:27:03 +0800136`Tempest Release Notes <https://docs.openstack.org/releasenotes/tempest>`_
Ken'ichi Ohmichi7f5e1d72016-08-29 12:01:44 -0700137shows what changes have been released on each version.
138
Matthew Treinish55511d92016-02-23 10:55:53 -0500139Tempest's released versions are broken into 2 sets of information. Depending on
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200140how you intend to consume Tempest you might need
Matthew Treinish55511d92016-02-23 10:55:53 -0500141
142The version is a set of 3 numbers:
143
144X.Y.Z
145
146While this is almost `semver`_ like, the way versioning is handled is slightly
147different:
148
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200149X is used to represent the supported OpenStack releases for Tempest tests
150in-tree, and to signify major feature changes to Tempest. It's a monotonically
Matthew Treinish55511d92016-02-23 10:55:53 -0500151increasing integer where each version either indicates a new supported OpenStack
152release, the drop of support for an OpenStack release (which will coincide with
153the upstream stable branch going EOL), or a major feature lands (or is removed)
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200154from Tempest.
Matthew Treinish55511d92016-02-23 10:55:53 -0500155
156Y.Z is used to represent library interface changes. This is treated the same
157way as minor and patch versions from `semver`_ but only for the library
158interface. When Y is incremented we've added functionality to the library
159interface and when Z is incremented it's a bug fix release for the library.
160Also note that both Y and Z are reset to 0 at each increment of X.
161
162.. _semver: http://semver.org/
163
Daryl Wallecke36f6232012-03-06 00:21:45 -0600164Configuration
165-------------
166
Joe H. Rahme00a75422015-03-16 17:46:24 +0100167Detailed configuration of Tempest is beyond the scope of this
Matthew Treinisha970d652015-03-11 15:39:24 -0400168document see :ref:`tempest-configuration` for more details on configuring
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200169Tempest. The ``etc/tempest.conf.sample`` attempts to be a self-documenting
170version of the configuration.
Sean Dagueb56052b2013-05-21 17:57:41 -0400171
Matthew Treinisha970d652015-03-11 15:39:24 -0400172You can generate a new sample tempest.conf file, run the following
Yushiro FURUKAWAe4b18ad2016-09-27 16:52:47 +0900173command from the top level of the Tempest directory::
Masayuki Igawaac401c72014-11-18 15:28:46 +0900174
Hai Shi6f52fc52017-04-03 21:17:37 +0800175 $ tox -e genconfig
Matthew Treinish6eb05852013-11-26 15:28:12 +0000176
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200177The most important pieces that are needed are the user ids, OpenStack
178endpoints, and basic flavors and images needed to run tests.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000179
180Unit Tests
181----------
182
Joe H. Rahme00a75422015-03-16 17:46:24 +0100183Tempest also has a set of unit tests which test the Tempest code itself. These
Atsushi SAKAI0a183b82015-07-28 21:52:17 +0900184tests can be run by specifying the test discovery path::
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000185
Masayuki Igawaebe46982017-09-14 16:38:40 -0600186 $ stestr --test-path ./tempest/tests run
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000187
Masayuki Igawaebe46982017-09-14 16:38:40 -0600188By setting ``--test-path`` option to ./tempest/tests it specifies that test discover
189should only be run on the unit test directory. The default value of ``test_path``
190is ``test_path=./tempest/test_discover`` which will only run test discover on the
Joe H. Rahme00a75422015-03-16 17:46:24 +0100191Tempest suite.
Matthew Treinisha7c7f9f2014-01-13 18:20:50 +0000192
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200193Alternatively, there are the py27 and py35 tox jobs which will run the unit
Masayuki Igawaafb11432016-06-02 16:09:50 +0900194tests with the corresponding version of python.
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500195
junboli9e25a572017-11-22 14:42:30 +0800196One common activity is to just run a single test, you can do this with tox
197simply by specifying to just run py27 or py35 tests against a single test::
198
199 $ tox -e py27 -- -n tempest.tests.test_microversions.TestMicroversionsTestsClass.test_config_version_none_23
200
201Or all tests in the test_microversions.py file::
202
203 $ tox -e py27 -- -n tempest.tests.test_microversions
204
205You may also use regular expressions to run any matching tests::
206
207 $ tox -e py27 -- test_microversions
208
209Additionally, when running a single test, or test-file, the ``-n/--no-discover``
210argument is no longer required, however it may perform faster if included.
211
212For more information on these options and details about stestr, please see the
213`stestr documentation <http://stestr.readthedocs.io/en/latest/MANUAL.html>`_.
214
Matthew Treinishaf37dc92014-02-13 14:35:38 -0500215Python 2.6
216----------
217
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200218Starting in the Kilo release the OpenStack services dropped all support for
Joe H. Rahme00a75422015-03-16 17:46:24 +0100219python 2.6. This change has been mirrored in Tempest, starting after the
220tempest-2 tag. This means that proposed changes to Tempest which only fix
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500221python 2.6 compatibility will be rejected, and moving forward more features not
Joe H. Rahme00a75422015-03-16 17:46:24 +0100222present in python 2.6 will be used. If you're running your OpenStack services
223on an earlier release with python 2.6 you can easily run Tempest against it
Matthew Treinishd28dd7b2015-02-23 11:52:33 -0500224from a remote system running python 2.7. (or deploy a cloud guest in your cloud
225that has python 2.7)
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400226
Matthew Treinish315aa212016-10-13 17:35:47 -0400227Python 3.x
Matthew Treinish3460aaa2015-05-11 22:18:00 -0400228----------
229
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200230Starting during the Pike cycle Tempest has a gating CI job that runs Tempest
231with Python 3. Any Tempest release after 15.0.0 should fully support running
Matthew Treinisha60fe382017-03-02 17:15:05 -0500232under Python 3 as well as Python 2.7.
Matthew Treinish828734a2015-07-06 15:43:46 -0400233
234Legacy run method
235-----------------
236
237The legacy method of running Tempest is to just treat the Tempest source code
238as a python unittest repository and run directly from the source repo. When
239running in this way you still start with a Tempest config file and the steps
240are basically the same except that it expects you know where the Tempest code
241lives on your system and requires a bit more manual interaction to get Tempest
242running. For example, when running Tempest this way things like a lock file
243directory do not get generated automatically and the burden is on the user to
244create and configure that.
245
246To start you need to create a configuration file. The easiest way to create a
247configuration file is to generate a sample in the ``etc/`` directory ::
248
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700249 $ cd $TEMPEST_ROOT_DIR
250 $ oslo-config-generator --config-file \
Erickson Santos7d274ed2016-07-26 14:16:57 +0000251 tempest/cmd/config-generator.tempest.conf \
Matthew Treinish828734a2015-07-06 15:43:46 -0400252 --output-file etc/tempest.conf
253
254After that, open up the ``etc/tempest.conf`` file and edit the
255configuration variables to match valid data in your environment.
256This includes your Keystone endpoint, a valid user and credentials,
257and reference data to be used in testing.
258
259.. note::
260
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200261 If you have a running DevStack environment, Tempest will be
Matthew Treinish828734a2015-07-06 15:43:46 -0400262 automatically configured and placed in ``/opt/stack/tempest``. It
263 will have a configuration file already set up to work with your
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200264 DevStack installation.
Matthew Treinish828734a2015-07-06 15:43:46 -0400265
266Tempest is not tied to any single test runner, but `testr`_ is the most commonly
267used tool. Also, the nosetests test runner is **not** recommended to run Tempest.
268
269After setting up your configuration file, you can execute the set of Tempest
270tests by using ``testr`` ::
271
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700272 $ testr run --parallel
Matthew Treinish828734a2015-07-06 15:43:46 -0400273
Matthew Treinish828734a2015-07-06 15:43:46 -0400274To run one single test serially ::
275
Ken'ichi Ohmichidcf55a02016-06-01 19:57:14 -0700276 $ testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server
Matthew Treinish828734a2015-07-06 15:43:46 -0400277
Jordan Pittier27ca2512017-02-22 16:25:28 +0100278Tox also contains several existing job configurations. For example::
Matthew Treinish828734a2015-07-06 15:43:46 -0400279
Hai Shi6f52fc52017-04-03 21:17:37 +0800280 $ tox -e full
Matthew Treinish828734a2015-07-06 15:43:46 -0400281
282which will run the same set of tests as the OpenStack gate. (it's exactly how
283the gate invokes Tempest) Or::
284
Hai Shi6f52fc52017-04-03 21:17:37 +0800285 $ tox -e smoke
Matthew Treinish828734a2015-07-06 15:43:46 -0400286
287to run the tests tagged as smoke.