Fix bug that allowed failing jobs to pause
When a playbook requested a job pause in a playbook before a failing task in the same playbook Zuul would happily do so. With this fix the job can only be paused when the job is succeeding. Change-Id: I939efb73c84abf051d300be3b642525d15a08e2d
This commit is contained in:
parent
18026465d6
commit
4418547143
|
@ -0,0 +1 @@
|
|||
test
|
5
tests/fixtures/config/job-pause/git/org_project4/playbooks/after-compile.yaml
vendored
Normal file
5
tests/fixtures/config/job-pause/git/org_project4/playbooks/after-compile.yaml
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
- hosts: all
|
||||
tasks:
|
||||
- name: Good
|
||||
debug:
|
||||
msg: This shall not fail
|
12
tests/fixtures/config/job-pause/git/org_project4/playbooks/compile-fail.yaml
vendored
Normal file
12
tests/fixtures/config/job-pause/git/org_project4/playbooks/compile-fail.yaml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
- hosts: all
|
||||
tasks:
|
||||
- name: Pause and let child run
|
||||
zuul_return:
|
||||
data:
|
||||
zuul:
|
||||
pause: true
|
||||
|
||||
# Fail the playbook AFTER we have set zuul_return
|
||||
- name: Fail
|
||||
fail:
|
||||
msg: This shall fail
|
|
@ -0,0 +1,15 @@
|
|||
- job:
|
||||
name: compile-fail
|
||||
run: playbooks/compile-fail.yaml
|
||||
|
||||
- job:
|
||||
name: after-compile
|
||||
run: playbooks/after-compile.yaml
|
||||
|
||||
- project:
|
||||
check:
|
||||
jobs:
|
||||
- compile-fail
|
||||
- after-compile:
|
||||
dependencies:
|
||||
- compile-fail
|
|
@ -7,3 +7,4 @@
|
|||
- org/project
|
||||
- org/project2
|
||||
- org/project3
|
||||
- org/project4
|
||||
|
|
|
@ -5531,6 +5531,22 @@ class TestJobPause(AnsibleZuulTestCase):
|
|||
dict(name='test2-after-compile1', result='SUCCESS', changes='1,1'),
|
||||
], ordered=False)
|
||||
|
||||
def test_job_pause_fail(self):
|
||||
"""
|
||||
Test that only succeeding jobs are allowed to pause.
|
||||
|
||||
compile-fail
|
||||
+--> after-compile
|
||||
"""
|
||||
A = self.fake_gerrit.addFakeChange('org/project4', 'master', 'A')
|
||||
|
||||
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.assertHistory([
|
||||
dict(name='compile-fail', result='FAILURE', changes='1,1'),
|
||||
])
|
||||
|
||||
def test_job_node_failure_resume(self):
|
||||
self.wait_timeout = 120
|
||||
|
||||
|
|
|
@ -1418,7 +1418,7 @@ class AnsibleJob(object):
|
|||
# check if we need to pause here
|
||||
result_data = self.getResultData()
|
||||
pause = result_data.get('zuul', {}).get('pause')
|
||||
if pause:
|
||||
if success and pause:
|
||||
self.pause()
|
||||
if self.aborted:
|
||||
return 'ABORTED'
|
||||
|
|
Loading…
Reference in New Issue