| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 1 | Reviewing Tempest Code | 
|  | 2 | ====================== | 
|  | 3 |  | 
|  | 4 | To start read the `OpenStack Common Review Checklist | 
| davyyy | ac670dc | 2017-11-16 21:27:03 +0800 | [diff] [blame] | 5 | <https://docs.openstack.org/infra/manual/developers.html#peer-review>`_ | 
| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 6 |  | 
|  | 7 |  | 
|  | 8 | Ensuring code is executed | 
|  | 9 | ------------------------- | 
|  | 10 |  | 
|  | 11 | For any new or change to a test it has to be verified in the gate. This means | 
|  | 12 | that the first thing to check with any change is that a gate job actually runs | 
|  | 13 | it. Tests which aren't executed either because of configuration or skips should | 
|  | 14 | not be accepted. | 
|  | 15 |  | 
| Jordan Pittier | f6a0b5e | 2016-09-30 16:20:30 +0200 | [diff] [blame] | 16 | If a new test is added that depends on a new config option (like a feature | 
|  | 17 | flag), the commit message must reference a change in DevStack or DevStack-Gate | 
|  | 18 | that enables the execution of this newly introduced test. This reference could | 
| davyyy | ac670dc | 2017-11-16 21:27:03 +0800 | [diff] [blame] | 19 | either be a `Cross-Repository Dependency <https://docs.openstack.org/infra/ | 
| Jordan Pittier | f6a0b5e | 2016-09-30 16:20:30 +0200 | [diff] [blame] | 20 | manual/developers.html#cross-repository-dependencies>`_ or a simple link | 
|  | 21 | to a Gerrit review. | 
|  | 22 |  | 
| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 23 |  | 
| Jordan Pittier | 74a56ab | 2017-04-26 16:46:20 +0200 | [diff] [blame] | 24 | Execution time | 
|  | 25 | -------------- | 
|  | 26 | While checking in the job logs that a new test is actually executed, also | 
|  | 27 | pay attention to the execution time of that test. Keep in mind that each test | 
|  | 28 | is going to be executed hundreds of time each day, because Tempest tests | 
|  | 29 | run in many OpenStack projects. It's worth considering how important/critical | 
|  | 30 | the feature under test is with how costly the new test is. | 
|  | 31 |  | 
|  | 32 |  | 
| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 33 | Unit Tests | 
|  | 34 | ---------- | 
|  | 35 |  | 
|  | 36 | For any change that adds new functionality to either common functionality or an | 
|  | 37 | out-of-band tool unit tests are required. This is to ensure we don't introduce | 
|  | 38 | future regressions and to test conditions which we may not hit in the gate runs. | 
| Felipe Monteiro | a7365ae | 2018-09-21 20:32:56 +0100 | [diff] [blame] | 39 | API and scenario tests aren't required to have unit tests since they should | 
|  | 40 | be self-verifying by running them in the gate. All service clients, on the | 
|  | 41 | other hand, `must have`_ unit tests, as they belong to ``tempest/lib``. | 
|  | 42 |  | 
|  | 43 | .. _must have: https://docs.openstack.org/tempest/latest/library.html#testing | 
| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 44 |  | 
|  | 45 |  | 
|  | 46 | API Stability | 
|  | 47 | ------------- | 
| Chang Liu | 18610f9 | 2018-04-02 09:57:46 +0800 | [diff] [blame] | 48 | Tests should only be added for published stable APIs. If a patch contains | 
|  | 49 | tests for an API which hasn't been marked as stable or for an API which | 
| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 50 | doesn't conform to the `API stability guidelines | 
|  | 51 | <https://wiki.openstack.org/wiki/Governance/Approved/APIStability>`_ then it | 
|  | 52 | should not be approved. | 
|  | 53 |  | 
|  | 54 |  | 
|  | 55 | Reject Copy and Paste Test Code | 
| Matthew Treinish | f45ba2e | 2015-08-24 15:05:01 -0400 | [diff] [blame] | 56 | ------------------------------- | 
| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 57 | When creating new tests that are similar to existing tests it is tempting to | 
|  | 58 | simply copy the code and make a few modifications. This increases code size and | 
|  | 59 | the maintenance burden. Such changes should not be approved if it is easy to | 
|  | 60 | abstract the duplicated code into a function or method. | 
|  | 61 |  | 
|  | 62 |  | 
| Jordan Pittier | 74a56ab | 2017-04-26 16:46:20 +0200 | [diff] [blame] | 63 | Tests overlap | 
|  | 64 | ------------- | 
|  | 65 | When a new test is being proposed, question whether this feature is not already | 
|  | 66 | tested with Tempest. Tempest has more than 1200 tests, spread amongst many | 
|  | 67 | directories, so it's easy to introduce test duplication. For example, testing | 
|  | 68 | volume attachment to a server could be a compute test or a volume test, depending | 
|  | 69 | on how you see it. So one must look carefully in the entire code base for possible | 
|  | 70 | overlap. As a rule of thumb, the older a feature is, the more likely it's | 
|  | 71 | already tested. | 
|  | 72 |  | 
|  | 73 |  | 
| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 74 | Being explicit | 
|  | 75 | -------------- | 
|  | 76 | When tests are being added that depend on a configurable feature or extension, | 
|  | 77 | polling the API to discover that it is enabled should not be done. This will | 
|  | 78 | just result in bugs being masked because the test can be skipped automatically. | 
|  | 79 | Instead the config file should be used to determine whether a test should be | 
|  | 80 | skipped or not. Do not approve changes that depend on an API call to determine | 
|  | 81 | whether to skip or not. | 
|  | 82 |  | 
|  | 83 |  | 
| Matthew Treinish | 13a1ed6 | 2015-09-08 10:39:58 -0400 | [diff] [blame] | 84 | Configuration Options | 
|  | 85 | --------------------- | 
| Jordan Pittier | 74a56ab | 2017-04-26 16:46:20 +0200 | [diff] [blame] | 86 | With the introduction of the Tempest external test plugin interface we needed | 
|  | 87 | to provide a stable contract for Tempest's configuration options. This means | 
| Matthew Treinish | 13a1ed6 | 2015-09-08 10:39:58 -0400 | [diff] [blame] | 88 | we can no longer simply remove a configuration option when it's no longer used. | 
|  | 89 | Patches proposed that remove options without a deprecation cycle should not | 
|  | 90 | be approved. Similarly when changing default values with configuration we need | 
|  | 91 | to similarly be careful that we don't break existing functionality. Also, when | 
|  | 92 | adding options, just as before, we need to weigh the benefit of adding an | 
|  | 93 | additional option against the complexity and maintenance overhead having it | 
|  | 94 | costs. | 
|  | 95 |  | 
|  | 96 |  | 
| Matthew Treinish | 5507888 | 2014-08-12 19:01:34 -0400 | [diff] [blame] | 97 | Test Documentation | 
|  | 98 | ------------------ | 
|  | 99 | When a new test is being added refer to the :ref:`TestDocumentation` section in | 
|  | 100 | hacking to see if the requirements are being met. With the exception of a class | 
|  | 101 | level docstring linking to the API ref doc in the API tests and a docstring for | 
|  | 102 | scenario tests this is up to the reviewers discretion whether a docstring is | 
|  | 103 | required or not. | 
|  | 104 |  | 
| Felipe Monteiro | f89ab81 | 2018-07-10 20:34:02 -0400 | [diff] [blame] | 105 |  | 
|  | 106 | Test Removal and Refactoring | 
|  | 107 | ---------------------------- | 
|  | 108 | Make sure that any test that is renamed, relocated (e.g. moved to another | 
|  | 109 | class), or removed does not belong to the `interop`_ testing suite -- which | 
|  | 110 | includes a select suite of Tempest tests for the purposes of validating that | 
|  | 111 | OpenStack vendor clouds are interoperable -- or a project's `whitelist`_ or | 
|  | 112 | `blacklist`_ files. | 
|  | 113 |  | 
|  | 114 | It is of critical importance that no interop, whitelist or blacklist test | 
|  | 115 | reference be broken by a patch set introduced to Tempest that renames, | 
|  | 116 | relocates or removes a referenced test. | 
|  | 117 |  | 
|  | 118 | Please check the existence of code which references Tempest tests with: | 
|  | 119 | http://codesearch.openstack.org/ | 
|  | 120 |  | 
|  | 121 | Interop | 
|  | 122 | ^^^^^^^ | 
|  | 123 | Make sure that modifications to an `interop`_ test are backwards-compatible. | 
|  | 124 | This means that code modifications to tests should not undermine the quality of | 
|  | 125 | the validation currently performed by the test or significantly alter the | 
|  | 126 | behavior of the test. | 
|  | 127 |  | 
|  | 128 | Removal | 
|  | 129 | ^^^^^^^ | 
|  | 130 | Reference the :ref:`test-removal` guidelines for understanding best practices | 
|  | 131 | associated with test removal. | 
|  | 132 |  | 
|  | 133 | .. _interop: https://www.openstack.org/brand/interop | 
|  | 134 | .. _whitelist: https://docs.openstack.org/tempest/latest/run.html#test-selection | 
|  | 135 | .. _blacklist: https://docs.openstack.org/tempest/latest/run.html#test-selection | 
|  | 136 |  | 
|  | 137 |  | 
| Matthew Treinish | b786dca | 2016-06-22 10:32:45 -0400 | [diff] [blame] | 138 | Release Notes | 
|  | 139 | ------------- | 
|  | 140 | Release notes are how we indicate to users and other consumers of Tempest what | 
|  | 141 | has changed in a given release. Since Tempest 10.0.0 we've been using `reno`_ | 
|  | 142 | to manage and build the release notes. There are certain types of changes that | 
|  | 143 | require release notes and we should not approve them without including a release | 
|  | 144 | note. These include but aren't limited to, any addition, deprecation or removal | 
|  | 145 | from the lib interface, any change to configuration options (including | 
|  | 146 | deprecation), CLI additions or deprecations, major feature additions, and | 
|  | 147 | anything backwards incompatible or would require a user to take note or do | 
|  | 148 | something extra. | 
|  | 149 |  | 
| chenxing | e98720a | 2017-07-19 03:42:23 +0000 | [diff] [blame] | 150 | .. _reno: https://docs.openstack.org/reno/latest/ | 
| Matthew Treinish | 5507888 | 2014-08-12 19:01:34 -0400 | [diff] [blame] | 151 |  | 
| Felipe Monteiro | f89ab81 | 2018-07-10 20:34:02 -0400 | [diff] [blame] | 152 |  | 
| Masayuki Igawa | 4661706 | 2016-09-02 16:38:56 +0900 | [diff] [blame] | 153 | Deprecated Code | 
|  | 154 | --------------- | 
|  | 155 | Sometimes we have some bugs in deprecated code. Basically, we leave it. Because | 
|  | 156 | we don't need to maintain it. However, if the bug is critical, we might need to | 
|  | 157 | fix it. When it will happen, we will deal with it on a case-by-case basis. | 
|  | 158 |  | 
| Felipe Monteiro | f89ab81 | 2018-07-10 20:34:02 -0400 | [diff] [blame] | 159 |  | 
| Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 160 | When to approve | 
|  | 161 | --------------- | 
| Felipe Monteiro | 6fe405d | 2018-09-16 11:13:39 -0600 | [diff] [blame] | 162 | * It's OK to hold off on an approval until a subject matter expert reviews it. | 
| Ghanshyam Mann | bfce1f2 | 2021-02-03 16:50:34 -0600 | [diff] [blame] | 163 | * Every patch needs at least single +2's before being approved. A single | 
|  | 164 | Tempest core reviewer can approve patches but can always wait for another | 
|  | 165 | +2 in any case. Following cases where single +2 can be used without any | 
|  | 166 | issue: | 
| Felipe Monteiro | 6fe405d | 2018-09-16 11:13:39 -0600 | [diff] [blame] | 167 |  | 
| Felipe Monteiro | 6fe405d | 2018-09-16 11:13:39 -0600 | [diff] [blame] | 168 | * If any trivial patch set fixes one of the items below: | 
|  | 169 |  | 
|  | 170 | * Documentation or code comment typo | 
|  | 171 | * Documentation ref link | 
|  | 172 | * Example: `example`_ | 
|  | 173 |  | 
|  | 174 | .. note:: | 
|  | 175 |  | 
|  | 176 | Any other small documentation, CI job, or code change does not fall under | 
|  | 177 | this category. | 
|  | 178 |  | 
|  | 179 | * If the patch **unblocks** a failing project gate, provided that: | 
|  | 180 |  | 
|  | 181 | * the project's PTL +1's the change | 
|  | 182 | * the patch does not affect any other project's testing gates | 
|  | 183 | * the patch does not cause any negative side effects | 
| Ghanshyam Mann | 2096631 | 2019-07-16 05:19:41 +0000 | [diff] [blame] | 184 | * If fixing and removing the faulty plugin (which leads to fail | 
|  | 185 | voting ``tempest-tox-plugin-sanity-check`` job) and unblock the | 
|  | 186 | tempest gate | 
| Felipe Monteiro | 6fe405d | 2018-09-16 11:13:39 -0600 | [diff] [blame] | 187 |  | 
| caoyuan | 349ba75 | 2019-04-23 19:40:06 +0800 | [diff] [blame] | 188 | .. _example: https://review.opendev.org/#/c/611032/ |