Refactor nodepool in tests

Replace `self.nodepool` with `scheduler.nodepool`.

This change only touches tests.

Change-Id: I8fb20286409a2a9ecedf489dc2fcbca1c8f0a5ff
Story: 2007192
This commit is contained in:
Jan Kubovy 2020-02-25 13:06:05 +01:00
parent 66793ea3ae
commit 3734a58cc2
2 changed files with 11 additions and 11 deletions

View File

@ -3716,7 +3716,6 @@ class ZuulTestCase(BaseTestCase):
self.fake_github.github_event_connector._event_forward_queue)
self.merge_server = None
self.nodepool = sched_app.sched.nodepool
self.zk = sched_app.sched.zk
# Cleanups are run in reverse order
@ -4323,11 +4322,12 @@ class ZuulTestCase(BaseTestCase):
return False
return True
def areAllNodeRequestsComplete(self):
def __areAllNodeRequestsComplete(self, matcher) -> bool:
if self.fake_nodepool.paused:
return True
if self.nodepool.requests:
return False
for app in self.scheds.filter(matcher):
if app.sched.nodepool.requests:
return False
return True
def __areAllMergeJobsWaiting(self, matcher) -> bool:
@ -4375,7 +4375,7 @@ class ZuulTestCase(BaseTestCase):
self.log.error("All builds reported: %s" %
(self.__haveAllBuildsReported(matcher),))
self.log.error("All requests completed: %s" %
(self.areAllNodeRequestsComplete(),))
(self.__areAllNodeRequestsComplete(matcher),))
for app in self.scheds.filter(matcher):
self.log.error("[Sched: %s] Merge client jobs: %s" %
(app.sched, app.sched.merger.jobs,))
@ -4393,7 +4393,7 @@ class ZuulTestCase(BaseTestCase):
if (self.__areAllMergeJobsWaiting(matcher) and
self.__haveAllBuildsReported(matcher) and
self.__areAllBuildsWaiting(matcher) and
self.areAllNodeRequestsComplete() and
self.__areAllNodeRequestsComplete(matcher) and
all(self.eventQueuesEmpty())):
# The queue empty check is placed at the end to
# ensure that if a component adds an event between

View File

@ -7341,14 +7341,14 @@ class TestSemaphore(ZuulTestCase):
tenant.semaphore_handler.semaphores)
# Simulate a single zk error in useNodeSet
orig_useNodeSet = self.nodepool.useNodeSet
orig_useNodeSet = self.scheds.first.sched.nodepool.useNodeSet
def broken_use_nodeset(nodeset, build_set=None, event=None):
# restore original useNodeSet
self.nodepool.useNodeSet = orig_useNodeSet
self.scheds.first.sched.nodepool.useNodeSet = orig_useNodeSet
raise NoNodeError()
self.nodepool.useNodeSet = broken_use_nodeset
self.scheds.first.sched.nodepool.useNodeSet = broken_use_nodeset
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
@ -7451,13 +7451,13 @@ class TestSemaphore(ZuulTestCase):
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertEqual(len(self.nodepool.requests), 2)
self.assertEqual(len(self.scheds.first.sched.nodepool.requests), 2)
# Now unpause nodepool to fulfill the node requests. We cannot use
# waitUntilSettled here because the executor is paused.
self.fake_nodepool.paused = False
for _ in iterate_timeout(30, 'fulfill node requests'):
if len(self.nodepool.requests) == 0:
if len(self.scheds.first.sched.nodepool.requests) == 0:
break
self.assertTrue('test-semaphore' in