blob: 1c61aa1a604df1bc2813a538c3e7ca9d67fd95b5 [file] [log] [blame]
James E. Blair9c17dbf2014-06-23 14:21:58 -07001#!/usr/bin/env python
2
3# Copyright 2012-2014 Hewlett-Packard Development Company, L.P.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17import logging
18import time
Jamie Lennoxff3e0b92016-11-23 10:38:25 +110019from unittest import skip
James E. Blair9c17dbf2014-06-23 14:21:58 -070020
21from tests.base import ZuulTestCase
22
23logging.basicConfig(level=logging.DEBUG,
24 format='%(asctime)s %(name)-32s '
25 '%(levelname)-8s %(message)s')
26
27
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110028class TestRequirementsApprovalNewerThan(ZuulTestCase):
29 """Requirements with a newer-than comment requirement"""
James E. Blair9c17dbf2014-06-23 14:21:58 -070030
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110031 tenant_config_file = 'config/requirements/newer-than/main.yaml'
32
James E. Blair9c17dbf2014-06-23 14:21:58 -070033 def test_pipeline_require_approval_newer_than(self):
34 "Test pipeline requirement: approval newer than"
35 return self._test_require_approval_newer_than('org/project1',
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110036 'project1-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -070037
38 def test_trigger_require_approval_newer_than(self):
39 "Test trigger requirement: approval newer than"
40 return self._test_require_approval_newer_than('org/project2',
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110041 'project2-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -070042
43 def _test_require_approval_newer_than(self, project, job):
James E. Blair9c17dbf2014-06-23 14:21:58 -070044 A = self.fake_gerrit.addFakeChange(project, 'master', 'A')
45 # A comment event that we will keep submitting to trigger
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110046 comment = A.addApproval('code-review', 2, username='nobody')
James E. Blair9c17dbf2014-06-23 14:21:58 -070047 self.fake_gerrit.addEvent(comment)
48 self.waitUntilSettled()
49 # No +1 from Jenkins so should not be enqueued
50 self.assertEqual(len(self.history), 0)
51
52 # Add a too-old +1, should not be enqueued
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110053 A.addApproval('verified', 1, username='jenkins',
Joshua Hesketh642824b2014-07-01 17:54:59 +100054 granted_on=time.time() - 72 * 60 * 60)
James E. Blair9c17dbf2014-06-23 14:21:58 -070055 self.fake_gerrit.addEvent(comment)
56 self.waitUntilSettled()
57 self.assertEqual(len(self.history), 0)
58
59 # Add a recent +1
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110060 self.fake_gerrit.addEvent(A.addApproval('verified', 1,
61 username='jenkins'))
James E. Blair9c17dbf2014-06-23 14:21:58 -070062 self.fake_gerrit.addEvent(comment)
63 self.waitUntilSettled()
64 self.assertEqual(len(self.history), 1)
65 self.assertEqual(self.history[0].name, job)
66
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110067
Jamie Lennox8faa71e2016-11-23 14:33:52 +110068class TestRequirementsApprovalOlderThan(ZuulTestCase):
69 """Requirements with a older-than comment requirement"""
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110070
Jamie Lennox8faa71e2016-11-23 14:33:52 +110071 tenant_config_file = 'config/requirements/older-than/main.yaml'
Jamie Lennoxb59a73f2016-11-23 14:27:18 +110072
James E. Blair9c17dbf2014-06-23 14:21:58 -070073 def test_pipeline_require_approval_older_than(self):
74 "Test pipeline requirement: approval older than"
75 return self._test_require_approval_older_than('org/project1',
Jamie Lennox8faa71e2016-11-23 14:33:52 +110076 'project1-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -070077
78 def test_trigger_require_approval_older_than(self):
79 "Test trigger requirement: approval older than"
80 return self._test_require_approval_older_than('org/project2',
Jamie Lennox8faa71e2016-11-23 14:33:52 +110081 'project2-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -070082
83 def _test_require_approval_older_than(self, project, job):
James E. Blair9c17dbf2014-06-23 14:21:58 -070084 A = self.fake_gerrit.addFakeChange(project, 'master', 'A')
85 # A comment event that we will keep submitting to trigger
Jamie Lennox8faa71e2016-11-23 14:33:52 +110086 comment = A.addApproval('code-review', 2, username='nobody')
James E. Blair9c17dbf2014-06-23 14:21:58 -070087 self.fake_gerrit.addEvent(comment)
88 self.waitUntilSettled()
89 # No +1 from Jenkins so should not be enqueued
90 self.assertEqual(len(self.history), 0)
91
92 # Add a recent +1 which should not be enqueued
Jamie Lennox8faa71e2016-11-23 14:33:52 +110093 A.addApproval('verified', 1)
James E. Blair9c17dbf2014-06-23 14:21:58 -070094 self.fake_gerrit.addEvent(comment)
95 self.waitUntilSettled()
96 self.assertEqual(len(self.history), 0)
97
98 # Add an old +1 which should be enqueued
Jamie Lennox8faa71e2016-11-23 14:33:52 +110099 A.addApproval('verified', 1, username='jenkins',
Joshua Hesketh642824b2014-07-01 17:54:59 +1000100 granted_on=time.time() - 72 * 60 * 60)
James E. Blair9c17dbf2014-06-23 14:21:58 -0700101 self.fake_gerrit.addEvent(comment)
102 self.waitUntilSettled()
103 self.assertEqual(len(self.history), 1)
104 self.assertEqual(self.history[0].name, job)
105
Jamie Lennox8faa71e2016-11-23 14:33:52 +1100106
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100107class TestRequirementsUserName(ZuulTestCase):
108 """Requirements with a username requirement"""
Jamie Lennox8faa71e2016-11-23 14:33:52 +1100109
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100110 tenant_config_file = 'config/requirements/username/main.yaml'
Jamie Lennox8faa71e2016-11-23 14:33:52 +1100111
James E. Blair9c17dbf2014-06-23 14:21:58 -0700112 def test_pipeline_require_approval_username(self):
113 "Test pipeline requirement: approval username"
114 return self._test_require_approval_username('org/project1',
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100115 'project1-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700116
117 def test_trigger_require_approval_username(self):
118 "Test trigger requirement: approval username"
119 return self._test_require_approval_username('org/project2',
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100120 'project2-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700121
122 def _test_require_approval_username(self, project, job):
James E. Blair9c17dbf2014-06-23 14:21:58 -0700123 A = self.fake_gerrit.addFakeChange(project, 'master', 'A')
124 # A comment event that we will keep submitting to trigger
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100125 comment = A.addApproval('code-review', 2, username='nobody')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700126 self.fake_gerrit.addEvent(comment)
127 self.waitUntilSettled()
128 # No approval from Jenkins so should not be enqueued
129 self.assertEqual(len(self.history), 0)
130
131 # Add an approval from Jenkins
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100132 A.addApproval('verified', 1, username='jenkins')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700133 self.fake_gerrit.addEvent(comment)
134 self.waitUntilSettled()
135 self.assertEqual(len(self.history), 1)
136 self.assertEqual(self.history[0].name, job)
137
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100138
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100139class TestRequirementsEmail(ZuulTestCase):
140 """Requirements with a email requirement"""
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100141
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100142 tenant_config_file = 'config/requirements/email/main.yaml'
Jamie Lennoxdb3b4e02016-11-23 14:36:12 +1100143
James E. Blair9c17dbf2014-06-23 14:21:58 -0700144 def test_pipeline_require_approval_email(self):
145 "Test pipeline requirement: approval email"
146 return self._test_require_approval_email('org/project1',
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100147 'project1-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700148
149 def test_trigger_require_approval_email(self):
150 "Test trigger requirement: approval email"
151 return self._test_require_approval_email('org/project2',
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100152 'project2-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700153
154 def _test_require_approval_email(self, project, job):
James E. Blair9c17dbf2014-06-23 14:21:58 -0700155 A = self.fake_gerrit.addFakeChange(project, 'master', 'A')
156 # A comment event that we will keep submitting to trigger
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100157 comment = A.addApproval('code-review', 2, username='nobody')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700158 self.fake_gerrit.addEvent(comment)
159 self.waitUntilSettled()
160 # No approval from Jenkins so should not be enqueued
161 self.assertEqual(len(self.history), 0)
162
163 # Add an approval from Jenkins
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100164 A.addApproval('verified', 1, username='jenkins')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700165 self.fake_gerrit.addEvent(comment)
166 self.waitUntilSettled()
167 self.assertEqual(len(self.history), 1)
168 self.assertEqual(self.history[0].name, job)
169
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100170
Jamie Lennox8ce65582016-11-23 15:20:39 +1100171class TestRequirementsVote1(ZuulTestCase):
172 """Requirements with a voting requirement"""
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100173
Jamie Lennox8ce65582016-11-23 15:20:39 +1100174 tenant_config_file = 'config/requirements/vote1/main.yaml'
Jamie Lennox90cb6b92016-11-23 14:37:19 +1100175
James E. Blair9c17dbf2014-06-23 14:21:58 -0700176 def test_pipeline_require_approval_vote1(self):
177 "Test pipeline requirement: approval vote with one value"
178 return self._test_require_approval_vote1('org/project1',
Jamie Lennox8ce65582016-11-23 15:20:39 +1100179 'project1-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700180
181 def test_trigger_require_approval_vote1(self):
182 "Test trigger requirement: approval vote with one value"
183 return self._test_require_approval_vote1('org/project2',
Jamie Lennox8ce65582016-11-23 15:20:39 +1100184 'project2-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700185
186 def _test_require_approval_vote1(self, project, job):
James E. Blair9c17dbf2014-06-23 14:21:58 -0700187 A = self.fake_gerrit.addFakeChange(project, 'master', 'A')
188 # A comment event that we will keep submitting to trigger
Jamie Lennox8ce65582016-11-23 15:20:39 +1100189 comment = A.addApproval('code-review', 2, username='nobody')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700190 self.fake_gerrit.addEvent(comment)
191 self.waitUntilSettled()
192 # No approval from Jenkins so should not be enqueued
193 self.assertEqual(len(self.history), 0)
194
195 # A -1 from jenkins should not cause it to be enqueued
Jamie Lennox8ce65582016-11-23 15:20:39 +1100196 A.addApproval('verified', -1, username='jenkins')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700197 self.fake_gerrit.addEvent(comment)
198 self.waitUntilSettled()
199 self.assertEqual(len(self.history), 0)
200
201 # A +1 should allow it to be enqueued
Jamie Lennox8ce65582016-11-23 15:20:39 +1100202 A.addApproval('verified', 1, username='jenkins')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700203 self.fake_gerrit.addEvent(comment)
204 self.waitUntilSettled()
205 self.assertEqual(len(self.history), 1)
206 self.assertEqual(self.history[0].name, job)
207
Jamie Lennox8ce65582016-11-23 15:20:39 +1100208
209class TestRequirementsVote2(ZuulTestCase):
210 """Requirements with a voting requirement"""
211
212 tenant_config_file = 'config/requirements/vote2/main.yaml'
213
James E. Blair9c17dbf2014-06-23 14:21:58 -0700214 def test_pipeline_require_approval_vote2(self):
215 "Test pipeline requirement: approval vote with two values"
216 return self._test_require_approval_vote2('org/project1',
Jamie Lennox8ce65582016-11-23 15:20:39 +1100217 'project1-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700218
219 def test_trigger_require_approval_vote2(self):
220 "Test trigger requirement: approval vote with two values"
221 return self._test_require_approval_vote2('org/project2',
Jamie Lennox8ce65582016-11-23 15:20:39 +1100222 'project2-job')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700223
224 def _test_require_approval_vote2(self, project, job):
James E. Blair9c17dbf2014-06-23 14:21:58 -0700225 A = self.fake_gerrit.addFakeChange(project, 'master', 'A')
226 # A comment event that we will keep submitting to trigger
Jamie Lennox8ce65582016-11-23 15:20:39 +1100227 comment = A.addApproval('code-review', 2, username='nobody')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700228 self.fake_gerrit.addEvent(comment)
229 self.waitUntilSettled()
230 # No approval from Jenkins so should not be enqueued
231 self.assertEqual(len(self.history), 0)
232
233 # A -1 from jenkins should not cause it to be enqueued
Jamie Lennox8ce65582016-11-23 15:20:39 +1100234 A.addApproval('verified', -1, username='jenkins')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700235 self.fake_gerrit.addEvent(comment)
236 self.waitUntilSettled()
237 self.assertEqual(len(self.history), 0)
238
239 # A -2 from jenkins should not cause it to be enqueued
Jamie Lennox8ce65582016-11-23 15:20:39 +1100240 A.addApproval('verified', -2, username='jenkins')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700241 self.fake_gerrit.addEvent(comment)
242 self.waitUntilSettled()
243 self.assertEqual(len(self.history), 0)
244
Joshua Hesketh642824b2014-07-01 17:54:59 +1000245 # A +1 from jenkins should allow it to be enqueued
Jamie Lennox8ce65582016-11-23 15:20:39 +1100246 A.addApproval('verified', 1, username='jenkins')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700247 self.fake_gerrit.addEvent(comment)
248 self.waitUntilSettled()
249 self.assertEqual(len(self.history), 1)
250 self.assertEqual(self.history[0].name, job)
251
252 # A +2 should allow it to be enqueued
253 B = self.fake_gerrit.addFakeChange(project, 'master', 'B')
254 # A comment event that we will keep submitting to trigger
Jamie Lennox8ce65582016-11-23 15:20:39 +1100255 comment = B.addApproval('code-review', 2, username='nobody')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700256 self.fake_gerrit.addEvent(comment)
257 self.waitUntilSettled()
258 self.assertEqual(len(self.history), 1)
259
Jamie Lennox8ce65582016-11-23 15:20:39 +1100260 B.addApproval('verified', 2, username='jenkins')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700261 self.fake_gerrit.addEvent(comment)
262 self.waitUntilSettled()
263 self.assertEqual(len(self.history), 2)
264 self.assertEqual(self.history[1].name, job)
265
Jamie Lennox8ce65582016-11-23 15:20:39 +1100266
267class TestRequirements(ZuulTestCase):
268 """Test pipeline and trigger requirements"""
269
270 tenant_config_file = 'config/requirements/main.yaml'
271
Jamie Lennoxff3e0b92016-11-23 10:38:25 +1100272 @skip("Disabled for early v3 development")
James E. Blair9c17dbf2014-06-23 14:21:58 -0700273 def test_pipeline_require_current_patchset(self):
274 "Test pipeline requirement: current-patchset"
James E. Blairf84026c2015-12-08 16:11:46 -0800275 self.updateConfigLayout(
276 'tests/fixtures/layout-requirement-current-patchset.yaml')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700277 self.sched.reconfigure(self.config)
278 self.registerJobs()
279 # Create two patchsets and let their tests settle out. Then
280 # comment on first patchset and check that no additional
281 # jobs are run.
282 A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
283 self.fake_gerrit.addEvent(A.addApproval('CRVW', 1))
284 self.waitUntilSettled()
285 A.addPatchset()
286 self.fake_gerrit.addEvent(A.addApproval('CRVW', 1))
287 self.waitUntilSettled()
288
289 self.assertEqual(len(self.history), 2) # one job for each ps
290 self.fake_gerrit.addEvent(A.getChangeCommentEvent(1))
291 self.waitUntilSettled()
292
293 # Assert no new jobs ran after event for old patchset.
294 self.assertEqual(len(self.history), 2)
295
296 # Make sure the same event on a new PS will trigger
297 self.fake_gerrit.addEvent(A.getChangeCommentEvent(2))
298 self.waitUntilSettled()
299 self.assertEqual(len(self.history), 3)
300
Jamie Lennoxff3e0b92016-11-23 10:38:25 +1100301 @skip("Disabled for early v3 development")
James E. Blair9c17dbf2014-06-23 14:21:58 -0700302 def test_pipeline_require_open(self):
303 "Test pipeline requirement: open"
James E. Blairf84026c2015-12-08 16:11:46 -0800304 self.updateConfigLayout(
305 'tests/fixtures/layout-requirement-open.yaml')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700306 self.sched.reconfigure(self.config)
307 self.registerJobs()
308
309 A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
310 status='MERGED')
311 self.fake_gerrit.addEvent(A.addApproval('CRVW', 2))
312 self.waitUntilSettled()
313 self.assertEqual(len(self.history), 0)
314
315 B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
316 self.fake_gerrit.addEvent(B.addApproval('CRVW', 2))
317 self.waitUntilSettled()
318 self.assertEqual(len(self.history), 1)
319
Jamie Lennoxff3e0b92016-11-23 10:38:25 +1100320 @skip("Disabled for early v3 development")
James E. Blair9c17dbf2014-06-23 14:21:58 -0700321 def test_pipeline_require_status(self):
322 "Test pipeline requirement: status"
James E. Blairf84026c2015-12-08 16:11:46 -0800323 self.updateConfigLayout(
324 'tests/fixtures/layout-requirement-status.yaml')
James E. Blair9c17dbf2014-06-23 14:21:58 -0700325 self.sched.reconfigure(self.config)
326 self.registerJobs()
327
328 A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
329 status='MERGED')
330 self.fake_gerrit.addEvent(A.addApproval('CRVW', 2))
331 self.waitUntilSettled()
332 self.assertEqual(len(self.history), 0)
333
334 B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
335 self.fake_gerrit.addEvent(B.addApproval('CRVW', 2))
336 self.waitUntilSettled()
337 self.assertEqual(len(self.history), 1)
Joshua Hesketh66c8e522014-06-26 15:30:08 +1000338
339 def _test_require_reject_username(self, project, job):
340 "Test negative username's match"
341 # Should only trigger if Jenkins hasn't voted.
James E. Blairf84026c2015-12-08 16:11:46 -0800342 self.updateConfigLayout(
Joshua Hesketh66c8e522014-06-26 15:30:08 +1000343 'tests/fixtures/layout-requirement-reject-username.yaml')
344 self.sched.reconfigure(self.config)
345 self.registerJobs()
346
347 # add in a change with no comments
348 A = self.fake_gerrit.addFakeChange(project, 'master', 'A')
349 self.waitUntilSettled()
350 self.assertEqual(len(self.history), 0)
351
352 # add in a comment that will trigger
353 self.fake_gerrit.addEvent(A.addApproval('CRVW', 1,
354 username='reviewer'))
355 self.waitUntilSettled()
356 self.assertEqual(len(self.history), 1)
357 self.assertEqual(self.history[0].name, job)
358
359 # add in a comment from jenkins user which shouldn't trigger
360 self.fake_gerrit.addEvent(A.addApproval('VRFY', 1, username='jenkins'))
361 self.waitUntilSettled()
362 self.assertEqual(len(self.history), 1)
363
364 # Check future reviews also won't trigger as a 'jenkins' user has
365 # commented previously
366 self.fake_gerrit.addEvent(A.addApproval('CRVW', 1,
367 username='reviewer'))
368 self.waitUntilSettled()
369 self.assertEqual(len(self.history), 1)
370
Jamie Lennoxff3e0b92016-11-23 10:38:25 +1100371 @skip("Disabled for early v3 development")
Joshua Hesketh66c8e522014-06-26 15:30:08 +1000372 def test_pipeline_reject_username(self):
373 "Test negative pipeline requirement: no comment from jenkins"
374 return self._test_require_reject_username('org/project1',
375 'project1-pipeline')
376
Jamie Lennoxff3e0b92016-11-23 10:38:25 +1100377 @skip("Disabled for early v3 development")
Joshua Hesketh66c8e522014-06-26 15:30:08 +1000378 def test_trigger_reject_username(self):
379 "Test negative trigger requirement: no comment from jenkins"
380 return self._test_require_reject_username('org/project2',
381 'project2-trigger')
382
383 def _test_require_reject(self, project, job):
384 "Test no approval matches a reject param"
James E. Blairf84026c2015-12-08 16:11:46 -0800385 self.updateConfigLayout(
Joshua Hesketh66c8e522014-06-26 15:30:08 +1000386 'tests/fixtures/layout-requirement-reject.yaml')
387 self.sched.reconfigure(self.config)
388 self.registerJobs()
389
390 A = self.fake_gerrit.addFakeChange(project, 'master', 'A')
391 self.waitUntilSettled()
392 self.assertEqual(len(self.history), 0)
393
394 # First positive vote should not queue until jenkins has +1'd
395 comment = A.addApproval('VRFY', 1, username='reviewer_a')
396 self.fake_gerrit.addEvent(comment)
397 self.waitUntilSettled()
398 self.assertEqual(len(self.history), 0)
399
400 # Jenkins should put in a +1 which will also queue
401 comment = A.addApproval('VRFY', 1, username='jenkins')
402 self.fake_gerrit.addEvent(comment)
403 self.waitUntilSettled()
404 self.assertEqual(len(self.history), 1)
405 self.assertEqual(self.history[0].name, job)
406
407 # Negative vote should not queue
408 comment = A.addApproval('VRFY', -1, username='reviewer_b')
409 self.fake_gerrit.addEvent(comment)
410 self.waitUntilSettled()
411 self.assertEqual(len(self.history), 1)
412
413 # Future approvals should do nothing
414 comment = A.addApproval('VRFY', 1, username='reviewer_c')
415 self.fake_gerrit.addEvent(comment)
416 self.waitUntilSettled()
417 self.assertEqual(len(self.history), 1)
418
419 # Change/update negative vote should queue
420 comment = A.addApproval('VRFY', 1, username='reviewer_b')
421 self.fake_gerrit.addEvent(comment)
422 self.waitUntilSettled()
423 self.assertEqual(len(self.history), 2)
424 self.assertEqual(self.history[1].name, job)
425
426 # Future approvals should also queue
427 comment = A.addApproval('VRFY', 1, username='reviewer_d')
428 self.fake_gerrit.addEvent(comment)
429 self.waitUntilSettled()
430 self.assertEqual(len(self.history), 3)
431 self.assertEqual(self.history[2].name, job)
432
Jamie Lennoxff3e0b92016-11-23 10:38:25 +1100433 @skip("Disabled for early v3 development")
Joshua Hesketh66c8e522014-06-26 15:30:08 +1000434 def test_pipeline_require_reject(self):
435 "Test pipeline requirement: rejections absent"
436 return self._test_require_reject('org/project1', 'project1-pipeline')
437
Jamie Lennoxff3e0b92016-11-23 10:38:25 +1100438 @skip("Disabled for early v3 development")
Joshua Hesketh66c8e522014-06-26 15:30:08 +1000439 def test_trigger_require_reject(self):
440 "Test trigger requirement: rejections absent"
441 return self._test_require_reject('org/project2', 'project2-trigger')