Browse Source

Re-enable multiple gerrit connection test

Re-enable the test with multiple gerrits affecting the same projects.
Extends the test a bit as the last test never showed actual interaction
between the two builds.

Story: 2000773
Task: 3412
Change-Id: Ia8621ea481057cc7602dd01ef149b2ebfbf0aa58
changes/99/406699/5
Jamie Lennox 5 years ago
committed by James E. Blair
parent
commit
d2e37337f5
  1. 5
      tests/base.py
  2. 2
      tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test1.yaml
  3. 2
      tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test2.yaml
  4. 42
      tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/zuul.yaml
  5. 1
      tests/fixtures/config/zuul-connections-multiple-gerrits/git/org_project1/README
  6. 6
      tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml
  7. 37
      tests/fixtures/layout-connections-multiple-gerrits.yaml
  8. 2
      tests/fixtures/zuul-connections-multiple-gerrits.conf
  9. 48
      tests/unit/test_connection.py

5
tests/base.py

@ -557,6 +557,8 @@ class FakeBuild(object):
if len(self.parameters.get('nodes')) == 1:
self.node = self.parameters['nodes'][0]['image']
self.unique = self.parameters['ZUUL_UUID']
self.pipeline = self.parameters['ZUUL_PIPELINE']
self.project = self.parameters['ZUUL_PROJECT']
self.name = self.parameters['job']
self.wait_condition = threading.Condition()
self.waiting = False
@ -571,7 +573,8 @@ class FakeBuild(object):
waiting = ''
if self.waiting:
waiting = ' [waiting]'
return '<FakeBuild %s %s%s>' % (self.name, self.changes, waiting)
return '<FakeBuild %s:%s %s%s>' % (self.pipeline, self.name,
self.changes, waiting)
def release(self):
"""Release this build."""

2
tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test1.yaml

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

2
tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test2.yaml

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

42
tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/zuul.yaml

@ -0,0 +1,42 @@
- pipeline:
name: review_check
manager: independent
source: review_gerrit
trigger:
review_gerrit:
- event: patchset-created
success:
review_gerrit:
verified: 1
failure:
review_gerrit:
verified: -1
- pipeline:
name: another_check
manager: independent
source: another_gerrit
trigger:
another_gerrit:
- event: patchset-created
success:
another_gerrit:
verified: 1
failure:
another_gerrit:
verified: -1
- job:
name: project-test1
- job:
name: project-test2
- project:
name: org/project1
review_check:
jobs:
- project-test1
another_check:
jobs:
- project-test2

1
tests/fixtures/config/zuul-connections-multiple-gerrits/git/org_project1/README

@ -0,0 +1 @@
test

6
tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml

@ -0,0 +1,6 @@
- tenant:
name: tenant-one
source:
review_gerrit:
config-repos:
- common-config

37
tests/fixtures/layout-connections-multiple-gerrits.yaml

@ -1,37 +0,0 @@
pipelines:
- name: check
manager: IndependentPipelineManager
source: review_gerrit
trigger:
review_gerrit:
- event: patchset-created
success:
review_gerrit:
VRFY: 1
failure:
review_gerrit:
VRFY: -1
- name: another_check
manager: IndependentPipelineManager
source: another_gerrit
trigger:
another_gerrit:
- event: patchset-created
success:
another_gerrit:
VRFY: 1
failure:
another_gerrit:
VRFY: -1
projects:
- name: org/project
check:
- project-review-gerrit
another_check:
- project-another-gerrit
- name: org/project1
another_check:
- project1-another-gerrit

2
tests/fixtures/zuul-connections-multiple-gerrits.conf

@ -2,7 +2,7 @@
server=127.0.0.1
[zuul]
layout_config=layout-connections-multiple-voters.yaml
tenant_config=main.yaml
url_pattern=http://logs.example.com/{change.number}/{change.patchset}/{pipeline.name}/{job.name}/{build.number}
job_name_in_report=true

48
tests/unit/test_connection.py

@ -47,28 +47,48 @@ class TestConnections(ZuulTestCase):
class TestMultipleGerrits(ZuulTestCase):
def setUp(self):
self.skip("Disabled for early v3 development")
def setup_config(self,
config_file='zuul-connections-multiple-gerrits.conf'):
super(TestMultipleGerrits, self).setup_config(config_file)
self.self.updateConfigLayout(
'layout-connections-multiple-gerrits.yaml')
config_file = 'zuul-connections-multiple-gerrits.conf'
tenant_config_file = 'config/zuul-connections-multiple-gerrits/main.yaml'
def test_multiple_project_separate_gerrits(self):
self.worker.hold_jobs_in_build = True
self.launch_server.hold_jobs_in_build = True
A = self.fake_another_gerrit.addFakeChange(
'org/project', 'master', 'A')
'org/project1', 'master', 'A')
self.fake_another_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertEqual(1, len(self.builds))
self.assertEqual('project-another-gerrit', self.builds[0].name)
self.assertTrue(self.job_has_changes(self.builds[0], A))
self.assertBuilds([dict(name='project-test2',
changes='1,1',
project='org/project1',
pipeline='another_check')])
self.worker.hold_jobs_in_build = False
self.worker.release()
# 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/project1', 'master', 'B')
self.fake_review_gerrit.addEvent(B.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertBuilds([
dict(name='project-test2',
changes='1,1',
project='org/project1',
pipeline='another_check'),
dict(name='project-test1',
changes='51,1',
project='org/project1',
pipeline='review_check'),
])
self.launch_server.hold_jobs_in_build = False
self.launch_server.release()
self.waitUntilSettled()
Loading…
Cancel
Save