Proposal to automate VPP-API "Flag Day"
[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 **VPP API FLAG DAY ALGORITHM USE CASE**
33
34 The following steps describe the use case of the proposed
35 implementation for automating the VPP API "Flag Day" algorithm:
36
37 #. A VPP patch with VPP API changes is submitted to
38    gerrit for review
39 #. CSIT verify job detects the VPP API change(s).
40    Note: This requires a new CSIT test described below in the
41    section "CSIT VPP API CHANGE DETECTION TEST".
42 #. CSIT verify job fails before starting to run any tests and
43    an email with the appropriate reason is sent to the VPP patch
44    submitter and vpp-api-dev@lists.fd.io including the VPP patch
45    information and API change(s) that were detected.
46 #. The VPP patch developer and CSIT team create a CSIT JIRA ticket
47    to identify the work required to support the new VPP API version.
48 #. CSIT developer creates a patch to existing CSIT tests to support
49    the new VPP API version and new features in the VPP patch as required.
50 #. CSIT developer runs CI verification tests for the CSIT patch against
51    the VPP patch (aka "Patch-On-Patch verification).
52    This process verifies support for the new VPP API, associated VPP
53    features and CSIT tests.  Both developers iterate until the
54    verification passes.
55 #. CSIT committer updates the supported API signature(s) such that
56    all signatures included in the CSIT branch are supported by the
57    current version of the CSIT tests. See "API FLAG DAY SCENERIOS" below
58    for examples.
59 #. CSIT committer merges CSIT patch and creates a new operational
60    branch in the CSIT repo.
61 #. VPP developer issues a recheck on the VPP patch and a VPP
62    Committer merges the patch.
63 #. Recheck of existing VPP patches in gerrit may cause the "VPP
64    API Incompatible Change Test" to send an email to the patch
65    submitter to rebase the patch to pick up the compatible VPP API
66    version files.
67
68 **FEATURES REQUIRED FOR IMPLEMENTATION**
69
70 **VPP API SIGNATURE GENERATION**
71
72 The VPP PAPI generation already produces the complete set of
73 signatures in JSON format for all api files and includes them in the
74 vpp-api-python.deb package.  Upon installation all of the \*.api.json
75 files are installed in the /usr/share/vpp/api directory.  Each record
76 in the .api.json file contains the name of the api message, the fields
77 and their data types, and a CRC of the json object.
78
79 **VPP API CLIENT SIGNATURES**
80
81 In each CSIT branch, all of the VPP API client signatures that are supported
82 by the CSIT tests in that branch are contained in separate directories
83 under the .../csit/resources/api/vpp directory. The CSIT VPP API
84 client signature directory structure is the same as the one published in
85 /usr/share/vpp/api as generated by vppapigen.
86
87 The granularity of the CSIT VPP API client signature support
88 will initially be on a per VPP API JSON file.  In the future, a per VPP
89 api message level of granularity may be added.  If CSIT is capable of
90 supporting more than one version of a VPP API JSON file, then a new
91 CSIT VPP api client signature directory will be created containing
92 all of the supported VPP API JSON files.  Typically this will be identical
93 to the previous version with the exception of the VPP API JSON files
94 which have been changed in the VPP patch which triggered the VPP API FLAG
95 day algorithm.
96
97 See https://gerrit.fd.io/r/19027 for the baseline implementation.
98
99 **VPP API CHANGES FILE INCLUDED in VPP PACKAGE**
100
101 The VPP build system shall add a file in the /usr/share/vpp/api
102 directory of the vpp package which is the same directory in which
103 the api JSON files are published.  This file will include the list of
104 VPP api files which were included in the patch to be verified.
105
106 See https://gerrit.fd.io/r/19479 for the baseline implementation.
107
108 **CSIT VPP API CHANGE DETECTION TEST**
109
110 The set of VPP api signatures which are supported by the CSIT tests in
111 a given CSIT branch shall be stored in .../csit/resources/api/vpp which
112 mirrors the same directory structure as the API signature directory
113 generated by vppapigen (e.g. /usr/share/api/vpp/core &
114 /usr/share/api/vpp/plugins).
115
116 The test compares the VPP patch's API signature directory with each of
117 the CSIT VPP API signabture directory and determine the following state:
118
119 - No Change
120 - Changed
121 - Rebase or Merge Parent VPP Patch [0]
122
123 [0] The Rebase or Merge Parent VPP Patch result occurs when there is no valid API
124 signature found in .../csit/resources/api/vpp AND there are no VPP API changes
125 included in the patch.  This could be the result of a patch whose parent does not
126 include the API changes merged in another VPP patch and supported by the new CSIT
127 oper branch.  This case would be resolved by rebasing the patch to HEAD.  The other
128 possibility is that the patch is a descendent of a patch with an incompatible API
129 change that has not been merged yet.  This case is resolved by completing the API
130 Flag Day algorithm on the parent patch such that the latest CSIT oper branch supports
131 the API in the parent.  This importance of the detection of this state is to provide
132 direct feedback to the VPP patch author about how to resolve the issue in a timely
133 manner.
134
135 Any condition other than "No Change" shall cause an email to be sent
136 to the VPP patch submitter.  If the condition is "Changed" then
137 vpp-api-dev@lists.fd.io shall also be copied on the notification email.
138
139 **RUN CSIT VERIFY JOB AGAINST A SPECIFIC VPP PATCH IN GERRIT REVIEW BRANCH**
140
141 This is the "Patch-On-Patch" methodology documented in [TBD]?
142
143
144 **VPP API FLAG DAY SCENARIOS**
145
146 In the beginning, let's assume there is a single VPP API Client signature
147 directory in the current oper branch called vpp-api-client.sig.1 which
148 contains core/vpe.api.json and plugin/acl.api.json which are supported
149 by the CSIT tests.
150
151 **VPP PATCH CONTAINS INCOMPATIBLE API CHANGES**
152
153 Next, a VPP developer modifies vpe.api with a whole set of
154 new type definitions.  When the patch is submitted to gerrit.fd.io, the
155 "CSIT VPP API CHANGE DETECTION TEST" detects the changed api file and
156 votes Verified -1.  Once CSIT has been updated to support the new type
157 definitions and verified against the VPP patch,
158 vpp-api-client.sig.1/core/vpe.api.json is replaced with the vpe.api.json
159 file from the patch. The CSIT changes are committed into CSIT master and a
160 new oper branch is created. The VPP patch is then rechecked and merged
161 into VPP master as soon as practicable. All existing VPP patches and any
162 new patches not including the VPP api change patch will fail verification
163 with a "Rebase or Merge Parent" notification upon recheck or initial
164 submission to gerrit.  Rebasing is then required in order to pass
165 verification of the new api changes.
166
167 **VPP PATCH CONTAINS BACKWARDS COMPATIBLE CHANGES**
168
169 The next day, a VPP developer finds a need to add a new
170 attribute to an api message in vpe.api with a default value defined.
171 This is a backwards compatible change for CSIT.  Since the "CSIT VPP
172 API CHANGE DETECTION TEST" only works on a per api file level of granularity,
173 the change is flagged with Verified -1.  However, in this case, the
174 CSIT developer can resolve the verify failure by adding a second VPP API
175 client signature directory, vpp-api-client.sig.2 which is a copy of
176 vpp-api-client.sig.1 with the vpe.api.json file updated with the contents
177 of the copy from the VPP patch.  After the CSIT changes are merged and a new
178 CSIT oper branch is created, the VPP patch will pass verification upon recheck.
179 All other patches will continue to pass verification upon recheck or initial
180 submission to gerrit by matching the signature in  vpp-api-client.sig.1 --
181 life is good.
182
183 **CSIT REMOVES SUPPORT FOR A VPP API VERSION**
184
185 Since it is not desirable to maintain a bazillion CSIT VPP API client
186 signatures, after a reasonable period of time (let's say a week), a
187 CSIT developer deletes vpp-api-client.sig.1 and renames
188 vpp-api-client.sig.2 to vpp-api-client.sig.1, merges to CSIT master,
189 and creates a new oper branch.  At this point, VPP patches that do not
190 contain the new vpe.api file will fail verification upon recheck or initial
191 submission to gerrit with a "Rebase or Merge Parent" notification and
192 will require rebasing to pass verification.
193
194 **CSIT ADDS SUPPORT FOR A NEW FEATURE API PRIOR TO VPP**
195
196 A VPP developer has lots of ideas and decides to add a new
197 plugin and api which supports the "Super-Duper Feature" to VPP in
198 a new plugin called the "Super-Duper Plugin" and associated super_duper.api
199 VPP binary APi message definition file. Being a thoughtful and
200 helpful developer, the VPP developer notifies the CSIT team providing
201 them with the super_duper.api.json file. A CSIT developer
202 quickly produces the Super-Duper Feature CSIT test suite and updates the VPP
203 API Client signature with vpe-api-client.sig.1/plugin/super_duper.api.json.
204 In the meantime, the VPP developer pushes the Super-Duper VPP patch which
205 fails the CSIT VPP API CHANGE DETECTION TEST. Both developers then work
206 together to verify both CSIT and the VPP patch.  The CSIT developer
207 then merges the CSIT code into master and creates a new oper branch.  Our
208 VPP developer is very pleased when the VPP patch containing
209 the Super-Duper Plugin verifies upon recheck. All other VPP patches without
210 api file changes continue to pass the CSIT VPP API CHANGE DETECTION TEST
211 before and after the Super-Duper VPP patch is merged.
212
213 **VPP PATCH CONTAINS A NEW FEATURE API BEFORE CSIT SUPPORT**
214
215 Now let's assume that the VPP developer was having a bad day
216 and forgot to notify the CSIT team about the new Super-Duper Plugin.
217 Upon pushing the VPP patch to gerrit, the VPP developer is pleased that
218 there is no nastygram email from the CSIT VPP API CHANGE DETECTION TEST.
219 All VPP patches without api file changes continue to pass the CSIT VPP
220 API CHANGE DETECTION TEST. Eventually a Super-Duper Plugin test suite is
221 added to CSIT along with vpe-api-client.sig.1/plugin/super_duper.api.json
222 and release in a new CSIT oper branch. All VPP patches that are do not contain
223 api changes and are verified via recheck or initial submission, continue to
224 pass the CSIT VPP API CHANGE DETECTION TEST.