Remove wait_for_image_resp_code
The nova api first creates an entry in glance,
before responding to snapshot creation request, so the entry
expected to be visible without any additional wait.
This change also introduces an OK code checker on the rest_client side,
it's extended usage can make unnecessary to assert the ok codes in the
test codes.
So the wait_for_image_status will implicitly validate the status code.
Change-Id: I9fdc1cc68501220e6688e2d7a745195b56d60cb9
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 8dfff6e..86ebefd 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -32,6 +32,9 @@
MAX_RECURSION_DEPTH = 2
TOKEN_CHARS_RE = re.compile('^[-A-Za-z0-9+/=]*$')
+# All the successful HTTP status codes from RFC 2616
+HTTP_SUCCESS = (200, 201, 202, 203, 204, 205, 206)
+
class RestClient(object):
TYPE = "json"
@@ -256,6 +259,20 @@
raise exceptions.AuthenticationFailure(user=user,
password=password)
+ def expected_success(self, expected_code, read_code):
+ assert_msg = ("This function only allowed to use for HTTP status"
+ "codes which explicitly defined in the RFC 2616. {0}"
+ " is not a defined Success Code!").format(expected_code)
+ assert expected_code in HTTP_SUCCESS, assert_msg
+
+ # NOTE(afazekas): the http status code above 400 is processed by
+ # the _error_checker method
+ if read_code < 400 and read_code != expected_code:
+ pattern = """Unexpected http success status code {0},
+ The expected status code is {1}"""
+ details = pattern.format(read_code, expected_code)
+ raise exceptions.InvalidHttpSuccessCode(details)
+
def post(self, url, body, headers):
return self.request('POST', url, headers, body)