From efde76183b6f14483e6c621cf68b4e163fd9595c Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Mon, 30 Sep 2013 11:29:23 +1300 Subject: [PATCH] Allow _status_timeout to be used for non-nova polling The error status and not-found exception used for status_timeout and delete_timeout are specific to nova. This change makes it possible to override the nova defaults. Specifically, this will improve the status polling of the orchestration scenario tests. Change-Id: Ib55f95ed51ecce3813a57c330e0f936414ec3ff2 --- tempest/scenario/manager.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py index c4b98d536d..8ccc899dde 100644 --- a/tempest/scenario/manager.py +++ b/tempest/scenario/manager.py @@ -280,16 +280,23 @@ class OfficialClientTest(tempest.test.BaseTestCase): cls.os_resources.remove(thing) del cls.resource_keys[key] - def status_timeout(self, things, thing_id, expected_status): + def status_timeout(self, things, thing_id, expected_status, + error_status='ERROR', + not_found_exception=nova_exceptions.NotFound): """ Given a thing and an expected status, do a loop, sleeping for a configurable amount of time, checking for the expected status to show. At any time, if the returned status of the thing is ERROR, fail out. """ - self._status_timeout(things, thing_id, expected_status=expected_status) + self._status_timeout(things, thing_id, + expected_status=expected_status, + error_status=error_status, + not_found_exception=not_found_exception) - def delete_timeout(self, things, thing_id): + def delete_timeout(self, things, thing_id, + error_status='ERROR', + not_found_exception=nova_exceptions.NotFound): """ Given a thing, do a loop, sleeping for a configurable amount of time, checking for the @@ -298,13 +305,17 @@ class OfficialClientTest(tempest.test.BaseTestCase): """ self._status_timeout(things, thing_id, - allow_notfound=True) + allow_notfound=True, + error_status=error_status, + not_found_exception=not_found_exception) def _status_timeout(self, things, thing_id, expected_status=None, - allow_notfound=False): + allow_notfound=False, + error_status='ERROR', + not_found_exception=nova_exceptions.NotFound): log_status = expected_status if expected_status else '' if allow_notfound: @@ -316,16 +327,16 @@ class OfficialClientTest(tempest.test.BaseTestCase): # for the singular resource to retrieve. try: thing = things.get(thing_id) - except nova_exceptions.NotFound: + except not_found_exception: if allow_notfound: return True else: raise new_status = thing.status - if new_status == 'ERROR': + if new_status == error_status: message = "%s failed to get to expected status. \ - In ERROR state." % (thing) + In %s state." % (thing, new_status) raise exceptions.BuildErrorException(message) elif new_status == expected_status and expected_status is not None: return True # All good.