Jay Pipes | 7f75763 | 2011-12-02 15:53:32 -0500 | [diff] [blame] | 1 | Tempest - The OpenStack Integration Test Suite |
| 2 | ============================================== |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 3 | |
Masayuki Igawa | b5d3293 | 2016-03-25 12:46:43 +0900 | [diff] [blame] | 4 | .. 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 Dague | b56052b | 2013-05-21 17:57:41 -0400 | [diff] [blame] | 12 | This is a set of integration tests to be run against a live OpenStack |
| 13 | cluster. Tempest has batteries of tests for OpenStack API validation, |
| 14 | Scenarios, and other specific tests useful in validating an OpenStack |
| 15 | deployment. |
| 16 | |
Sean Dague | a26454d | 2013-11-01 18:09:55 -0400 | [diff] [blame] | 17 | Design Principles |
Matthew Treinish | 077a563 | 2014-06-04 11:43:10 -0400 | [diff] [blame] | 18 | ----------------- |
Sean Dague | a26454d | 2013-11-01 18:09:55 -0400 | [diff] [blame] | 19 | Tempest 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 Treinish | 464d287 | 2015-04-29 12:23:01 -0400 | [diff] [blame] | 29 | or libraries. |
Sean Dague | a26454d | 2013-11-01 18:09:55 -0400 | [diff] [blame] | 30 | - 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 |
OctopusZhang | 03b8900 | 2015-11-05 11:24:14 +0800 | [diff] [blame] | 33 | included in the OpenStack base. If there are some features of |
| 34 | OpenStack that are not verifiable through standard interfaces, this |
Sean Dague | a26454d | 2013-11-01 18:09:55 -0400 | [diff] [blame] | 35 | 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. |
zhangfeng | c53e4e1 | 2015-08-21 04:09:08 +0000 | [diff] [blame] | 43 | - Tempest should be self-testing. |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 44 | |
| 45 | Quickstart |
| 46 | ---------- |
| 47 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 48 | To run Tempest, you first need to create a configuration file that will tell |
| 49 | Tempest where to find the various OpenStack services and other testing behavior |
| 50 | switches. Where the configuration file lives and how you interact with it |
| 51 | depends on how you'll be running Tempest. There are 2 methods of using Tempest. |
| 52 | The first, which is a newer and recommended workflow treats Tempest as a system |
| 53 | installed program. The second older method is to run Tempest assuming your |
| 54 | working dir is the actually Tempest source repo, and there are a number of |
| 55 | assumptions related to that. For this section we'll only cover the newer method |
| 56 | as it is simpler, and quicker to work with. |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 57 | |
OctopusZhang | 03b8900 | 2015-11-05 11:24:14 +0800 | [diff] [blame] | 58 | #. You first need to install Tempest. This is done with pip after you check out |
| 59 | the Tempest repo:: |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 60 | |
Ken'ichi Ohmichi | 9883ff2 | 2016-04-22 18:24:15 -0700 | [diff] [blame] | 61 | $ git clone http://git.openstack.org/openstack/tempest |
OctopusZhang | 03b8900 | 2015-11-05 11:24:14 +0800 | [diff] [blame] | 62 | $ pip install tempest/ |
Justin Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 63 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 64 | 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 Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 66 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 67 | #. 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 Shepherd | 0d9bbd1 | 2011-08-11 12:57:44 -0500 | [diff] [blame] | 73 | |
Ken'ichi Ohmichi | 9883ff2 | 2016-04-22 18:24:15 -0700 | [diff] [blame] | 74 | #. Setup a local working Tempest dir. This is done by using the tempest init |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 75 | command:: |
Jay Pipes | 7f75763 | 2011-12-02 15:53:32 -0500 | [diff] [blame] | 76 | |
Ken'ichi Ohmichi | 9883ff2 | 2016-04-22 18:24:15 -0700 | [diff] [blame] | 77 | $ tempest init cloud-01 |
Matthew Treinish | a970d65 | 2015-03-11 15:39:24 -0400 | [diff] [blame] | 78 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 79 | works the same as:: |
Attila Fazekas | 58d2330 | 2013-07-24 10:25:02 +0200 | [diff] [blame] | 80 | |
Ken'ichi Ohmichi | 9883ff2 | 2016-04-22 18:24:15 -0700 | [diff] [blame] | 81 | $ mkdir cloud-01 && cd cloud-01 && tempest init |
Daryl Walleck | e36f623 | 2012-03-06 00:21:45 -0600 | [diff] [blame] | 82 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 83 | 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 Fazekas | 58d2330 | 2013-07-24 10:25:02 +0200 | [diff] [blame] | 87 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 88 | #. 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 Treinish | a970d65 | 2015-03-11 15:39:24 -0400 | [diff] [blame] | 93 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 94 | #. 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 Treinish | b17460e | 2013-09-17 17:04:03 +0000 | [diff] [blame] | 97 | |
Matthew Treinish | 42d6951 | 2015-09-11 14:46:21 -0400 | [diff] [blame] | 98 | $ ostestr --regex '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario))' |
Matthew Treinish | a970d65 | 2015-03-11 15:39:24 -0400 | [diff] [blame] | 99 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 100 | will run the same set of tests as the default gate jobs. |
Matthew Treinish | a970d65 | 2015-03-11 15:39:24 -0400 | [diff] [blame] | 101 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 102 | .. _testr: https://testrepository.readthedocs.org/en/latest/MANUAL.html |
| 103 | .. _ostestr: http://docs.openstack.org/developer/os-testr/ |
nayna-patel | ddb489c | 2012-11-13 22:06:45 +0000 | [diff] [blame] | 104 | |
Matthew Treinish | 55511d9 | 2016-02-23 10:55:53 -0500 | [diff] [blame] | 105 | Library |
| 106 | ------- |
| 107 | Tempest exposes a library interface. This interface is a stable interface and |
| 108 | should be backwards compatible (including backwards compatibility with the |
| 109 | old tempest-lib package, with the exception of the import). If you plan to |
| 110 | directly consume tempest in your project you should only import code from the |
| 111 | tempest library interface, other pieces of tempest do not have the same |
| 112 | stable interface and there are no guarantees on the Python API unless otherwise |
| 113 | stated. |
| 114 | |
| 115 | For more details refer to the library documentation here: :ref:`library` |
| 116 | |
| 117 | Release Versioning |
| 118 | ------------------ |
| 119 | Tempest's released versions are broken into 2 sets of information. Depending on |
| 120 | how you intend to consume tempest you might need |
| 121 | |
| 122 | The version is a set of 3 numbers: |
| 123 | |
| 124 | X.Y.Z |
| 125 | |
| 126 | While this is almost `semver`_ like, the way versioning is handled is slightly |
| 127 | different: |
| 128 | |
| 129 | X is used to represent the supported OpenStack releases for tempest tests |
| 130 | in-tree, and to signify major feature changes to tempest. It's a monotonically |
| 131 | increasing integer where each version either indicates a new supported OpenStack |
| 132 | release, the drop of support for an OpenStack release (which will coincide with |
| 133 | the upstream stable branch going EOL), or a major feature lands (or is removed) |
| 134 | from tempest. |
| 135 | |
| 136 | Y.Z is used to represent library interface changes. This is treated the same |
| 137 | way as minor and patch versions from `semver`_ but only for the library |
| 138 | interface. When Y is incremented we've added functionality to the library |
| 139 | interface and when Z is incremented it's a bug fix release for the library. |
| 140 | Also note that both Y and Z are reset to 0 at each increment of X. |
| 141 | |
| 142 | .. _semver: http://semver.org/ |
| 143 | |
Daryl Walleck | e36f623 | 2012-03-06 00:21:45 -0600 | [diff] [blame] | 144 | Configuration |
| 145 | ------------- |
| 146 | |
Joe H. Rahme | 00a7542 | 2015-03-16 17:46:24 +0100 | [diff] [blame] | 147 | Detailed configuration of Tempest is beyond the scope of this |
Matthew Treinish | a970d65 | 2015-03-11 15:39:24 -0400 | [diff] [blame] | 148 | document see :ref:`tempest-configuration` for more details on configuring |
zhangfeng | c53e4e1 | 2015-08-21 04:09:08 +0000 | [diff] [blame] | 149 | Tempest. The etc/tempest.conf.sample attempts to be a self-documenting version |
Matthew Treinish | a970d65 | 2015-03-11 15:39:24 -0400 | [diff] [blame] | 150 | of the configuration. |
Sean Dague | b56052b | 2013-05-21 17:57:41 -0400 | [diff] [blame] | 151 | |
Matthew Treinish | a970d65 | 2015-03-11 15:39:24 -0400 | [diff] [blame] | 152 | You can generate a new sample tempest.conf file, run the following |
Joe H. Rahme | 00a7542 | 2015-03-16 17:46:24 +0100 | [diff] [blame] | 153 | command from the top level of the Tempest directory: |
Masayuki Igawa | ac401c7 | 2014-11-18 15:28:46 +0900 | [diff] [blame] | 154 | |
| 155 | tox -egenconfig |
Matthew Treinish | 6eb0585 | 2013-11-26 15:28:12 +0000 | [diff] [blame] | 156 | |
Sean Dague | b56052b | 2013-05-21 17:57:41 -0400 | [diff] [blame] | 157 | The most important pieces that are needed are the user ids, openstack |
Matthew Treinish | a970d65 | 2015-03-11 15:39:24 -0400 | [diff] [blame] | 158 | endpoint, and basic flavors and images needed to run tests. |
Matthew Treinish | a7c7f9f | 2014-01-13 18:20:50 +0000 | [diff] [blame] | 159 | |
| 160 | Unit Tests |
| 161 | ---------- |
| 162 | |
Joe H. Rahme | 00a7542 | 2015-03-16 17:46:24 +0100 | [diff] [blame] | 163 | Tempest also has a set of unit tests which test the Tempest code itself. These |
Atsushi SAKAI | 0a183b8 | 2015-07-28 21:52:17 +0900 | [diff] [blame] | 164 | tests can be run by specifying the test discovery path:: |
Matthew Treinish | a7c7f9f | 2014-01-13 18:20:50 +0000 | [diff] [blame] | 165 | |
| 166 | $> OS_TEST_PATH=./tempest/tests testr run --parallel |
| 167 | |
| 168 | By setting OS_TEST_PATH to ./tempest/tests it specifies that test discover |
| 169 | should only be run on the unit test directory. The default value of OS_TEST_PATH |
| 170 | is OS_TEST_PATH=./tempest/test_discover which will only run test discover on the |
Joe H. Rahme | 00a7542 | 2015-03-16 17:46:24 +0100 | [diff] [blame] | 171 | Tempest suite. |
Matthew Treinish | a7c7f9f | 2014-01-13 18:20:50 +0000 | [diff] [blame] | 172 | |
| 173 | Alternatively, you can use the run_tests.sh script which will create a venv and |
Matthew Treinish | 3460aaa | 2015-05-11 22:18:00 -0400 | [diff] [blame] | 174 | run the unit tests. There are also the py27 and py34 tox jobs which will run |
| 175 | the unit tests with the corresponding version of python. |
Matthew Treinish | af37dc9 | 2014-02-13 14:35:38 -0500 | [diff] [blame] | 176 | |
| 177 | Python 2.6 |
| 178 | ---------- |
| 179 | |
Matthew Treinish | d28dd7b | 2015-02-23 11:52:33 -0500 | [diff] [blame] | 180 | Starting in the kilo release the OpenStack services dropped all support for |
Joe H. Rahme | 00a7542 | 2015-03-16 17:46:24 +0100 | [diff] [blame] | 181 | python 2.6. This change has been mirrored in Tempest, starting after the |
| 182 | tempest-2 tag. This means that proposed changes to Tempest which only fix |
Matthew Treinish | d28dd7b | 2015-02-23 11:52:33 -0500 | [diff] [blame] | 183 | python 2.6 compatibility will be rejected, and moving forward more features not |
Joe H. Rahme | 00a7542 | 2015-03-16 17:46:24 +0100 | [diff] [blame] | 184 | present in python 2.6 will be used. If you're running your OpenStack services |
| 185 | on an earlier release with python 2.6 you can easily run Tempest against it |
Matthew Treinish | d28dd7b | 2015-02-23 11:52:33 -0500 | [diff] [blame] | 186 | from a remote system running python 2.7. (or deploy a cloud guest in your cloud |
| 187 | that has python 2.7) |
Matthew Treinish | 3460aaa | 2015-05-11 22:18:00 -0400 | [diff] [blame] | 188 | |
| 189 | Python 3.4 |
| 190 | ---------- |
| 191 | |
| 192 | Starting during the Liberty release development cycle work began on enabling |
| 193 | Tempest to run under both Python 2.7 and Python 3.4. Tempest strives to fully |
| 194 | support running with Python 3.4. A gating unit test job was added to also run |
| 195 | Tempest's unit tests under Python 3.4. This means that the Tempest code at |
| 196 | least imports under Python 3.4 and things that have unit test coverage will |
zhangfeng | c53e4e1 | 2015-08-21 04:09:08 +0000 | [diff] [blame] | 197 | work on Python 3.4. However, because large parts of Tempest are self-verifying |
Matthew Treinish | 3460aaa | 2015-05-11 22:18:00 -0400 | [diff] [blame] | 198 | there might be uncaught issues running on Python 3.4. So until there is a gating |
| 199 | job which does a full Tempest run using Python 3.4 there isn't any guarantee |
| 200 | that running Tempest under Python 3.4 is bug free. |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 201 | |
| 202 | Legacy run method |
| 203 | ----------------- |
| 204 | |
| 205 | The legacy method of running Tempest is to just treat the Tempest source code |
| 206 | as a python unittest repository and run directly from the source repo. When |
| 207 | running in this way you still start with a Tempest config file and the steps |
| 208 | are basically the same except that it expects you know where the Tempest code |
| 209 | lives on your system and requires a bit more manual interaction to get Tempest |
| 210 | running. For example, when running Tempest this way things like a lock file |
| 211 | directory do not get generated automatically and the burden is on the user to |
| 212 | create and configure that. |
| 213 | |
| 214 | To start you need to create a configuration file. The easiest way to create a |
| 215 | configuration file is to generate a sample in the ``etc/`` directory :: |
| 216 | |
| 217 | $> cd $TEMPEST_ROOT_DIR |
| 218 | $> oslo-config-generator --config-file \ |
David Paterson | 0bf52d4 | 2015-04-13 21:55:58 -0400 | [diff] [blame] | 219 | etc/config-generator.tempest.conf \ |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 220 | --output-file etc/tempest.conf |
| 221 | |
| 222 | After that, open up the ``etc/tempest.conf`` file and edit the |
| 223 | configuration variables to match valid data in your environment. |
| 224 | This includes your Keystone endpoint, a valid user and credentials, |
| 225 | and 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 | |
| 234 | Tempest is not tied to any single test runner, but `testr`_ is the most commonly |
| 235 | used tool. Also, the nosetests test runner is **not** recommended to run Tempest. |
| 236 | |
| 237 | After setting up your configuration file, you can execute the set of Tempest |
| 238 | tests by using ``testr`` :: |
| 239 | |
| 240 | $> testr run --parallel |
| 241 | |
Matthew Treinish | 828734a | 2015-07-06 15:43:46 -0400 | [diff] [blame] | 242 | To run one single test serially :: |
| 243 | |
| 244 | $> testr run tempest.api.compute.servers.test_servers_negative.ServersNegativeTestJSON.test_reboot_non_existent_server |
| 245 | |
| 246 | Alternatively, you can use the run_tempest.sh script which will create a venv |
| 247 | and run the tests or use tox to do the same. Tox also contains several existing |
| 248 | job configurations. For example:: |
| 249 | |
| 250 | $> tox -efull |
| 251 | |
| 252 | which will run the same set of tests as the OpenStack gate. (it's exactly how |
| 253 | the gate invokes Tempest) Or:: |
| 254 | |
| 255 | $> tox -esmoke |
| 256 | |
| 257 | to run the tests tagged as smoke. |