yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #78343
[Bug 1823278] Re: SynchronousThreadPoolExecutorFixture mock spec does not work
Reviewed: https://review.opendev.org/650171
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=87b7f0c2aff153eecd8bdf3cb5503287d0e77a24
Submitter: Zuul
Branch: master
commit 87b7f0c2aff153eecd8bdf3cb5503287d0e77a24
Author: melanie witt <melwittt@xxxxxxxxx>
Date: Fri Apr 5 01:24:23 2019 +0000
Fix SynchronousThreadPoolExecutorFixture mock of Future
The fixture is not mocking the Future.result() method correctly and an
attempt to access it results in the following error:
AttributeError: Mock object has no attribute 'result'
Instead of mocking the submit() method, we can just swap out the
GreenThreadPoolExecutor for the SynchronousExecutor to make the
executor synchronous for testing.
A few changes were also needed in unit tests that are running with the
thread pool executor. Because the thread pool executor is created in
the compute manager's __init__ method, we need to patch the synchronous
executor in before calling the base test class's setUp method. Next, a
couple of unit tests were asserting that an exception would be raised
from the thread pool executor's submit() method but that will not
happen because if an exception is raised during a submitted task, that
exception will not be raised until Future.result() is called. And
Future.result() is never called in the compute manager.
Closes-Bug: #1823278
Change-Id: I719c222a5fa3d654e7397f126a1338e653b7bbcc
** Changed in: nova
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1823278
Title:
SynchronousThreadPoolExecutorFixture mock spec does not work
Status in OpenStack Compute (nova):
Fix Released
Bug description:
The fixture's fake submit() method returns a mocked future that is
intended to be a Mock with spec=futurist.Future but the speccing
doesn't work because the spec is passed a string when it needs to be a
class or an instance. Because of the bug, code like this:
self.useFixture(fixtures.SynchronousThreadPoolExecutorFixture())
executor = futurist.GreenThreadPoolExecutor()
future = executor.submit(...)
result = future.result()
raises the following error:
AttributeError: Mock object has no attribute 'result'
The mock spec just needs to be changed from a string to a class or
instance.
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1823278/+subscriptions
References