Test gerrit and github drivers in same tenant

Only sources which use the same connection as the event originates from
are queried for changes. This avoids eg. querying the change on
different gerrit or github than the event originated from.

Change-Id: Ie1c5b223d4eec13c18f2381c3e387a0ca7801137
Co-Authored-By: Jesse Keating <omgjlk@us.ibm.com>
This commit is contained in:
Jan Hruban 2016-11-11 16:43:31 +01:00 committed by Jesse Keating
parent ddeb95ac33
commit 3c440b03fa
8 changed files with 144 additions and 0 deletions

View File

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

View File

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

View File

@ -0,0 +1,46 @@
- pipeline:
name: check_github
manager: independent
trigger:
github:
- event: pull_request
action:
- opened
- changed
- reopened
success:
github:
status: 'success'
failure:
github:
status: 'failure'
- pipeline:
name: check_gerrit
manager: independent
trigger:
gerrit:
- event: patchset-created
success:
gerrit:
verify: 1
failure:
gerrit:
verify: 1
- job:
name: project-gerrit
- job:
name: project1-github
- project:
name: org/project
check_gerrit:
jobs:
- project-gerrit
- project:
name: org/project1
check_github:
jobs:
- project1-github

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1 @@
test

View File

@ -0,0 +1,11 @@
- tenant:
name: tenant-one
source:
github:
config-projects:
- common-config
untrusted-projects:
- org/project1
gerrit:
untrusted-projects:
- org/project

View File

@ -0,0 +1,31 @@
[gearman]
server=127.0.0.1
[zuul]
tenant_config=config/multi-driver/main.yaml
job_name_in_report=true
[merger]
git_dir=/tmp/zuul-test/git
git_user_email=zuul@example.com
git_user_name=zuul
zuul_url=http://zuul.example.com/p
[executor]
git_dir=/tmp/zuul-test/executor-git
[connection gerrit]
driver=gerrit
server=review.example.com
user=jenkins
sshkey=none
[connection github]
driver=github
[connection outgoing_smtp]
driver=smtp
server=localhost
port=25
default_from=zuul@example.com
default_to=you@example.com

View File

@ -0,0 +1,50 @@
# Copyright 2015 GoodData
# Copyright (c) 2017 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import logging
from tests.base import ZuulTestCase
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-32s '
'%(levelname)-8s %(message)s')
class TestGerritAndGithub(ZuulTestCase):
config_file = 'zuul-connections-gerrit-and-github.conf'
tenant_config_file = 'config/multi-driver/main.yaml'
def setup_config(self):
super(TestGerritAndGithub, self).setup_config()
def test_multiple_project_gerrit_and_github(self):
self.executor_server.hold_jobs_in_build = True
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
B = self.fake_github.openFakePullRequest('org/project1', 'master', 'B')
self.fake_github.emitEvent(B.getPullRequestOpenedEvent())
self.waitUntilSettled()
self.assertEqual(2, len(self.builds))
self.assertEqual('project-gerrit', self.builds[0].name)
self.assertEqual('project1-github', self.builds[1].name)
self.assertTrue(self.builds[0].hasChanges(A))
self.assertTrue(self.builds[1].hasChanges(B))
self.executor_server.hold_jobs_in_build = False
self.executor_server.release()
self.waitUntilSettled()