Merge "Only report to gerrit if the action is from gerrit" into feature/zuulv3
This commit is contained in:
commit
3c4c1572e2
@ -24,6 +24,25 @@
|
||||
another_gerrit:
|
||||
verified: -1
|
||||
|
||||
- pipeline:
|
||||
name: common_check
|
||||
manager: independent
|
||||
trigger:
|
||||
another_gerrit:
|
||||
- event: patchset-created
|
||||
review_gerrit:
|
||||
- event: patchset-created
|
||||
success:
|
||||
review_gerrit:
|
||||
verified: 1
|
||||
another_gerrit:
|
||||
verified: 1
|
||||
failure:
|
||||
review_gerrit:
|
||||
verified: -1
|
||||
another_gerrit:
|
||||
verified: -1
|
||||
|
||||
- job:
|
||||
name: project-test1
|
||||
|
||||
@ -41,3 +60,16 @@
|
||||
another_check:
|
||||
jobs:
|
||||
- project-test2
|
||||
|
||||
|
||||
- project:
|
||||
name: review.example.com/org/project2
|
||||
common_check:
|
||||
jobs:
|
||||
- project-test1
|
||||
|
||||
- project:
|
||||
name: another.example.com/org/project2
|
||||
common_check:
|
||||
jobs:
|
||||
- project-test2
|
||||
|
1
tests/fixtures/config/zuul-connections-multiple-gerrits/git/org_project2/README
vendored
Normal file
1
tests/fixtures/config/zuul-connections-multiple-gerrits/git/org_project2/README
vendored
Normal file
@ -0,0 +1 @@
|
||||
test
|
@ -6,6 +6,8 @@
|
||||
- common-config
|
||||
untrusted-projects:
|
||||
- org/project1
|
||||
- org/project2
|
||||
another_gerrit:
|
||||
untrusted-projects:
|
||||
- org/project1
|
||||
- org/project2
|
||||
|
@ -266,6 +266,48 @@ class TestMultipleGerrits(ZuulTestCase):
|
||||
self.executor_server.release()
|
||||
self.waitUntilSettled()
|
||||
|
||||
def test_multiple_project_separate_gerrits_common_pipeline(self):
|
||||
self.executor_server.hold_jobs_in_build = True
|
||||
|
||||
A = self.fake_another_gerrit.addFakeChange(
|
||||
'org/project2', 'master', 'A')
|
||||
self.fake_another_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
||||
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.assertBuilds([dict(name='project-test2',
|
||||
changes='1,1',
|
||||
project='org/project2',
|
||||
pipeline='common_check')])
|
||||
|
||||
# NOTE(jamielennox): the tests back the git repo for both connections
|
||||
# onto the same git repo on the file system. If we just create another
|
||||
# fake change the fake_review_gerrit will try to create another 1,1
|
||||
# change and git will fail to create the ref. Arbitrarily set it to get
|
||||
# around the problem.
|
||||
self.fake_review_gerrit.change_number = 50
|
||||
|
||||
B = self.fake_review_gerrit.addFakeChange(
|
||||
'org/project2', 'master', 'B')
|
||||
self.fake_review_gerrit.addEvent(B.getPatchsetCreatedEvent(1))
|
||||
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.assertBuilds([
|
||||
dict(name='project-test2',
|
||||
changes='1,1',
|
||||
project='org/project2',
|
||||
pipeline='common_check'),
|
||||
dict(name='project-test1',
|
||||
changes='51,1',
|
||||
project='org/project2',
|
||||
pipeline='common_check'),
|
||||
])
|
||||
|
||||
self.executor_server.hold_jobs_in_build = False
|
||||
self.executor_server.release()
|
||||
self.waitUntilSettled()
|
||||
|
||||
|
||||
class TestConnectionsMerger(ZuulTestCase):
|
||||
config_file = 'zuul-connections-merger.conf'
|
||||
|
@ -15,7 +15,7 @@
|
||||
import logging
|
||||
import voluptuous as v
|
||||
|
||||
|
||||
from zuul.driver.gerrit.gerritsource import GerritSource
|
||||
from zuul.reporter import BaseReporter
|
||||
|
||||
|
||||
@ -27,6 +27,17 @@ class GerritReporter(BaseReporter):
|
||||
|
||||
def report(self, pipeline, item):
|
||||
"""Send a message to gerrit."""
|
||||
|
||||
# If the source is no GerritSource we cannot report anything here.
|
||||
if not isinstance(item.change.project.source, GerritSource):
|
||||
return
|
||||
|
||||
# For supporting several Gerrit connections we also must filter by
|
||||
# the canonical hostname.
|
||||
if item.change.project.source.connection.canonical_hostname != \
|
||||
self.connection.canonical_hostname:
|
||||
return
|
||||
|
||||
message = self._formatItemReport(pipeline, item)
|
||||
|
||||
self.log.debug("Report change %s, params %s, message: %s" %
|
||||
|
Loading…
Reference in New Issue
Block a user