Merge "scheduler: fix enqueue event to use canonical project name"

This commit is contained in:
Zuul 2018-07-17 16:57:42 +00:00 committed by Gerrit Code Review
commit 777f1b50ee
6 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,2 @@
- hosts: all
tasks: []

View File

@ -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

View File

@ -0,0 +1 @@
test

View File

@ -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

View File

@ -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'

View File

@ -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 "