Add a test for starting zuul-web after a branch is created

This is a mirror of test_cache_new_branch from the configloader
tests, but it starts zuul-web after creating a new branch instead
of starting zuul-scheduler.  This ensures that we have test
coverage of this branch-creation race condition for both components
which create layouts.

Change-Id: I0fbd9870be88c187fe1b2f26835d7663d68b28e7
This commit is contained in:
James E. Blair
2024-07-30 13:31:14 -07:00
parent a16b51e06a
commit 3efb931373

View File

@@ -32,7 +32,12 @@ from zuul.zk.locks import tenant_write_lock
import zuul.web
from tests.base import ZuulTestCase, AnsibleZuulTestCase
from tests.base import ZuulWebFixture, FIXTURE_DIR, iterate_timeout
from tests.base import (
FIXTURE_DIR,
ZuulWebFixture,
iterate_timeout,
okay_tracebacks,
)
from tests.base import simple_layout
@@ -1864,6 +1869,26 @@ class TestBrokenConfigCache(BaseWithWeb):
self.assertIn('Configuration files missing',
config_errors[0]['error'])
@okay_tracebacks('_cacheTenantYAMLBranch')
def test_web_cache_new_branch(self):
# This tests web startup right after a new branch is
# created.
first = self.scheds.first
lock1 = first.sched.layout_update_lock
lock2 = first.sched.run_handler_lock
with lock1, lock2:
self.create_branch('org/project1', 'stable')
self.fake_gerrit.addEvent(
self.fake_gerrit.getFakeBranchCreatedEvent(
'org/project1', 'stable'))
self.startWebServer()
# startWebServer will only return after the initial layout
# update, so if we're here, the test has already passed.
# Verify we have a layout for good measure.
tenant = self.web.web.abide.tenants.get('tenant-one')
self.assertIsNotNone(tenant)
self.waitUntilSettled()
class TestWebSocketInfo(TestInfo):