diff options
author | James E. Blair <jim@acmegating.com> | 2022-09-03 14:03:36 -0700 |
---|---|---|
committer | James E. Blair <jim@acmegating.com> | 2022-09-08 13:01:28 -0700 |
commit | 1958bbad03d4c2eb59502df8682bdfcb248400c2 (patch) | |
tree | ffb6bffdbd41ff93eea1a732aff536db906b2058 /tests/unit/test_scheduler.py | |
parent | 64fa9db5799d33838267183f5c6734d4ba5ee7c9 (diff) | |
download | zuul-1958bbad03d4c2eb59502df8682bdfcb248400c2.tar.gz |
Add nodeset alternatives
This feature instructs Zuul to attempt a second or more node request
with a different node configuration (ie, possibly different labels)
if the first one fails.
It is intended to address the case where a cloud provider is unable
to supply specialized high-performance nodes, and the user would like
the job to proceed anyway on lower-performance nodes.
Change-Id: Idede4244eaa3b21a34c20099214fda6ecdc992df
Diffstat (limited to 'tests/unit/test_scheduler.py')
-rw-r--r-- | tests/unit/test_scheduler.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py index 978bc00a4..321905327 100644 --- a/tests/unit/test_scheduler.py +++ b/tests/unit/test_scheduler.py @@ -36,6 +36,7 @@ from zuul.driver.gerrit import gerritreporter import zuul.scheduler import zuul.model import zuul.merger.merger +from zuul.lib import yamlutil as yaml from tests.base import ( SSLZuulTestCase, @@ -6078,6 +6079,50 @@ For CI problems and help debugging, contact ci@example.org""" self.assertFalse(node['_lock']) self.assertEqual(node['state'], 'ready') + @simple_layout('layouts/nodeset-fallback.yaml') + def test_nodeset_fallback(self): + # Test that nodeset fallback works + self.executor_server.hold_jobs_in_build = True + + # Verify that we get the correct number and order of + # alternates from our nested config. + tenant = self.scheds.first.sched.abide.tenants.get('tenant-one') + job = tenant.layout.getJob('check-job') + alts = job.flattenNodesetAlternatives(tenant.layout) + self.assertEqual(4, len(alts)) + self.assertEqual('fast-nodeset', alts[0].name) + self.assertEqual('', alts[1].name) + self.assertEqual('red-nodeset', alts[2].name) + self.assertEqual('blue-nodeset', alts[3].name) + + self.fake_nodepool.pause() + A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A') + self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1)) + self.waitUntilSettled() + + req = self.fake_nodepool.getNodeRequests()[0] + self.fake_nodepool.addFailRequest(req) + + self.fake_nodepool.unpause() + self.waitUntilSettled() + + build = self.getBuildByName('check-job') + inv_path = os.path.join(build.jobdir.root, 'ansible', 'inventory.yaml') + inventory = yaml.safe_load(open(inv_path, 'r')) + label = inventory['all']['hosts']['controller']['nodepool']['label'] + self.assertEqual('slow-label', label) + + self.executor_server.hold_jobs_in_build = False + self.executor_server.release() + self.waitUntilSettled() + + self.assertEqual(A.data['status'], 'NEW') + self.assertEqual(A.reported, 1) + self.assertNotIn('NODE_FAILURE', A.messages[0]) + self.assertHistory([ + dict(name='check-job', result='SUCCESS', changes='1,1'), + ], ordered=False) + @simple_layout('layouts/multiple-templates.yaml') def test_multiple_project_templates(self): # Test that applying multiple project templates to a project |