From 541c6cd91deb1b10b203ebb0f2fe50686edcd131 Mon Sep 17 00:00:00 2001 From: agireesh Date: Tue, 17 Oct 2023 14:57:32 +0530 Subject: [PATCH] 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 --- manila_tempest_tests/common/waiters.py | 10 +++++++--- .../tests/api/admin/test_share_servers_migration.py | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/manila_tempest_tests/common/waiters.py b/manila_tempest_tests/common/waiters.py index 8a97c8ee..11a02d35 100644 --- a/manila_tempest_tests/common/waiters.py +++ b/manila_tempest_tests/common/waiters.py @@ -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) diff --git a/manila_tempest_tests/tests/api/admin/test_share_servers_migration.py b/manila_tempest_tests/tests/api/admin/test_share_servers_migration.py index 25357457..d3ec3f1b 100644 --- a/manila_tempest_tests/tests/api/admin/test_share_servers_migration.py +++ b/manila_tempest_tests/tests/api/admin/test_share_servers_migration.py @@ -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(