Fix background layout updates in zuul-web
Change Ia0a524053a110e8e48f709d219651e2ad9c8513d updated the scheduler to more aggressively use the file cache, but did not make the corresponding updates to zuul-web. This means that configuration changes are not being reflected in the web UI until the service restarts. This corrects that and adds a test. Change-Id: Iebdf485105bd02e57fa0d3db5ba162308b640ca0
This commit is contained in:
1
tests/fixtures/config/empty-config/git/common-config/README
vendored
Normal file
1
tests/fixtures/config/empty-config/git/common-config/README
vendored
Normal file
@@ -0,0 +1 @@
|
||||
test
|
||||
52
tests/fixtures/config/empty-config/git/common-config/new-zuul.yaml
vendored
Normal file
52
tests/fixtures/config/empty-config/git/common-config/new-zuul.yaml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
- pipeline:
|
||||
name: check
|
||||
manager: independent
|
||||
trigger:
|
||||
gerrit:
|
||||
- event: patchset-created
|
||||
- event: comment-added
|
||||
comment: '^(Patch Set [0-9]+:\n\n)?(?i:recheck)$'
|
||||
success:
|
||||
gerrit:
|
||||
Verified: 1
|
||||
failure:
|
||||
gerrit:
|
||||
Verified: -1
|
||||
|
||||
- pipeline:
|
||||
name: gate
|
||||
manager: dependent
|
||||
success-message: Build succeeded (gate).
|
||||
trigger:
|
||||
gerrit:
|
||||
- event: comment-added
|
||||
approval:
|
||||
- Approved: 1
|
||||
success:
|
||||
gerrit:
|
||||
Verified: 2
|
||||
submit: true
|
||||
failure:
|
||||
gerrit:
|
||||
Verified: -2
|
||||
start:
|
||||
gerrit:
|
||||
Verified: 0
|
||||
precedence: high
|
||||
|
||||
- job:
|
||||
name: base
|
||||
parent: null
|
||||
|
||||
- job:
|
||||
name: test
|
||||
run: playbooks/run.yaml
|
||||
|
||||
- project:
|
||||
name: common-config
|
||||
check:
|
||||
jobs:
|
||||
- test
|
||||
gate:
|
||||
jobs:
|
||||
- test
|
||||
2
tests/fixtures/config/empty-config/git/common-config/playbooks/run.yaml
vendored
Normal file
2
tests/fixtures/config/empty-config/git/common-config/playbooks/run.yaml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
- hosts: all
|
||||
tasks: []
|
||||
1
tests/fixtures/config/empty-config/git/org_project/README
vendored
Normal file
1
tests/fixtures/config/empty-config/git/org_project/README
vendored
Normal file
@@ -0,0 +1 @@
|
||||
test
|
||||
8
tests/fixtures/config/empty-config/main.yaml
vendored
Normal file
8
tests/fixtures/config/empty-config/main.yaml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
- tenant:
|
||||
name: tenant-one
|
||||
source:
|
||||
gerrit:
|
||||
config-projects:
|
||||
- common-config
|
||||
untrusted-projects:
|
||||
- org/project
|
||||
@@ -1265,6 +1265,23 @@ class TestWebMultiTenant(BaseTestWeb):
|
||||
sorted(["tenant-one", "tenant-two", "tenant-four"]))
|
||||
|
||||
|
||||
class TestEmptyConfig(BaseTestWeb):
|
||||
tenant_config_file = 'config/empty-config/main.yaml'
|
||||
|
||||
def test_empty_config_startup(self):
|
||||
# Test that we can bootstrap a tenant with an empty config
|
||||
|
||||
resp = self.get_url("api/tenant/tenant-one/jobs").json()
|
||||
self.assertEqual(len(resp), 1)
|
||||
self.commitConfigUpdate(
|
||||
'common-config',
|
||||
'config/empty-config/git/common-config/new-zuul.yaml')
|
||||
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
|
||||
self.waitUntilSettled()
|
||||
resp = self.get_url("api/tenant/tenant-one/jobs").json()
|
||||
self.assertEqual(len(resp), 3)
|
||||
|
||||
|
||||
class TestWebSecrets(BaseTestWeb):
|
||||
tenant_config_file = 'config/secrets/main.yaml'
|
||||
|
||||
|
||||
@@ -2084,7 +2084,6 @@ class ZuulWeb(object):
|
||||
tenant_names = set(self.abide.tenants)
|
||||
tenant_names.update(self.unparsed_abide.tenants.keys())
|
||||
|
||||
min_ltimes = defaultdict(lambda: defaultdict(lambda: -1))
|
||||
for tenant_name in tenant_names:
|
||||
# Reload the tenant if the layout changed.
|
||||
if (self.local_layout_state.get(tenant_name)
|
||||
@@ -2096,11 +2095,15 @@ class ZuulWeb(object):
|
||||
layout_uuid = layout_state and layout_state.uuid
|
||||
|
||||
if layout_state:
|
||||
min_ltimes = self.tenant_layout_state.getMinLtimes(
|
||||
layout_state)
|
||||
branch_cache_min_ltimes = (
|
||||
layout_state.branch_cache_min_ltimes)
|
||||
else:
|
||||
# Consider all project branch caches valid if
|
||||
# we don't have a layout state.
|
||||
min_ltimes = defaultdict(
|
||||
lambda: defaultdict(lambda: -1))
|
||||
branch_cache_min_ltimes = defaultdict(lambda: -1)
|
||||
|
||||
# The tenant will be stored in self.abide.tenants after
|
||||
|
||||
Reference in New Issue
Block a user