summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-07-27 21:14:13 +0000
committerGerrit Code Review <review@openstack.org>2022-07-27 21:14:13 +0000
commitba2f4b8eac744f14df5790fc96cc8c1aff1ab0ff (patch)
tree6fd3892e64b816e203408c436702bf6ba54fcf6a /tests
parent1636ecd23b5e647c16485372262aceef1f83277c (diff)
parentd039cc1258f06891a0e9ab61ca6f6d3d25145c1d (diff)
downloadzuul-ba2f4b8eac744f14df5790fc96cc8c1aff1ab0ff.tar.gz
Merge "Fix deduplicated build references"
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_circular_dependencies.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/unit/test_circular_dependencies.py b/tests/unit/test_circular_dependencies.py
index 202248d09..2223008d5 100644
--- a/tests/unit/test_circular_dependencies.py
+++ b/tests/unit/test_circular_dependencies.py
@@ -1770,6 +1770,48 @@ class TestGerritCircularDependencies(ZuulTestCase):
self.assertEqual(items[1].change.project.name, 'org/project1')
self.assertEqual(len(items[1].current_build_set.retry_builds), 1)
+ @simple_layout('layouts/job-dedup-auto-shared.yaml')
+ def test_job_deduplication_multi_scheduler(self):
+ # Test that a second scheduler can correctly refresh
+ # deduplicated builds
+ self.executor_server.hold_jobs_in_build = True
+ 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()
+
+ app = self.createScheduler()
+ app.start()
+ self.assertEqual(len(self.scheds), 2)
+
+ # Hold the lock on the first scheduler so that only the second
+ # will act.
+ with self.scheds.first.sched.run_handler_lock:
+ self.executor_server.hold_jobs_in_build = False
+ self.executor_server.release()
+ self.waitUntilSettled(matcher=[app])
+
+ 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)
+
@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