Remove leftovers related to Xenial
[csit.git] / docs / automating_vpp_api_flag_day.rst
1 ..
2    Copyright (c) 2019 Cisco and/or its affiliates.
3    Licensed under the Apache License, Version 2.0 (the "License");
4    you may not use this file except in compliance with the License.
5    You may obtain a copy of the License at:
6 ..
7        http://www.apache.org/licenses/LICENSE-2.0
8 ..
9    Unless required by applicable law or agreed to in writing, software
10    distributed under the License is distributed on an "AS IS" BASIS,
11    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12    See the License for the specific language governing permissions and
13    limitations under the License.
14
15
16 AUTOMATING VPP-API FLAG DAY IN CSIT
17 ===================================
18
19 **ABSTRACT**
20
21 This document is intended to provide a solution to the problem of
22 automating the detection of VPP API changes which are not backwards
23 compatible with existing CSIT tests and to automate the "Flag Day"
24 process of deploying a new set of CSIT tests which are compatible
25 with the new version of the VPP API without causing a halt to the
26 normal VPP/CSIT operational CI process. This shall initially be
27 limited to changes in \*.api files contained in the vpp repo.
28 Eventually the detection algorithm could be extended to include
29 other integration points such as "directory" structure of stats
30 segment or PAPI python library dependencies.
31
32 **MOTIVATION**
33
34 Aside of per-release activities (release report), CSIT also provides testing
35 that requires somewhat tight coupling to the latest (merged but not released)
36 VPP code. Currently, the coupling is not as tight as possible.
37 Instead of testing HEAD builds of VPP directly with HEAD CSIT code,
38 HEAD of one project is run with somewhat older codebase of the other project.
39 Definition of what is the older codebase to use is maintained by CSIT project.
40 For older CSIT codebase, the project creates so-called "oper" branches.
41 For older VPP codebase, CSIT master HEAD contains identifiers
42 for "stable" VPP builds. Such older codebases are also used for verify jobs,
43 where HEAD of the other project is replaced by the commit under review.
44
45 One particular type of jobs useful for VPP development is trending jobs.
46 They test latests VPP build with oper branch of CSIT,
47 and analytics is applied to detect regressions in preformance.
48 For this to work properly, VPP project needs a warning against breaking
49 the assumptions the current oper branch makes about VPP behavior.
50 In the past, the most frequent type of such breakage was API change.
51
52 Earlier attempts to create a process to minimize breakage have focused
53 on creating a new verify job for VPP (called api-crc job) that
54 votes -1 on a change that affect CRC values for API messages CSIT uses.
55 The list of messages and CRC values (multiple values are allowed)
56 is maintained in CSIT repository (in oper branch).
57 The process was less explicit on how should CSIT project maintain such list.
58 As CSIT was not willing to support two incpompatible API messages
59 by the same codebase (commit), there were unavoidable windows
60 where either trenging jobs, or CSIT verify jobs were failing.
61
62 Practice showed that human (or infra) errors can create two kinds of breakages.
63 Either the unavoidable short window gets long, affecting a trending job run
64 or two, or the api-crc job starts giving -1 to innocent changes
65 because oper branch went out of sync with VPP HEAD codebase.
66 This second type of failure prevents any merges to VPP for a long time
67 (12 hours is the typical time, give time zone differences).
68
69 The current version of this document is still being somewhat vague
70 on the CSIT side of the process, but introduces a new requirement:
71 The api-crc job should not give false -1, under any reasonable circumstance.
72 That means, if a VPP change (nor any of its unmerged ancestor commits)
73 does not affect any CRC values for messages used by CSIT,
74 -1 should only mean "rebase is needed", and rebasing to HEAD should result
75 in +1 from the api-crc job.
76
77 **VPP API FLAG DAY ALGORITHM USE CASE**
78
79 The following steps describe the use case of the proposed
80 implementation for automating the VPP API "Flag Day" algorithm:
81
82 #. A VPP patch with VPP API changes is submitted to
83    gerrit for review. This usually means .api files are edited,
84    but a patch that affects the way CRCs are computed is also an API change.
85 #. The api-crc job detects the API CRC values have changed
86    for some messages used by CSIT.
87    Note: This requires a new CSIT test described below in the
88    section "CSIT VPP API CHANGE DETECTION TEST".
89 #. The api-crc job runs in parallel with any other VPP verify job,
90    so other jobs can hint at the impact on CSIT.
91    Some API changes do not need any edit on CSIT side, except for the CRC value.
92    If the api-crc job fails, an email with the appropriate reason
93    is sent to the VPP patch submitter and vpp-api-dev@lists.fd.io
94    including the VPP patch information and API change(s) that were detected.
95 #. The VPP patch developer and CSIT team create a CSIT JIRA ticket
96    to identify the work required to support the new VPP API version.
97 #. CSIT developer creates a patch to existing CSIT tests to support
98    the new VPP API version and new features in the VPP patch as required.
99 #. CSIT developer runs CI verification tests (without CRC checks)
100    for the CSIT patch against the VPP patch (aka "Patch-On-Patch verification").
101    This process verifies support for the new VPP API, associated VPP
102    features and CSIT tests.  Both developers iterate until the
103    verification passes.
104 #. CSIT developer creates a separate change, that only edits the CSIT CRC list
105    to include both stable VPP CRCs, and CRCs of the VPP change under review.
106 #. CSIT committer requires proofs both CRCs are included correctly
107    (for example the api-crc job is run with overriden CSIT_REF parameter).
108 #. When CSIT committer sees both CSIT changes are ready,
109    the CRC-editing change is merged to CSIT master branch
110    and cherry-picked to the latest oper branch.
111    This does not break any jobs.
112 #. VPP developer issues a recheck on the VPP patch
113 #. On success, VPP Committer merges the patch.
114 #. VPP committer sends an e-mail to vpp-api-dev stating the support for
115    the previous CRC values will soon be removed.
116 #. VPP merge jobs create and upload new VPP packages.
117    This breaks trending jobs, but both VPP and CSIT verify jobs still work.
118 #. CSIT developer bumps stable vpp version in the test affecting change
119    and rechecks it still works.
120 #. CSIT committer merges this change (to both master and oper).
121    This fixes trending jobs. Both VPP and CSIT verify jobs continue to work.
122 #. CSIT committer creates a patch that removes the old CRC values.
123 #. CSIT committer merges that patch.
124    This breaks verify jobs for old changes in VPP.
125 #. CSIT committer sends an e-mail to vpp-api-dev stating the support for
126    the previous CRC values has been removed, and rebase is needed
127    for all affected VPP changes.
128 #. Recheck of existing VPP patches in gerrit may cause the "VPP
129    API Incompatible Change Test" to send an email to the patch
130    submitter to rebase the patch to pick up the compatible VPP API
131    version files.
132
133 **FEATURES REQUIRED FOR IMPLEMENTATION**
134
135 **VPP API SIGNATURE GENERATION**
136
137 The VPP PAPI generation already produces the complete set of
138 signatures in JSON format for all api files and includes them in the
139 vpp-api-python.deb package.  Upon installation all of the \*.api.json
140 files are installed in the /usr/share/vpp/api directory.  Each record
141 in the .api.json file contains the name of the api message, the fields
142 and their data types, and a CRC of the json object.
143
144 **VPP API CLIENT SIGNATURES**
145
146 In each CSIT branch, all of the VPP API client signatures that are supported
147 by the CSIT tests in that branch are contained in separate directories
148 under the .../csit/resources/api/vpp directory. The CSIT VPP API
149 client signature directory structure is the same as the one published in
150 /usr/share/vpp/api as generated by vppapigen.
151
152 The granularity of the CSIT VPP API client signature support
153 will initially be on a per VPP API JSON file.  In the future, a per VPP
154 api message level of granularity may be added.  If CSIT is capable of
155 supporting more than one version of a VPP API JSON file, then a new
156 CSIT VPP api client signature directory will be created containing
157 all of the supported VPP API JSON files.  Typically this will be identical
158 to the previous version with the exception of the VPP API JSON files
159 which have been changed in the VPP patch which triggered the VPP API FLAG
160 day algorithm.
161
162 See https://gerrit.fd.io/r/19027 for the baseline implementation.
163
164 **VPP API CHANGES FILE INCLUDED in VPP PACKAGE**
165
166 The VPP build system shall add a file in the /usr/share/vpp/api
167 directory of the vpp package which is the same directory in which
168 the api JSON files are published.  This file will include the list of
169 VPP api files which were included in the patch to be verified.
170
171 See https://gerrit.fd.io/r/19479 for the baseline implementation.
172
173 **CSIT VPP API CHANGE DETECTION TEST**
174
175 The set of VPP api signatures which are supported by the CSIT tests in
176 a given CSIT branch shall be stored in .../csit/resources/api/vpp which
177 mirrors the same directory structure as the API signature directory
178 generated by vppapigen (e.g. /usr/share/api/vpp/core &
179 /usr/share/api/vpp/plugins).
180
181 The test compares the VPP patch's API signature directory with each of
182 the CSIT VPP API signabture directory and determine the following state:
183
184 - No Change
185 - Changed
186 - Rebase or Merge Parent VPP Patch [0]
187
188 [0] The Rebase or Merge Parent VPP Patch result occurs when there is no valid API
189 signature found in .../csit/resources/api/vpp AND there are no VPP API changes
190 included in the patch.  This could be the result of a patch whose parent does not
191 include the API changes merged in another VPP patch and supported by the new CSIT
192 oper branch.  This case would be resolved by rebasing the patch to HEAD.  The other
193 possibility is that the patch is a descendent of a patch with an incompatible API
194 change that has not been merged yet.  This case is resolved by completing the API
195 Flag Day algorithm on the parent patch such that the latest CSIT oper branch supports
196 the API in the parent.  This importance of the detection of this state is to provide
197 direct feedback to the VPP patch author about how to resolve the issue in a timely
198 manner.
199
200 Any condition other than "No Change" shall cause an email to be sent
201 to the VPP patch submitter.  If the condition is "Changed" then
202 vpp-api-dev@lists.fd.io shall also be copied on the notification email.
203
204 **RUN CSIT VERIFY JOB AGAINST A SPECIFIC VPP PATCH IN GERRIT REVIEW BRANCH**
205
206 This is the "Patch-On-Patch" methodology documented in [TBD]?
207
208
209 **VPP API FLAG DAY SCENARIOS**
210
211 In the beginning, let's assume there is a single VPP API Client signature
212 directory in the current oper branch called vpp-api-client.sig.1 which
213 contains core/vpe.api.json and plugin/acl.api.json which are supported
214 by the CSIT tests.
215
216 **VPP PATCH CONTAINS INCOMPATIBLE API CHANGES**
217
218 Next, a VPP developer modifies vpe.api with a whole set of
219 new type definitions.  When the patch is submitted to gerrit.fd.io, the
220 "CSIT VPP API CHANGE DETECTION TEST" detects the changed api file and
221 votes Verified -1.  Once CSIT has been updated to support the new type
222 definitions and verified against the VPP patch,
223 vpp-api-client.sig.1/core/vpe.api.json is replaced with the vpe.api.json
224 file from the patch. The CSIT changes are committed into CSIT master and a
225 new oper branch is created. The VPP patch is then rechecked and merged
226 into VPP master as soon as practicable. All existing VPP patches and any
227 new patches not including the VPP api change patch will fail verification
228 with a "Rebase or Merge Parent" notification upon recheck or initial
229 submission to gerrit.  Rebasing is then required in order to pass
230 verification of the new api changes.
231
232 **VPP PATCH CONTAINS BACKWARDS COMPATIBLE CHANGES**
233
234 The next day, a VPP developer finds a need to add a new
235 attribute to an api message in vpe.api with a default value defined.
236 This is a backwards compatible change for CSIT.  Since the "CSIT VPP
237 API CHANGE DETECTION TEST" only works on a per api file level of granularity,
238 the change is flagged with Verified -1.  However, in this case, the
239 CSIT developer can resolve the verify failure by adding a second VPP API
240 client signature directory, vpp-api-client.sig.2 which is a copy of
241 vpp-api-client.sig.1 with the vpe.api.json file updated with the contents
242 of the copy from the VPP patch.  After the CSIT changes are merged and a new
243 CSIT oper branch is created, the VPP patch will pass verification upon recheck.
244 All other patches will continue to pass verification upon recheck or initial
245 submission to gerrit by matching the signature in  vpp-api-client.sig.1 --
246 life is good.
247
248 **CSIT REMOVES SUPPORT FOR A VPP API VERSION**
249
250 Since it is not desirable to maintain a bazillion CSIT VPP API client
251 signatures, after a reasonable period of time (let's say a week), a
252 CSIT developer deletes vpp-api-client.sig.1 and renames
253 vpp-api-client.sig.2 to vpp-api-client.sig.1, merges to CSIT master,
254 and creates a new oper branch.  At this point, VPP patches that do not
255 contain the new vpe.api file will fail verification upon recheck or initial
256 submission to gerrit with a "Rebase or Merge Parent" notification and
257 will require rebasing to pass verification.
258
259 **CSIT ADDS SUPPORT FOR A NEW FEATURE API PRIOR TO VPP**
260
261 A VPP developer has lots of ideas and decides to add a new
262 plugin and api which supports the "Super-Duper Feature" to VPP in
263 a new plugin called the "Super-Duper Plugin" and associated super_duper.api
264 VPP binary APi message definition file. Being a thoughtful and
265 helpful developer, the VPP developer notifies the CSIT team providing
266 them with the super_duper.api.json file. A CSIT developer
267 quickly produces the Super-Duper Feature CSIT test suite and updates the VPP
268 API Client signature with vpe-api-client.sig.1/plugin/super_duper.api.json.
269 In the meantime, the VPP developer pushes the Super-Duper VPP patch which
270 fails the CSIT VPP API CHANGE DETECTION TEST. Both developers then work
271 together to verify both CSIT and the VPP patch.  The CSIT developer
272 then merges the CSIT code into master and creates a new oper branch.  Our
273 VPP developer is very pleased when the VPP patch containing
274 the Super-Duper Plugin verifies upon recheck. All other VPP patches without
275 api file changes continue to pass the CSIT VPP API CHANGE DETECTION TEST
276 before and after the Super-Duper VPP patch is merged.
277
278 **VPP PATCH CONTAINS A NEW FEATURE API BEFORE CSIT SUPPORT**
279
280 Now let's assume that the VPP developer was having a bad day
281 and forgot to notify the CSIT team about the new Super-Duper Plugin.
282 Upon pushing the VPP patch to gerrit, the VPP developer is pleased that
283 there is no nastygram email from the CSIT VPP API CHANGE DETECTION TEST.
284 All VPP patches without api file changes continue to pass the CSIT VPP
285 API CHANGE DETECTION TEST. Eventually a Super-Duper Plugin test suite is
286 added to CSIT along with vpe-api-client.sig.1/plugin/super_duper.api.json
287 and release in a new CSIT oper branch. All VPP patches that are do not contain
288 api changes and are verified via recheck or initial submission, continue to
289 pass the CSIT VPP API CHANGE DETECTION TEST.