Fix race in test for cancel of starting builds

Since the worker info required for canceling a build is now set in the
run handler when the BuildStartedEvent is processed, we need to also
wait for the worker info to be available.

Otherwise the event for the abandoned change might be processed before
the BuildStartedEvent, which will cause the test to fail.

Change-Id: I3128e97dfa5f40667ede274bd8718b1a0a5815a6
This commit is contained in:
Simon Westphahl 2021-05-04 13:03:46 +02:00
parent b83008b90c
commit bbee4d45b7
1 changed files with 7 additions and 1 deletions

View File

@ -2693,7 +2693,13 @@ class TestScheduler(ZuulTestCase):
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
for _ in iterate_timeout(30, 'Wait for build to be in starting phase'):
if self.executor_server.job_workers:
if not self.executor_server.job_workers:
continue
# Wait until the BuildStartedEvent was processed by the scheduler
# as we need the worker info in order to cancel a build.
builds = self.scheds.first.sched.executor.builds.values()
if all(b.worker.name != "Unknown" for b in builds):
break
# Abandon change to cancel build