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. |
| 39 | Tests, and service clients aren't required to have unit tests since they should |
| 40 | be self verifying by running them in the gate. |
| 41 | |
| 42 | |
| 43 | API Stability |
| 44 | ------------- |
| 45 | Tests should only be added for a published stable APIs. If a patch contains |
| 46 | tests for an API which hasn't been marked as stable or for an API that which |
| 47 | doesn't conform to the `API stability guidelines |
| 48 | <https://wiki.openstack.org/wiki/Governance/Approved/APIStability>`_ then it |
| 49 | should not be approved. |
| 50 | |
| 51 | |
| 52 | Reject Copy and Paste Test Code |
Matthew Treinish | f45ba2e | 2015-08-24 15:05:01 -0400 | [diff] [blame] | 53 | ------------------------------- |
Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 54 | When creating new tests that are similar to existing tests it is tempting to |
| 55 | simply copy the code and make a few modifications. This increases code size and |
| 56 | the maintenance burden. Such changes should not be approved if it is easy to |
| 57 | abstract the duplicated code into a function or method. |
| 58 | |
| 59 | |
Jordan Pittier | 74a56ab | 2017-04-26 16:46:20 +0200 | [diff] [blame] | 60 | Tests overlap |
| 61 | ------------- |
| 62 | When a new test is being proposed, question whether this feature is not already |
| 63 | tested with Tempest. Tempest has more than 1200 tests, spread amongst many |
| 64 | directories, so it's easy to introduce test duplication. For example, testing |
| 65 | volume attachment to a server could be a compute test or a volume test, depending |
| 66 | on how you see it. So one must look carefully in the entire code base for possible |
| 67 | overlap. As a rule of thumb, the older a feature is, the more likely it's |
| 68 | already tested. |
| 69 | |
| 70 | |
Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 71 | Being explicit |
| 72 | -------------- |
| 73 | When tests are being added that depend on a configurable feature or extension, |
| 74 | polling the API to discover that it is enabled should not be done. This will |
| 75 | just result in bugs being masked because the test can be skipped automatically. |
| 76 | Instead the config file should be used to determine whether a test should be |
| 77 | skipped or not. Do not approve changes that depend on an API call to determine |
| 78 | whether to skip or not. |
| 79 | |
| 80 | |
Matthew Treinish | 13a1ed6 | 2015-09-08 10:39:58 -0400 | [diff] [blame] | 81 | Configuration Options |
| 82 | --------------------- |
Jordan Pittier | 74a56ab | 2017-04-26 16:46:20 +0200 | [diff] [blame] | 83 | With the introduction of the Tempest external test plugin interface we needed |
| 84 | to provide a stable contract for Tempest's configuration options. This means |
Matthew Treinish | 13a1ed6 | 2015-09-08 10:39:58 -0400 | [diff] [blame] | 85 | we can no longer simply remove a configuration option when it's no longer used. |
| 86 | Patches proposed that remove options without a deprecation cycle should not |
| 87 | be approved. Similarly when changing default values with configuration we need |
| 88 | to similarly be careful that we don't break existing functionality. Also, when |
| 89 | adding options, just as before, we need to weigh the benefit of adding an |
| 90 | additional option against the complexity and maintenance overhead having it |
| 91 | costs. |
| 92 | |
| 93 | |
Matthew Treinish | 5507888 | 2014-08-12 19:01:34 -0400 | [diff] [blame] | 94 | Test Documentation |
| 95 | ------------------ |
| 96 | When a new test is being added refer to the :ref:`TestDocumentation` section in |
| 97 | hacking to see if the requirements are being met. With the exception of a class |
| 98 | level docstring linking to the API ref doc in the API tests and a docstring for |
| 99 | scenario tests this is up to the reviewers discretion whether a docstring is |
| 100 | required or not. |
| 101 | |
Matthew Treinish | b786dca | 2016-06-22 10:32:45 -0400 | [diff] [blame] | 102 | Release Notes |
| 103 | ------------- |
| 104 | Release notes are how we indicate to users and other consumers of Tempest what |
| 105 | has changed in a given release. Since Tempest 10.0.0 we've been using `reno`_ |
| 106 | to manage and build the release notes. There are certain types of changes that |
| 107 | require release notes and we should not approve them without including a release |
| 108 | note. These include but aren't limited to, any addition, deprecation or removal |
| 109 | from the lib interface, any change to configuration options (including |
| 110 | deprecation), CLI additions or deprecations, major feature additions, and |
| 111 | anything backwards incompatible or would require a user to take note or do |
| 112 | something extra. |
| 113 | |
chenxing | e98720a | 2017-07-19 03:42:23 +0000 | [diff] [blame] | 114 | .. _reno: https://docs.openstack.org/reno/latest/ |
Matthew Treinish | 5507888 | 2014-08-12 19:01:34 -0400 | [diff] [blame] | 115 | |
Masayuki Igawa | 4661706 | 2016-09-02 16:38:56 +0900 | [diff] [blame] | 116 | Deprecated Code |
| 117 | --------------- |
| 118 | Sometimes we have some bugs in deprecated code. Basically, we leave it. Because |
| 119 | we don't need to maintain it. However, if the bug is critical, we might need to |
| 120 | fix it. When it will happen, we will deal with it on a case-by-case basis. |
| 121 | |
Matthew Treinish | 16dd51b | 2014-06-11 12:04:51 -0400 | [diff] [blame] | 122 | When to approve |
| 123 | --------------- |
| 124 | * Every patch needs two +2s before being approved. |
| 125 | * Its ok to hold off on an approval until a subject matter expert reviews it |
| 126 | * If a patch has already been approved but requires a trivial rebase to merge, |
| 127 | you do not have to wait for a second +2, since the patch has already had |
| 128 | two +2s. |