Unit tests: fix absurdly slow tests

Eliminate the 3 slowest unit tests, which collectively block one of the
test processes for a minute and a half, by stubbing out the sleep() calls
in tenacity.

ServerInternalPortTest.test_prepare_ports_for_replace_detach_failed
  75s -> 0.3s
SoftwareConfigServiceTest.test_push_metadata_software_deployments_retry
  11s -> 0.2s
ServerInternalPortTest.test_restore_ports_after_rollback_attach_failed
  4.6s -> 0.3s

Change-Id: I4ee0c7eb249c4e8aa6ab6da1e4f945e3a629451b
This commit is contained in:
Zane Bitter 2018-01-10 12:29:11 -05:00
parent d3614902dd
commit 41bd6e0958
2 changed files with 5 additions and 0 deletions

View File

@ -677,6 +677,7 @@ class SoftwareConfigServiceTest(common.HeatTestCase):
with mock.patch.object(self.ctx.session, 'refresh'):
f = self.engine.software_config._push_metadata_software_deployments
self.patchobject(f.retry, 'sleep')
self.assertRaises(
exception.ConcurrentTransaction,
f,

View File

@ -4839,6 +4839,8 @@ class ServerInternalPortTest(ServersTest):
server._data = {"internal_ports": jsonutils.dumps(port_ids)}
self.patchobject(nova.NovaClientPlugin, 'interface_detach')
self.patchobject(nova.NovaClientPlugin, 'fetch_server')
self.patchobject(nova.NovaClientPlugin.check_interface_detach.retry,
'sleep')
nova.NovaClientPlugin.fetch_server.side_effect = [Fake()] * 10
exc = self.assertRaises(exception.InterfaceDetachFailed,
@ -4966,6 +4968,8 @@ class ServerInternalPortTest(ServersTest):
return_value=True)
self.patchobject(nova.NovaClientPlugin, 'interface_attach')
self.patchobject(nova.NovaClientPlugin, 'fetch_server')
self.patchobject(nova.NovaClientPlugin.check_interface_attach.retry,
'sleep')
# need to mock 11 times: 1 for port 1122, 10 for port 3344
nova.NovaClientPlugin.fetch_server.side_effect = [Fake()] * 11