From 3adefa4a4d32e56548b6e854a6f93c06b7fb177a Mon Sep 17 00:00:00 2001 From: Gregory Thiemonge Date: Mon, 7 Sep 2020 08:37:51 +0200 Subject: [PATCH] Fix loop in waiter when error_ok is True If error_ok=True is passed to wait_for_status and a resource is in 'ERROR' status, the function infinitely loops check_timeout value is now considered in case of ERROR statuses in resources. Story: 2008110 Task: 40826 Change-Id: I9d62b2f4ec55a6fd6cba38d446711c16f03a5ade --- octavia_tempest_plugin/tests/waiters.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/octavia_tempest_plugin/tests/waiters.py b/octavia_tempest_plugin/tests/waiters.py index e0d9d2da..fa6c1129 100644 --- a/octavia_tempest_plugin/tests/waiters.py +++ b/octavia_tempest_plugin/tests/waiters.py @@ -68,7 +68,7 @@ def wait_for_status(show_client, id, status_key, status, LOG.info('{name}\'s status updated to {status}.'.format( name=show_client.__name__, status=status)) return object_details - elif object_details[status_key] == 'ERROR': + elif object_details[status_key] == 'ERROR' and not error_ok: message = ('{name} {field} updated to an invalid state of ' 'ERROR'.format(name=show_client.__name__, field=status_key)) @@ -76,9 +76,9 @@ def wait_for_status(show_client, id, status_key, status, if caller: message = '({caller}) {message}'.format(caller=caller, message=message) - if not error_ok: - raise exceptions.UnexpectedResponseCode(message) - elif int(time.time()) - start >= check_timeout: + raise exceptions.UnexpectedResponseCode(message) + + if int(time.time()) - start >= check_timeout: message = ( '{name} {field} failed to update to {expected_status} within ' 'the required time {timeout}. Current status of {name}: '