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
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index c4b98d5..8ccc899 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -280,16 +280,23 @@
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 @@
"""
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 @@
# 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.