Browse Source

Use scheduler manager consistently in tests

To improve consistency and remove `self.sched` and
use `self.scheds.first.sched` in all tests.

This change only touches tests.

Change-Id: I0a8c3f8ad634d1d88f3c68a11e4d5587993f4a0d
Story: 2007192
changes/42/709542/10
Jan Kubovy 1 year ago
parent
commit
7df5508dbd
13 changed files with 244 additions and 217 deletions
  1. +9
    -4
      tests/base.py
  2. +46
    -53
      tests/unit/test_configloader.py
  3. +2
    -2
      tests/unit/test_connection.py
  4. +6
    -6
      tests/unit/test_cross_crd.py
  5. +6
    -6
      tests/unit/test_gerrit_crd.py
  6. +5
    -5
      tests/unit/test_gerrit_legacy_crd.py
  7. +7
    -7
      tests/unit/test_git_driver.py
  8. +1
    -1
      tests/unit/test_github_crd.py
  9. +21
    -13
      tests/unit/test_github_driver.py
  10. +10
    -6
      tests/unit/test_pagure_driver.py
  11. +105
    -90
      tests/unit/test_scheduler.py
  12. +16
    -16
      tests/unit/test_v3.py
  13. +10
    -8
      tests/unit/test_zuultrigger.py

+ 9
- 4
tests/base.py View File

@ -3497,6 +3497,12 @@ class SchedulerTestManager:
def __iter__(self):
return iter(self.instances)
@property
def first(self) -> SchedulerTestApp:
if len(self.instances) == 0:
raise Exception("No scheduler!")
return self.instances[0]
def filter(self, matcher=None) -> Iterable[SchedulerTestApp]:
fcn = None # type: Optional[Callable[[int, SchedulerTestApp], bool]]
if type(matcher) == list:
@ -3703,7 +3709,6 @@ class ZuulTestCase(BaseTestCase):
self.scheds = SchedulerTestManager()
sched_app = self.scheds.create(
self.log, self.config, self.zk_config, self.connections)
self.sched = sched_app.sched
self.event_queues = sched_app.event_queues + self.event_queues
if hasattr(self, 'fake_github'):
@ -4099,7 +4104,7 @@ class ZuulTestCase(BaseTestCase):
self.assertNodepoolState()
self.assertNoGeneratedKeys()
ipm = zuul.manager.independent.IndependentPipelineManager
for tenant in self.sched.abide.tenants.values():
for tenant in self.scheds.first.sched.abide.tenants.values():
for pipeline in tenant.layout.pipelines.values():
if isinstance(pipeline.manager, ipm):
self.assertEqual(len(pipeline.queues), 0)
@ -4418,7 +4423,7 @@ class ZuulTestCase(BaseTestCase):
self.log.info("Completed build: %s" % build)
for build in self.builds:
self.log.info("Running build: %s" % build)
for tenant in self.sched.abide.tenants.values():
for tenant in self.scheds.first.sched.abide.tenants.values():
for pipeline in tenant.layout.pipelines.values():
for pipeline_queue in pipeline.queues:
if len(pipeline_queue.queue) != 0:
@ -4462,7 +4467,7 @@ class ZuulTestCase(BaseTestCase):
def assertEmptyQueues(self):
# Make sure there are no orphaned jobs
for tenant in self.sched.abide.tenants.values():
for tenant in self.scheds.first.sched.abide.tenants.values():
for pipeline in tenant.layout.pipelines.values():
for pipeline_queue in pipeline.queues:
if len(pipeline_queue.queue) != 0:


+ 46
- 53
tests/unit/test_configloader.py View File

