blob: 8a1e1526b4c2d0e33f988893a8ad176acee79559 [file] [log] [blame]
Matthew Treinish16dd51b2014-06-11 12:04:51 -04001Reviewing Tempest Code
2======================
3
4To start read the `OpenStack Common Review Checklist
davyyyac670dc2017-11-16 21:27:03 +08005<https://docs.openstack.org/infra/manual/developers.html#peer-review>`_
Matthew Treinish16dd51b2014-06-11 12:04:51 -04006
7
8Ensuring code is executed
9-------------------------
10
11For any new or change to a test it has to be verified in the gate. This means
12that the first thing to check with any change is that a gate job actually runs
13it. Tests which aren't executed either because of configuration or skips should
14not be accepted.
15
Jordan Pittierf6a0b5e2016-09-30 16:20:30 +020016If a new test is added that depends on a new config option (like a feature
17flag), the commit message must reference a change in DevStack or DevStack-Gate
18that enables the execution of this newly introduced test. This reference could
davyyyac670dc2017-11-16 21:27:03 +080019either be a `Cross-Repository Dependency <https://docs.openstack.org/infra/
Jordan Pittierf6a0b5e2016-09-30 16:20:30 +020020manual/developers.html#cross-repository-dependencies>`_ or a simple link
21to a Gerrit review.
22
Matthew Treinish16dd51b2014-06-11 12:04:51 -040023
Jordan Pittier74a56ab2017-04-26 16:46:20 +020024Execution time
25--------------
26While checking in the job logs that a new test is actually executed, also
27pay attention to the execution time of that test. Keep in mind that each test
28is going to be executed hundreds of time each day, because Tempest tests
29run in many OpenStack projects. It's worth considering how important/critical
30the feature under test is with how costly the new test is.
31
32
Matthew Treinish16dd51b2014-06-11 12:04:51 -040033Unit Tests
34----------
35
36For any change that adds new functionality to either common functionality or an
37out-of-band tool unit tests are required. This is to ensure we don't introduce
38future regressions and to test conditions which we may not hit in the gate runs.
39Tests, and service clients aren't required to have unit tests since they should
40be self verifying by running them in the gate.
41
42
43API Stability
44-------------
Chang Liu18610f92018-04-02 09:57:46 +080045Tests should only be added for published stable APIs. If a patch contains
46tests for an API which hasn't been marked as stable or for an API which
Matthew Treinish16dd51b2014-06-11 12:04:51 -040047doesn't conform to the `API stability guidelines
48<https://wiki.openstack.org/wiki/Governance/Approved/APIStability>`_ then it
49should not be approved.
50
51
52Reject Copy and Paste Test Code
Matthew Treinishf45ba2e2015-08-24 15:05:01 -040053-------------------------------
Matthew Treinish16dd51b2014-06-11 12:04:51 -040054When creating new tests that are similar to existing tests it is tempting to
55simply copy the code and make a few modifications. This increases code size and
56the maintenance burden. Such changes should not be approved if it is easy to
57abstract the duplicated code into a function or method.
58
59
Jordan Pittier74a56ab2017-04-26 16:46:20 +020060Tests overlap
61-------------
62When a new test is being proposed, question whether this feature is not already
63tested with Tempest. Tempest has more than 1200 tests, spread amongst many
64directories, so it's easy to introduce test duplication. For example, testing
65volume attachment to a server could be a compute test or a volume test, depending
66on how you see it. So one must look carefully in the entire code base for possible
67overlap. As a rule of thumb, the older a feature is, the more likely it's
68already tested.
69
70
Matthew Treinish16dd51b2014-06-11 12:04:51 -040071Being explicit
72--------------
73When tests are being added that depend on a configurable feature or extension,
74polling the API to discover that it is enabled should not be done. This will
75just result in bugs being masked because the test can be skipped automatically.
76Instead the config file should be used to determine whether a test should be
77skipped or not. Do not approve changes that depend on an API call to determine
78whether to skip or not.
79
80
Matthew Treinish13a1ed62015-09-08 10:39:58 -040081Configuration Options
82---------------------
Jordan Pittier74a56ab2017-04-26 16:46:20 +020083With the introduction of the Tempest external test plugin interface we needed
84to provide a stable contract for Tempest's configuration options. This means
Matthew Treinish13a1ed62015-09-08 10:39:58 -040085we can no longer simply remove a configuration option when it's no longer used.
86Patches proposed that remove options without a deprecation cycle should not
87be approved. Similarly when changing default values with configuration we need
88to similarly be careful that we don't break existing functionality. Also, when
89adding options, just as before, we need to weigh the benefit of adding an
90additional option against the complexity and maintenance overhead having it
91costs.
92
93
Matthew Treinish55078882014-08-12 19:01:34 -040094Test Documentation
95------------------
96When a new test is being added refer to the :ref:`TestDocumentation` section in
97hacking to see if the requirements are being met. With the exception of a class
98level docstring linking to the API ref doc in the API tests and a docstring for
99scenario tests this is up to the reviewers discretion whether a docstring is
100required or not.
101
Felipe Monteirof89ab812018-07-10 20:34:02 -0400102
103Test Removal and Refactoring
104----------------------------
105Make sure that any test that is renamed, relocated (e.g. moved to another
106class), or removed does not belong to the `interop`_ testing suite -- which
107includes a select suite of Tempest tests for the purposes of validating that
108OpenStack vendor clouds are interoperable -- or a project's `whitelist`_ or
109`blacklist`_ files.
110
111It is of critical importance that no interop, whitelist or blacklist test
112reference be broken by a patch set introduced to Tempest that renames,
113relocates or removes a referenced test.
114
115Please check the existence of code which references Tempest tests with:
116http://codesearch.openstack.org/
117
118Interop
119^^^^^^^
120Make sure that modifications to an `interop`_ test are backwards-compatible.
121This means that code modifications to tests should not undermine the quality of
122the validation currently performed by the test or significantly alter the
123behavior of the test.
124
125Removal
126^^^^^^^
127Reference the :ref:`test-removal` guidelines for understanding best practices
128associated with test removal.
129
130.. _interop: https://www.openstack.org/brand/interop
131.. _whitelist: https://docs.openstack.org/tempest/latest/run.html#test-selection
132.. _blacklist: https://docs.openstack.org/tempest/latest/run.html#test-selection
133
134
Matthew Treinishb786dca2016-06-22 10:32:45 -0400135Release Notes
136-------------
137Release notes are how we indicate to users and other consumers of Tempest what
138has changed in a given release. Since Tempest 10.0.0 we've been using `reno`_
139to manage and build the release notes. There are certain types of changes that
140require release notes and we should not approve them without including a release
141note. These include but aren't limited to, any addition, deprecation or removal
142from the lib interface, any change to configuration options (including
143deprecation), CLI additions or deprecations, major feature additions, and
144anything backwards incompatible or would require a user to take note or do
145something extra.
146
chenxinge98720a2017-07-19 03:42:23 +0000147.. _reno: https://docs.openstack.org/reno/latest/
Matthew Treinish55078882014-08-12 19:01:34 -0400148
Felipe Monteirof89ab812018-07-10 20:34:02 -0400149
Masayuki Igawa46617062016-09-02 16:38:56 +0900150Deprecated Code
151---------------
152Sometimes we have some bugs in deprecated code. Basically, we leave it. Because
153we don't need to maintain it. However, if the bug is critical, we might need to
154fix it. When it will happen, we will deal with it on a case-by-case basis.
155
Felipe Monteirof89ab812018-07-10 20:34:02 -0400156
Matthew Treinish16dd51b2014-06-11 12:04:51 -0400157When to approve
158---------------
Masayuki Igawab78b9232017-11-17 16:12:37 +0900159* Every patch needs two +2s before being approved.
Felipe Monteirof89ab812018-07-10 20:34:02 -0400160* It's ok to hold off on an approval until a subject matter expert reviews it
Masayuki Igawab78b9232017-11-17 16:12:37 +0900161* If a patch has already been approved but requires a trivial rebase to merge,
162 you do not have to wait for a second +2, since the patch has already had
163 two +2s.