Add a scenario test for spare pool
This patch adds a scenario test for testing amphora spare pool feature.
It adds new check jobs to test against master as well as stable
branches.
Change-Id: I87249017453628e3d2cd320a02677d81397f1b26
diff --git a/octavia_tempest_plugin/tests/waiters.py b/octavia_tempest_plugin/tests/waiters.py
index 5abb26e..89e8455 100644
--- a/octavia_tempest_plugin/tests/waiters.py
+++ b/octavia_tempest_plugin/tests/waiters.py
@@ -180,3 +180,31 @@
raise exceptions.TimeoutException(message)
time.sleep(check_interval)
+
+
+def wait_for_spare_amps(list_func, check_interval, check_timeout):
+ """Waits for amphorae in spare pool.
+
+ :param list_func: The tempest service client amphora list method.
+ Ex. cls.os_admin.amphora_client.list_amphorae
+ :check_interval: How often to check the status, in seconds.
+ :check_timeout: The maximum time, in seconds, to check the status.
+ :raises TimeoutException: No amphora available in spare pool in the
+ check_timeout period.
+ :returns: A list of amphorae in spare pool.
+ """
+
+ LOG.info('Waiting for amphorae in spare pool')
+ start = int(time.time())
+ while True:
+ spare_amps = list_func(
+ query_params='{status}={status_ready}'.format(
+ status=const.STATUS, status_ready=const.STATUS_READY))
+ if len(spare_amps) >= 1:
+ return spare_amps
+ if int(time.time()) - start >= check_timeout:
+ message = ("No available amphorae in spare pool within the "
+ "required time {timeout}.".format(
+ timeout=check_timeout))
+ raise exceptions.TimeoutException(message)
+ time.sleep(check_interval)