@ -38,7 +38,7 @@ class TestTenantSimple(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/simple.yaml'
def test_tenant_simple(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(['common-config'],
[x.name for x in tenant.config_projects])
self.assertEqual(['org/project1', 'org/project2'],
@ -70,7 +70,7 @@ class TestTenantSimple(TenantParserTestCase):
project2_config[1].pipelines['check'].job_list.jobs)
def test_variant_description(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
job = tenant.layout.jobs.get("project2-job")
self.assertEqual(job[0].variant_description, "")
self.assertEqual(job[1].variant_description, "stable")
@ -80,7 +80,7 @@ class TestTenantOverride(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/override.yaml'
def test_tenant_override(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(['common-config'],
[x.name for x in tenant.config_projects])
self.assertEqual(['org/project1', 'org/project2', 'org/project4'],
@ -116,7 +116,7 @@ class TestTenantGroups(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/groups.yaml'
def test_tenant_groups(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(['common-config'],
[x.name for x in tenant.config_projects])
self.assertEqual(['org/project1', 'org/project2'],
@ -153,7 +153,7 @@ class TestTenantGroups2(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/groups2.yaml'
def test_tenant_groups2(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(['common-config'],
[x.name for x in tenant.config_projects])
self.assertEqual(['org/project1', 'org/project2', 'org/project3'],
@ -190,7 +190,7 @@ class TestTenantGroups3(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/groups3.yaml'
def test_tenant_groups3(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(False, tenant.exclude_unprotected_branches)
self.assertEqual(['common-config'],
[x.name for x in tenant.config_projects])
@ -226,7 +226,7 @@ class TestTenantGroups4(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/groups4.yaml'
def test_tenant_groups(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(['common-config'],
[x.name for x in tenant.config_projects])
self.assertEqual(['org/project1', 'org/project2'],
@ -255,7 +255,7 @@ class TestTenantGroups4(TenantParserTestCase):
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
new_layout = tenant.layout
self.assertEqual(old_layout, new_layout)
@ -265,7 +265,7 @@ class TestTenantGroups5(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/groups5.yaml'
def test_tenant_single_projet_exclude(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(['common-config'],
[x.name for x in tenant.config_projects])
self.assertEqual(['org/project1'],
@ -296,7 +296,7 @@ class TestTenantUnprotectedBranches(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/unprotected-branches.yaml'
def test_tenant_unprotected_branches(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(True, tenant.exclude_unprotected_branches)
self.assertEqual(['common-config'],
@ -325,7 +325,7 @@ class TestTenantExcludeAll(TenantParserTestCase):
"""
# The config in org/project5 depends on config in org/project1 so
# validate that there are no config errors in that tenant.
tenant_two = self.sched.abide.tenants.get('tenant-two')
tenant_two = self.scheds.first.sched.abide.tenants.get('tenant-two')
self.assertEquals(
len(tenant_two.layout.loading_errors), 0,
"No error should have been accumulated")
@ -335,7 +335,7 @@ class TestTenantConfigBranches(ZuulTestCase):
tenant_config_file = 'config/tenant-parser/simple.yaml'
def _validate_job(self, job, branch):
tenant_one = self.sched.abide.tenants.get('tenant-one')
tenant_one = self.scheds.first.sched.abide.tenants.get('tenant-one')
jobs = tenant_one.layout.getJobs(job)
self.assertEquals(len(jobs), 1)
self.assertIn(jobs[0].source_context.branch, branch)
@ -353,14 +353,14 @@ class TestTenantConfigBranches(ZuulTestCase):
self.create_branch('common-config', 'stable')
self.create_branch('common-config', 'feat_x')
self.sched.reconfigure(self.config)
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
# Job must be defined in master
self._validate_job(common_job, 'master')
# Reconfigure with load-branch stable for common-config
self.newTenantConfig('config/tenant-parser/branch.yaml')
self.sched.reconfigure(self.config)
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
# Now job must be defined on stable branch
self._validate_job(common_job, 'stable')
@ -370,7 +370,7 @@ class TestSplitConfig(ZuulTestCase):
tenant_config_file = 'config/split-config/main.yaml'
def test_split_config(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertIn('project-test1', tenant.layout.jobs)
self.assertIn('project-test2', tenant.layout.jobs)
test1 = tenant.layout.getJob('project-test1')
@ -445,7 +445,7 @@ class TestConfigConflict(ZuulTestCase):
tenant_config_file = 'config/conflict-config/main.yaml'
def test_conflict_config(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
jobs = sorted(tenant.layout.jobs.keys())
self.assertEqual(
['base', 'noop', 'trusted-zuul.yaml-job',
@ -457,9 +457,11 @@ class TestAuthorizationRuleParser(ZuulTestCase):
tenant_config_file = 'config/tenant-parser/authorizations.yaml'
def test_rules_are_loaded(self):
rules = self.sched.abide.admin_rules
self.assertTrue('auth-rule-one' in rules, self.sched.abide)
self.assertTrue('auth-rule-two' in rules, self.sched.abide)
rules = self.scheds.first.sched.abide.admin_rules
self.assertTrue('auth-rule-one' in rules,
self.scheds.first.sched.abide)
self.assertTrue('auth-rule-two' in rules,
self.scheds.first.sched.abide)
claims_1 = {'sub': 'venkman'}
claims_2 = {'sub': 'gozer',
'iss': 'another_dimension'}
@ -591,39 +593,32 @@ class TestAuthorizationRuleParserWithTemplating(ZuulTestCase):
tenant_config_file = 'config/tenant-parser/authorizations-templating.yaml'
def test_rules_are_loaded(self):
rules = self.sched.abide.admin_rules
self.assertTrue('tenant-admin' in rules, self.sched.abide)
self.assertTrue('tenant-admin-complex' in rules, self.sched.abide)
rules = self.scheds.first.sched.abide.admin_rules
self.assertTrue('tenant-admin' in rules, self.scheds.first.sched.abide)
self.assertTrue('tenant-admin-complex' in rules,
self.scheds.first.sched.abide)
def test_tenant_substitution(self):
claims_1 = {'group': 'tenant-one-admin'}
claims_2 = {'group': 'tenant-two-admin'}
rules = self.sched.abide.admin_rules
tenant_one = self.sched.abide.tenants.get('tenant-one')
tenant_two = self.sched.abide.tenants.get('tenant-two')
self.assertTrue(rules['tenant-admin'](claims_1,
tenant_one))
self.assertTrue(rules['tenant-admin'](claims_2,
tenant_two))
self.assertTrue(not rules['tenant-admin'](claims_1,
tenant_two))
self.assertTrue(not rules['tenant-admin'](claims_2,
tenant_one))
rules = self.scheds.first.sched.abide.admin_rules
tenant_one = self.scheds.first.sched.abide.tenants.get('tenant-one')
tenant_two = self.scheds.first.sched.abide.tenants.get('tenant-two')
self.assertTrue(rules['tenant-admin'](claims_1, tenant_one))
self.assertTrue(rules['tenant-admin'](claims_2, tenant_two))
self.assertTrue(not rules['tenant-admin'](claims_1, tenant_two))
self.assertTrue(not rules['tenant-admin'](claims_2, tenant_one))
def test_tenant_substitution_in_list(self):
claims_1 = {'group': ['tenant-one-admin', 'some-other-tenant']}
claims_2 = {'group': ['tenant-two-admin', 'some-other-tenant']}
rules = self.sched.abide.admin_rules
tenant_one = self.sched.abide.tenants.get('tenant-one')
tenant_two = self.sched.abide.tenants.get('tenant-two')
self.assertTrue(rules['tenant-admin'](claims_1,
tenant_one))
self.assertTrue(rules['tenant-admin'](claims_2,
tenant_two))
self.assertTrue(not rules['tenant-admin'](claims_1,
tenant_two))
self.assertTrue(not rules['tenant-admin'](claims_2,
tenant_one))
rules = self.scheds.first.sched.abide.admin_rules
tenant_one = self.scheds.first.sched.abide.tenants.get('tenant-one')
tenant_two = self.scheds.first.sched.abide.tenants.get('tenant-two')
self.assertTrue(rules['tenant-admin'](claims_1, tenant_one))
self.assertTrue(rules['tenant-admin'](claims_2, tenant_two))
self.assertTrue(not rules['tenant-admin'](claims_1, tenant_two))
self.assertTrue(not rules['tenant-admin'](claims_2, tenant_one))
def test_tenant_substitution_in_dict(self):
claims_2 = {
@ -633,21 +628,19 @@ class TestAuthorizationRuleParserWithTemplating(ZuulTestCase):
}
}
}
rules = self.sched.abide.admin_rules
tenant_one = self.sched.abide.tenants.get('tenant-one')
tenant_two = self.sched.abide.tenants.get('tenant-two')
self.assertTrue(
not rules['tenant-admin-complex'](claims_2,
tenant_one))
self.assertTrue(
rules['tenant-admin-complex'](claims_2, tenant_two))
rules = self.scheds.first.sched.abide.admin_rules
tenant_one = self.scheds.first.sched.abide.tenants.get('tenant-one')
tenant_two = self.scheds.first.sched.abide.tenants.get('tenant-two')
self.assertTrue(not rules['tenant-admin-complex'](claims_2,
tenant_one))
self.assertTrue(rules['tenant-admin-complex'](claims_2, tenant_two))
class TestTenantExtra(TenantParserTestCase):
tenant_config_file = 'config/tenant-parser/extra.yaml'
def test_tenant_extra(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertTrue('project2-extra-file' in tenant.layout.jobs)
self.assertTrue('project2-extra-dir' in tenant.layout.jobs)


+ 2
- 2
tests/unit/test_connection.py View File

@ -122,7 +122,7 @@ class TestSQLConnection(ZuulDBTestCase):
def check_results(connection_name):
# Grab the sa tables
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
reporter = _get_reporter_from_connection_name(
tenant.layout.pipelines['check'].success_actions,
connection_name
@ -241,7 +241,7 @@ class TestSQLConnection(ZuulDBTestCase):
def check_results(connection_name_1, connection_name_2):
# Grab the sa tables for resultsdb
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
reporter1 = _get_reporter_from_connection_name(
tenant.layout.pipelines['check'].success_actions,
connection_name_1


+ 6
- 6
tests/unit/test_cross_crd.py View File

@ -274,7 +274,7 @@ class TestGerritToGithubCRD(ZuulTestCase):
self.assertEqual(changes, '1,%s 1,1' %
(B.head_sha,))
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
def test_crd_check_duplicate(self):
@ -288,7 +288,7 @@ class TestGerritToGithubCRD(ZuulTestCase):
# A Depends-On: B
A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
A.subject, B.url)
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
# Add two dependent changes...
@ -350,7 +350,7 @@ class TestGerritToGithubCRD(ZuulTestCase):
# Make sure the items still share a change queue, and the
# first one is not live.
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 1)
queue = tenant.layout.pipelines['check'].queues[0]
first_item = queue.queue[0]
@ -725,7 +725,7 @@ class TestGithubToGerritCRD(ZuulTestCase):
self.assertEqual(changes, '1,1 1,%s' %
(A.head_sha,))
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
def test_crd_check_duplicate(self):
@ -738,7 +738,7 @@ class TestGithubToGerritCRD(ZuulTestCase):
# A Depends-On: B
A.editBody('Depends-On: %s\n' % (B.data['url'],))
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
# Add two dependent changes...
@ -799,7 +799,7 @@ class TestGithubToGerritCRD(ZuulTestCase):
# Make sure the items still share a change queue, and the
# first one is not live.
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 1)
queue = tenant.layout.pipelines['check'].queues[0]
first_item = queue.queue[0]


+ 6
- 6
tests/unit/test_gerrit_crd.py View File

@ -425,7 +425,7 @@ class TestGerritCRD(ZuulTestCase):
self.assertEqual(B.reported, 0)
self.assertEqual(self.history[0].changes, '2,1 1,1')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
def test_crd_check_git_depends(self):
@ -453,7 +453,7 @@ class TestGerritCRD(ZuulTestCase):
self.assertEqual(self.history[0].changes, '1,1')
self.assertEqual(self.history[-1].changes, '1,1 2,1')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
self.assertIn('Build succeeded', A.messages[0])
@ -464,7 +464,7 @@ class TestGerritCRD(ZuulTestCase):
self.executor_server.hold_jobs_in_build = True
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
B = self.fake_gerrit.addFakeChange('org/project1', 'master', 'B')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
# Add two git-dependent changes...
@ -520,7 +520,7 @@ class TestGerritCRD(ZuulTestCase):
# Make sure the items still share a change queue, and the
# first one is not live.
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 1)
queue = tenant.layout.pipelines['check'].queues[0]
first_item = queue.queue[0]
@ -573,7 +573,7 @@ class TestGerritCRD(ZuulTestCase):
# Make sure none of the items share a change queue, and all
# are live.
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
self.assertEqual(len(check_pipeline.queues), 3)
self.assertEqual(len(check_pipeline.getAllItems()), 3)
@ -767,7 +767,7 @@ class TestGerritCRDAltBaseUrl(ZuulTestCase):
self.assertEqual(B.reported, 0)
self.assertEqual(self.history[0].changes, '2,1 1,1')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)


+ 5
- 5
tests/unit/test_gerrit_legacy_crd.py View File

@ -354,7 +354,7 @@ class TestGerritLegacyCRD(ZuulTestCase):
self.assertEqual(B.reported, 0)
self.assertEqual(self.history[0].changes, '2,1 1,1')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
def test_crd_check_git_depends(self):
@ -382,7 +382,7 @@ class TestGerritLegacyCRD(ZuulTestCase):
self.assertEqual(self.history[0].changes, '1,1')
self.assertEqual(self.history[-1].changes, '1,1 2,1')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
self.assertIn('Build succeeded', A.messages[0])
@ -393,7 +393,7 @@ class TestGerritLegacyCRD(ZuulTestCase):
self.executor_server.hold_jobs_in_build = True
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
B = self.fake_gerrit.addFakeChange('org/project1', 'master', 'B')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
# Add two git-dependent changes...
@ -449,7 +449,7 @@ class TestGerritLegacyCRD(ZuulTestCase):
# Make sure the items still share a change queue, and the
# first one is not live.
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 1)
queue = tenant.layout.pipelines['check'].queues[0]
first_item = queue.queue[0]
@ -502,7 +502,7 @@ class TestGerritLegacyCRD(ZuulTestCase):
# Make sure none of the items share a change queue, and all
# are live.
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
self.assertEqual(len(check_pipeline.queues), 3)
self.assertEqual(len(check_pipeline.getAllItems()), 3)


+ 7
- 7
tests/unit/test_git_driver.py View File

@ -26,8 +26,8 @@ class TestGitDriver(ZuulTestCase):
def setUp(self):
super(TestGitDriver, self).setUp()
self.git_connection = self.sched.connections.getSource('git').\
connection
self.git_connection = self.scheds.first.sched.connections\
.getSource('git').connection
def setup_config(self, config_file: str):
config = super(TestGitDriver, self).setup_config(config_file)
@ -35,7 +35,7 @@ class TestGitDriver(ZuulTestCase):
return config
def test_basic(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
# Check that we have the git source for common-config and the
# gerrit source for the project.
self.assertEqual('git', tenant.config_projects[0].source.name)
@ -91,8 +91,8 @@ class TestGitDriver(ZuulTestCase):
# Let's stop the git Watcher to let us merge some changes commits
# We want to verify that config changes are detected for commits
# on the range oldrev..newrev
self.sched.connections.getSource('git').connection.\
watcher_thread._pause = True
self.scheds.first.sched.connections.getSource('git').connection\
.watcher_thread._pause = True
# Add a config change
change = {
'name': 'org/project',
@ -114,8 +114,8 @@ class TestGitDriver(ZuulTestCase):
'common-config', 'Adding f2',
{'f2': "Content"})
# Restart the git watcher
self.sched.connections.getSource('git').connection.\
watcher_thread._pause = False
self.scheds.first.sched.connections.getSource('git').connection\
.watcher_thread._pause = False
# Wait for the tenant reconfiguration to happen
self.waitForEvent(count)


+ 1
- 1
tests/unit/test_github_crd.py View File

@ -48,7 +48,7 @@ class TestGithubCrossRepoDeps(ZuulTestCase):
B.head_sha))
# There should be no more changes in the queue
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
@simple_layout('layouts/crd-github.yaml', driver='github')


+ 21
- 13
tests/unit/test_github_driver.py View File

@ -397,7 +397,7 @@ class TestGithubDriver(ZuulTestCase):
@simple_layout('layouts/basic-github.yaml', driver='github')
def test_git_https_url(self):
"""Test that git_ssh option gives git url with ssh"""
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
_, project = tenant.getProject('org/project')
url = self.fake_github.real_getGitUrl(project)
@ -406,7 +406,7 @@ class TestGithubDriver(ZuulTestCase):
@simple_layout('layouts/basic-github.yaml', driver='github')
def test_git_ssh_url(self):
"""Test that git_ssh option gives git url with ssh"""
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
_, project = tenant.getProject('org/project')
url = self.fake_github_ssh.real_getGitUrl(project)
@ -415,7 +415,7 @@ class TestGithubDriver(ZuulTestCase):
@simple_layout('layouts/basic-github.yaml', driver='github')
def test_git_enterprise_url(self):
"""Test that git_url option gives git url with proper host"""
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
_, project = tenant.getProject('org/project')
url = self.fake_github_ent.real_getGitUrl(project)
@ -898,7 +898,8 @@ class TestGithubDriver(ZuulTestCase):
modified_files=modified_files)
# record previous tenant reconfiguration time, which may not be set
old = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
old = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
self.waitUntilSettled()
if expected_cat_jobs is not None:
@ -908,7 +909,8 @@ class TestGithubDriver(ZuulTestCase):
self.fake_github.emitEvent(pevent)
self.waitUntilSettled()
new = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
new = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
if expect_reconfigure:
# New timestamp should be greater than the old timestamp
@ -1086,7 +1088,7 @@ class TestGithubDriver(ZuulTestCase):
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
self.assertEqual(check_pipeline.getAllItems(), [])
self.assertEqual(self.countJobResults(self.history, 'ABORTED'), 2)
@ -1222,7 +1224,8 @@ class TestGithubUnprotectedBranches(ZuulTestCase):
tenant_config_file = 'config/unprotected-branches/main.yaml'
def test_unprotected_branches(self):
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants\
.get('tenant-one')
project1 = tenant.untrusted_projects[0]
project2 = tenant.untrusted_projects[1]
@ -1243,7 +1246,7 @@ class TestGithubUnprotectedBranches(ZuulTestCase):
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
tpc1 = tenant.project_configs[project1.canonical_name]
tpc2 = tenant.project_configs[project2.canonical_name]
@ -1338,12 +1341,14 @@ class TestGithubUnprotectedBranches(ZuulTestCase):
modified_files=['zuul.yaml'])
# record previous tenant reconfiguration time, which may not be set
old = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
old = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
self.waitUntilSettled()
self.fake_github.emitEvent(pevent)
self.waitUntilSettled()
new = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
new = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
# We don't expect a reconfiguration because the push was to an
# unprotected branch
@ -1356,7 +1361,8 @@ class TestGithubUnprotectedBranches(ZuulTestCase):
self.fake_github.emitEvent(pevent)
self.waitUntilSettled()
new = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
new = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
# We now expect that zuul reconfigured itself
self.assertLess(old, new)
@ -1380,7 +1386,8 @@ class TestGithubUnprotectedBranches(ZuulTestCase):
self.waitUntilSettled()
# record previous tenant reconfiguration time, which may not be set
old = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
old = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
self.waitUntilSettled()
# Delete the branch
@ -1393,7 +1400,8 @@ class TestGithubUnprotectedBranches(ZuulTestCase):
self.fake_github.emitEvent(pevent)
self.waitUntilSettled()
new = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
new = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
# We now expect that zuul reconfigured itself as we deleted a protected
# branch


+ 10
- 6
tests/unit/test_pagure_driver.py View File

@ -214,10 +214,12 @@ class TestPagureDriver(ZuulTestCase):
newrev = repo.commit('refs/heads/stable-1.0').hexsha
event = self.fake_pagure.getGitBranchEvent(
'org/project', 'stable-1.0', 'creation', newrev)
old = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
old = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
self.fake_pagure.emitEvent(event)
self.waitUntilSettled()
new = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
new = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
# New timestamp should be greater than the old timestamp
self.assertLess(old, new)
self.assertEqual(1, len(self.history))
@ -245,7 +247,8 @@ class TestPagureDriver(ZuulTestCase):
def test_ref_updated_and_tenant_reconfigure(self):
self.waitUntilSettled()
old = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
old = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
zuul_yaml = [
{'job': {
@ -271,7 +274,8 @@ class TestPagureDriver(ZuulTestCase):
self.fake_pagure.emitEvent(event)
self.waitUntilSettled()
new = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
new = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
# New timestamp should be greater than the old timestamp
self.assertLess(old, new)
@ -325,7 +329,7 @@ class TestPagureDriver(ZuulTestCase):
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
self.assertEqual(check_pipeline.getAllItems(), [])
self.assertEqual(self.countJobResults(self.history, 'ABORTED'), 2)
@ -587,7 +591,7 @@ class TestPagureDriver(ZuulTestCase):
B.commit_stop))
# There should be no more changes in the queue
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
@simple_layout('layouts/crd-pagure.yaml', driver='pagure')


+ 105
- 90
tests/unit/test_scheduler.py View File

@ -26,6 +26,7 @@ from kazoo.exceptions import NoNodeError
import git
import testtools
from zuul.scheduler import Scheduler
import zuul.change_matcher
from zuul.driver.gerrit import gerritreporter
@ -797,7 +798,7 @@ class TestScheduler(ZuulTestCase):
# project-test1 and project-test2 for C
self.assertEqual(len(self.builds), 5)
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
items = tenant.layout.pipelines['gate'].getAllItems()
builds = items[0].current_build_set.getBuilds()
self.assertEqual(self.countJobResults(builds, 'SUCCESS'), 1)
@ -908,7 +909,8 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
time.sleep(2)
data = json.loads(self.sched.formatStatusJSON('tenant-one'))
data = json.loads(self.scheds.first.sched
.formatStatusJSON('tenant-one'))
found_job = None
for pipeline in data['pipelines']:
if pipeline['name'] != 'gate':
@ -1224,7 +1226,7 @@ class TestScheduler(ZuulTestCase):
"Test whether a change is ready to merge"
# TODO: move to test_gerrit (this is a unit test!)
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
(trusted, project) = tenant.getProject('org/project')
source = project.source
@ -2137,10 +2139,10 @@ class TestScheduler(ZuulTestCase):
@simple_layout('layouts/autohold.yaml')
def test_autohold_request_expiration(self):
orig_exp = self.sched.EXPIRED_HOLD_REQUEST_TTL
orig_exp = Scheduler.EXPIRED_HOLD_REQUEST_TTL
def reset_exp():
self.sched.EXPIRED_HOLD_REQUEST_TTL = orig_exp
self.scheds.first.sched.EXPIRED_HOLD_REQUEST_TTL = orig_exp
self.addCleanup(reset_exp)
@ -2171,7 +2173,7 @@ class TestScheduler(ZuulTestCase):
# Temporarily shorten hold time so that the hold request can be
# auto-deleted (which is done on another test failure). And wait
# long enough for nodes to expire and request to delete.
self.sched.EXPIRED_HOLD_REQUEST_TTL = 1
self.scheds.first.sched.EXPIRED_HOLD_REQUEST_TTL = 1
time.sleep(3)
B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
@ -2317,7 +2319,7 @@ class TestScheduler(ZuulTestCase):
"Test that the merger works with large changes after a repack"
# https://bugs.executepad.net/zuul/+bug/1078946
# This test assumes the repo is already cloned; make sure it is
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
trusted, project = tenant.getProject('org/project')
url = self.fake_gerrit.getGitUrl(project)
self.executor_server.merger._addProject('review.example.com',
@ -2399,7 +2401,7 @@ class TestScheduler(ZuulTestCase):
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
# Add two git-dependent changes
@ -2520,7 +2522,7 @@ class TestScheduler(ZuulTestCase):
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
# Add two git-dependent changes
@ -2746,7 +2748,7 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
self.assertEqual(len(self.gearman_server.getQueue()), 0)
self.assertTrue(self.sched._areAllBuildsComplete())
self.assertTrue(self.scheds.first.sched._areAllBuildsComplete())
self.assertEqual(len(self.history), 0)
self.assertEqual(A.data['status'], 'MERGED')
self.assertEqual(A.reported, 2)
@ -2763,7 +2765,7 @@ class TestScheduler(ZuulTestCase):
self.assertEqual(A.reported, False)
# Check queue is empty afterwards
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
items = check_pipeline.getAllItems()
self.assertEqual(len(items), 0)
@ -2859,7 +2861,7 @@ class TestScheduler(ZuulTestCase):
def test_statsd(self):
"Test each of the statsd methods used in the scheduler"
statsd = self.sched.statsd
statsd = self.scheds.first.sched.statsd
statsd.incr('test-incr')
statsd.timing('test-timing', 3)
statsd.gauge('test-gauge', 12)
@ -2878,7 +2880,7 @@ class TestScheduler(ZuulTestCase):
self.assertReportedStat('hostname-gauge.1_2_3_4.1_2', '12', 'g')
def test_statsd_conflict(self):
statsd = self.sched.statsd
statsd = self.scheds.first.sched.statsd
statsd.gauge('test-gauge', 12)
# since test-gauge is already a value, we can't make
# subvalues. Test the assert works.
@ -2907,7 +2909,7 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
# asserting that project-merge is removed from queue
self.assertEqual(len(self.gearman_server.getQueue()), 0)
self.assertTrue(self.sched._areAllBuildsComplete())
self.assertTrue(self.scheds.first.sched._areAllBuildsComplete())
self.assertEqual(len(self.history), 1)
self.assertEqual(self.history[0].name, 'gate-noop')
@ -3149,7 +3151,7 @@ class TestScheduler(ZuulTestCase):
def test_queue_names(self):
"Test shared change queue names"
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
(trusted, project1) = tenant.getProject('org/project1')
(trusted, project2) = tenant.getProject('org/project2')
q1 = tenant.layout.pipelines['gate'].getQueue(project1)
@ -3160,7 +3162,7 @@ class TestScheduler(ZuulTestCase):
@simple_layout("layouts/template-queue.yaml")
def test_template_queue(self):
"Test a shared queue can be constructed from a project-template"
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
(trusted, project1) = tenant.getProject('org/project1')
(trusted, project2) = tenant.getProject('org/project2')
q1 = tenant.layout.pipelines['gate'].getQueue(project1)
@ -3171,7 +3173,7 @@ class TestScheduler(ZuulTestCase):
@simple_layout("layouts/regex-template-queue.yaml")
def test_regex_template_queue(self):
"Test a shared queue can be constructed from a regex project-template"
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
(trusted, project1) = tenant.getProject('org/project1')
(trusted, project2) = tenant.getProject('org/project2')
q1 = tenant.layout.pipelines['gate'].getQueue(project1)
@ -3182,7 +3184,7 @@ class TestScheduler(ZuulTestCase):
@simple_layout("layouts/regex-queue.yaml")
def test_regex_queue(self):
"Test a shared queue can be constructed from a regex project"
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
(trusted, project1) = tenant.getProject('org/project1')
(trusted, project2) = tenant.getProject('org/project2')
q1 = tenant.layout.pipelines['gate'].getQueue(project1)
@ -3221,24 +3223,28 @@ class TestScheduler(ZuulTestCase):
def test_reconfigure_merge(self):
"""Test that two reconfigure events are merged"""
tenant = self.sched.abide.tenants['tenant-one']
tenant = self.scheds.first.sched.abide.tenants['tenant-one']
(trusted, project) = tenant.getProject('org/project')
self.sched.run_handler_lock.acquire()
self.assertEqual(self.sched.management_event_queue.qsize(), 0)
self.scheds.first.sched.run_handler_lock.acquire()
self.assertEqual(
self.scheds.first.sched.management_event_queue.qsize(), 0)
self.sched.reconfigureTenant(tenant, project, None)
self.assertEqual(self.sched.management_event_queue.qsize(), 1)
self.scheds.first.sched.reconfigureTenant(tenant, project, None)
self.assertEqual(
self.scheds.first.sched.management_event_queue.qsize(), 1)
self.sched.reconfigureTenant(tenant, project, None)
self.scheds.first.sched.reconfigureTenant(tenant, project, None)
# The second event should have been combined with the first
# so we should still only have one entry.
self.assertEqual(self.sched.management_event_queue.qsize(), 1)
self.assertEqual(
self.scheds.first.sched.management_event_queue.qsize(), 1)
self.sched.run_handler_lock.release()
self.scheds.first.sched.run_handler_lock.release()
self.waitUntilSettled()
self.assertEqual(self.sched.management_event_queue.qsize(), 0)
self.assertEqual(
self.scheds.first.sched.management_event_queue.qsize(), 0)
def test_live_reconfiguration(self):
"Test that live reconfiguration works"
@ -3267,7 +3273,8 @@ class TestScheduler(ZuulTestCase):
"Test that live reconfiguration via command socket works"
# record previous tenant reconfiguration time, which may not be set
old = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
old = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
self.waitUntilSettled()
command_socket = self.config.get('scheduler', 'command_socket')
@ -3282,7 +3289,8 @@ class TestScheduler(ZuulTestCase):
while True:
if time.time() - start > 15:
raise Exception("Timeout waiting for full reconfiguration")
new = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
new = self.scheds.first.sched.tenant_last_reconfigured\
.get('tenant-one', 0)
if old < new:
break
else:
@ -3297,7 +3305,7 @@ class TestScheduler(ZuulTestCase):
self.fake_gerrit.addEvent(A.addApproval('Approved', 1))
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
pipeline = tenant.layout.pipelines['gate']
change = pipeline.getAllItems()[0].change
# Set this to an invalid value to cause an exception during
@ -3665,7 +3673,7 @@ class TestScheduler(ZuulTestCase):
self.assertEqual(B.reported, 0)
self.assertEqual(C.reported, 0)
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(len(tenant.layout.pipelines['check'].queues), 0)
self.assertIn('Build succeeded', A.messages[0])
@ -3769,7 +3777,8 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
def get_job():
data = json.loads(self.sched.formatStatusJSON('tenant-one'))
data = json.loads(self.scheds.first.sched
.formatStatusJSON('tenant-one'))
for pipeline in data['pipelines']:
for queue in pipeline['change_queues']:
for head in queue['heads']:
@ -3781,7 +3790,7 @@ class TestScheduler(ZuulTestCase):
job = get_job()
self.assertTrue(job['queued'])
self.sched.reconfigure(self.config)
self.scheds.execute(lambda app: app.sched.reconfigure(self.config))
self.waitUntilSettled()
job = get_job()
@ -3944,7 +3953,8 @@ class TestScheduler(ZuulTestCase):
# Ensure that the status json has the ref so we can render it in the
# web ui.
data = json.loads(self.sched.formatStatusJSON('tenant-one'))
data = json.loads(self.scheds.first.sched
.formatStatusJSON('tenant-one'))
pipeline = [x for x in data['pipelines'] if x['name'] == 'periodic'][0]
first = pipeline['change_queues'][0]['heads'][0][0]
second = pipeline['change_queues'][1]['heads'][0][0]
@ -4058,7 +4068,7 @@ class TestScheduler(ZuulTestCase):
# should succeed.
report_mock.side_effect = Exception('Gerrit failed to report')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check = tenant.layout.pipelines['check']
check.success_actions = sorted(check.success_actions,
@ -4388,7 +4398,7 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
gate_pipeline = tenant.layout.pipelines['gate']
self.assertEqual(gate_pipeline.getAllItems(), [])
self.assertEqual(self.countJobResults(self.history, 'ABORTED'), 1)
@ -4426,7 +4436,7 @@ class TestScheduler(ZuulTestCase):
ref=None)
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
check_pipeline = tenant.layout.pipelines['check']
self.assertEqual(len(check_pipeline.getAllItems()), 2)
self.assertEqual(self.countJobResults(self.history, 'ABORTED'), 1)
@ -4627,7 +4637,7 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
items = tenant.layout.pipelines['gate'].getAllItems()
enqueue_times = {}
for item in items:
@ -4825,7 +4835,7 @@ class TestScheduler(ZuulTestCase):
self.executor_server.release('project-.*')
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
# A failed so window is reduced by 1 to 1.
self.assertEqual(queue.window, 1)
@ -4913,7 +4923,7 @@ class TestScheduler(ZuulTestCase):
self.executor_server.release('project-.*')
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
# A failed so window is reduced by 1 to 1.
self.assertEqual(queue.window, 1)
@ -5035,7 +5045,7 @@ class TestScheduler(ZuulTestCase):
# D's remaining job
self.assertEqual(self.builds[2].name, 'project-test2')
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
self.assertEqual(queue.window, 1)
@ -5066,7 +5076,7 @@ class TestScheduler(ZuulTestCase):
self.fake_gerrit.addEvent(B.addApproval('Approved', 1))
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
self.assertEqual(queue.window, 20)
self.assertTrue(len(self.builds), 4)
@ -5076,7 +5086,7 @@ class TestScheduler(ZuulTestCase):
self.commitConfigUpdate('org/common-config',
'layouts/reconfigure-window2.yaml')
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
# Even though we have configured a smaller window, the value
# on the existing shared queue should be used.
@ -5084,7 +5094,7 @@ class TestScheduler(ZuulTestCase):
self.assertTrue(len(self.builds), 4)
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
self.assertEqual(queue.window, 20)
self.assertTrue(len(self.builds), 4)
@ -5114,7 +5124,7 @@ class TestScheduler(ZuulTestCase):
self.fake_gerrit.addEvent(B.addApproval('Approved', 1))
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
self.assertEqual(queue.window, 2)
self.assertEqual(len(self.builds), 4)
@ -5124,7 +5134,7 @@ class TestScheduler(ZuulTestCase):
'layouts/reconfigure-window-fixed2.yaml')
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
self.waitUntilSettled()
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
# Because we have configured a static window, it should
# be allowed to shrink on reconfiguration.
@ -5134,7 +5144,7 @@ class TestScheduler(ZuulTestCase):
self.assertEqual(len(self.builds), 4)
self.scheds.execute(lambda app: app.sched.reconfigure(app.config))
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
self.assertEqual(queue.window, 1)
self.waitUntilSettled()
@ -5173,7 +5183,7 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
self.log.debug("B complete")
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
self.assertEqual(queue.window, 2)
self.assertEqual(len(self.builds), 2)
@ -5185,7 +5195,7 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
self.log.debug("Reconfiguration complete")
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
# Because we have configured a static window, it should
# be allowed to shrink on reconfiguration.
@ -5209,7 +5219,7 @@ class TestScheduler(ZuulTestCase):
self.waitUntilSettled()
self.log.debug("Executor unpause complete")
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
queue = tenant.layout.pipelines['gate'].queues[0]
self.assertEqual(queue.window, 1)
@ -5342,7 +5352,7 @@ For CI problems and help debugging, contact ci@example.org"""
def test_merge_failure_reporters(self):
"""Check that the config is set up correctly"""
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(
"Merge Failed.\n\nThis change or one of its cross-repo "
"dependencies was unable to be automatically merged with the "
@ -5527,7 +5537,7 @@ For CI problems and help debugging, contact ci@example.org"""
def test_disable_at(self):
"Test a pipeline will only report to the disabled trigger when failing"
tenant = self.sched.abide.tenants.get('tenant-one')
tenant = self.scheds.first.sched.abide.tenants.get('tenant-one')
self.assertEqual(3, tenant.layout.pipelines['check'].disable_at)
self.assertEqual(
0, tenant.layout.pipelines['check']._consecutive_failures)