blob: f3f2d3c96060f5f9e3af4278c008a323a157d696 [file] [log] [blame]
James E. Blaircdd00072012-06-08 19:17:28 -07001:title: Project Gating
2
3Project Gating
4==============
5
6Traditionally, many software development projects merge changes from
7developers into the repository, and then identify regressions
8resulting from those changes (perhaps by running a test suite with a
9continuous integration system such as Jenkins), followed by more
10patches to fix those bugs. When the mainline of development is
11broken, it can be very frustrating for developers and can cause lost
12productivity, particularly so when the number of contributors or
13contributions is large.
14
15The process of gating attempts to prevent changes that introduce
16regressions from being merged. This keeps the mainline of development
17open and working for all developers, and only when a change is
18confirmed to work without disruption is it merged.
19
20Many projects practice an informal method of gating where developers
21with mainline commit access ensure that a test suite runs before
22merging a change. With more developers, more changes, and more
23comprehensive test suites, that process does not scale very well, and
24is not the best use of a developer's time. Zuul can help automate
25this process, with a particular emphasis on ensuring large numbers of
26changes are tested correctly.
27
28Zuul was designed to handle the workflow of the OpenStack project, but
29can be used with any project.
30
31A particular focus of Zuul is ensuring correctly ordered testing of
32changes in parallel. A gating system should always test each change
33applied to the tip of the branch exactly as it is going to be merged.
34A simple way to do that would be to test one change at a time, and
35merge it only if it passes tests. That works very well, but if
36changes take a long time to test, developers may have to wait a long
37time for their changes to make it into the repository. With some
38projects, it may take hours to test changes, and it is easy for
39developers to create changes at a rate faster than they can be tested
40and merged.
41
Clark Boylan00635dc2012-09-19 14:03:08 -070042Zuul's DependentPipelineManager allows for parallel execution of test
James E. Blaircdd00072012-06-08 19:17:28 -070043jobs for gating while ensuring changes are tested correctly, exactly
44as if they had been tested one at a time. It does this by performing
45speculative execution of test jobs; it assumes that all jobs will
46succeed and tests them in parallel accordingly. If they do succeed,
47they can all be merged. However, if one fails, then changes that were
48expecting it to succeed are re-tested without the failed change. In
49the best case, as many changes as execution contexts are available may
50be tested in parallel and merged at once. In the worst case, changes
51are tested one at a time (as each subsequent change fails, changes
52behind it start again). In practice, the OpenStack project observes
53something closer to the best case.
54
55For example, if a core developer approves five changes in rapid
56succession::
57
58 A, B, C, D, E
59
60Zuul queues those changes in the order they were approved, and notes
Antoine Musso3a43e142013-10-30 23:51:58 +010061that each subsequent change depends on the one ahead of it merging:
James E. Blaircdd00072012-06-08 19:17:28 -070062
Antoine Musso3a43e142013-10-30 23:51:58 +010063.. blockdiag::
64
65 blockdiag foo {
66 node_width = 40;
67 span_width = 40;
68 A <- B <- C <- D <- E;
69 }
James E. Blaircdd00072012-06-08 19:17:28 -070070
71Zuul then starts immediately testing all of the changes in parallel.
72But in the case of changes that depend on others, it instructs the
73test system to include the changes ahead of it, with the assumption
74they pass. That means jobs testing change *B* include change *A* as
75well::
76
77 Jobs for A: merge change A, then test
78 Jobs for B: merge changes A and B, then test
79 Jobs for C: merge changes A, B and C, then test
80 Jobs for D: merge changes A, B, C and D, then test
81 Jobs for E: merge changes A, B, C, D and E, then test
82
Antoine Musso3a43e142013-10-30 23:51:58 +010083Hence jobs triggered to tests A will only test A and ignore B, C, D:
James E. Blaircdd00072012-06-08 19:17:28 -070084
Antoine Musso3a43e142013-10-30 23:51:58 +010085.. blockdiag::
James E. Blaircdd00072012-06-08 19:17:28 -070086
Antoine Musso3a43e142013-10-30 23:51:58 +010087 blockdiag foo {
88 node_width = 40;
89 span_width = 40;
90 master -> A -> B -> C -> D -> E;
91 group jobs_for_A {
92 label = "Merged changes for A";
93 master -> A;
94 }
95 group ignored_to_test_A {
96 label = "Ignored changes";
97 color = "lightgray";
98 B -> C -> D -> E;
99 }
100 }
James E. Blaircdd00072012-06-08 19:17:28 -0700101
Antoine Musso3a43e142013-10-30 23:51:58 +0100102The jobs for E would include the whole dependency chain: A, B, C, D, and E.
103E will be tested assuming A, B, C, and D passed:
104
105.. blockdiag::
106
107 blockdiag foo {
108 node_width = 40;
109 span_width = 40;
110 group jobs_for_E {
111 label = "Merged changes for E";
112 master -> A -> B -> C -> D -> E;
113 }
114 }
115
116If changes *A* and *B* pass tests (green), and *C*, *D*, and *E* fail (red):
117
118.. blockdiag::
119
120 blockdiag foo {
121 node_width = 40;
122 span_width = 40;
123
124 A [color = lightgreen];
125 B [color = lightgreen];
126 C [color = pink];
127 D [color = pink];
128 E [color = pink];
129
130 master <- A <- B <- C <- D <- E;
131 }
132
133Zuul will merge change *A* followed by change *B*, leaving this queue:
134
135.. blockdiag::
136
137 blockdiag foo {
138 node_width = 40;
139 span_width = 40;
140
141 C [color = pink];
142 D [color = pink];
143 E [color = pink];
144
145 C <- D <- E;
146 }
James E. Blaircdd00072012-06-08 19:17:28 -0700147
148Since *D* was dependent on *C*, it is not clear whether *D*'s failure is the
Antoine Musso3a43e142013-10-30 23:51:58 +0100149result of a defect in *D* or *C*:
James E. Blaircdd00072012-06-08 19:17:28 -0700150
Antoine Musso3a43e142013-10-30 23:51:58 +0100151.. blockdiag::
James E. Blaircdd00072012-06-08 19:17:28 -0700152
Antoine Musso3a43e142013-10-30 23:51:58 +0100153 blockdiag foo {
154 node_width = 40;
155 span_width = 40;
James E. Blaircdd00072012-06-08 19:17:28 -0700156
Antoine Musso3a43e142013-10-30 23:51:58 +0100157 C [color = pink];
158 D [label = "D\n?"];
159 E [label = "E\n?"];
160
161 C <- D <- E;
162 }
163
164Since *C* failed, Zuul will report its failure and drop *C* from the queue,
165keeping D and E:
166
167.. blockdiag::
168
169 blockdiag foo {
170 node_width = 40;
171 span_width = 40;
172
173 D [label = "D\n?"];
174 E [label = "E\n?"];
175
176 D <- E;
177 }
James E. Blaircdd00072012-06-08 19:17:28 -0700178
179This queue is the same as if two new changes had just arrived, so Zuul
180starts the process again testing *D* against the tip of the branch, and
Antoine Musso3a43e142013-10-30 23:51:58 +0100181*E* against *D*:
182
183.. blockdiag::
184
185 blockdiag foo {
186 node_width = 40;
187 span_width = 40;
188 master -> D -> E;
189 group jobs_for_D {
190 label = "Merged changes for D";
191 master -> D;
192 }
193 group ignored_to_test_D {
194 label = "Skip";
195 color = "lightgray";
196 E;
197 }
198 }
199
200.. blockdiag::
201
202 blockdiag foo {
203 node_width = 40;
204 span_width = 40;
205 group jobs_for_E {
206 label = "Merged changes for E";
207 master -> D -> E;
208 }
209 }
210