Skip to content

Commit 625469d

Browse files
author
Balazs Gibizer
committed
Avoid excessive sleep in vmware unit test
The patch Id6e2be2b407eb08e269c35e0f89d235c67a1ab99 added a retry decorator on create_vm in vmware driver. Such decorator makes the negative unit test do excessive sleeps and retries. The test eventually stopped by the test executor with a Timeout exception but the test was modified to assert that as a success. This makes the test pass after 160 seconds. This patch mocks the sleep behind the retry decorator to make the test fast and reverts the assert in the test. Change-Id: I7c7e698bf559b69a2f09402c265e6e387c3b077a Related-Bug: #1908408
1 parent 7c1ca50 commit 625469d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

nova/tests/unit/virt/vmwareapi/test_vm_util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
# under the License.
1616

1717
import collections
18-
import fixtures
1918

2019
import mock
20+
from oslo_service import fixture as oslo_svc_fixture
2121
from oslo_utils import units
2222
from oslo_utils import uuidutils
2323
from oslo_vmware import exceptions as vexc
@@ -1024,6 +1024,8 @@ def test_create_vm_invalid_guestid(self, mock_log_warn):
10241024
"""Ensure we warn when create_vm() fails after we passed an
10251025
unrecognised guestId
10261026
"""
1027+
# avoid real sleeps during test due to te retry decorator on create_vm
1028+
self.useFixture(oslo_svc_fixture.SleepFixture())
10271029

10281030
found = [False]
10291031

@@ -1042,8 +1044,7 @@ def fake_log_warn(msg, values):
10421044
vm_util.ExtraSpecs(),
10431045
os_type='invalid_os_type')
10441046

1045-
# Because of retries timeout will be raised
1046-
self.assertRaises(fixtures.TimeoutException,
1047+
self.assertRaises(vexc.VMwareDriverException,
10471048
vm_util.create_vm, session, self._instance,
10481049
'folder', config_spec, 'res-pool')
10491050
self.assertTrue(found[0])

0 commit comments

Comments
 (0)