Merge "Implement node equality" into feature/zuulv3
diff --git a/tests/base.py b/tests/base.py
index 566ceae..506e22c 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -557,6 +557,8 @@
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 @@
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."""
diff --git a/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/mutex-one.yaml b/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/mutex-one.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/mutex-one.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+ tasks: []
diff --git a/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/mutex-two.yaml b/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/mutex-two.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/mutex-two.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+ tasks: []
diff --git a/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/project-test1.yaml b/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/project-test1.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-mutex/playbooks/project-test1.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+ tasks: []
diff --git a/tests/fixtures/config/single-tenant/git/layout-mutex/zuul.yaml b/tests/fixtures/config/single-tenant/git/layout-mutex/zuul.yaml
new file mode 100644
index 0000000..e91903a
--- /dev/null
+++ b/tests/fixtures/config/single-tenant/git/layout-mutex/zuul.yaml
@@ -0,0 +1,33 @@
+- pipeline:
+ name: check
+ manager: independent
+ source:
+ gerrit
+ trigger:
+ gerrit:
+ - event: patchset-created
+ success:
+ gerrit:
+ verified: 1
+ failure:
+ gerrit:
+ verified: -1
+
+- job:
+ name: project-test1
+
+- job:
+ name: mutex-one
+ mutex: test-mutex
+
+- job:
+ name: mutex-two
+ mutex: test-mutex
+
+- project:
+ name: org/project
+ check:
+ jobs:
+ - project-test1
+ - mutex-one
+ - mutex-two
diff --git a/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test1.yaml b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test1.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test1.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+ tasks: []
diff --git a/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test2.yaml b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test2.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/playbooks/project-test2.yaml
@@ -0,0 +1,2 @@
+- hosts: all
+ tasks: []
diff --git a/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/zuul.yaml b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/common-config/zuul.yaml
new file mode 100644
index 0000000..302dfcf
--- /dev/null
+++ b/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
diff --git a/tests/fixtures/config/zuul-connections-multiple-gerrits/git/org_project1/README b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/org_project1/README
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/fixtures/config/zuul-connections-multiple-gerrits/git/org_project1/README
@@ -0,0 +1 @@
+test
diff --git a/tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml b/tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml
new file mode 100644
index 0000000..730cc7e
--- /dev/null
+++ b/tests/fixtures/config/zuul-connections-multiple-gerrits/main.yaml
@@ -0,0 +1,6 @@
+- tenant:
+ name: tenant-one
+ source:
+ review_gerrit:
+ config-repos:
+ - common-config
diff --git a/tests/fixtures/layout-connections-multiple-gerrits.yaml b/tests/fixtures/layout-connections-multiple-gerrits.yaml
deleted file mode 100644
index 029f42f..0000000
--- a/tests/fixtures/layout-connections-multiple-gerrits.yaml
+++ /dev/null
@@ -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
diff --git a/tests/fixtures/layout-mutex.yaml b/tests/fixtures/layout-mutex.yaml
deleted file mode 100644
index fcd0529..0000000
--- a/tests/fixtures/layout-mutex.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-pipelines:
- - name: check
- manager: IndependentPipelineManager
- trigger:
- gerrit:
- - event: patchset-created
- success:
- gerrit:
- verified: 1
- failure:
- gerrit:
- verified: -1
-
-jobs:
- - name: mutex-one
- mutex: test-mutex
- - name: mutex-two
- mutex: test-mutex
-
-projects:
- - name: org/project
- check:
- - project-test1
- - mutex-one
- - mutex-two
diff --git a/tests/fixtures/zuul-connections-multiple-gerrits.conf b/tests/fixtures/zuul-connections-multiple-gerrits.conf
index f067e6e..89f0aa6 100644
--- a/tests/fixtures/zuul-connections-multiple-gerrits.conf
+++ b/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
diff --git a/tests/nodepool/test_nodepool_integration.py b/tests/nodepool/test_nodepool_integration.py
index ef459e4..67968a3 100644
--- a/tests/nodepool/test_nodepool_integration.py
+++ b/tests/nodepool/test_nodepool_integration.py
@@ -53,7 +53,7 @@
# Test a simple node request
nodeset = model.NodeSet()
- nodeset.addNode(model.Node('controller', 'fake-nodepool'))
+ nodeset.addNode(model.Node('controller', 'fake-label'))
job = model.Job('testjob')
job.nodeset = nodeset
request = self.nodepool.requestNodes(None, job)
diff --git a/tests/unit/test_connection.py b/tests/unit/test_connection.py
index f8d1bf5..d9bc72f 100644
--- a/tests/unit/test_connection.py
+++ b/tests/unit/test_connection.py
@@ -47,28 +47,48 @@
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()
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 6426692..3b9d562 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -2111,7 +2111,6 @@
self.assertEqual(self.history[4].pipeline, 'check')
self.assertEqual(self.history[5].pipeline, 'check')
- @skip("Disabled for early v3 development")
def test_json_status(self):
"Test that we can retrieve JSON status info"
self.launch_server.hold_jobs_in_build = True
@@ -2125,7 +2124,8 @@
port = self.webapp.server.socket.getsockname()[1]
- req = urllib.request.Request("http://localhost:%s/status.json" % port)
+ req = urllib.request.Request(
+ "http://localhost:%s/tenant-one/status" % port)
f = urllib.request.urlopen(req)
headers = f.info()
self.assertIn('Content-Length', headers)
@@ -2159,19 +2159,18 @@
self.assertEqual('project-merge', status_jobs[0]['name'])
self.assertEqual('https://server/job/project-merge/0/',
status_jobs[0]['url'])
- self.assertEqual('http://logs.example.com/1/1/gate/project-merge/0',
+ self.assertEqual('https://server/job/project-merge/0/',
status_jobs[0]['report_url'])
-
self.assertEqual('project-test1', status_jobs[1]['name'])
- self.assertEqual('https://server/job/project-test1/1/',
+ self.assertEqual('https://server/job/project-test1/0/',
status_jobs[1]['url'])
- self.assertEqual('http://logs.example.com/1/1/gate/project-test1/1',
+ self.assertEqual('https://server/job/project-test1/0/',
status_jobs[1]['report_url'])
self.assertEqual('project-test2', status_jobs[2]['name'])
- self.assertEqual('https://server/job/project-test2/2/',
+ self.assertEqual('https://server/job/project-test2/0/',
status_jobs[2]['url'])
- self.assertEqual('http://logs.example.com/1/1/gate/project-test2/2',
+ self.assertEqual('https://server/job/project-test2/0/',
status_jobs[2]['report_url'])
@skip("Disabled for early v3 development")
@@ -2182,11 +2181,9 @@
self.sched.reconfigure(self.config)
self.assertEqual(len(self.sched.layout.pipelines['gate'].queues), 1)
- @skip("Disabled for early v3 development")
def test_mutex(self):
"Test job mutexes"
- self.config.set('zuul', 'layout_config',
- 'tests/fixtures/layout-mutex.yaml')
+ self.updateConfigLayout('layout-mutex')
self.sched.reconfigure(self.config)
self.launch_server.hold_jobs_in_build = True