diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fixtures/layouts/job-dedup-noop.yaml | 55 | ||||
-rw-r--r-- | tests/unit/test_circular_dependencies.py | 36 |
2 files changed, 91 insertions, 0 deletions
diff --git a/tests/fixtures/layouts/job-dedup-noop.yaml b/tests/fixtures/layouts/job-dedup-noop.yaml new file mode 100644 index 000000000..9383fd8b6 --- /dev/null +++ b/tests/fixtures/layouts/job-dedup-noop.yaml @@ -0,0 +1,55 @@ +- queue: + name: integrated + allow-circular-dependencies: true + +- pipeline: + name: gate + manager: dependent + success-message: Build succeeded (gate). + require: + gerrit: + approval: + - Approved: 1 + trigger: + gerrit: + - event: comment-added + approval: + - Approved: 1 + success: + gerrit: + Verified: 2 + submit: true + failure: + gerrit: + Verified: -2 + start: + gerrit: + Verified: 0 + precedence: high + +- job: + name: base + parent: null + pre-run: playbooks/pre.yaml + run: playbooks/run.yaml + nodeset: + nodes: + - label: debian + name: controller + +- job: + name: common-job + required-projects: + - org/project1 + +- job: + name: project1-job + +- project: + name: org/project1 + queue: integrated + gate: + jobs: + - noop + - common-job + - project1-job diff --git a/tests/unit/test_circular_dependencies.py b/tests/unit/test_circular_dependencies.py index ac5ad13f5..d70293f17 100644 --- a/tests/unit/test_circular_dependencies.py +++ b/tests/unit/test_circular_dependencies.py @@ -1703,6 +1703,42 @@ class TestGerritCircularDependencies(ZuulTestCase): ], ordered=False) self.assertEqual(len(self.fake_nodepool.history), 3) + @simple_layout('layouts/job-dedup-noop.yaml') + def test_job_deduplication_noop(self): + # Test that we don't deduplicate noop (there's no good reason + # to do so) + A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') + B = self.fake_gerrit.addFakeChange('org/project1', 'master', 'B') + + # A <-> B + A.data["commitMessage"] = "{}\n\nDepends-On: {}\n".format( + A.subject, B.data["url"] + ) + B.data["commitMessage"] = "{}\n\nDepends-On: {}\n".format( + B.subject, A.data["url"] + ) + + A.addApproval('Code-Review', 2) + B.addApproval('Code-Review', 2) + + self.fake_gerrit.addEvent(A.addApproval('Approved', 1)) + self.fake_gerrit.addEvent(B.addApproval('Approved', 1)) + + self.waitUntilSettled() + + self.assertEqual(A.data['status'], 'MERGED') + self.assertEqual(B.data['status'], 'MERGED') + self.assertHistory([ + dict(name="project1-job", result="SUCCESS", changes="2,1 1,1"), + dict(name="common-job", result="SUCCESS", changes="2,1 1,1"), + ], ordered=False) + # It's tricky to get info about a noop build, but the jobs in + # the report have the build UUID, so we make sure it's + # different. + a_noop = [l for l in A.messages[-1].split('\n') if 'noop' in l][0] + b_noop = [l for l in B.messages[-1].split('\n') if 'noop' in l][0] + self.assertNotEqual(a_noop, b_noop) + @simple_layout('layouts/job-dedup-retry.yaml') def test_job_deduplication_retry(self): A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A') |