From 2d85cb2c38cc0aa077277a811c8d756bbdfc4f10 Mon Sep 17 00:00:00 2001 From: Giampaolo Lauria Date: Mon, 10 Dec 2012 16:47:48 -0500 Subject: [PATCH] Modified sample tests to FlavorExtraData API. Added subs wherever applicable. Added checks for correct return codes after REST ops Modified sample tests to FlavorManage API to differentiate them from the ones in FlavorExtraData. Partially implements blueprint nova-api-samples Fixes bug 1070162 Change-Id: I57c6611f379bef2ff586551b5501c4f7654e4374 --- .../flavors-extra-data-post-req.json | 12 +++++----- .../flavors-extra-data-post-req.xml | 4 ++-- .../flavors-extra-data-post-resp.xml | 2 +- .../flavor-create-post-req.json | 4 ---- .../flavor-create-post-req.xml | 2 -- .../flavors-extra-data-get-resp.json.tpl | 10 ++++----- .../flavors-extra-data-get-resp.xml.tpl | 8 +++---- .../flavors-extra-data-list-resp.json.tpl | 22 +++++++++---------- .../flavors-extra-data-list-resp.xml.tpl | 22 +++++++++---------- .../flavors-extra-data-post-req.json.tpl | 12 +++++----- .../flavors-extra-data-post-req.xml.tpl | 4 ++-- .../flavors-extra-data-post-resp.json.tpl | 10 ++++----- .../flavors-extra-data-post-resp.xml.tpl | 8 +++---- .../flavor-create-post-req.json.tpl | 6 +---- .../flavor-create-post-req.xml.tpl | 2 -- nova/tests/integrated/test_api_samples.py | 21 +++++++++++++----- 16 files changed, 74 insertions(+), 75 deletions(-) diff --git a/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json b/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json index 0a88eb248390..787f5f3b7f6b 100644 --- a/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json +++ b/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json @@ -1,12 +1,12 @@ { "flavor": { - "OS-FLV-EXT-DATA:ephemeral": 30, - "disk": 10, - "id": "666", "name": "flavortest", "ram": 1024, + "vcpus": 2, + "disk": 10, + "id": "666", "rxtx_factor": 2.0, - "swap": 5, - "vcpus": 2 + "OS-FLV-EXT-DATA:ephemeral": 30, + "swap": 5 } -} +} \ No newline at end of file diff --git a/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml b/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml index cc2d05eed510..99aec19ed809 100644 --- a/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml +++ b/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml @@ -1,11 +1,11 @@ + OS-FLV-EXT-DATA:ephemeral="30" /> \ No newline at end of file diff --git a/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml b/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml index c877553a1b27..7da3e237970d 100644 --- a/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml +++ b/doc/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/doc/api_samples/os-flavor-manage/flavor-create-post-req.json b/doc/api_samples/os-flavor-manage/flavor-create-post-req.json index 9c5661cdbf6f..8a3830f09434 100644 --- a/doc/api_samples/os-flavor-manage/flavor-create-post-req.json +++ b/doc/api_samples/os-flavor-manage/flavor-create-post-req.json @@ -5,9 +5,5 @@ "vcpus": 2, "disk": 10, "id": "10", - "os-flavor-access:is_public": true, - "rxtx_factor": 1, - "OS-FLV-EXT-DATA:ephemeral": 0, - "swap": 0 } } diff --git a/doc/api_samples/os-flavor-manage/flavor-create-post-req.xml b/doc/api_samples/os-flavor-manage/flavor-create-post-req.xml index 2018acb0f305..b90c108d0ce7 100644 --- a/doc/api_samples/os-flavor-manage/flavor-create-post-req.xml +++ b/doc/api_samples/os-flavor-manage/flavor-create-post-req.xml @@ -5,6 +5,4 @@ 2 10 10 - 1 - 0 diff --git a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.json.tpl b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.json.tpl index 3b421b4e1ddf..3422de9f5ebd 100644 --- a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.json.tpl @@ -2,19 +2,19 @@ "flavor": { "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, - "id": "1", + "id": "%(flavor_id)s", "links": [ { - "href": "http://openstack.example.com/v2/openstack/flavors/1", + "href": "%(host)s/v2/openstack/flavors/%(flavor_id)s", "rel": "self" }, { - "href": "http://openstack.example.com/openstack/flavors/1", + "href": "%(host)s/openstack/flavors/%(flavor_id)s", "rel": "bookmark" } ], - "name": "m1.tiny", + "name": "%(flavor_name)s", "ram": 512, "vcpus": 1 } -} \ No newline at end of file +} diff --git a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.xml.tpl index dfecff1fc35f..dc143010a88c 100644 --- a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.xml.tpl @@ -1,5 +1,5 @@ - - - - \ No newline at end of file + + + + diff --git a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.json.tpl b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.json.tpl index ee7696bed73b..2c79efeaf468 100644 --- a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.json.tpl @@ -6,11 +6,11 @@ "id": "1", "links": [ { - "href": "http://openstack.example.com/v2/openstack/flavors/1", + "href": "%(host)s/v2/openstack/flavors/1", "rel": "self" }, { - "href": "http://openstack.example.com/openstack/flavors/1", + "href": "%(host)s/openstack/flavors/1", "rel": "bookmark" } ], @@ -24,11 +24,11 @@ "id": "2", "links": [ { - "href": "http://openstack.example.com/v2/openstack/flavors/2", + "href": "%(host)s/v2/openstack/flavors/2", "rel": "self" }, { - "href": "http://openstack.example.com/openstack/flavors/2", + "href": "%(host)s/openstack/flavors/2", "rel": "bookmark" } ], @@ -42,11 +42,11 @@ "id": "3", "links": [ { - "href": "http://openstack.example.com/v2/openstack/flavors/3", + "href": "%(host)s/v2/openstack/flavors/3", "rel": "self" }, { - "href": "http://openstack.example.com/openstack/flavors/3", + "href": "%(host)s/openstack/flavors/3", "rel": "bookmark" } ], @@ -60,11 +60,11 @@ "id": "4", "links": [ { - "href": "http://openstack.example.com/v2/openstack/flavors/4", + "href": "%(host)s/v2/openstack/flavors/4", "rel": "self" }, { - "href": "http://openstack.example.com/openstack/flavors/4", + "href": "%(host)s/openstack/flavors/4", "rel": "bookmark" } ], @@ -78,11 +78,11 @@ "id": "5", "links": [ { - "href": "http://openstack.example.com/v2/openstack/flavors/5", + "href": "%(host)s/v2/openstack/flavors/5", "rel": "self" }, { - "href": "http://openstack.example.com/openstack/flavors/5", + "href": "%(host)s/openstack/flavors/5", "rel": "bookmark" } ], @@ -91,4 +91,4 @@ "vcpus": 8 } ] -} \ No newline at end of file +} diff --git a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.xml.tpl index 7b53621b7a19..7108ebd79be8 100644 --- a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.xml.tpl @@ -1,23 +1,23 @@ - - + + - - + + - - + + - - + + - - + + - \ No newline at end of file + diff --git a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json.tpl b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json.tpl index 0a88eb248390..64385ad682d5 100644 --- a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json.tpl +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json.tpl @@ -1,12 +1,12 @@ { "flavor": { - "OS-FLV-EXT-DATA:ephemeral": 30, - "disk": 10, - "id": "666", - "name": "flavortest", + "name": "%(flavor_name)s", "ram": 1024, + "vcpus": 2, + "disk": 10, + "id": "%(flavor_id)s", "rxtx_factor": 2.0, - "swap": 5, - "vcpus": 2 + "OS-FLV-EXT-DATA:ephemeral": 30, + "swap": 5 } } diff --git a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml.tpl b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml.tpl index cc2d05eed510..df74ab383fdc 100644 --- a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml.tpl +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml.tpl @@ -1,11 +1,11 @@ diff --git a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.json.tpl b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.json.tpl index 9eb2c77ff528..3a92dabca862 100644 --- a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.json.tpl +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.json.tpl @@ -2,19 +2,19 @@ "flavor": { "OS-FLV-EXT-DATA:ephemeral": 30, "disk": 10, - "id": "666", + "id": "%(flavor_id)s", "links": [ { - "href": "http://openstack.example.com/v2/openstack/flavors/666", + "href": "%(host)s/v2/openstack/flavors/%(flavor_id)s", "rel": "self" }, { - "href": "http://openstack.example.com/openstack/flavors/666", + "href": "%(host)s/openstack/flavors/%(flavor_id)s", "rel": "bookmark" } ], - "name": "flavortest", + "name": "%(flavor_name)s", "ram": 1024, "vcpus": 2 } -} \ No newline at end of file +} diff --git a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml.tpl index c877553a1b27..df7fc07a324c 100644 --- a/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml.tpl @@ -1,5 +1,5 @@ - - - - \ No newline at end of file + + + + diff --git a/nova/tests/integrated/api_samples/os-flavor-manage/flavor-create-post-req.json.tpl b/nova/tests/integrated/api_samples/os-flavor-manage/flavor-create-post-req.json.tpl index 9ff3957b9c8e..5383e5d15e43 100644 --- a/nova/tests/integrated/api_samples/os-flavor-manage/flavor-create-post-req.json.tpl +++ b/nova/tests/integrated/api_samples/os-flavor-manage/flavor-create-post-req.json.tpl @@ -4,10 +4,6 @@ "ram": 1024, "vcpus": 2, "disk": 10, - "id": "%(flavor_id)s", - "os-flavor-access:is_public": true, - "rxtx_factor": 1, - "OS-FLV-EXT-DATA:ephemeral": 0, - "swap": 0 + "id": "%(flavor_id)s" } } diff --git a/nova/tests/integrated/api_samples/os-flavor-manage/flavor-create-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-flavor-manage/flavor-create-post-req.xml.tpl index 6b03dc2f91a9..764cebe8e49e 100644 --- a/nova/tests/integrated/api_samples/os-flavor-manage/flavor-create-post-req.xml.tpl +++ b/nova/tests/integrated/api_samples/os-flavor-manage/flavor-create-post-req.xml.tpl @@ -5,6 +5,4 @@ 2 10 %(flavor_id)s - 1 - 0 diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index b864b84fadfb..6648fa896fb9 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -774,23 +774,34 @@ class FlavorsExtraDataJsonTest(ApiSampleTestBase): return f def test_flavors_extra_data_get(self): - response = self._do_get('flavors/1') - subs = self._get_regexes() + flavor_id = 1 + response = self._do_get('flavors/%s' % flavor_id) + self.assertEqual(response.status, 200) + subs = { + 'flavor_id': flavor_id, + 'flavor_name': 'm1.tiny' + } + subs.update(self._get_regexes()) return self._verify_response('flavors-extra-data-get-resp', subs, response) def test_flavors_extra_data_list(self): response = self._do_get('flavors/detail') + self.assertEqual(response.status, 200) subs = self._get_regexes() return self._verify_response('flavors-extra-data-list-resp', subs, response) - def test_flavors_extra_data_post(self): + def test_flavors_extra_data_create(self): + subs = { + 'flavor_id': 666, + 'flavor_name': 'flavortest' + } response = self._do_post('flavors', 'flavors-extra-data-post-req', - {}) + subs) self.assertEqual(response.status, 200) - subs = self._get_regexes() + subs.update(self._get_regexes()) return self._verify_response('flavors-extra-data-post-resp', subs, response)