summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-02-05 18:49:44 +0000
committerGerrit Code Review <review@openstack.org>2019-02-05 18:49:44 +0000
commite1c0eb080d001aabc761ea15f8bb1a2ac30749e0 (patch)
tree0a36460f6e56b87597e1022fa6d9c57c6e953fb0
parent59be0ac518880dd060d6a9d4b777c6e4de6e00fd (diff)
parentb999b7c8621d43ff60153f92680289a370efda62 (diff)
Merge "Fix wedged scheduler on force-merge of non-existing template"
-rw-r--r--tests/fixtures/config/force-merge-template/git/common-config/playbooks/test.yaml2
-rw-r--r--tests/fixtures/config/force-merge-template/git/common-config/zuul.yaml35
-rw-r--r--tests/fixtures/config/force-merge-template/git/org_project/README1
-rw-r--r--tests/fixtures/config/force-merge-template/git/org_project/zuul.yaml7
-rw-r--r--tests/fixtures/config/force-merge-template/git/org_project2/README1
-rw-r--r--tests/fixtures/config/force-merge-template/git/org_project2/zuul.yaml4
-rw-r--r--tests/fixtures/config/force-merge-template/main.yaml17
-rw-r--r--tests/unit/test_v3.py44
-rw-r--r--zuul/manager/__init__.py7
9 files changed, 117 insertions, 1 deletions
diff --git a/tests/fixtures/config/force-merge-template/git/common-config/playbooks/test.yaml b/tests/fixtures/config/force-merge-template/git/common-config/playbooks/test.yaml
new file mode 100644
index 0000000..f679dce
--- /dev/null
+++ b/tests/fixtures/config/force-merge-template/git/common-config/playbooks/test.yaml
@@ -0,0 +1,2 @@
1- hosts: all
2 tasks: []
diff --git a/tests/fixtures/config/force-merge-template/git/common-config/zuul.yaml b/tests/fixtures/config/force-merge-template/git/common-config/zuul.yaml
new file mode 100644
index 0000000..27c5e5b
--- /dev/null
+++ b/tests/fixtures/config/force-merge-template/git/common-config/zuul.yaml
@@ -0,0 +1,35 @@
1- pipeline:
2 name: check
3 manager: independent
4 trigger:
5 gerrit:
6 - event: patchset-created
7 success:
8 gerrit:
9 Verified: 1
10 failure:
11 gerrit:
12 Verified: -1
13
14- pipeline:
15 name: post
16 manager: independent
17 trigger:
18 gerrit:
19 - event: ref-updated
20 ref: ^(?!refs/).*$
21 precedence: low
22
23
24- job:
25 name: base
26 parent: null
27
28- job:
29 name: post-job
30 run: playbooks/test.yaml
31
32- job:
33 name: other-job
34 run: playbooks/test.yaml
35
diff --git a/tests/fixtures/config/force-merge-template/git/org_project/README b/tests/fixtures/config/force-merge-template/git/org_project/README
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/fixtures/config/force-merge-template/git/org_project/README
@@ -0,0 +1 @@
test
diff --git a/tests/fixtures/config/force-merge-template/git/org_project/zuul.yaml b/tests/fixtures/config/force-merge-template/git/org_project/zuul.yaml
new file mode 100644
index 0000000..0d20a6d
--- /dev/null
+++ b/tests/fixtures/config/force-merge-template/git/org_project/zuul.yaml
@@ -0,0 +1,7 @@
1- project:
2 check:
3 jobs:
4 - noop
5 post:
6 jobs:
7 - post-job
diff --git a/tests/fixtures/config/force-merge-template/git/org_project2/README b/tests/fixtures/config/force-merge-template/git/org_project2/README
new file mode 100644
index 0000000..9daeafb
--- /dev/null
+++ b/tests/fixtures/config/force-merge-template/git/org_project2/README
@@ -0,0 +1 @@
test
diff --git a/tests/fixtures/config/force-merge-template/git/org_project2/zuul.yaml b/tests/fixtures/config/force-merge-template/git/org_project2/zuul.yaml
new file mode 100644
index 0000000..350c08c
--- /dev/null
+++ b/tests/fixtures/config/force-merge-template/git/org_project2/zuul.yaml
@@ -0,0 +1,4 @@
1- project:
2 check:
3 jobs:
4 - other-job
diff --git a/tests/fixtures/config/force-merge-template/main.yaml b/tests/fixtures/config/force-merge-template/main.yaml
new file mode 100644
index 0000000..7aed1a3
--- /dev/null
+++ b/tests/fixtures/config/force-merge-template/main.yaml
@@ -0,0 +1,17 @@
1- tenant:
2 name: tenant-one
3 source:
4 gerrit:
5 config-projects:
6 - common-config
7 untrusted-projects:
8 - org/project
9
10- tenant:
11 name: tenant-two
12 source:
13 gerrit:
14 config-projects:
15 - common-config
16 untrusted-projects:
17 - org/project2
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 4ae89fd..bd96fa9 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -5002,3 +5002,47 @@ class TestProvidesRequires(ZuulDBTestCase):
5002 ]) 5002 ])
5003 self.assertIn('image-user : SKIPPED', B.messages[0]) 5003 self.assertIn('image-user : SKIPPED', B.messages[0])
5004 self.assertIn('not met by build', B.messages[0]) 5004 self.assertIn('not met by build', B.messages[0])
5005
5006
5007class TestForceMergeMissingTemplate(ZuulTestCase):
5008 tenant_config_file = "config/force-merge-template/main.yaml"
5009
5010 def test_force_merge_missing_template(self):
5011 """
5012 Tests that force merging a change using a non-existent project
5013 template triggering a post job doesn't wedge zuul on reporting.
5014 """
5015
5016 # Create change that adds uses a non-existent project template
5017 conf = textwrap.dedent(
5018 """
5019 - project:
5020 templates:
5021 - non-existent
5022 check:
5023 jobs:
5024 - noop
5025 post:
5026 jobs:
5027 - post-job
5028 """)
5029
5030 file_dict = {'zuul.yaml': conf}
5031 A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
5032 files=file_dict)
5033
5034 # Now force merge the change
5035 A.setMerged()
5036 self.fake_gerrit.addEvent(A.getChangeMergedEvent())
5037 self.waitUntilSettled()
5038 self.fake_gerrit.addEvent(A.getRefUpdatedEvent())
5039 self.waitUntilSettled()
5040
5041 B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B')
5042 self.fake_gerrit.addEvent(B.getPatchsetCreatedEvent(1))
5043 self.waitUntilSettled()
5044
5045 self.assertEqual(B.reported, 1)
5046 self.assertHistory([
5047 dict(name='other-job', result='SUCCESS', changes='2,1'),
5048 ])
diff --git a/zuul/manager/__init__.py b/zuul/manager/__init__.py
index 326bbfd..416f3f1 100644
--- a/zuul/manager/__init__.py
+++ b/zuul/manager/__init__.py
@@ -912,7 +912,12 @@ class PipelineManager(object):
912 layout = (item.layout or self.pipeline.tenant.layout) 912 layout = (item.layout or self.pipeline.tenant.layout)
913 913
914 project_in_pipeline = True 914 project_in_pipeline = True
915 if not layout.getProjectPipelineConfig(item): 915 ppc = None
916 try:
917 ppc = layout.getProjectPipelineConfig(item)
918 except Exception:
919 self.log.exception("Invalid config for change %s" % item.change)
920 if not ppc:
916 self.log.debug("Project %s not in pipeline %s for change %s" % ( 921 self.log.debug("Project %s not in pipeline %s for change %s" % (
917 item.change.project, self.pipeline, item.change)) 922 item.change.project, self.pipeline, item.change))
918 project_in_pipeline = False 923 project_in_pipeline = False