Fix support for multiple github connection
This change enables using multiple github connection by fixing this exception: File "zuul/executor/server.py", line 1228, in _execute repo_state[task.connection_name][task.project_name] KeyError: 'org/project' Change-Id: I678bd8984233ced580e637aeea6d74ad7d799a08
This commit is contained in:
parent
3d9b9fa46b
commit
d567fae882
|
@ -0,0 +1,2 @@
|
|||
- hosts: all
|
||||
tasks: []
|
|
@ -0,0 +1,22 @@
|
|||
- pipeline:
|
||||
name: check
|
||||
manager: independent
|
||||
trigger:
|
||||
github_ro:
|
||||
- event: pull_request
|
||||
action:
|
||||
- opened
|
||||
|
||||
- job:
|
||||
name: base
|
||||
parent: null
|
||||
|
||||
- job:
|
||||
name: project-test
|
||||
run: playbooks/test.yaml
|
||||
|
||||
- project:
|
||||
name: org/project
|
||||
check:
|
||||
jobs:
|
||||
- project-test
|
|
@ -0,0 +1 @@
|
|||
test
|
|
@ -0,0 +1,9 @@
|
|||
- tenant:
|
||||
name: tenant-one
|
||||
source:
|
||||
github:
|
||||
config-projects:
|
||||
- org/common-config
|
||||
github_ro:
|
||||
untrusted-projects:
|
||||
- org/project
|
|
@ -0,0 +1,31 @@
|
|||
[gearman]
|
||||
server=127.0.0.1
|
||||
|
||||
[scheduler]
|
||||
tenant_config=config/multi-github/main.yaml
|
||||
|
||||
[web]
|
||||
root=http://zuul.example.com/
|
||||
|
||||
[merger]
|
||||
git_dir=/tmp/zuul-test/git
|
||||
git_user_email=zuul@example.com
|
||||
git_user_name=zuul
|
||||
|
||||
[executor]
|
||||
git_dir=/tmp/zuul-test/executor-git
|
||||
|
||||
[connection github]
|
||||
driver=github
|
||||
webhook_token=0000000000000000000000000000000000000000
|
||||
app_id=1
|
||||
app_key=$APP_KEY_FIXTURE$
|
||||
|
||||
[connection github_ro]
|
||||
driver=github
|
||||
webhook_token=0000000000000000000000000000000000000000
|
||||
app_id=1
|
||||
app_key=$APP_KEY_FIXTURE$
|
||||
|
||||
[database]
|
||||
dburi=$MYSQL_FIXTURE_DBURI$
|
|
@ -1315,6 +1315,23 @@ class TestGithubDriver(ZuulTestCase):
|
|||
self.getJobFromHistory('project-test2').result)
|
||||
|
||||
|
||||
class TestMultiGithubDriver(ZuulTestCase):
|
||||
config_file = 'zuul-multi-github.conf'
|
||||
tenant_config_file = 'config/multi-github/main.yaml'
|
||||
|
||||
def test_multi_app(self):
|
||||
"""Test that we can handle multiple app."""
|
||||
A = self.fake_github_ro.openFakePullRequest(
|
||||
'org/project', 'master', 'A')
|
||||
self.fake_github_ro.emitEvent(A.getPullRequestOpenedEvent())
|
||||
self.waitUntilSettled()
|
||||
self.executor_server.release()
|
||||
self.waitUntilSettled()
|
||||
self.assertEqual(
|
||||
'SUCCESS',
|
||||
self.getJobFromHistory('project-test').result)
|
||||
|
||||
|
||||
class TestGithubUnprotectedBranches(ZuulTestCase):
|
||||
config_file = 'zuul-github-driver.conf'
|
||||
tenant_config_file = 'config/unprotected-branches/main.yaml'
|
||||
|
|
|
@ -181,11 +181,18 @@ def construct_build_params(uuid, sched, nodeset, job, item, pipeline,
|
|||
projects.add(project)
|
||||
required_projects.add(project)
|
||||
for change in dependent_changes:
|
||||
# We have to find the project this way because it may not
|
||||
# be registered in the tenant (ie, a foreign project).
|
||||
source = sched.connections.getSourceByCanonicalHostname(
|
||||
change['project']['canonical_hostname'])
|
||||
project = source.getProject(change['project']['name'])
|
||||
try:
|
||||
(_, project) = item.pipeline.tenant.getProject(
|
||||
change['project']['canonical_name'])
|
||||
if not project:
|
||||
raise KeyError()
|
||||
except Exception:
|
||||
# We have to find the project this way because it may not
|
||||
# be registered in the tenant (ie, a foreign project).
|
||||
source = sched.connections.getSourceByCanonicalHostname(
|
||||
change['project']['canonical_hostname'])
|
||||
project = source.getProject(change['project']['name'])
|
||||
|
||||
if project not in projects:
|
||||
params['projects'].append(make_project_dict(project))
|
||||
projects.add(project)
|
||||
|
|
Loading…
Reference in New Issue