From 6ef4f078aa4466794834ac5a266296ec8e367c16 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 28 Apr 2020 15:43:12 -0700 Subject: [PATCH] Fix test_crd_check_unknown tests These tests have a race where we rely on input events for unknown projects in gerrit/github to populate our fake change and project databases for those event sources. Before our dependent change is able to be processed we need the parent change's event to be fully processed and populate the database. Without this we get database lookup errors which leads to us never running jobs for the dependent change. When that happens we are unable to properly assert the test conditions that the dependent change is tested without the parent change. Fix this by adding the parent change events, waiting for things to settle, then adding the child change events. Change-Id: I0641c44051d760c7be0f408f6b9b59222b8d4e90 --- tests/unit/test_cross_crd.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_cross_crd.py b/tests/unit/test_cross_crd.py index 70b370e812..f418d6f938 100644 --- a/tests/unit/test_cross_crd.py +++ b/tests/unit/test_cross_crd.py @@ -438,8 +438,12 @@ class TestGerritToGithubCRD(ZuulTestCase): A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % ( A.subject, B.url) - # Make sure zuul has seen an event on B. + # Make sure zuul has seen an event on B. This is necessary + # in order to populate our fake github project db. self.fake_github.emitEvent(B.getPullRequestEditedEvent()) + # Note we wait until settled here as the event processing for + # the next event may not have the updated db yet otherwise. + self.waitUntilSettled() self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) self.waitUntilSettled() @@ -900,6 +904,9 @@ class TestGithubToGerritCRD(ZuulTestCase): # Make sure zuul has seen an event on B. self.fake_gerrit.addEvent(B.getPatchsetCreatedEvent(1)) + # Note we wait until settled here as the event processing for + # the next event may not have the updated db yet otherwise. + self.waitUntilSettled() self.fake_github.emitEvent(A.getPullRequestEditedEvent()) self.waitUntilSettled()