Consolidate waiters methods
Currently, for each resource there is a waiter method.
The code is almost the same in all waiter methods.
This patch suggests proposes to consolidate these methods.
Change-Id: I92f4628051731a9f7e05404b48a96d2ed27a855b
diff --git a/manila_tempest_tests/tests/api/base.py b/manila_tempest_tests/tests/api/base.py
index 2310591..b657935 100755
--- a/manila_tempest_tests/tests/api/base.py
+++ b/manila_tempest_tests/tests/api/base.py
@@ -481,7 +481,7 @@
client = d["kwargs"]["client"]
share_id = d["share"]["id"]
try:
- waiters.wait_for_share_status(
+ waiters.wait_for_resource_status(
client, share_id, "available")
d["available"] = True
except (share_exceptions.ShareBuildErrorException,
@@ -541,8 +541,9 @@
else:
cls.method_resources.insert(0, resource)
- waiters.wait_for_share_group_status(
- client, share_group['id'], 'available')
+ waiters.wait_for_resource_status(
+ client, share_group['id'], 'available',
+ resource_name='share_group')
return share_group
@classmethod
@@ -591,7 +592,8 @@
cls.class_resources.insert(0, resource)
else:
cls.method_resources.insert(0, resource)
- waiters.wait_for_snapshot_status(client, snapshot["id"], "available")
+ waiters.wait_for_resource_status(client, snapshot["id"], "available",
+ resource_name='snapshot')
return snapshot
@classmethod
@@ -612,8 +614,9 @@
cls.class_resources.insert(0, resource)
else:
cls.method_resources.insert(0, resource)
- waiters.wait_for_share_group_snapshot_status(
- client, sg_snapshot["id"], "available")
+ waiters.wait_for_resource_status(
+ client, sg_snapshot["id"], "available",
+ resource_name="share_group_snapshot")
return sg_snapshot
@classmethod
@@ -699,8 +702,9 @@
cls.class_resources.insert(0, resource)
else:
cls.method_resources.insert(0, resource)
- waiters.wait_for_share_replica_status(
- client, replica["id"], constants.STATUS_AVAILABLE)
+ waiters.wait_for_resource_status(
+ client, replica["id"], constants.STATUS_AVAILABLE,
+ resource_name='share_replica')
return replica
@classmethod
@@ -718,9 +722,9 @@
version=CONF.share.max_api_microversion):
client = client or cls.shares_v2_client
replica = client.promote_share_replica(replica_id, version=version)
- waiters.wait_for_share_replica_status(
+ waiters.wait_for_resource_status(
client, replica["id"], constants.REPLICATION_STATE_ACTIVE,
- status_attr="replica_state")
+ resource_name='share_replica', status_attr="replica_state")
return replica
@classmethod
@@ -1086,7 +1090,7 @@
'share_network_id': self.shares_v2_client.share_network_id}
share = self.shares_v2_client.create_share(**params)
self.addCleanup(self.shares_v2_client.delete_share, share['id'])
- waiters.wait_for_share_status(
+ waiters.wait_for_resource_status(
self.shares_v2_client, share['id'], "error")
return waiters.wait_for_message(self.shares_v2_client, share['id'])
@@ -1101,8 +1105,10 @@
rule = client.create_access_rule(share_id, access_type, access_to,
access_level)
- waiters.wait_for_access_rule_status(client, share_id, rule['id'],
- status, raise_rule_in_error_state)
+ waiters.wait_for_resource_status(
+ client, share_id, status, resource_name='access_rule',
+ rule_id=rule['id'],
+ raise_rule_in_error_state=raise_rule_in_error_state)
if cleanup:
self.addCleanup(client.wait_for_resource_deletion,
rule_id=rule['id'], share_id=share_id)
@@ -1184,7 +1190,7 @@
description=description,
share_server_id=share_server_id
)
- waiters.wait_for_share_status(
+ waiters.wait_for_resource_status(
self.shares_v2_client, managed_share['id'],
constants.STATUS_AVAILABLE
)
@@ -1206,9 +1212,9 @@
params.get('identifier', share_server['identifier']),
share_network_subnet_id=subnet_id,
)
- waiters.wait_for_share_server_status(
+ waiters.wait_for_resource_status(
self.shares_v2_client, managed_share_server['id'],
- constants.SERVER_STATE_ACTIVE,
+ constants.SERVER_STATE_ACTIVE, resource_name='share_server'
)
return managed_share_server