From 7b42be7893e324908005a5fcd827a9b186e04094 Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Thu, 2 Aug 2018 14:26:12 -0500 Subject: [PATCH] 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 --- nova/tests/unit/compute/test_compute_mgr.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index 311cca5adcc..1ed96e50011 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -6266,6 +6266,8 @@ def test_deallocate_network_auto_requested_or_none_provided(self): 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,