Browse Source

Don't set child jobs to skipped on post failure

Only create fake build objects for child jobs if there aren't real
ones.  This avoids a situation where a child job of a paused parent
completes, but then has its result retroactively changed to "SKIPPED"
after the parent encounters a post-run failure.

Change-Id: Ide180c0712434d9208ee053bdcf10af22fc3bfde
changes/54/638054/1
James E. Blair 2 years ago
parent
commit
abf7fe9767
9 changed files with 96 additions and 3 deletions
  1. +17
    -0
      tests/fixtures/config/job-pause2/git/common-config/zuul.yaml
  2. +1
    -0
      tests/fixtures/config/job-pause2/git/org_project/README
  3. +4
    -0
      tests/fixtures/config/job-pause2/git/org_project/playbooks/compile-post.yaml
  4. +7
    -0
      tests/fixtures/config/job-pause2/git/org_project/playbooks/compile.yaml
  5. +2
    -0
      tests/fixtures/config/job-pause2/git/org_project/playbooks/test.yaml
  6. +16
    -0
      tests/fixtures/config/job-pause2/git/org_project/zuul.yaml
  7. +7
    -0
      tests/fixtures/config/job-pause2/main.yaml
  8. +37
    -0
      tests/unit/test_v3.py
  9. +5
    -3
      zuul/model.py

+ 17
- 0
tests/fixtures/config/job-pause2/git/common-config/zuul.yaml View File

@ -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

+ 1
- 0
tests/fixtures/config/job-pause2/git/org_project/README View File

@ -0,0 +1 @@
test

+ 4
- 0
tests/fixtures/config/job-pause2/git/org_project/playbooks/compile-post.yaml View File

@ -0,0 +1,4 @@
- hosts: all
tasks:
- fail:
msg: Fail in post

+ 7
- 0
tests/fixtures/config/job-pause2/git/org_project/playbooks/compile.yaml View File

@ -0,0 +1,7 @@
- hosts: all
tasks:
- name: Pause and let child run
zuul_return:
data:
zuul:
pause: true

+ 2
- 0
tests/fixtures/config/job-pause2/git/org_project/playbooks/test.yaml View File

@ -0,0 +1,2 @@
- hosts: all
tasks: []

+ 16
- 0
tests/fixtures/config/job-pause2/git/org_project/zuul.yaml View File

@ -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

+ 7
- 0
tests/fixtures/config/job-pause2/main.yaml View File

@ -0,0 +1,7 @@
- tenant:
name: tenant-one
source:
gerrit:
config-projects:
- common-config
- org/project

+ 37
- 0
tests/unit/test_v3.py View File

@ -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"


+ 5
- 3
zuul/model.py View File

@ -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)


Loading…
Cancel
Save