From cbd1457a71f9f8dfaa286de2083e8bafb2298053 Mon Sep 17 00:00:00 2001 From: Haiwei Xu Date: Thu, 3 Apr 2014 01:03:03 +0900 Subject: [PATCH] Verify the response attributes of 'aggregate-add-remove-host' API This patch verifies the response attributes of 'aggregate-add-remove-host'. The response attributes of v2 and v3 are the same: { "aggregate": { "availability_zone": "nova", "created_at": "2012-12-04T12:04:24.399784", "deleted": false, "deleted_at": null, "hosts": [], "id": 1, "metadata": { "availability_zone": "nova" }, "name": "name", "updated_at": null } } The status_code is different: v2 -> 200, v3 -> 202 Partially implements blueprint nova-api-attribute-test Change-Id: I6f6bdc458f15f8af812fee6926e5133df09f9fa1 --- tempest/api_schema/compute/aggregates.py | 2 ++ tempest/api_schema/compute/v3/aggregates.py | 4 ++++ tempest/services/compute/json/aggregates_client.py | 2 ++ tempest/services/compute/v3/json/aggregates_client.py | 2 ++ 4 files changed, 10 insertions(+) diff --git a/tempest/api_schema/compute/aggregates.py b/tempest/api_schema/compute/aggregates.py index 402ad4ed4b..9393a16b5f 100644 --- a/tempest/api_schema/compute/aggregates.py +++ b/tempest/api_schema/compute/aggregates.py @@ -82,3 +82,5 @@ del common_create_aggregate['response_body']['properties']['aggregate'][ common_create_aggregate['response_body']['properties']['aggregate'][ 'required'] = ['availability_zone', 'created_at', 'deleted', 'deleted_at', 'id', 'name', 'updated_at'] + +aggregate_add_remove_host = get_aggregate diff --git a/tempest/api_schema/compute/v3/aggregates.py b/tempest/api_schema/compute/v3/aggregates.py index b9f9915984..02726411f0 100644 --- a/tempest/api_schema/compute/v3/aggregates.py +++ b/tempest/api_schema/compute/v3/aggregates.py @@ -23,3 +23,7 @@ delete_aggregate = { create_aggregate = copy.deepcopy(aggregates.common_create_aggregate) # V3 API's response status_code is 201 create_aggregate['status_code'] = [201] + +aggregate_add_remove_host = copy.deepcopy(aggregates.aggregate_add_remove_host) +# V3 API's response status_code is 202 +aggregate_add_remove_host['status_code'] = [202] diff --git a/tempest/services/compute/json/aggregates_client.py b/tempest/services/compute/json/aggregates_client.py index fa04bfee10..71d6f6333f 100644 --- a/tempest/services/compute/json/aggregates_client.py +++ b/tempest/services/compute/json/aggregates_client.py @@ -88,6 +88,7 @@ class AggregatesClientJSON(rest_client.RestClient): resp, body = self.post('os-aggregates/%s/action' % aggregate_id, post_body) body = json.loads(body) + self.validate_response(schema.aggregate_add_remove_host, resp, body) return resp, body['aggregate'] def remove_host(self, aggregate_id, host): @@ -99,6 +100,7 @@ class AggregatesClientJSON(rest_client.RestClient): resp, body = self.post('os-aggregates/%s/action' % aggregate_id, post_body) body = json.loads(body) + self.validate_response(schema.aggregate_add_remove_host, resp, body) return resp, body['aggregate'] def set_metadata(self, aggregate_id, meta): diff --git a/tempest/services/compute/v3/json/aggregates_client.py b/tempest/services/compute/v3/json/aggregates_client.py index ee15c52a6e..d9b79305ae 100644 --- a/tempest/services/compute/v3/json/aggregates_client.py +++ b/tempest/services/compute/v3/json/aggregates_client.py @@ -88,6 +88,7 @@ class AggregatesV3ClientJSON(rest_client.RestClient): resp, body = self.post('os-aggregates/%s/action' % aggregate_id, post_body) body = json.loads(body) + self.validate_response(v3_schema.aggregate_add_remove_host, resp, body) return resp, body['aggregate'] def remove_host(self, aggregate_id, host): @@ -99,6 +100,7 @@ class AggregatesV3ClientJSON(rest_client.RestClient): resp, body = self.post('os-aggregates/%s/action' % aggregate_id, post_body) body = json.loads(body) + self.validate_response(v3_schema.aggregate_add_remove_host, resp, body) return resp, body['aggregate'] def set_metadata(self, aggregate_id, meta):