From 5aed111523ef902514f0e0dcfbc92b87c14518b2 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 15 Dec 2016 09:18:05 -0800 Subject: [PATCH] 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 --- .../single-tenant/git/common-config/zuul.yaml | 1 + tests/fixtures/layout-abort-attempts.yaml | 30 ------------------- tests/test_scheduler.py | 3 -- zuul/configloader.py | 1 + zuul/model.py | 2 +- 5 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 tests/fixtures/layout-abort-attempts.yaml diff --git a/tests/fixtures/config/single-tenant/git/common-config/zuul.yaml b/tests/fixtures/config/single-tenant/git/common-config/zuul.yaml index 8975fc46a3..e7296fc63b 100644 --- a/tests/fixtures/config/single-tenant/git/common-config/zuul.yaml +++ b/tests/fixtures/config/single-tenant/git/common-config/zuul.yaml @@ -65,6 +65,7 @@ - job: name: project-test1 + attempts: 4 nodes: - name: controller image: image1 diff --git a/tests/fixtures/layout-abort-attempts.yaml b/tests/fixtures/layout-abort-attempts.yaml deleted file mode 100644 index 86d9d783d9..0000000000 --- a/tests/fixtures/layout-abort-attempts.yaml +++ /dev/null @@ -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 diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py index 99f6311c3f..b9f6261d81 100755 --- a/tests/test_scheduler.py +++ b/tests/test_scheduler.py @@ -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)) diff --git a/zuul/configloader.py b/zuul/configloader.py index 3f85771460..a6d7cc732b 100644 --- a/zuul/configloader.py +++ b/zuul/configloader.py @@ -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), } diff --git a/zuul/model.py b/zuul/model.py index e90142d55c..6e0176fb72 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -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):