summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-12-05 12:04:40 +0000
committerGerrit Code Review <review@openstack.org>2018-12-05 12:04:40 +0000
commit65a89f441b8c84501e87a8f26e37d38e08b0e42c (patch)
tree5b1c189560bfda5e098203aa5709aabd1aba2efb
parente2887fea7079bb5a9ed3342c2ee1995bcd56a1a8 (diff)
parentf605862a4d6824b6c9ea5b907c2ca3feb7793adc (diff)
Merge "Fix "reverse" Depends-On detection with new Gerrit URL schema"
-rw-r--r--tests/unit/test_gerrit_crd.py31
-rw-r--r--zuul/driver/gerrit/gerritconnection.py1
2 files changed, 25 insertions, 7 deletions
diff --git a/tests/unit/test_gerrit_crd.py b/tests/unit/test_gerrit_crd.py
index cabaf7c..5f796ac 100644
--- a/tests/unit/test_gerrit_crd.py
+++ b/tests/unit/test_gerrit_crd.py
@@ -18,6 +18,12 @@ from tests.base import (
18 simple_layout, 18 simple_layout,
19) 19)
20 20
21URL_FORMATS = [
22 '{baseurl}/{change_no}',
23 '{baseurl}/#/c/{change_no}',
24 '{baseurl}/c/{project}/+/{change_no}/',
25]
26
21 27
22class TestGerritCRD(ZuulTestCase): 28class TestGerritCRD(ZuulTestCase):
23 tenant_config_file = 'config/single-tenant/main.yaml' 29 tenant_config_file = 'config/single-tenant/main.yaml'
@@ -95,15 +101,14 @@ class TestGerritCRD(ZuulTestCase):
95 # changes - repeat the simple test on each of the 3 to ensure they can be 101 # changes - repeat the simple test on each of the 3 to ensure they can be
96 # parsed, the other tests just use the default URL schema provided in 102 # parsed, the other tests just use the default URL schema provided in
97 # FakeGerritChange.data['url'] . 103 # FakeGerritChange.data['url'] .
104 def test_crd_gate_url_schema0(self):
105 self._test_crd_gate(URL_FORMATS[0])
98 106
99 def test_crd_gate_url_schema1(self): 107 def test_crd_gate_url_schema1(self):
100 self._test_crd_gate('{baseurl}/{change_no}') 108 self._test_crd_gate(URL_FORMATS[1])
101 109
102 def test_crd_gate_url_schema2(self): 110 def test_crd_gate_url_schema2(self):
103 self._test_crd_gate('{baseurl}/#/c/{change_no}') 111 self._test_crd_gate(URL_FORMATS[2])
104
105 def test_crd_gate_url_schema3(self):
106 self._test_crd_gate('{baseurl}/c/{project}/+/{change_no}/')
107 112
108 def test_crd_gate_triangle(self): 113 def test_crd_gate_triangle(self):
109 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') 114 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
@@ -260,7 +265,7 @@ class TestGerritCRD(ZuulTestCase):
260 self.assertEqual(A.data['status'], 'MERGED') 265 self.assertEqual(A.data['status'], 'MERGED')
261 self.assertEqual(A.reported, 2) 266 self.assertEqual(A.reported, 2)
262 267
263 def test_crd_gate_reverse(self): 268 def _test_crd_gate_reverse(self, url_fmt):
264 "Test reverse cross-repo dependencies" 269 "Test reverse cross-repo dependencies"
265 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') 270 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
266 B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B') 271 B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B')
@@ -269,8 +274,11 @@ class TestGerritCRD(ZuulTestCase):
269 274
270 # A Depends-On: B 275 # A Depends-On: B
271 276
277 url = url_fmt.format(baseurl=B.gerrit.baseurl.rstrip('/'),
278 project=B.project,
279 change_no=B.number)
272 A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % ( 280 A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
273 A.subject, B.data['url']) 281 A.subject, url)
274 282
275 self.fake_gerrit.addEvent(A.addApproval('Approved', 1)) 283 self.fake_gerrit.addEvent(A.addApproval('Approved', 1))
276 self.waitUntilSettled() 284 self.waitUntilSettled()
@@ -300,6 +308,15 @@ class TestGerritCRD(ZuulTestCase):
300 'project-merge', 'org/project1').changes 308 'project-merge', 'org/project1').changes
301 self.assertEqual(changes, '2,1 1,1') 309 self.assertEqual(changes, '2,1 1,1')
302 310
311 def test_crd_gate_reverse_schema0(self):
312 self._test_crd_gate_reverse(URL_FORMATS[0])
313
314 def test_crd_gate_reverse_schema1(self):
315 self._test_crd_gate_reverse(URL_FORMATS[1])
316
317 def test_crd_gate_reverse_schema2(self):
318 self._test_crd_gate_reverse(URL_FORMATS[2])
319
303 def test_crd_cycle(self): 320 def test_crd_cycle(self):
304 "Test cross-repo dependency cycles" 321 "Test cross-repo dependency cycles"
305 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') 322 A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
diff --git a/zuul/driver/gerrit/gerritconnection.py b/zuul/driver/gerrit/gerritconnection.py
index 63d1d3d..64f9308 100644
--- a/zuul/driver/gerrit/gerritconnection.py
+++ b/zuul/driver/gerrit/gerritconnection.py
@@ -558,6 +558,7 @@ class GerritConnection(BaseConnection):
558 change.uris = [ 558 change.uris = [
559 '%s/%s' % (baseurl, change.number), 559 '%s/%s' % (baseurl, change.number),
560 '%s/#/c/%s' % (baseurl, change.number), 560 '%s/#/c/%s' % (baseurl, change.number),
561 '%s/c/%s/+/%s' % (baseurl, change.project.name, change.number),
561 ] 562 ]
562 563
563 max_ps = 0 564 max_ps = 0