diff --git a/tests/fixtures/config/job-pause2/git/common-config/zuul.yaml b/tests/fixtures/config/job-pause2/git/common-config/zuul.yaml new file mode 100644 index 0000000000..a07342e2ec --- /dev/null +++ b/tests/fixtures/config/job-pause2/git/common-config/zuul.yaml @@ -0,0 +1,17 @@ +- pipeline: + name: check + manager: independent + post-review: true + trigger: + gerrit: + - event: patchset-created + success: + gerrit: + Verified: 1 + failure: + gerrit: + Verified: -1 + +- job: + name: base + parent: null diff --git a/tests/fixtures/config/job-pause2/git/org_project/README b/tests/fixtures/config/job-pause2/git/org_project/README new file mode 100644 index 0000000000..9daeafb986 --- /dev/null +++ b/tests/fixtures/config/job-pause2/git/org_project/README @@ -0,0 +1 @@ +test diff --git a/tests/fixtures/config/job-pause2/git/org_project/playbooks/compile-post.yaml b/tests/fixtures/config/job-pause2/git/org_project/playbooks/compile-post.yaml new file mode 100644 index 0000000000..f13b263dd3 --- /dev/null +++ b/tests/fixtures/config/job-pause2/git/org_project/playbooks/compile-post.yaml @@ -0,0 +1,4 @@ +- hosts: all + tasks: + - fail: + msg: Fail in post diff --git a/tests/fixtures/config/job-pause2/git/org_project/playbooks/compile.yaml b/tests/fixtures/config/job-pause2/git/org_project/playbooks/compile.yaml new file mode 100644 index 0000000000..9d6f2dae80 --- /dev/null +++ b/tests/fixtures/config/job-pause2/git/org_project/playbooks/compile.yaml @@ -0,0 +1,7 @@ +- hosts: all + tasks: + - name: Pause and let child run + zuul_return: + data: + zuul: + pause: true diff --git a/tests/fixtures/config/job-pause2/git/org_project/playbooks/test.yaml b/tests/fixtures/config/job-pause2/git/org_project/playbooks/test.yaml new file mode 100644 index 0000000000..f679dceaef --- /dev/null +++ b/tests/fixtures/config/job-pause2/git/org_project/playbooks/test.yaml @@ -0,0 +1,2 @@ +- hosts: all + tasks: [] diff --git a/tests/fixtures/config/job-pause2/git/org_project/zuul.yaml b/tests/fixtures/config/job-pause2/git/org_project/zuul.yaml new file mode 100644 index 0000000000..3b1044bfc9 --- /dev/null +++ b/tests/fixtures/config/job-pause2/git/org_project/zuul.yaml @@ -0,0 +1,16 @@ +- job: + name: compile + run: playbooks/compile.yaml + post-run: playbooks/compile-post.yaml + +- job: + name: test + run: playbooks/test.yaml + +- project: + check: + jobs: + - compile + - test: + dependencies: + - compile diff --git a/tests/fixtures/config/job-pause2/main.yaml b/tests/fixtures/config/job-pause2/main.yaml new file mode 100644 index 0000000000..a2130154fd --- /dev/null +++ b/tests/fixtures/config/job-pause2/main.yaml @@ -0,0 +1,7 @@ +- tenant: + name: tenant-one + source: + gerrit: + config-projects: + - common-config + - org/project diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py index 9c62652415..a30fc26b31 100644 --- a/tests/unit/test_v3.py +++ b/tests/unit/test_v3.py @@ -4592,6 +4592,15 @@ class TestJobPause(AnsibleZuulTestCase): return f.read() def test_job_pause(self): + """ + compile1 + +--> compile2 + | +--> test-after-compile2 + +--> test1-after-compile1 + +--> test2-after-compile1 + test-good + test-fail + """ self.wait_timeout = 120 @@ -4721,6 +4730,34 @@ class TestJobPause(AnsibleZuulTestCase): self.assertIn('test : SKIPPED', A.messages[0]) +class TestJobPausePostFail(AnsibleZuulTestCase): + tenant_config_file = 'config/job-pause2/main.yaml' + + def _get_file(self, build, path): + p = os.path.join(build.jobdir.root, path) + with open(p) as f: + return f.read() + + def test_job_pause_post_fail(self): + """Tests that a parent job which has a post failure does not + retroactively set its child job's result to SKIPPED. + + compile + +--> test + + """ + # Output extra ansible info so we might see errors. + A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A') + + self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) + self.waitUntilSettled() + + self.assertHistory([ + dict(name='test', result='SUCCESS', changes='1,1'), + dict(name='compile', result='POST_FAILURE', changes='1,1'), + ]) + + class TestContainerJobs(AnsibleZuulTestCase): tenant_config_file = "config/container-build-resources/main.yaml" diff --git a/zuul/model.py b/zuul/model.py index f0a8d485e3..a6f5be4bf4 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -2410,9 +2410,11 @@ class QueueItem(object): build.job.name) for job in skipped: - fakebuild = Build(job, None) - fakebuild.result = 'SKIPPED' - self.addBuild(fakebuild) + child_build = self.current_build_set.getBuild(job.name) + if not child_build: + fakebuild = Build(job, None) + fakebuild.result = 'SKIPPED' + self.addBuild(fakebuild) def setNodeRequestFailure(self, job): fakebuild = Build(job, None)