diff options
| author | Giampaolo Lauria <lauria@us.ibm.com> | 2012-12-10 16:47:48 -0500 |
|---|---|---|
| committer | Giampaolo Lauria <lauria@us.ibm.com> | 2012-12-10 22:43:43 -0500 |
| commit | 2d85cb2c38cc0aa077277a811c8d756bbdfc4f10 (patch) | |
| tree | 61754b3b829f28f6a4536c33ba1bec5bdb42ca9b | |
| parent | fcedc02a6f320681ae20bc1641c8bf6cd519885e (diff) | |
| download | nova-2d85cb2c38cc0aa077277a811c8d756bbdfc4f10.tar.gz nova-2d85cb2c38cc0aa077277a811c8d756bbdfc4f10.tar.xz nova-2d85cb2c38cc0aa077277a811c8d756bbdfc4f10.zip | |
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
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 0a88eb248..787f5f3b7 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 cc2d05eed..99aec19ed 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 @@ <?xml version="1.0" encoding="UTF-8"?> <flavor xmlns="http://docs.openstack.org/compute/api/v1.1" xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" - name="testflavor1" + name="flavortest" ram="1024" vcpus="2" disk="10" id="666" swap="5" rxtx_factor="2.0" - OS-FLV-EXT-DATA:ephemeral="30" /> + 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 c877553a1..7da3e2379 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 @@ <?xml version='1.0' encoding='UTF-8'?> -<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="testflavor1" id="666" OS-FLV-EXT-DATA:ephemeral="30"> +<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="flavortest" id="666" OS-FLV-EXT-DATA:ephemeral="30"> <atom:link href="http://openstack.example.com/v2/openstack/flavors/666" rel="self"/> <atom:link href="http://openstack.example.com/openstack/flavors/666" rel="bookmark"/> </flavor>
\ 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 9c5661cdb..8a3830f09 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 2018acb0f..b90c108d0 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 @@ <vcpus>2</vcpus> <disk>10</disk> <id>10</id> - <rxtx_factor>1</rxtx_factor> - <swap>0</swap> </flavor> 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 3b421b4e1..3422de9f5 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 dfecff1fc..dc143010a 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 @@ <?xml version='1.0' encoding='UTF-8'?> -<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-EXT-DATA:ephemeral="0"> - <atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/> - <atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/> -</flavor>
\ No newline at end of file +<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="0" vcpus="1" ram="512" name="%(flavor_name)s" id="%(flavor_id)s" OS-FLV-EXT-DATA:ephemeral="0"> + <atom:link href="%(host)s/v2/openstack/flavors/%(flavor_id)s" rel="self"/> + <atom:link href="%(host)s/openstack/flavors/%(flavor_id)s" rel="bookmark"/> +</flavor> 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 ee7696bed..2c79efeaf 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 7b53621b7..7108ebd79 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 @@ <?xml version='1.0' encoding='UTF-8'?> <flavors xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1"> <flavor disk="0" vcpus="1" ram="512" name="m1.tiny" id="1" OS-FLV-EXT-DATA:ephemeral="0"> - <atom:link href="http://openstack.example.com/v2/openstack/flavors/1" rel="self"/> - <atom:link href="http://openstack.example.com/openstack/flavors/1" rel="bookmark"/> + <atom:link href="%(host)s/v2/openstack/flavors/1" rel="self"/> + <atom:link href="%(host)s/openstack/flavors/1" rel="bookmark"/> </flavor> <flavor disk="20" vcpus="1" ram="2048" name="m1.small" id="2" OS-FLV-EXT-DATA:ephemeral="0"> - <atom:link href="http://openstack.example.com/v2/openstack/flavors/2" rel="self"/> - <atom:link href="http://openstack.example.com/openstack/flavors/2" rel="bookmark"/> + <atom:link href="%(host)s/v2/openstack/flavors/2" rel="self"/> + <atom:link href="%(host)s/openstack/flavors/2" rel="bookmark"/> </flavor> <flavor disk="40" vcpus="2" ram="4096" name="m1.medium" id="3" OS-FLV-EXT-DATA:ephemeral="0"> - <atom:link href="http://openstack.example.com/v2/openstack/flavors/3" rel="self"/> - <atom:link href="http://openstack.example.com/openstack/flavors/3" rel="bookmark"/> + <atom:link href="%(host)s/v2/openstack/flavors/3" rel="self"/> + <atom:link href="%(host)s/openstack/flavors/3" rel="bookmark"/> </flavor> <flavor disk="80" vcpus="4" ram="8192" name="m1.large" id="4" OS-FLV-EXT-DATA:ephemeral="0"> - <atom:link href="http://openstack.example.com/v2/openstack/flavors/4" rel="self"/> - <atom:link href="http://openstack.example.com/openstack/flavors/4" rel="bookmark"/> + <atom:link href="%(host)s/v2/openstack/flavors/4" rel="self"/> + <atom:link href="%(host)s/openstack/flavors/4" rel="bookmark"/> </flavor> <flavor disk="160" vcpus="8" ram="16384" name="m1.xlarge" id="5" OS-FLV-EXT-DATA:ephemeral="0"> - <atom:link href="http://openstack.example.com/v2/openstack/flavors/5" rel="self"/> - <atom:link href="http://openstack.example.com/openstack/flavors/5" rel="bookmark"/> + <atom:link href="%(host)s/v2/openstack/flavors/5" rel="self"/> + <atom:link href="%(host)s/openstack/flavors/5" rel="bookmark"/> </flavor> -</flavors>
\ No newline at end of file +</flavors> 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 0a88eb248..64385ad68 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 cc2d05eed..df74ab383 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 @@ <?xml version="1.0" encoding="UTF-8"?> <flavor xmlns="http://docs.openstack.org/compute/api/v1.1" xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" - name="testflavor1" + name="%(flavor_name)s" ram="1024" vcpus="2" disk="10" - id="666" + id="%(flavor_id)s" swap="5" rxtx_factor="2.0" OS-FLV-EXT-DATA:ephemeral="30" /> 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 9eb2c77ff..3a92dabca 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 c877553a1..df7fc07a3 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 @@ <?xml version='1.0' encoding='UTF-8'?> -<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="testflavor1" id="666" OS-FLV-EXT-DATA:ephemeral="30"> - <atom:link href="http://openstack.example.com/v2/openstack/flavors/666" rel="self"/> - <atom:link href="http://openstack.example.com/openstack/flavors/666" rel="bookmark"/> -</flavor>
\ No newline at end of file +<flavor xmlns:OS-FLV-EXT-DATA="http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" disk="10" vcpus="2" ram="1024" name="%(flavor_name)s" id="%(flavor_id)s" OS-FLV-EXT-DATA:ephemeral="30"> + <atom:link href="%(host)s/v2/openstack/flavors/%(flavor_id)s" rel="self"/> + <atom:link href="%(host)s/openstack/flavors/%(flavor_id)s" rel="bookmark"/> +</flavor> 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 9ff3957b9..5383e5d15 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 6b03dc2f9..764cebe8e 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 @@ <vcpus>2</vcpus> <disk>10</disk> <id>%(flavor_id)s</id> - <rxtx_factor>1</rxtx_factor> - <swap>0</swap> </flavor> diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index b864b84fa..6648fa896 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) |
