Gerrit checks: trigger new patchset behavior
Consider a "pending-check" event to be a type of patchset-created event, so that the scheduler will perform its check to remove obsolete patchsets from pipelines. Change-Id: Ie808deaa8615d85ebda232e095c12b90c3617f6b
This commit is contained in:
parent
1e04bdb4aa
commit
fecb7b2c73
|
@ -421,6 +421,45 @@ class TestChecksApi(ZuulTestCase):
|
|||
self.assertEqual(A.reported, 0, "no messages should be reported")
|
||||
self.assertEqual(A.messages, [], "no messages should be reported")
|
||||
|
||||
@simple_layout('layouts/gerrit-checks.yaml')
|
||||
def test_new_patchset(self):
|
||||
self.executor_server.hold_jobs_in_build = True
|
||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
||||
A.setCheck('zuul:check', reset=True)
|
||||
self.waitForPoll('gerrit')
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.assertEqual(A.checks_history[0]['zuul:check']['state'],
|
||||
'NOT_STARTED')
|
||||
self.assertEqual(A.checks_history[1]['zuul:check']['state'],
|
||||
'SCHEDULED')
|
||||
self.assertEqual(A.checks_history[2]['zuul:check']['state'],
|
||||
'RUNNING')
|
||||
self.assertEqual(len(A.checks_history), 3)
|
||||
|
||||
A.addPatchset()
|
||||
A.setCheck('zuul:check', reset=True)
|
||||
self.waitForPoll('gerrit')
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.executor_server.hold_jobs_in_build = False
|
||||
self.executor_server.release()
|
||||
self.waitUntilSettled()
|
||||
print(A.checks_history)
|
||||
self.assertEqual(A.checks_history[3]['zuul:check']['state'],
|
||||
'NOT_STARTED')
|
||||
self.assertEqual(A.checks_history[4]['zuul:check']['state'],
|
||||
'SCHEDULED')
|
||||
self.assertEqual(A.checks_history[5]['zuul:check']['state'],
|
||||
'RUNNING')
|
||||
self.assertEqual(A.checks_history[6]['zuul:check']['state'],
|
||||
'SUCCESSFUL')
|
||||
self.assertEqual(len(A.checks_history), 7)
|
||||
self.assertHistory([
|
||||
dict(name='test-job', result='ABORTED', changes='1,1'),
|
||||
dict(name='test-job', result='SUCCESS', changes='1,2'),
|
||||
], ordered=False)
|
||||
|
||||
|
||||
class TestPolling(ZuulTestCase):
|
||||
config_file = 'zuul-gerrit-no-stream.conf'
|
||||
|
|
|
@ -175,7 +175,7 @@ class GerritTriggerEvent(TriggerEvent):
|
|||
return ret
|
||||
|
||||
def isPatchsetCreated(self):
|
||||
return 'patchset-created' == self.type
|
||||
return self.type in ('patchset-created', 'pending-check')
|
||||
|
||||
def isChangeAbandoned(self):
|
||||
return 'change-abandoned' == self.type
|
||||
|
|
Loading…
Reference in New Issue