blob: a1a05e0cbc23bfbf34c94d0e808ec24bb1cf22e3 [file] [log] [blame]
Gregory Haynes4fc12542015-04-22 20:38:06 -07001# Copyright 2015 GoodData
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# 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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15import logging
Jan Hrubane252a732017-01-03 15:03:09 +010016import re
17from testtools.matchers import MatchesRegex
Jan Hruban324ca5b2015-11-05 19:28:54 +010018import time
Gregory Haynes4fc12542015-04-22 20:38:06 -070019
Wayne1a78c612015-06-11 17:14:13 -070020from tests.base import ZuulTestCase, simple_layout, random_sha1
Gregory Haynes4fc12542015-04-22 20:38:06 -070021
22logging.basicConfig(level=logging.DEBUG,
23 format='%(asctime)s %(name)-32s '
24 '%(levelname)-8s %(message)s')
25
26
27class TestGithubDriver(ZuulTestCase):
28 config_file = 'zuul-github-driver.conf'
29
30 @simple_layout('layouts/basic-github.yaml', driver='github')
31 def test_pull_event(self):
32 self.executor_server.hold_jobs_in_build = True
33
Jan Hruban37615e52015-11-19 14:30:49 +010034 A = self.fake_github.openFakePullRequest('org/project', 'master', 'A')
35 self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
Gregory Haynes4fc12542015-04-22 20:38:06 -070036 self.waitUntilSettled()
37
38 build_params = self.builds[0].parameters
39 self.assertEqual('master', build_params['ZUUL_BRANCH'])
Jan Hruban37615e52015-11-19 14:30:49 +010040 self.assertEqual(str(A.number), build_params['ZUUL_CHANGE'])
41 self.assertEqual(A.head_sha, build_params['ZUUL_PATCHSET'])
Gregory Haynes4fc12542015-04-22 20:38:06 -070042
43 self.executor_server.hold_jobs_in_build = False
44 self.executor_server.release()
45 self.waitUntilSettled()
46
47 self.assertEqual('SUCCESS',
48 self.getJobFromHistory('project-test1').result)
49 self.assertEqual('SUCCESS',
50 self.getJobFromHistory('project-test2').result)
51
52 job = self.getJobFromHistory('project-test2')
53 zuulvars = job.parameters['vars']['zuul']
Jan Hruban37615e52015-11-19 14:30:49 +010054 self.assertEqual(A.number, zuulvars['change'])
55 self.assertEqual(A.head_sha, zuulvars['patchset'])
56 self.assertEqual(1, len(A.comments))
Jan Hruband4edee82015-12-16 12:49:51 +010057 self.assertEqual(2, len(self.history))
58
59 # test_pull_unmatched_branch_event(self):
60 self.create_branch('org/project', 'unmatched_branch')
61 B = self.fake_github.openFakePullRequest(
62 'org/project', 'unmatched_branch', 'B')
63 self.fake_github.emitEvent(B.getPullRequestOpenedEvent())
64 self.waitUntilSettled()
65
66 self.assertEqual(2, len(self.history))
Wayne1a78c612015-06-11 17:14:13 -070067
Jan Hruban570d01c2016-03-10 21:51:32 +010068 @simple_layout('layouts/files-github.yaml', driver='github')
69 def test_pull_matched_file_event(self):
70 A = self.fake_github.openFakePullRequest(
71 'org/project', 'master', 'A',
72 files=['random.txt', 'build-requires'])
73 self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
74 self.waitUntilSettled()
75 self.assertEqual(1, len(self.history))
76
77 # test_pull_unmatched_file_event
78 B = self.fake_github.openFakePullRequest('org/project', 'master', 'B',
79 files=['random.txt'])
80 self.fake_github.emitEvent(B.getPullRequestOpenedEvent())
81 self.waitUntilSettled()
82 self.assertEqual(1, len(self.history))
83
Jan Hrubanc7ab1602015-10-14 15:29:33 +020084 @simple_layout('layouts/basic-github.yaml', driver='github')
85 def test_comment_event(self):
Jan Hruban37615e52015-11-19 14:30:49 +010086 A = self.fake_github.openFakePullRequest('org/project', 'master', 'A')
87 self.fake_github.emitEvent(A.getCommentAddedEvent('test me'))
Jan Hrubanc7ab1602015-10-14 15:29:33 +020088 self.waitUntilSettled()
89 self.assertEqual(2, len(self.history))
90
91 # Test an unmatched comment, history should remain the same
Jan Hruban37615e52015-11-19 14:30:49 +010092 B = self.fake_github.openFakePullRequest('org/project', 'master', 'B')
93 self.fake_github.emitEvent(B.getCommentAddedEvent('casual comment'))
Jan Hrubanc7ab1602015-10-14 15:29:33 +020094 self.waitUntilSettled()
95 self.assertEqual(2, len(self.history))
96
Wayne1a78c612015-06-11 17:14:13 -070097 @simple_layout('layouts/push-tag-github.yaml', driver='github')
98 def test_tag_event(self):
99 self.executor_server.hold_jobs_in_build = True
100
101 sha = random_sha1()
102 self.fake_github.emitEvent(
103 self.fake_github.getPushEvent('org/project', 'refs/tags/newtag',
104 new_rev=sha))
105 self.waitUntilSettled()
106
107 build_params = self.builds[0].parameters
108 self.assertEqual('refs/tags/newtag', build_params['ZUUL_REF'])
109 self.assertEqual('00000000000000000000000000000000',
110 build_params['ZUUL_OLDREV'])
111 self.assertEqual(sha, build_params['ZUUL_NEWREV'])
112
113 self.executor_server.hold_jobs_in_build = False
114 self.executor_server.release()
115 self.waitUntilSettled()
116
117 self.assertEqual('SUCCESS',
118 self.getJobFromHistory('project-tag').result)
119
120 @simple_layout('layouts/push-tag-github.yaml', driver='github')
121 def test_push_event(self):
122 self.executor_server.hold_jobs_in_build = True
123
124 old_sha = random_sha1()
125 new_sha = random_sha1()
126 self.fake_github.emitEvent(
127 self.fake_github.getPushEvent('org/project', 'refs/heads/master',
128 old_sha, new_sha))
129 self.waitUntilSettled()
130
131 build_params = self.builds[0].parameters
132 self.assertEqual('refs/heads/master', build_params['ZUUL_REF'])
133 self.assertEqual(old_sha, build_params['ZUUL_OLDREV'])
134 self.assertEqual(new_sha, build_params['ZUUL_NEWREV'])
135
136 self.executor_server.hold_jobs_in_build = False
137 self.executor_server.release()
138 self.waitUntilSettled()
139
140 self.assertEqual('SUCCESS',
141 self.getJobFromHistory('project-post').result)
Jan Hruband4edee82015-12-16 12:49:51 +0100142 self.assertEqual(1, len(self.history))
143
144 # test unmatched push event
145 old_sha = random_sha1()
146 new_sha = random_sha1()
147 self.fake_github.emitEvent(
148 self.fake_github.getPushEvent('org/project',
149 'refs/heads/unmatched_branch',
150 old_sha, new_sha))
151 self.waitUntilSettled()
152
153 self.assertEqual(1, len(self.history))
Jan Hruban6d53c5e2015-10-24 03:03:34 +0200154
Jan Hruban16ad31f2015-11-07 14:39:07 +0100155 @simple_layout('layouts/labeling-github.yaml', driver='github')
156 def test_labels(self):
Jan Hruban37615e52015-11-19 14:30:49 +0100157 A = self.fake_github.openFakePullRequest('org/project', 'master', 'A')
Jan Hruban16ad31f2015-11-07 14:39:07 +0100158 self.fake_github.emitEvent(A.addLabel('test'))
159 self.waitUntilSettled()
160 self.assertEqual(1, len(self.history))
161 self.assertEqual('project-labels', self.history[0].name)
162 self.assertEqual(['tests passed'], A.labels)
163
164 # test label removed
Jan Hruban37615e52015-11-19 14:30:49 +0100165 B = self.fake_github.openFakePullRequest('org/project', 'master', 'B')
Jan Hruban16ad31f2015-11-07 14:39:07 +0100166 B.addLabel('do not test')
167 self.fake_github.emitEvent(B.removeLabel('do not test'))
168 self.waitUntilSettled()
169 self.assertEqual(2, len(self.history))
170 self.assertEqual('project-labels', self.history[1].name)
171 self.assertEqual(['tests passed'], B.labels)
172
173 # test unmatched label
Jan Hruban37615e52015-11-19 14:30:49 +0100174 C = self.fake_github.openFakePullRequest('org/project', 'master', 'C')
Jan Hruban16ad31f2015-11-07 14:39:07 +0100175 self.fake_github.emitEvent(C.addLabel('other label'))
176 self.waitUntilSettled()
177 self.assertEqual(2, len(self.history))
178 self.assertEqual(['other label'], C.labels)
179
Jan Hruban324ca5b2015-11-05 19:28:54 +0100180 @simple_layout('layouts/dequeue-github.yaml', driver='github')
181 def test_dequeue_pull_synchronized(self):
182 self.executor_server.hold_jobs_in_build = True
183
Jan Hruban37615e52015-11-19 14:30:49 +0100184 A = self.fake_github.openFakePullRequest(
185 'org/one-job-project', 'master', 'A')
186 self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
Jan Hruban324ca5b2015-11-05 19:28:54 +0100187 self.waitUntilSettled()
188
189 # event update stamp has resolution one second, wait so the latter
190 # one has newer timestamp
191 time.sleep(1)
Jan Hruban37615e52015-11-19 14:30:49 +0100192 A.addCommit()
193 self.fake_github.emitEvent(A.getPullRequestSynchronizeEvent())
Jan Hruban324ca5b2015-11-05 19:28:54 +0100194 self.waitUntilSettled()
195
196 self.executor_server.hold_jobs_in_build = False
197 self.executor_server.release()
198 self.waitUntilSettled()
199
200 self.assertEqual(2, len(self.history))
201 self.assertEqual(1, self.countJobResults(self.history, 'ABORTED'))
202
203 @simple_layout('layouts/dequeue-github.yaml', driver='github')
204 def test_dequeue_pull_abandoned(self):
205 self.executor_server.hold_jobs_in_build = True
206
Jan Hruban37615e52015-11-19 14:30:49 +0100207 A = self.fake_github.openFakePullRequest(
208 'org/one-job-project', 'master', 'A')
209 self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
Jan Hruban324ca5b2015-11-05 19:28:54 +0100210 self.waitUntilSettled()
Jan Hruban37615e52015-11-19 14:30:49 +0100211 self.fake_github.emitEvent(A.getPullRequestClosedEvent())
Jan Hruban324ca5b2015-11-05 19:28:54 +0100212 self.waitUntilSettled()
213
214 self.executor_server.hold_jobs_in_build = False
215 self.executor_server.release()
216 self.waitUntilSettled()
217
218 self.assertEqual(1, len(self.history))
219 self.assertEqual(1, self.countJobResults(self.history, 'ABORTED'))
220
Jan Hruban6d53c5e2015-10-24 03:03:34 +0200221 @simple_layout('layouts/basic-github.yaml', driver='github')
222 def test_git_https_url(self):
223 """Test that git_ssh option gives git url with ssh"""
224 url = self.fake_github.real_getGitUrl('org/project')
225 self.assertEqual('https://github.com/org/project', url)
226
227 @simple_layout('layouts/basic-github.yaml', driver='github')
228 def test_git_ssh_url(self):
229 """Test that git_ssh option gives git url with ssh"""
230 url = self.fake_github_ssh.real_getGitUrl('org/project')
231 self.assertEqual('ssh://git@github.com/org/project.git', url)
Jan Hrubane252a732017-01-03 15:03:09 +0100232
Jesse Keatingbe4ef8a2016-12-06 11:29:13 -0800233 @simple_layout('layouts/basic-github.yaml', driver='github')
234 def test_git_enterprise_url(self):
235 """Test that git_url option gives git url with proper host"""
236 url = self.fake_github_ent.real_getGitUrl('org/project')
237 self.assertEqual('ssh://git@github.enterprise.io/org/project.git', url)
238
Jan Hrubane252a732017-01-03 15:03:09 +0100239 @simple_layout('layouts/reporting-github.yaml', driver='github')
240 def test_reporting(self):
241 # pipeline reports pull status both on start and success
242 self.executor_server.hold_jobs_in_build = True
Jan Hruban37615e52015-11-19 14:30:49 +0100243 A = self.fake_github.openFakePullRequest('org/project', 'master', 'A')
244 self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
Jan Hrubane252a732017-01-03 15:03:09 +0100245 self.waitUntilSettled()
Jan Hruban37615e52015-11-19 14:30:49 +0100246 self.assertIn('check', A.statuses)
247 check_status = A.statuses['check']
Jan Hrubanddeb95a2017-01-03 15:12:41 +0100248 check_url = ('http://zuul.example.com/status/#%s,%s' %
249 (A.number, A.head_sha))
Jan Hrubane252a732017-01-03 15:03:09 +0100250 self.assertEqual('Standard check', check_status['description'])
251 self.assertEqual('pending', check_status['state'])
Jan Hrubanddeb95a2017-01-03 15:12:41 +0100252 self.assertEqual(check_url, check_status['url'])
Jan Hruban37615e52015-11-19 14:30:49 +0100253 self.assertEqual(0, len(A.comments))
Jan Hrubane252a732017-01-03 15:03:09 +0100254
255 self.executor_server.hold_jobs_in_build = False
256 self.executor_server.release()
257 self.waitUntilSettled()
Jan Hruban37615e52015-11-19 14:30:49 +0100258 check_status = A.statuses['check']
Jan Hrubane252a732017-01-03 15:03:09 +0100259 self.assertEqual('Standard check', check_status['description'])
260 self.assertEqual('success', check_status['state'])
Jan Hrubanddeb95a2017-01-03 15:12:41 +0100261 self.assertEqual(check_url, check_status['url'])
Jan Hruban37615e52015-11-19 14:30:49 +0100262 self.assertEqual(1, len(A.comments))
263 self.assertThat(A.comments[0],
Jan Hrubane252a732017-01-03 15:03:09 +0100264 MatchesRegex('.*Build succeeded.*', re.DOTALL))
265
266 # pipeline does not report any status but does comment
267 self.executor_server.hold_jobs_in_build = True
268 self.fake_github.emitEvent(
Jan Hruban37615e52015-11-19 14:30:49 +0100269 A.getCommentAddedEvent('reporting check'))
Jan Hrubane252a732017-01-03 15:03:09 +0100270 self.waitUntilSettled()
Jan Hruban37615e52015-11-19 14:30:49 +0100271 self.assertNotIn('reporting', A.statuses)
Jan Hrubane252a732017-01-03 15:03:09 +0100272 # comments increased by one for the start message
Jan Hruban37615e52015-11-19 14:30:49 +0100273 self.assertEqual(2, len(A.comments))
274 self.assertThat(A.comments[1],
Jan Hrubane252a732017-01-03 15:03:09 +0100275 MatchesRegex('.*Starting reporting jobs.*', re.DOTALL))
276 self.executor_server.hold_jobs_in_build = False
277 self.executor_server.release()
278 self.waitUntilSettled()
Jan Hruban37615e52015-11-19 14:30:49 +0100279 self.assertNotIn('reporting', A.statuses)
280 self.assertEqual(2, len(A.comments))
Jan Hruban49bff072015-11-03 11:45:46 +0100281
282 @simple_layout('layouts/merging-github.yaml', driver='github')
283 def test_report_pull_merge(self):
284 # pipeline merges the pull request on success
Jan Hruban3b415922016-02-03 13:10:22 +0100285 A = self.fake_github.openFakePullRequest('org/project', 'master',
286 'PR title')
Jan Hruban49bff072015-11-03 11:45:46 +0100287 self.fake_github.emitEvent(A.getCommentAddedEvent('merge me'))
288 self.waitUntilSettled()
289 self.assertTrue(A.is_merged)
Jan Hruban3b415922016-02-03 13:10:22 +0100290 self.assertThat(A.merge_message,
291 MatchesRegex('.*PR title.*Reviewed-by.*', re.DOTALL))
Jan Hruban49bff072015-11-03 11:45:46 +0100292
293 # pipeline merges the pull request on success after failure
294 self.fake_github.merge_failure = True
Jan Hruban37615e52015-11-19 14:30:49 +0100295 B = self.fake_github.openFakePullRequest('org/project', 'master', 'B')
Jan Hruban49bff072015-11-03 11:45:46 +0100296 self.fake_github.emitEvent(B.getCommentAddedEvent('merge me'))
297 self.waitUntilSettled()
298 self.assertFalse(B.is_merged)
299 self.fake_github.merge_failure = False
300
301 # pipeline merges the pull request on second run of merge
302 # first merge failed on 405 Method Not Allowed error
303 self.fake_github.merge_not_allowed_count = 1
Jan Hruban37615e52015-11-19 14:30:49 +0100304 C = self.fake_github.openFakePullRequest('org/project', 'master', 'C')
Jan Hruban49bff072015-11-03 11:45:46 +0100305 self.fake_github.emitEvent(C.getCommentAddedEvent('merge me'))
306 self.waitUntilSettled()
307 self.assertTrue(C.is_merged)
308
309 # pipeline does not merge the pull request
310 # merge failed on 405 Method Not Allowed error - twice
311 self.fake_github.merge_not_allowed_count = 2
Jan Hruban37615e52015-11-19 14:30:49 +0100312 D = self.fake_github.openFakePullRequest('org/project', 'master', 'D')
Jan Hruban49bff072015-11-03 11:45:46 +0100313 self.fake_github.emitEvent(D.getCommentAddedEvent('merge me'))
314 self.waitUntilSettled()
315 self.assertFalse(D.is_merged)
Jan Hruban37615e52015-11-19 14:30:49 +0100316
317 @simple_layout('layouts/dependent-github.yaml', driver='github')
318 def test_parallel_changes(self):
319 "Test that changes are tested in parallel and merged in series"
320
321 self.executor_server.hold_jobs_in_build = True
322 A = self.fake_github.openFakePullRequest('org/project', 'master', 'A')
323 B = self.fake_github.openFakePullRequest('org/project', 'master', 'B')
324 C = self.fake_github.openFakePullRequest('org/project', 'master', 'C')
325
326 self.fake_github.emitEvent(A.addLabel('merge'))
327 self.fake_github.emitEvent(B.addLabel('merge'))
328 self.fake_github.emitEvent(C.addLabel('merge'))
329
330 self.waitUntilSettled()
331 self.assertEqual(len(self.builds), 1)
332 self.assertEqual(self.builds[0].name, 'project-merge')
333 self.assertTrue(self.builds[0].hasChanges(A))
334
335 self.executor_server.release('.*-merge')
336 self.waitUntilSettled()
337 self.assertEqual(len(self.builds), 3)
338 self.assertEqual(self.builds[0].name, 'project-test1')
339 self.assertTrue(self.builds[0].hasChanges(A))
340 self.assertEqual(self.builds[1].name, 'project-test2')
341 self.assertTrue(self.builds[1].hasChanges(A))
342 self.assertEqual(self.builds[2].name, 'project-merge')
343 self.assertTrue(self.builds[2].hasChanges(A, B))
344
345 self.executor_server.release('.*-merge')
346 self.waitUntilSettled()
347 self.assertEqual(len(self.builds), 5)
348 self.assertEqual(self.builds[0].name, 'project-test1')
349 self.assertTrue(self.builds[0].hasChanges(A))
350 self.assertEqual(self.builds[1].name, 'project-test2')
351 self.assertTrue(self.builds[1].hasChanges(A))
352
353 self.assertEqual(self.builds[2].name, 'project-test1')
354 self.assertTrue(self.builds[2].hasChanges(A))
355 self.assertEqual(self.builds[3].name, 'project-test2')
356 self.assertTrue(self.builds[3].hasChanges(A, B))
357
358 self.assertEqual(self.builds[4].name, 'project-merge')
359 self.assertTrue(self.builds[4].hasChanges(A, B, C))
360
361 self.executor_server.release('.*-merge')
362 self.waitUntilSettled()
363 self.assertEqual(len(self.builds), 6)
364 self.assertEqual(self.builds[0].name, 'project-test1')
365 self.assertTrue(self.builds[0].hasChanges(A))
366 self.assertEqual(self.builds[1].name, 'project-test2')
367 self.assertTrue(self.builds[1].hasChanges(A))
368
369 self.assertEqual(self.builds[2].name, 'project-test1')
370 self.assertTrue(self.builds[2].hasChanges(A, B))
371 self.assertEqual(self.builds[3].name, 'project-test2')
372 self.assertTrue(self.builds[3].hasChanges(A, B))
373
374 self.assertEqual(self.builds[4].name, 'project-test1')
375 self.assertTrue(self.builds[4].hasChanges(A, B, C))
376 self.assertEqual(self.builds[5].name, 'project-test2')
377 self.assertTrue(self.builds[5].hasChanges(A, B, C))
378
379 all_builds = self.builds[:]
380 self.release(all_builds[2])
381 self.release(all_builds[3])
382 self.waitUntilSettled()
383 self.assertFalse(A.is_merged)
384 self.assertFalse(B.is_merged)
385 self.assertFalse(C.is_merged)
386
387 self.release(all_builds[0])
388 self.release(all_builds[1])
389 self.waitUntilSettled()
390 self.assertTrue(A.is_merged)
391 self.assertTrue(B.is_merged)
392 self.assertFalse(C.is_merged)
393
394 self.executor_server.hold_jobs_in_build = False
395 self.executor_server.release()
396 self.waitUntilSettled()
397 self.assertEqual(len(self.builds), 0)
398 self.assertEqual(len(self.history), 9)
399 self.assertTrue(C.is_merged)
400
401 self.assertNotIn('merge', A.labels)
402 self.assertNotIn('merge', B.labels)
403 self.assertNotIn('merge', C.labels)
404
405 @simple_layout('layouts/dependent-github.yaml', driver='github')
406 def test_failed_changes(self):
407 "Test that a change behind a failed change is retested"
408 self.executor_server.hold_jobs_in_build = True
409
410 A = self.fake_github.openFakePullRequest('org/project', 'master', 'A')
411 B = self.fake_github.openFakePullRequest('org/project', 'master', 'B')
412
413 self.executor_server.failJob('project-test1', A)
414
415 self.fake_github.emitEvent(A.addLabel('merge'))
416 self.fake_github.emitEvent(B.addLabel('merge'))
417 self.waitUntilSettled()
418
419 self.executor_server.release('.*-merge')
420 self.waitUntilSettled()
421
422 self.executor_server.hold_jobs_in_build = False
423 self.executor_server.release()
424
425 self.waitUntilSettled()
426 # It's certain that the merge job for change 2 will run, but
427 # the test1 and test2 jobs may or may not run.
428 self.assertTrue(len(self.history) > 6)
429 self.assertFalse(A.is_merged)
430 self.assertTrue(B.is_merged)
431 self.assertNotIn('merge', A.labels)
432 self.assertNotIn('merge', B.labels)
433
434 @simple_layout('layouts/dependent-github.yaml', driver='github')
435 def test_failed_change_at_head(self):
436 "Test that if a change at the head fails, jobs behind it are canceled"
437
438 self.executor_server.hold_jobs_in_build = True
439 A = self.fake_github.openFakePullRequest('org/project', 'master', 'A')
440 B = self.fake_github.openFakePullRequest('org/project', 'master', 'B')
441 C = self.fake_github.openFakePullRequest('org/project', 'master', 'C')
442
443 self.executor_server.failJob('project-test1', A)
444
445 self.fake_github.emitEvent(A.addLabel('merge'))
446 self.fake_github.emitEvent(B.addLabel('merge'))
447 self.fake_github.emitEvent(C.addLabel('merge'))
448
449 self.waitUntilSettled()
450
451 self.assertEqual(len(self.builds), 1)
452 self.assertEqual(self.builds[0].name, 'project-merge')
453 self.assertTrue(self.builds[0].hasChanges(A))
454
455 self.executor_server.release('.*-merge')
456 self.waitUntilSettled()
457 self.executor_server.release('.*-merge')
458 self.waitUntilSettled()
459 self.executor_server.release('.*-merge')
460 self.waitUntilSettled()
461
462 self.assertEqual(len(self.builds), 6)
463 self.assertEqual(self.builds[0].name, 'project-test1')
464 self.assertEqual(self.builds[1].name, 'project-test2')
465 self.assertEqual(self.builds[2].name, 'project-test1')
466 self.assertEqual(self.builds[3].name, 'project-test2')
467 self.assertEqual(self.builds[4].name, 'project-test1')
468 self.assertEqual(self.builds[5].name, 'project-test2')
469
470 self.release(self.builds[0])
471 self.waitUntilSettled()
472
473 # project-test2, project-merge for B
474 self.assertEqual(len(self.builds), 2)
475 self.assertEqual(self.countJobResults(self.history, 'ABORTED'), 4)
476
477 self.executor_server.hold_jobs_in_build = False
478 self.executor_server.release()
479 self.waitUntilSettled()
480
481 self.assertEqual(len(self.builds), 0)
482 self.assertEqual(len(self.history), 15)
483 self.assertFalse(A.is_merged)
484 self.assertTrue(B.is_merged)
485 self.assertTrue(C.is_merged)
486 self.assertNotIn('merge', A.labels)
487 self.assertNotIn('merge', B.labels)
488 self.assertNotIn('merge', C.labels)