Fix test_rerun_on_abort

Change I6d7d8d0f7e49a11e926667fbe772535ebdd35e89 erroneously altered
test_rerun_on_abort to match the observed behavior.

Change I6e64ef03cbb10ce858b22d6a4590f58ace0a5332 restored the values
in the test but then erroneously changed the accounting system to
match the observed behavior.

The actual problem is that this test also exercises the 'attempts' job
attribute, and does so by specifying it in a custom test configuration.
The test was failing because that attribute, which instructs zuul to
attempt to run a job for a non-default number of retries, was not being
read.

It was not being read because the test was still using the old configuration
loading scheme.  It updated the "layout_file" which isn't a thing anymore
and asked the scheduler to reload.  The scheduler *did* reload, but it
simply reloaded the same configuration.  The solution to this is to either
create a new configuration, or, in this case, since the additional
configuration needed is compatible with the configuration used by the tests
siblings, simply add it to the active config file for the test.

Once the test is loading the correct configuration, one can observe that
the 'attempts' attribute was not added to the validator.  That is corrected
in this change as well.

With all of this complete, the test passes in its original form and no
modifications to the job retry accounting system.

Change-Id: Icf6d697cbae0166bc516faf5b7e60cac05885ab0
This commit is contained in:
James E. Blair 2016-12-15 09:18:05 -08:00
parent 9b8d8079cd
commit 5aed111523
5 changed files with 3 additions and 34 deletions

View File

@ -65,6 +65,7 @@
- job:
name: project-test1
attempts: 4
nodes:
- name: controller
image: image1

View File

@ -1,30 +0,0 @@
pipelines:
- name: check
manager: IndependentPipelineManager
trigger:
gerrit:
- event: patchset-created
success:
gerrit:
verified: 1
failure:
gerrit:
verified: -1
- name: post
manager: IndependentPipelineManager
trigger:
gerrit:
- event: ref-updated
ref: ^(?!refs/).*$
jobs:
- name: project-test1
attempts: 4
projects:
- name: org/project
check:
- project-merge:
- project-test1
- project-test2

View File

@ -4535,9 +4535,6 @@ For CI problems and help debugging, contact ci@example.org"""
def test_rerun_on_abort(self):
"Test that if a launch server fails to run a job, it is run again"
self.config.set('zuul', 'layout_config',
'tests/fixtures/layout-abort-attempts.yaml')
self.sched.reconfigure(self.config)
self.launch_server.hold_jobs_in_build = True
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))

View File

@ -100,6 +100,7 @@ class JobParser(object):
'irrelevant-files': to_list(str),
'nodes': vs.Any([node], str),
'timeout': int,
'attempts': int,
'_source_project': model.Project,
'_source_branch': vs.Any(str, None),
}

View File

@ -666,7 +666,7 @@ class BuildSet(object):
def addBuild(self, build):
self.builds[build.job.name] = build
if build.job.name not in self.tries:
self.tries[build.job.name] = 0
self.tries[build.job.name] = 1
build.build_set = self
def removeBuild(self, build):