From 95951ed68f6f41dd0e854bfff5f161c3b26b1b84 Mon Sep 17 00:00:00 2001 From: Ghanshyam Date: Mon, 31 Mar 2014 11:57:22 +0900 Subject: [PATCH] Check add/remove flavor access APIs attributes This patch adds the JSON schema for Nova V2/V3 add & remove flavor access APIs response and validate the response with added JSON schema to block the backward incompatibility change in the future. The response body of V2 & V3 for add & remove flavor access APIs are same and given below: { "flavor_access": [ { "flavor_id": "10", "tenant_id": "fake_tenant" } } Partially implements blueprint nova-api-attribute-test Change-Id: I0e876494b9d1bda418076844ed3211f5513af76c --- tempest/api_schema/compute/flavors_access.py | 2 +- tempest/services/compute/json/flavors_client.py | 7 ++++++- tempest/services/compute/v3/json/flavors_client.py | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tempest/api_schema/compute/flavors_access.py b/tempest/api_schema/compute/flavors_access.py index 152e24ce8a..cd31b0a949 100644 --- a/tempest/api_schema/compute/flavors_access.py +++ b/tempest/api_schema/compute/flavors_access.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -list_flavor_access = { +add_remove_list_flavor_access = { 'status_code': [200], 'response_body': { 'type': 'object', diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py index bc4a64f7d9..3babf4ea1d 100644 --- a/tempest/services/compute/json/flavors_client.py +++ b/tempest/services/compute/json/flavors_client.py @@ -128,7 +128,8 @@ class FlavorsClientJSON(rest_client.RestClient): """Gets flavor access information given the flavor id.""" resp, body = self.get('flavors/%s/os-flavor-access' % flavor_id) body = json.loads(body) - self.validate_response(schema_access.list_flavor_access, resp, body) + self.validate_response(schema_access.add_remove_list_flavor_access, + resp, body) return resp, body['flavor_access'] def add_flavor_access(self, flavor_id, tenant_id): @@ -141,6 +142,8 @@ class FlavorsClientJSON(rest_client.RestClient): post_body = json.dumps(post_body) resp, body = self.post('flavors/%s/action' % flavor_id, post_body) body = json.loads(body) + self.validate_response(schema_access.add_remove_list_flavor_access, + resp, body) return resp, body['flavor_access'] def remove_flavor_access(self, flavor_id, tenant_id): @@ -153,4 +156,6 @@ class FlavorsClientJSON(rest_client.RestClient): post_body = json.dumps(post_body) resp, body = self.post('flavors/%s/action' % flavor_id, post_body) body = json.loads(body) + self.validate_response(schema_access.add_remove_list_flavor_access, + resp, body) return resp, body['flavor_access'] diff --git a/tempest/services/compute/v3/json/flavors_client.py b/tempest/services/compute/v3/json/flavors_client.py index 3fdb3cadbb..1cbbdb2aa2 100644 --- a/tempest/services/compute/v3/json/flavors_client.py +++ b/tempest/services/compute/v3/json/flavors_client.py @@ -128,7 +128,8 @@ class FlavorsV3ClientJSON(rest_client.RestClient): """Gets flavor access information given the flavor id.""" resp, body = self.get('flavors/%s/flavor-access' % flavor_id) body = json.loads(body) - self.validate_response(schema_access.list_flavor_access, resp, body) + self.validate_response(schema_access.add_remove_list_flavor_access, + resp, body) return resp, body['flavor_access'] def add_flavor_access(self, flavor_id, tenant_id): @@ -141,6 +142,8 @@ class FlavorsV3ClientJSON(rest_client.RestClient): post_body = json.dumps(post_body) resp, body = self.post('flavors/%s/action' % flavor_id, post_body) body = json.loads(body) + self.validate_response(schema_access.add_remove_list_flavor_access, + resp, body) return resp, body['flavor_access'] def remove_flavor_access(self, flavor_id, tenant_id): @@ -153,4 +156,6 @@ class FlavorsV3ClientJSON(rest_client.RestClient): post_body = json.dumps(post_body) resp, body = self.post('flavors/%s/action' % flavor_id, post_body) body = json.loads(body) + self.validate_response(schema_access.add_remove_list_flavor_access, + resp, body) return resp, body['flavor_access']