Fixed Share server migration test related to CIFS.
Modify "wait_for_resource_status" method so that we can pass the timeout parameter from test cases and modify the test cases as per lib changes. Change-Id: Id67589bf2d2094355003a16e3379867ba81bfb6b
This commit is contained in:
parent
dae4d135da
commit
541c6cd91d
@ -45,7 +45,8 @@ def wait_for_resource_status(client, resource_id, status,
|
||||
resource_name='share', rule_id=None,
|
||||
status_attr='status',
|
||||
raise_rule_in_error_state=True,
|
||||
version=LATEST_MICROVERSION):
|
||||
version=LATEST_MICROVERSION,
|
||||
timeout=None):
|
||||
"""Waits for a resource to reach a given status."""
|
||||
|
||||
get_resource_action = {
|
||||
@ -86,6 +87,9 @@ def wait_for_resource_status(client, resource_id, status,
|
||||
start = int(time.time())
|
||||
|
||||
exp_status = status if isinstance(status, list) else [status]
|
||||
resource_status_check_time_out = client.build_timeout
|
||||
if timeout is not None:
|
||||
resource_status_check_time_out = timeout
|
||||
while resource_status not in exp_status:
|
||||
time.sleep(client.build_interval)
|
||||
body = resource_action(*method_args, **method_kwargs)[rn]
|
||||
@ -102,11 +106,11 @@ def wait_for_resource_status(client, resource_id, status,
|
||||
raise_method = _get_name_of_raise_method(resource_name)
|
||||
resource_exception = getattr(share_exceptions, raise_method)
|
||||
raise resource_exception(resource_id=resource_id)
|
||||
if int(time.time()) - start >= client.build_timeout:
|
||||
if int(time.time()) - start >= resource_status_check_time_out:
|
||||
message = ('%s %s failed to reach %s status (current %s) '
|
||||
'within the required time (%s s).' %
|
||||
(resource_name.replace('_', ' '), resource_id, status,
|
||||
resource_status, client.build_timeout))
|
||||
resource_status, resource_status_check_time_out))
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
|
||||
|
@ -282,10 +282,11 @@ class ShareServerMigrationBasicNFS(MigrationShareServerBase):
|
||||
src_server_id, dest_host, preserve_snapshots=preserve_snapshots)
|
||||
|
||||
expected_state = constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE
|
||||
timeout = CONF.share.share_server_migration_timeout
|
||||
waiters.wait_for_resource_status(
|
||||
self.shares_v2_client, src_server_id,
|
||||
expected_state, resource_name='share_server',
|
||||
status_attr='task_state'
|
||||
status_attr='task_state', timeout=timeout
|
||||
)
|
||||
|
||||
# Get for the destination share server.
|
||||
@ -352,10 +353,11 @@ class ShareServerMigrationBasicNFS(MigrationShareServerBase):
|
||||
preserve_snapshots=preserve_snapshots)
|
||||
|
||||
expected_state = constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE
|
||||
timeout = CONF.share.share_server_migration_timeout
|
||||
waiters.wait_for_resource_status(
|
||||
self.shares_v2_client, src_server_id,
|
||||
expected_state, resource_name='share_server',
|
||||
status_attr='task_state'
|
||||
status_attr='task_state', timeout=timeout
|
||||
)
|
||||
# Get for the destination share server.
|
||||
dest_server_id = self._get_share_server_destination_for_migration(
|
||||
|
Loading…
x
Reference in New Issue
Block a user