diff options
author | James E. Blair <jim@acmegating.com> | 2023-01-04 15:28:38 -0800 |
---|---|---|
committer | James E. Blair <jim@acmegating.com> | 2023-01-04 15:33:49 -0800 |
commit | f82ef0882cbbbab468bf0b5551cdf91d715f0321 (patch) | |
tree | ea4d1b34dc103989f6cb0fb829c4450df7fc9343 /tests | |
parent | d1f34d506aaecd30b599391a05813b57ded1fee0 (diff) | |
download | zuul-f82ef0882cbbbab468bf0b5551cdf91d715f0321.tar.gz |
Further avoid unnecessary change dependency updates
When adding a unit test for change I4fd6c0d4cf2839010ddf7105a7db12da06ef1074
I noticed that we were still querying the dependent change 4 times instead of
the expected 2. This was due to an indentation error which caused all 3
query retry attempts to execute.
This change corrects that and adds a unit test that covers this as well as
the previous optimization.
Change-Id: I798d8d713b8303abcebc32d5f9ccad84bd4a28b0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fixtures/layouts/two-check.yaml | 47 | ||||
-rw-r--r-- | tests/unit/test_scheduler.py | 16 |
2 files changed, 63 insertions, 0 deletions
diff --git a/tests/fixtures/layouts/two-check.yaml b/tests/fixtures/layouts/two-check.yaml new file mode 100644 index 000000000..bc3e59818 --- /dev/null +++ b/tests/fixtures/layouts/two-check.yaml @@ -0,0 +1,47 @@ +- pipeline: + name: check1 + manager: independent + trigger: + gerrit: + - event: patchset-created + success: + gerrit: + Verified: 1 + failure: + gerrit: + Verified: -1 + +- pipeline: + name: check2 + manager: independent + trigger: + gerrit: + - event: patchset-created + success: + gerrit: + Verified: 1 + failure: + gerrit: + Verified: -1 + +- job: + name: base + parent: null + run: playbooks/base.yaml + nodeset: + nodes: + - label: ubuntu-xenial + name: controller + +- job: + name: check-job + run: playbooks/check.yaml + +- project: + name: org/project + check1: + jobs: + - check-job + check2: + jobs: + - check-job diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py index 6a0da1279..5c36e6621 100644 --- a/tests/unit/test_scheduler.py +++ b/tests/unit/test_scheduler.py @@ -3713,6 +3713,22 @@ class TestScheduler(ZuulTestCase): self.assertEqual(self.history[4].pipeline, 'check') self.assertEqual(self.history[5].pipeline, 'check') + @simple_layout('layouts/two-check.yaml') + def test_query_dependency_count(self): + # Test that we efficiently query dependent changes + A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A') + B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B') + B.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % ( + B.subject, A.data['url']) + self.fake_gerrit.addEvent(B.getPatchsetCreatedEvent(1)) + self.waitUntilSettled() + # 1. The query to find the change id + # from the Depends-On string "change:1" (simpleQuery) + # 2. The query to populate the change once we know the id + # (queryChange) + self.assertEqual(A.queried, 2) + self.assertEqual(B.queried, 1) + def test_reconfigure_merge(self): """Test that two reconfigure events are merged""" # Wrap the recofiguration handler so we can count how many |