Grease test_try_deallocate_network_retry_direct

That's "grease" in the sense of "lubricate", or "make faster". Not in
the sense of "kill with an M3 submachine gun".

This test hits the compute manager's _try_deallocate_network helper in
such a way as to deliberately activate and exhaust its RetryDecorator,
which adds 12s to the test time. This patch mocks the sleep in that
retry loop, taking the test down to sub-second like it should be.

Change-Id: I60d11fc9a9e8569b1663c7319a5c25b921c5de1a
This commit is contained in:
Eric Fried 2018-08-02 14:26:12 -05:00
parent 05f88f6e3b
commit 7b42be7893

View File

@ -6266,6 +6266,8 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
self.context, mock.sentinel.instance,
requested_networks=requested_networks)
@mock.patch('oslo_service.loopingcall._ThreadingEvent.wait',
new=mock.Mock())
@mock.patch('nova.compute.manager.ComputeManager._deallocate_network')
@mock.patch('nova.compute.manager.LOG.warning')
def test_try_deallocate_network_retry_direct(self, warning_mock,