diff --git a/tests/fixtures/config/ambiguous-names/git/common-config/playbooks/project-merge.yaml b/tests/fixtures/config/ambiguous-names/git/common-config/playbooks/project-merge.yaml new file mode 100644 index 0000000000..f679dceaef --- /dev/null +++ b/tests/fixtures/config/ambiguous-names/git/common-config/playbooks/project-merge.yaml @@ -0,0 +1,2 @@ +- hosts: all + tasks: [] diff --git a/tests/fixtures/config/ambiguous-names/git/common-config/zuul.yaml b/tests/fixtures/config/ambiguous-names/git/common-config/zuul.yaml new file mode 100644 index 0000000000..af23e68565 --- /dev/null +++ b/tests/fixtures/config/ambiguous-names/git/common-config/zuul.yaml @@ -0,0 +1,47 @@ +- pipeline: + name: check + manager: independent + trigger: + 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: base + parent: null + +- job: + name: project-merge + hold-following-changes: true + nodeset: + nodes: + - name: controller + label: label1 + run: playbooks/project-merge.yaml + +- project: + name: review.example.com/org/project + check: + jobs: + - project-merge + +- project: + name: another.example.com/org/project + check: + jobs: + - project-merge + +- project: + name: common-config + check: + jobs: + - project-merge diff --git a/tests/fixtures/config/ambiguous-names/git/org_project/README b/tests/fixtures/config/ambiguous-names/git/org_project/README new file mode 100644 index 0000000000..9daeafb986 --- /dev/null +++ b/tests/fixtures/config/ambiguous-names/git/org_project/README @@ -0,0 +1 @@ +test diff --git a/tests/fixtures/config/ambiguous-names/main.yaml b/tests/fixtures/config/ambiguous-names/main.yaml new file mode 100644 index 0000000000..bdcfc7c7ce --- /dev/null +++ b/tests/fixtures/config/ambiguous-names/main.yaml @@ -0,0 +1,11 @@ +- tenant: + name: tenant-one + source: + review_gerrit: + config-projects: + - common-config + untrusted-projects: + - org/project + another_gerrit: + untrusted-projects: + - org/project diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py index 158141b8d5..9d84c92df3 100755 --- a/tests/unit/test_scheduler.py +++ b/tests/unit/test_scheduler.py @@ -4983,6 +4983,30 @@ For CI problems and help debugging, contact ci@example.org""" ], ordered=False) +class TestAmbiguousProjectNames(ZuulTestCase): + config_file = 'zuul-connections-multiple-gerrits.conf' + tenant_config_file = 'config/ambiguous-names/main.yaml' + + def test_client_enqueue_canonical(self): + "Test that the RPC client can enqueue a change using canonical name" + A = self.fake_review_gerrit.addFakeChange('org/project', 'master', 'A') + A.addApproval('Code-Review', 2) + A.addApproval('Approved', 1) + + client = zuul.rpcclient.RPCClient('127.0.0.1', + self.gearman_server.port) + self.addCleanup(client.shutdown) + r = client.enqueue(tenant='tenant-one', + pipeline='check', + project='review.example.com/org/project', + trigger='gerrit', + change='1,1') + self.waitUntilSettled() + self.assertEqual(self.getJobFromHistory('project-merge').result, + 'SUCCESS') + self.assertEqual(r, True) + + class TestExecutor(ZuulTestCase): tenant_config_file = 'config/single-tenant/main.yaml' diff --git a/zuul/scheduler.py b/zuul/scheduler.py index 04c56a469c..93d0448a54 100644 --- a/zuul/scheduler.py +++ b/zuul/scheduler.py @@ -828,7 +828,9 @@ class Scheduler(threading.Thread): def _doEnqueueEvent(self, event): tenant = self.abide.tenants.get(event.tenant_name) - (trusted, project) = tenant.getProject(event.project_name) + full_project_name = ('/'.join([event.project_hostname, + event.project_name])) + (trusted, project) = tenant.getProject(full_project_name) pipeline = tenant.layout.pipelines[event.forced_pipeline] change = project.source.getChange(event, project) self.log.debug("Event %s for change %s was directly assigned "