diff --git a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py index d8d5987bc..47c681414 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -2912,6 +2912,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): self.driver.do_setup(None) self.driver.check_for_setup_error() self.driver._helpers.check_fcmapping_interval = 0 + self.mock_gr_sleep = mock.patch.object( + storwize_svc_common.StorwizeSVCCommonDriver, "DEFAULT_GR_SLEEP", 0) def _set_flag(self, flag, value, configuration=None): if not configuration: @@ -5152,6 +5154,8 @@ class StorwizeHelpersTestCase(test.TestCase): def setUp(self): super(StorwizeHelpersTestCase, self).setUp() self.storwize_svc_common = storwize_svc_common.StorwizeHelpers(None) + self.mock_wait_time = mock.patch.object( + storwize_svc_common.StorwizeHelpers, "WAIT_TIME", 0) @mock.patch.object(storwize_svc_common.StorwizeSSH, 'lslicense') @mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsguicapabilities') diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index 2d47783e5..6a51667f1 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -539,6 +539,7 @@ class StorwizeHelpers(object): # 'default': to indicate the value, when the parameter is disabled. # 'param': to indicate the corresponding parameter in the command. # 'type': to indicate the type of this value. + WAIT_TIME = 5 svc_qos_keys = {'IOThrottling': {'default': '0', 'param': 'rate', 'type': int}} @@ -1187,8 +1188,7 @@ class StorwizeHelpers(object): def _prepare_fc_map(self, fc_map_id, timeout): self.ssh.prestartfcmap(fc_map_id) mapping_ready = False - wait_time = 5 - max_retries = (timeout // wait_time) + 1 + max_retries = (timeout // self.WAIT_TIME) + 1 for try_number in range(1, max_retries): mapping_attrs = self._get_flashcopy_mapping_attributes(fc_map_id) if (mapping_attrs is None or @@ -1207,7 +1207,7 @@ class StorwizeHelpers(object): 'attr': mapping_attrs}) LOG.error(msg) raise exception.VolumeBackendAPIException(data=msg) - greenthread.sleep(wait_time) + greenthread.sleep(self.WAIT_TIME) if not mapping_ready: msg = (_('Mapping %(id)s prepare failed to complete within the' @@ -1897,6 +1897,7 @@ class StorwizeSVCCommonDriver(san.SanDriver, METRO = 'metro' VALID_REP_TYPES = (GLOBAL, METRO) FAILBACK_VALUE = 'default' + DEFAULT_GR_SLEEP = random.randint(20, 500) / 100.0 def __init__(self, *args, **kwargs): super(StorwizeSVCCommonDriver, self).__init__(*args, **kwargs) @@ -2140,7 +2141,7 @@ class StorwizeSVCCommonDriver(san.SanDriver, except Exception as e: LOG.error(_LE('Error has occurred: %s'), e) last_exception = e - greenthread.sleep(random.randint(20, 500) / 100.0) + greenthread.sleep(self.DEFAULT_GR_SLEEP) try: raise processutils.ProcessExecutionError( exit_code=last_exception.exit_code,