NetApp: Eliminate timed delays in unit tests
Eliminate unit test delays by using "zero interval" looping calls. Change-Id: Ica3d4eec06cf46343d3bebd7f500cf9f9375e452
This commit is contained in:
parent
d021a7098d
commit
f8e3d952f2
|
@ -430,6 +430,14 @@ class ZeroIntervalLoopingCall(loopingcall.FixedIntervalLoopingCall):
|
|||
0, 0, stop_on_exception)
|
||||
|
||||
|
||||
class ZeroIntervalWithTimeoutLoopingCall(
|
||||
loopingcall.FixedIntervalWithTimeoutLoopingCall):
|
||||
def start(self, interval, initial_delay=None,
|
||||
stop_on_exception=True, timeout=0):
|
||||
return super(ZeroIntervalWithTimeoutLoopingCall, self).start(
|
||||
0, 0, stop_on_exception, timeout)
|
||||
|
||||
|
||||
def replace_obj_loader(testcase, obj):
|
||||
def fake_obj_load_attr(self, name):
|
||||
# This will raise KeyError for non existing fields as expected
|
||||
|
|
|
@ -25,6 +25,7 @@ from cinder import exception
|
|||
from cinder.objects import fields
|
||||
from cinder.tests.unit import fake_volume
|
||||
from cinder.tests.unit import test
|
||||
from cinder.tests.unit import utils as test_utils
|
||||
import cinder.tests.unit.volume.drivers.netapp.dataontap.fakes as fake
|
||||
from cinder.tests.unit.volume.drivers.netapp.dataontap.utils import fakes as\
|
||||
fake_utils
|
||||
|
@ -1023,6 +1024,8 @@ class NetAppBlockStorageCmodeLibraryTestCase(test.TestCase):
|
|||
@ddt.data(('data', na_utils.NetAppDriverTimeout),
|
||||
('destroyed', na_utils.NetAppDriverException))
|
||||
@ddt.unpack
|
||||
@mock.patch('oslo_service.loopingcall.FixedIntervalWithTimeoutLoopingCall',
|
||||
new=test_utils.ZeroIntervalWithTimeoutLoopingCall)
|
||||
def test_move_lun_error(self, status_on_error, move_exception):
|
||||
self.library.configuration.netapp_migrate_volume_timeout = 1
|
||||
fake_job_status = {
|
||||
|
@ -1173,6 +1176,8 @@ class NetAppBlockStorageCmodeLibraryTestCase(test.TestCase):
|
|||
('destroyed', na_utils.NetAppDriverException),
|
||||
('destroyed', na_utils.NetAppDriverException))
|
||||
@ddt.unpack
|
||||
@mock.patch('oslo_service.loopingcall.FixedIntervalWithTimeoutLoopingCall',
|
||||
new=test_utils.ZeroIntervalWithTimeoutLoopingCall)
|
||||
def test_copy_lun_error(self, status_on_error, copy_exception):
|
||||
self.library.configuration.netapp_migrate_volume_timeout = 1
|
||||
fake_job_status = {
|
||||
|
|
|
@ -27,6 +27,7 @@ from cinder.image import image_utils
|
|||
from cinder.objects import fields
|
||||
from cinder.tests.unit import fake_volume
|
||||
from cinder.tests.unit import test
|
||||
from cinder.tests.unit import utils as test_utils
|
||||
from cinder.tests.unit.volume.drivers.netapp.dataontap import fakes as fake
|
||||
from cinder.tests.unit.volume.drivers.netapp.dataontap.utils import fakes as \
|
||||
fake_ssc
|
||||
|
@ -1926,6 +1927,8 @@ class NetAppCmodeNfsDriverTestCase(test.TestCase):
|
|||
('destroyed', na_utils.NetAppDriverException),
|
||||
('destroyed', na_utils.NetAppDriverException))
|
||||
@ddt.unpack
|
||||
@mock.patch('oslo_service.loopingcall.FixedIntervalWithTimeoutLoopingCall',
|
||||
new=test_utils.ZeroIntervalWithTimeoutLoopingCall)
|
||||
def test_copy_file_error(self, status_on_error, copy_exception):
|
||||
self.driver.configuration.netapp_migrate_volume_timeout = 1
|
||||
fake_job_status = {
|
||||
|
|
|
@ -19,6 +19,7 @@ from oslo_config import cfg
|
|||
|
||||
from cinder.tests.unit import fake_volume
|
||||
from cinder.tests.unit import test
|
||||
from cinder.tests.unit import utils as test_utils
|
||||
from cinder.tests.unit.volume.drivers.netapp.dataontap import fakes as\
|
||||
dataontap_fakes
|
||||
from cinder.tests.unit.volume.drivers.netapp.dataontap.utils import fakes
|
||||
|
@ -691,6 +692,8 @@ class NetAppCDOTDataMotionMixinTestCase(test.TestCase):
|
|||
self.assertFalse(mock_client_call.called)
|
||||
|
||||
@ddt.data('mixed', None)
|
||||
@mock.patch('oslo_service.loopingcall.FixedIntervalWithTimeoutLoopingCall',
|
||||
new=test_utils.ZeroIntervalWithTimeoutLoopingCall)
|
||||
def test_create_destination_flexgroup_online_timeout(self, volume_state):
|
||||
aggr_map = {
|
||||
fakes.PROVISIONING_OPTS['aggregate'][0]: 'aggr01',
|
||||
|
|
Loading…
Reference in New Issue