From 12a92b18662c8be02416fbd7f5242c22db2aa69d Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Wed, 26 Mar 2014 11:54:53 -0700 Subject: [PATCH] Revert "Allow multiple invocations of the same job" This reverts commit 3aa372722546252f629ad996ce206ece5ab7e582. There are several more places in Zuul where it is assumed that job names are unique. Fixing them all would be complicated and perhaps not worth the benefit. Go back to requiring that they be unique for a project. Change-Id: I5b8aa33d6aed9cb086f44594ce59947c0190cc11 --- doc/source/zuul.rst | 4 ++-- tests/fixtures/layout.yaml | 5 ----- tests/test_scheduler.py | 9 ++------- zuul/model.py | 7 ++++--- zuul/scheduler.py | 9 ++++----- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst index 72743421f0..9649c8ec31 100644 --- a/doc/source/zuul.rst +++ b/doc/source/zuul.rst @@ -772,8 +772,8 @@ for the project. Note that if multiple templates are used for a project and one template specifies a job that is also specified in another template, -or specified in the project itself, those jobs will be duplicated in -the resulting project configuration. +or specified in the project itself, the configuration defined by +either the last template or the project itself will take priority. logging.conf ~~~~~~~~~~~~ diff --git a/tests/fixtures/layout.yaml b/tests/fixtures/layout.yaml index b1c94de0ce..b02c7829b7 100644 --- a/tests/fixtures/layout.yaml +++ b/tests/fixtures/layout.yaml @@ -117,9 +117,6 @@ project-templates: - name: test-five check: - '{name}-{something}-test5' - - name: test-five-also - check: - - '{name}-{something}-test5' projects: - name: org/project @@ -215,8 +212,6 @@ projects: - name: test-three-and-four - name: test-five something: foo - - name: test-five-also - something: foo check: - project-test6 diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py index 351854db5f..ee072f71d2 100755 --- a/tests/test_scheduler.py +++ b/tests/test_scheduler.py @@ -2061,13 +2061,8 @@ class TestScheduler(testtools.TestCase): ).result, 'SUCCESS') self.assertEqual(self.getJobFromHistory('layered-project-test4' ).result, 'SUCCESS') - # test5 should run twice because two templates define it - test5_count = 0 - for job in self.worker.build_history: - if job.name == 'layered-project-foo-test5': - test5_count += 1 - self.assertEqual(job.result, 'SUCCESS') - self.assertEqual(test5_count, 2) + self.assertEqual(self.getJobFromHistory('layered-project-foo-test5' + ).result, 'SUCCESS') self.assertEqual(self.getJobFromHistory('project-test6').result, 'SUCCESS') diff --git a/zuul/model.py b/zuul/model.py index 1a7c421c20..e5a82b7046 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -596,9 +596,10 @@ class JobTree(object): self.job_trees = [] def addJob(self, job): - t = JobTree(job) - self.job_trees.append(t) - return t + if job not in [x.job for x in self.job_trees]: + t = JobTree(job) + self.job_trees.append(t) + return t def getJobs(self): jobs = [] diff --git a/zuul/scheduler.py b/zuul/scheduler.py index 1a4474c233..3de35b0f02 100644 --- a/zuul/scheduler.py +++ b/zuul/scheduler.py @@ -384,11 +384,10 @@ class Scheduler(threading.Thread): config_project.update( {pipeline.name: expanded[pipeline.name] + config_project.get(pipeline.name, [])}) - # TODO: future enhancement -- add an option to the - # template block to indicate that duplicate jobs should be - # merged (especially to handle the case where they have - # children and you want all of the children to run after a - # single run of the parent). + # TODO: future enhancement -- handle the case where + # duplicate jobs have different children and you want all + # of the children to run after a single run of the + # parent). layout.projects[config_project['name']] = project mode = config_project.get('merge-mode', 'merge-resolve')