blob: eb6551abdc9b02382cf433d0b7785007c75f2a8f [file] [log] [blame]
Attila Fazekas23fdf1d2013-06-09 16:35:23 +02001Tempest Coding Guide
2====================
3
Joe Gordon1374f882013-07-12 17:00:34 +01004- Step 1: Read the OpenStack Style Commandments
chenxinge98720a2017-07-19 03:42:23 +00005 https://docs.openstack.org/hacking/latest/
Joe Gordon1374f882013-07-12 17:00:34 +01006- Step 2: Read on
7
8Tempest Specific Commandments
Sergey Vilgelmeac094a2018-11-21 18:27:51 -06009-----------------------------
Joe Gordon1374f882013-07-12 17:00:34 +010010
ghanshyam50f19472014-11-26 17:04:37 +090011- [T102] Cannot import OpenStack python clients in tempest/api &
Masayuki Igawab78b9232017-11-17 16:12:37 +090012 tempest/scenario tests
Matthew Treinish5e4c0f22013-09-10 18:38:28 +000013- [T104] Scenario tests require a services decorator
Andrea Frittolia5ddd552014-08-19 18:30:00 +010014- [T105] Tests cannot use setUpClass/tearDownClass
Masayuki Igawafcacf962014-02-19 14:00:01 +090015- [T106] vim configuration should not be kept in source files.
Ken'ichi Ohmichi7581bcd2015-02-16 04:09:58 +000016- [T107] Check that a service tag isn't in the module path
Ken'ichi Ohmichi80369a92015-04-06 23:41:14 +000017- [T108] Check no hyphen at the end of rand_name() argument
John Warren3059a092015-08-31 15:34:49 -040018- [T109] Cannot use testtools.skip decorator; instead use
Masayuki Igawab78b9232017-11-17 16:12:37 +090019 decorators.skip_because from tempest.lib
Ken'ichi Ohmichic0d96be2015-11-11 12:33:48 +000020- [T110] Check that service client names of GET should be consistent
Ken'ichi Ohmichi4f525f72016-03-25 15:20:01 -070021- [T111] Check that service client names of DELETE should be consistent
Ken'ichi Ohmichi0dc97472016-03-25 15:10:08 -070022- [T112] Check that tempest.lib should not import local tempest code
Ken'ichi Ohmichid079c892016-04-19 11:23:36 -070023- [T113] Check that tests use data_utils.rand_uuid() instead of uuid.uuid4()
Matthew Treinish59d9eaa2016-05-31 23:42:55 -040024- [T114] Check that tempest.lib does not use tempest config
Ken'ichi Ohmichif741d0b2017-05-01 16:56:14 -070025- [T115] Check that admin tests should exist under admin path
Ghanshyam2a180b82014-06-16 13:54:22 +090026- [N322] Method's default argument shouldn't be mutable
junbolibc2ae862017-07-29 15:46:48 +080027- [T116] Unsupported 'message' Exception attribute in PY3
Felipe Monteiro4d011af2018-07-18 00:11:48 -040028- [T117] Check negative tests have ``@decorators.attr(type=['negative'])``
29 applied.
Attila Fazekas23fdf1d2013-06-09 16:35:23 +020030
Matthew Treinish8b372892012-12-07 17:13:16 -050031Test Data/Configuration
32-----------------------
33- Assume nothing about existing test data
34- Tests should be self contained (provide their own data)
35- Clean up test data at the completion of each test
36- Use configuration files for values that will vary by environment
37
Felipe Monteirof22e6ec2018-11-03 17:51:18 -040038Supported OpenStack Components
39------------------------------
40
41Tempest's :ref:`library` and :ref:`plugin interface <tempest_plugin>` can be
42leveraged to support integration testing for virtually any OpenStack component.
43
44However, Tempest only offers **in-tree** integration testing coverage for the
45following components:
46
47* Cinder
48* Glance
49* Keystone
50* Neutron
51* Nova
52* Swift
53
54Historically, Tempest offered in-tree testing for other components as well, but
55since the introduction of the `External Plugin Interface`_, Tempest's in-tree
56testing scope has been limited to the projects above. Integration tests for
57projects not included above should go into one of the
58`relevant plugin projects`_.
59
60.. _External Plugin Interface: https://specs.openstack.org/openstack/qa-specs/specs/tempest/implemented/tempest-external-plugin-interface.html
61.. _relevant plugin projects: https://docs.openstack.org/tempest/latest/plugin-registry.html#detected-plugins
Matthew Treinish8b372892012-12-07 17:13:16 -050062
Attila Fazekas10fd63d2013-07-04 18:38:21 +020063Exception Handling
64------------------
65According to the ``The Zen of Python`` the
Attila Fazekas58d23302013-07-24 10:25:02 +020066``Errors should never pass silently.``
Attila Fazekas10fd63d2013-07-04 18:38:21 +020067Tempest usually runs in special environment (jenkins gate jobs), in every
68error or failure situation we should provide as much error related
69information as possible, because we usually do not have the chance to
70investigate the situation after the issue happened.
71
72In every test case the abnormal situations must be very verbosely explained,
73by the exception and the log.
74
75In most cases the very first issue is the most important information.
76
Mithil Arunbe067ec2014-11-05 15:58:50 +053077Try to avoid using ``try`` blocks in the test cases, as both the ``except``
78and ``finally`` blocks could replace the original exception,
Attila Fazekas10fd63d2013-07-04 18:38:21 +020079when the additional operations leads to another exception.
80
Mithil Arunbe067ec2014-11-05 15:58:50 +053081Just letting an exception to propagate, is not a bad idea in a test case,
Bruce R. Montague44a6a192013-12-17 09:06:04 -080082at all.
Attila Fazekas10fd63d2013-07-04 18:38:21 +020083
84Try to avoid using any exception handling construct which can hide the errors
85origin.
86
87If you really need to use a ``try`` block, please ensure the original
88exception at least logged. When the exception is logged you usually need
89to ``raise`` the same or a different exception anyway.
90
Chris Yeohc2ff7272013-07-22 22:25:25 +093091Use of ``self.addCleanup`` is often a good way to avoid having to catch
92exceptions and still ensure resources are correctly cleaned up if the
93test fails part way through.
94
Mithil Arunbe067ec2014-11-05 15:58:50 +053095Use the ``self.assert*`` methods provided by the unit test framework.
96This signals the failures early on.
Attila Fazekas10fd63d2013-07-04 18:38:21 +020097
Mithil Arunbe067ec2014-11-05 15:58:50 +053098Avoid using the ``self.fail`` alone, its stack trace will signal
Bruce R. Montague44a6a192013-12-17 09:06:04 -080099the ``self.fail`` line as the origin of the error.
Attila Fazekas10fd63d2013-07-04 18:38:21 +0200100
101Avoid constructing complex boolean expressions for assertion.
Attila Fazekas7899d312013-08-16 09:18:17 +0200102The ``self.assertTrue`` or ``self.assertFalse`` without a ``msg`` argument,
103will just tell you the single boolean value, and you will not know anything
104about the values used in the formula, the ``msg`` argument might be good enough
105for providing more information.
106
107Most other assert method can include more information by default.
Attila Fazekas10fd63d2013-07-04 18:38:21 +0200108For example ``self.assertIn`` can include the whole set.
109
Matthew Treinishf45ba2e2015-08-24 15:05:01 -0400110It is recommended to use testtools `matcher`_ for the more tricky assertions.
111You can implement your own specific `matcher`_ as well.
Attila Fazekas7899d312013-08-16 09:18:17 +0200112
davyyyac670dc2017-11-16 21:27:03 +0800113.. _matcher: https://testtools.readthedocs.org/en/latest/for-test-authors.html#matchers
Attila Fazekas7899d312013-08-16 09:18:17 +0200114
Attila Fazekas10fd63d2013-07-04 18:38:21 +0200115If the test case fails you can see the related logs and the information
116carried by the exception (exception class, backtrack and exception info).
Mithil Arunbe067ec2014-11-05 15:58:50 +0530117This and the service logs are your only guide to finding the root cause of flaky
118issues.
Attila Fazekas10fd63d2013-07-04 18:38:21 +0200119
Attila Fazekas7899d312013-08-16 09:18:17 +0200120Test cases are independent
121--------------------------
122Every ``test_method`` must be callable individually and MUST NOT depends on,
123any other ``test_method`` or ``test_method`` ordering.
124
125Test cases MAY depend on commonly initialized resources/facilities, like
126credentials management, testresources and so on. These facilities, MUST be able
Mithil Arunbe067ec2014-11-05 15:58:50 +0530127to work even if just one ``test_method`` is selected for execution.
Attila Fazekas7899d312013-08-16 09:18:17 +0200128
Matthew Treinish5e4c0f22013-09-10 18:38:28 +0000129Service Tagging
130---------------
131Service tagging is used to specify which services are exercised by a particular
mmkmmk57ce3bb9b2017-09-20 13:41:41 +0900132test method. You specify the services with the ``tempest.common.utils.services``
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200133decorator. For example:
Matthew Treinish5e4c0f22013-09-10 18:38:28 +0000134
Felipe Monteiro46920b82018-07-09 23:58:20 -0400135``@utils.services('compute', 'image')``
Matthew Treinish5e4c0f22013-09-10 18:38:28 +0000136
137Valid service tag names are the same as the list of directories in tempest.api
138that have tests.
139
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200140For scenario tests having a service tag is required. For the API tests service
141tags are only needed if the test method makes an API call (either directly or
Matthew Treinish5e4c0f22013-09-10 18:38:28 +0000142indirectly through another service) that differs from the parent directory
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200143name. For example, any test that make an API call to a service other than Nova
144in ``tempest.api.compute`` would require a service tag for those services,
145however they do not need to be tagged as ``compute``.
Matthew Treinish5e4c0f22013-09-10 18:38:28 +0000146
Felipe Monteiro46920b82018-07-09 23:58:20 -0400147Test Attributes
148---------------
149Tempest leverages `test attributes`_ which are a simple but effective way of
150distinguishing between different "types" of API tests. A test can be "tagged"
151with such attributes using the ``decorators.attr`` decorator, for example::
152
153 @decorators.attr(type=['negative'])
154 def test_aggregate_create_aggregate_name_length_less_than_1(self):
155 [...]
156
157These test attributes can be used for test selection via regular expressions.
158For example, ``(?!.*\[.*\bslow\b.*\])(^tempest\.scenario)`` runs all the tests
159in the ``scenario`` test module, *except* for those tagged with the ``slow``
160attribute (via a negative lookahead in the regular expression). These
161attributes are used in Tempest's ``tox.ini`` as well as Tempest's Zuul job
162definitions for specifying particular batches of Tempest test suites to run.
163
164.. _test attributes: https://testtools.readthedocs.io/en/latest/for-test-authors.html?highlight=attr#test-attributes
165
166Negative Attribute
167^^^^^^^^^^^^^^^^^^
168The ``type='negative'`` attribute is used to signify that a test is a negative
169test, which is a test that handles invalid input gracefully. This attribute
170should be applied to all negative test scenarios.
171
172This attribute must be applied to each test that belongs to a negative test
173class, i.e. a test class name ending with "Negative.*" substring.
174
Felipe Monteiro46920b82018-07-09 23:58:20 -0400175Slow Attribute
176^^^^^^^^^^^^^^
177The ``type='slow'`` attribute is used to signify that a test takes a long time
178to run, relatively speaking. This attribute is usually applied to
179:ref:`scenario tests <scenario_field_guide>`, which involve a complicated
180series of API operations, the total runtime of which can be relatively long.
181This long runtime has performance implications on `Zuul`_ jobs, which is why
182the ``slow`` attribute is leveraged to run slow tests on a selective basis,
183to keep total `Zuul`_ job runtime down to a reasonable time frame.
184
185.. _Zuul: https://docs.openstack.org/infra/zuul/
186
187Smoke Attribute
188^^^^^^^^^^^^^^^
189The ``type='smoke'`` attribute is used to signify that a test is a so-called
190smoke test, which is a type of test that tests the most vital OpenStack
191functionality, like listing servers or flavors or creating volumes. The
192attribute should be sparingly applied to only the tests that sanity-check the
193most essential functionality of an OpenStack cloud.
194
Andrea Frittolia5ddd552014-08-19 18:30:00 +0100195Test fixtures and resources
196---------------------------
197Test level resources should be cleaned-up after the test execution. Clean-up
Masayuki Igawabbbaad62017-11-21 16:04:03 +0900198is best scheduled using ``addCleanup`` which ensures that the resource cleanup
Andrea Frittolia5ddd552014-08-19 18:30:00 +0100199code is always invoked, and in reverse order with respect to the creation
200order.
201
Masayuki Igawabbbaad62017-11-21 16:04:03 +0900202Test class level resources should be defined in the ``resource_setup`` method
203of the test class, except for any credential obtained from the credentials
204provider, which should be set-up in the ``setup_credentials`` method.
205Cleanup is best scheduled using ``addClassResourceCleanup`` which ensures that
Andrea Frittoli3be57482017-08-25 22:41:26 +0100206the cleanup code is always invoked, and in reverse order with respect to the
207creation order.
208
209In both cases - test level and class level cleanups - a wait loop should be
210scheduled before the actual delete of resources with an asynchronous delete.
Andrea Frittolia5ddd552014-08-19 18:30:00 +0100211
Masayuki Igawabbbaad62017-11-21 16:04:03 +0900212The test base class ``BaseTestCase`` defines Tempest framework for class level
213fixtures. ``setUpClass`` and ``tearDownClass`` are defined here and cannot be
Andrea Frittolia5ddd552014-08-19 18:30:00 +0100214overwritten by subclasses (enforced via hacking rule T105).
215
216Set-up is split in a series of steps (setup stages), which can be overwritten
217by test classes. Set-up stages are:
Masayuki Igawae63cf0f2016-05-25 10:25:21 +0900218
Masayuki Igawabbbaad62017-11-21 16:04:03 +0900219- ``skip_checks``
220- ``setup_credentials``
221- ``setup_clients``
222- ``resource_setup``
Andrea Frittolia5ddd552014-08-19 18:30:00 +0100223
224Tear-down is also split in a series of steps (teardown stages), which are
225stacked for execution only if the corresponding setup stage had been
226reached during the setup phase. Tear-down stages are:
Masayuki Igawae63cf0f2016-05-25 10:25:21 +0900227
Masayuki Igawabbbaad62017-11-21 16:04:03 +0900228- ``clear_credentials`` (defined in the base test class)
229- ``resource_cleanup``
Andrea Frittolia5ddd552014-08-19 18:30:00 +0100230
231Skipping Tests
232--------------
233Skipping tests should be based on configuration only. If that is not possible,
234it is likely that either a configuration flag is missing, or the test should
235fail rather than be skipped.
236Using discovery for skipping tests is generally discouraged.
237
238When running a test that requires a certain "feature" in the target
239cloud, if that feature is missing we should fail, because either the test
240configuration is invalid, or the cloud is broken and the expected "feature" is
241not there even if the cloud was configured with it.
242
Matthew Treinish8b79bb32013-10-10 17:11:05 -0400243Negative Tests
244--------------
Chris Hoge2b478412016-06-23 16:03:28 -0700245Error handling is an important aspect of API design and usage. Negative
246tests are a way to ensure that an application can gracefully handle
247invalid or unexpected input. However, as a black box integration test
248suite, Tempest is not suitable for handling all negative test cases, as
249the wide variety and complexity of negative tests can lead to long test
250runs and knowledge of internal implementation details. The bulk of
Ken'ichi Ohmichi8db40752016-09-28 14:43:05 -0700251negative testing should be handled with project function tests.
252All negative tests should be based on `API-WG guideline`_ . Such negative
253tests can block any changes from accurate failure code to invalid one.
254
davyyyac670dc2017-11-16 21:27:03 +0800255.. _API-WG guideline: https://specs.openstack.org/openstack/api-wg/guidelines/http.html#failure-code-clarifications
Ken'ichi Ohmichi8db40752016-09-28 14:43:05 -0700256
257If facing some gray area which is not clarified on the above guideline, propose
258a new guideline to the API-WG. With a proposal to the API-WG we will be able to
259build a consensus across all OpenStack projects and improve the quality and
260consistency of all the APIs.
261
262In addition, we have some guidelines for additional negative tests.
263
264- About BadRequest(HTTP400) case: We can add a single negative tests of
265 BadRequest for each resource and method(POST, PUT).
266 Please don't implement more negative tests on the same combination of
267 resource and method even if API request parameters are different from
268 the existing test.
269- About NotFound(HTTP404) case: We can add a single negative tests of
270 NotFound for each resource and method(GET, PUT, DELETE, HEAD).
271 Please don't implement more negative tests on the same combination
272 of resource and method.
273
274The above guidelines don't cover all cases and we will grow these guidelines
275organically over time. Patches outside of the above guidelines are left up to
276the reviewers' discretion and if we face some conflicts between reviewers, we
277will expand the guideline based on our discussion and experience.
Matthew Treinish8b79bb32013-10-10 17:11:05 -0400278
Giulio Fidente83181a92013-10-01 06:02:24 +0200279Test skips because of Known Bugs
280--------------------------------
Giulio Fidente83181a92013-10-01 06:02:24 +0200281If a test is broken because of a bug it is appropriate to skip the test until
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200282bug has been fixed. You should use the ``skip_because`` decorator so that
Giulio Fidente83181a92013-10-01 06:02:24 +0200283Tempest's skip tracking tool can watch the bug status.
284
285Example::
286
287 @skip_because(bug="980688")
288 def test_this_and_that(self):
289 ...
290
Chris Yeohc2ff7272013-07-22 22:25:25 +0930291Guidelines
292----------
293- Do not submit changesets with only testcases which are skipped as
294 they will not be merged.
295- Consistently check the status code of responses in testcases. The
296 earlier a problem is detected the easier it is to debug, especially
297 where there is complicated setup required.
Matthew Treinish96c28d12013-09-16 17:05:09 +0000298
DennyZhang900f02b2013-09-23 08:34:04 -0500299Parallel Test Execution
300-----------------------
Matthew Treinish96c28d12013-09-16 17:05:09 +0000301Tempest by default runs its tests in parallel this creates the possibility for
302interesting interactions between tests which can cause unexpected failures.
Andrea Frittoli (andreaf)17209bb2015-05-22 10:16:57 -0700303Dynamic credentials provides protection from most of the potential race
304conditions between tests outside the same class. But there are still a few of
305things to watch out for to try to avoid issues when running your tests in
306parallel.
Matthew Treinish96c28d12013-09-16 17:05:09 +0000307
Sean Dagueed6e5862016-04-04 10:49:13 -0400308- Resources outside of a project scope still have the potential to conflict. This
Matthew Treinish96c28d12013-09-16 17:05:09 +0000309 is a larger concern for the admin tests since most resources and actions that
Sean Dagueed6e5862016-04-04 10:49:13 -0400310 require admin privileges are outside of projects.
Matthew Treinish96c28d12013-09-16 17:05:09 +0000311
312- Races between methods in the same class are not a problem because
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200313 parallelization in Tempest is at the test class level, but if there is a json
Matthew Treinish96c28d12013-09-16 17:05:09 +0000314 and xml version of the same test class there could still be a race between
315 methods.
316
jeremy.zhangc0f95562017-05-26 13:41:57 +0800317- The rand_name() function from tempest.lib.common.utils.data_utils should be
318 used anywhere a resource is created with a name. Static naming should be
319 avoided to prevent resource conflicts.
Matthew Treinish96c28d12013-09-16 17:05:09 +0000320
321- If the execution of a set of tests is required to be serialized then locking
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200322 can be used to perform this. See usage of ``LockFixture`` for examples of
323 using locking.
Marc Koderer31fe4832013-11-06 17:02:03 +0100324
Matthew Treinish6eb05852013-11-26 15:28:12 +0000325Sample Configuration File
326-------------------------
327The sample config file is autogenerated using a script. If any changes are made
David Kranzfb0f51f2014-11-11 14:07:20 -0500328to the config variables in tempest/config.py then the sample config file must be
329regenerated. This can be done running::
330
Hai Shi6f52fc52017-04-03 21:17:37 +0800331 tox -e genconfig
Matthew Treinishecf212c2013-12-06 18:23:54 +0000332
333Unit Tests
334----------
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200335Unit tests are a separate class of tests in Tempest. They verify Tempest
Matthew Treinishecf212c2013-12-06 18:23:54 +0000336itself, and thus have a different set of guidelines around them:
337
3381. They can not require anything running externally. All you should need to
339 run the unit tests is the git tree, python and the dependencies installed.
340 This includes running services, a config file, etc.
341
3422. The unit tests cannot use setUpClass, instead fixtures and testresources
343 should be used for shared state between tests.
Matthew Treinish55078882014-08-12 19:01:34 -0400344
345
346.. _TestDocumentation:
347
348Test Documentation
349------------------
350For tests being added we need to require inline documentation in the form of
Xicheng Chang6fb98ec2015-08-13 14:02:52 -0700351docstrings to explain what is being tested. In API tests for a new API a class
Matthew Treinish55078882014-08-12 19:01:34 -0400352level docstring should be added to an API reference doc. If one doesn't exist
353a TODO comment should be put indicating that the reference needs to be added.
354For individual API test cases a method level docstring should be used to
355explain the functionality being tested if the test name isn't descriptive
356enough. For example::
357
358 def test_get_role_by_id(self):
359 """Get a role by its id."""
360
361the docstring there is superfluous and shouldn't be added. but for a method
362like::
363
364 def test_volume_backup_create_get_detailed_list_restore_delete(self):
365 pass
366
367a docstring would be useful because while the test title is fairly descriptive
368the operations being performed are complex enough that a bit more explanation
369will help people figure out the intent of the test.
370
371For scenario tests a class level docstring describing the steps in the scenario
372is required. If there is more than one test case in the class individual
373docstrings for the workflow in each test methods can be used instead. A good
374example of this would be::
375
zhufl42bcb552018-09-17 16:06:30 +0800376 class TestServerBasicOps(manager.ScenarioTest):
Matthew Treinish55078882014-08-12 19:01:34 -0400377
zhufl42bcb552018-09-17 16:06:30 +0800378 """The test suite for server basic operations
379
380 This smoke test case follows this basic set of operations:
381 * Create a keypair for use in launching an instance
382 * Create a security group to control network access in instance
383 * Add simple permissive rules to the security group
384 * Launch an instance
385 * Perform ssh to instance
386 * Verify metadata service
387 * Verify metadata on config_drive
388 * Terminate the instance
Dougal Matthews4bebca02014-10-28 08:36:04 +0000389 """
Matthew Treinisha970d652015-03-11 15:39:24 -0400390
Chris Hoge0e000ed2015-07-28 14:19:53 -0500391Test Identification with Idempotent ID
392--------------------------------------
393
394Every function that provides a test must have an ``idempotent_id`` decorator
395that is a unique ``uuid-4`` instance. This ID is used to complement the fully
Naomichi Wakuidbe9aab2015-08-26 03:36:02 +0000396qualified test name and track test functionality through refactoring. The
Chris Hoge0e000ed2015-07-28 14:19:53 -0500397format of the metadata looks like::
398
Ken'ichi Ohmichi8a082112017-03-06 16:03:17 -0800399 @decorators.idempotent_id('585e934c-448e-43c4-acbf-d06a9b899997')
Chris Hoge0e000ed2015-07-28 14:19:53 -0500400 def test_list_servers_with_detail(self):
401 # The created server should be in the detailed list of all servers
402 ...
403
Andrea Frittoli (andreaf)1370baf2016-04-29 14:26:22 -0500404Tempest.lib includes a ``check-uuid`` tool that will test for the existence
Matthew Treinishc1802bc2015-12-03 18:48:11 -0500405and uniqueness of idempotent_id metadata for every test. If you have
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200406Tempest installed you run the tool against Tempest by calling from the
407Tempest repo::
Chris Hoge0e000ed2015-07-28 14:19:53 -0500408
Matthew Treinishc1802bc2015-12-03 18:48:11 -0500409 check-uuid
Chris Hoge0e000ed2015-07-28 14:19:53 -0500410
411It can be invoked against any test suite by passing a package name::
412
Matthew Treinishc1802bc2015-12-03 18:48:11 -0500413 check-uuid --package <package_name>
Chris Hoge0e000ed2015-07-28 14:19:53 -0500414
415Tests without an ``idempotent_id`` can be automatically fixed by running
416the command with the ``--fix`` flag, which will modify the source package
417by inserting randomly generated uuids for every test that does not have
418one::
419
Matthew Treinishc1802bc2015-12-03 18:48:11 -0500420 check-uuid --fix
Chris Hoge0e000ed2015-07-28 14:19:53 -0500421
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200422The ``check-uuid`` tool is used as part of the Tempest gate job
Chris Hoge0e000ed2015-07-28 14:19:53 -0500423to ensure that all tests have an ``idempotent_id`` decorator.
424
Matthew Treinisha970d652015-03-11 15:39:24 -0400425Branchless Tempest Considerations
426---------------------------------
427
428Starting with the OpenStack Icehouse release Tempest no longer has any stable
429branches. This is to better ensure API consistency between releases because
430the API behavior should not change between releases. This means that the stable
431branches are also gated by the Tempest master branch, which also means that
432proposed commits to Tempest must work against both the master and all the
433currently supported stable branches of the projects. As such there are a few
434special considerations that have to be accounted for when pushing new changes
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200435to Tempest.
Matthew Treinisha970d652015-03-11 15:39:24 -0400436
4371. New Tests for new features
438^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
439
440When adding tests for new features that were not in previous releases of the
Felipe Monteiro356f0592018-03-26 21:51:52 -0400441projects the new test has to be properly skipped with a feature flag. This can
442be just as simple as using the ``@utils.requires_ext()`` or
443``testtools.skipUnless`` decorators to check if the required extension (or
444discoverable optional API) or feature is enabled or can be as difficult as
Andrea Frittolicd368412017-08-14 21:37:56 +0100445adding a new config option to the appropriate section. If there isn't a method
446of selecting the new **feature** from the config file then there won't be a
Felipe Monteiro356f0592018-03-26 21:51:52 -0400447mechanism to disable the test with older stable releases and the new test
448won't be able to merge.
449
450Introduction of a new feature flag requires specifying a default value for
451the corresponding config option that is appropriate in the latest OpenStack
452release. Because Tempest is branchless, the feature flag's default value will
453need to be overridden to a value that is appropriate in earlier releases
454in which the feature isn't available. In DevStack, this can be accomplished
455by modifying Tempest's `lib installation script`_ for previous branches
456(because DevStack is branched).
457
sunqingliang68606c832018-11-09 14:25:17 +0800458.. _lib installation script: https://git.openstack.org/cgit/openstack-dev/devstack/tree/lib/tempest
Matthew Treinisha970d652015-03-11 15:39:24 -0400459
4602. Bug fix on core project needing Tempest changes
461^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
462
463When trying to land a bug fix which changes a tested API you'll have to use the
464following procedure::
465
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200466 1. Propose change to the project, get a +2 on the change even with failing
467 2. Propose skip on Tempest which will only be approved after the
Matthew Treinisha970d652015-03-11 15:39:24 -0400468 corresponding change in the project has a +2 on change
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200469 3. Land project change in master and all open stable branches (if required)
470 4. Land changed test in Tempest
Matthew Treinisha970d652015-03-11 15:39:24 -0400471
472Otherwise the bug fix won't be able to land in the project.
473
gaofei6ec582f2018-01-24 14:08:36 +0800474Handily, `Zuul's cross-repository dependencies
junboli477fd022017-09-06 17:25:11 +0800475<https://docs.openstack.org/infra/zuul/user/gating.html#cross-project-dependencies>`_.
Jordan Pittier74a56ab2017-04-26 16:46:20 +0200476can be leveraged to do without step 2 and to have steps 3 and 4 happen
477"atomically". To do that, make the patch written in step 1 to depend (refer to
478Zuul's documentation above) on the patch written in step 4. The commit message
479for the Tempest change should have a link to the Gerrit review that justifies
480that change.
481
Matthew Treinisha970d652015-03-11 15:39:24 -04004823. New Tests for existing features
483^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
484
485If a test is being added for a feature that exists in all the current releases
486of the projects then the only concern is that the API behavior is the same
487across all the versions of the project being tested. If the behavior is not
488consistent the test will not be able to merge.
489
490API Stability
491-------------
492
493For new tests being added to Tempest the assumption is that the API being
494tested is considered stable and adheres to the OpenStack API stability
495guidelines. If an API is still considered experimental or in development then
496it should not be tested by Tempest until it is considered stable.