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