From 111e27123c9e6141fdfdb93bd47d3f52ae01da35 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Mon, 29 Jul 2024 14:26:08 -0700 Subject: [PATCH] Fix test_crd_gate_unknown This test was missing some necessary setup, which caused an exception to be raised from the test fake during pipeline processing. The scenario is that change A depends on change B in a project that is unknown to Zuul. The result of the exception was nearly the correct behavior, in that change A did not run any jobs, but we do actually report an error message on change A indicating that the reason we ran no jobs is because we can't work with change B. By correcting the exception here, we now exercise the correct behavior in the test. Its assertions are updated to match. Change-Id: Ic98daaac830f75e612d8bf22cd2379f3807b8c2f --- tests/unit/test_cross_crd.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/unit/test_cross_crd.py b/tests/unit/test_cross_crd.py index 03cd996259..9766f94c1b 100644 --- a/tests/unit/test_cross_crd.py +++ b/tests/unit/test_cross_crd.py @@ -194,6 +194,9 @@ class TestGerritToGithubCRD(ZuulTestCase): def test_crd_gate_unknown(self): "Test unknown projects in dependent pipeline" self.init_repo("github/unknown", tag='init') + # We also need make the repo known to the fake github as a + # side-effect of getting the project. + self.fake_github.source.getProject("github/unknown") A = self.fake_gerrit.addFakeChange('gerrit/project1', 'master', 'A') B = self.fake_github.openFakePullRequest('github/unknown', 'master', 'B') @@ -207,13 +210,14 @@ class TestGerritToGithubCRD(ZuulTestCase): self.fake_gerrit.addEvent(A.addApproval('Approved', 1)) self.waitUntilSettled() - # Unknown projects cannot share a queue with any other - # since they don't have common jobs with any other (they have no jobs). - # Changes which depend on unknown project changes - # should not be processed in dependent pipeline + # Unknown projects cannot share a queue with any other since + # they don't have common jobs with any other (they have no + # jobs). Changes which depend on unknown project changes + # should only report an error. self.assertEqual(A.data['status'], 'NEW') self.assertFalse(B.is_merged) - self.assertEqual(A.reported, 0) + self.assertEqual(A.reported, 1) + self.assertIn("does not share a change queue", A.messages[-1]) self.assertEqual(len(B.comments), 0) self.assertEqual(len(self.history), 0) @@ -232,7 +236,7 @@ class TestGerritToGithubCRD(ZuulTestCase): self.waitUntilSettled() self.assertEqual(A.data['status'], 'MERGED') - self.assertEqual(A.reported, 2) + self.assertEqual(A.reported, 3) self.assertTrue(B.is_merged) self.assertEqual(len(B.comments), 0) @@ -437,6 +441,9 @@ class TestGerritToGithubCRD(ZuulTestCase): def test_crd_check_unknown(self): "Test unknown projects in independent pipeline" self.init_repo("github/unknown", tag='init') + # We also need make the repo known to the fake github as a + # side-effect of getting the project. + self.fake_github.source.getProject("github/unknown") A = self.fake_gerrit.addFakeChange('gerrit/project1', 'master', 'A') B = self.fake_github.openFakePullRequest( 'github/unknown', 'master', 'B')