diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-12 23:21:20 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-12 23:21:20 +0000 |
| commit | 5bb5a10abc9d3731303e87f129256e331e6359b4 (patch) | |
| tree | d1a7222436508ba9b7fac744cf7c32f90130278c /nova | |
| parent | e13b19ab3e7857fdd4c5a185df81879f97b7dd4d (diff) | |
| parent | 223b9f19e5bc1cb09d1837237ecd2494c1c49616 (diff) | |
| download | nova-5bb5a10abc9d3731303e87f129256e331e6359b4.tar.gz nova-5bb5a10abc9d3731303e87f129256e331e6359b4.tar.xz nova-5bb5a10abc9d3731303e87f129256e331e6359b4.zip | |
Merge "Adds API sample test for Flavors Extra Data extension."
Diffstat (limited to 'nova')
9 files changed, 228 insertions, 0 deletions
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 new file mode 100644 index 000000000..3b421b4e1 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.json.tpl @@ -0,0 +1,20 @@ +{ + "flavor": { + "OS-FLV-EXT-DATA:ephemeral": 0, + "disk": 0, + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/1", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny", + "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 new file mode 100644 index 000000000..dfecff1fc --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-get-resp.xml.tpl @@ -0,0 +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 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 new file mode 100644 index 000000000..ee7696bed --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.json.tpl @@ -0,0 +1,94 @@ +{ + "flavors": [ + { + "OS-FLV-EXT-DATA:ephemeral": 0, + "disk": 0, + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/1", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ], + "name": "m1.tiny", + "ram": 512, + "vcpus": 1 + }, + { + "OS-FLV-EXT-DATA:ephemeral": 0, + "disk": 20, + "id": "2", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/2", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/2", + "rel": "bookmark" + } + ], + "name": "m1.small", + "ram": 2048, + "vcpus": 1 + }, + { + "OS-FLV-EXT-DATA:ephemeral": 0, + "disk": 40, + "id": "3", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/3", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/3", + "rel": "bookmark" + } + ], + "name": "m1.medium", + "ram": 4096, + "vcpus": 2 + }, + { + "OS-FLV-EXT-DATA:ephemeral": 0, + "disk": 80, + "id": "4", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/4", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/4", + "rel": "bookmark" + } + ], + "name": "m1.large", + "ram": 8192, + "vcpus": 4 + }, + { + "OS-FLV-EXT-DATA:ephemeral": 0, + "disk": 160, + "id": "5", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/5", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/5", + "rel": "bookmark" + } + ], + "name": "m1.xlarge", + "ram": 16384, + "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 new file mode 100644 index 000000000..7b53621b7 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-list-resp.xml.tpl @@ -0,0 +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"/> + </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"/> + </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"/> + </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"/> + </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"/> + </flavor> +</flavors>
\ 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 new file mode 100644 index 000000000..b0e481a62 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.json.tpl @@ -0,0 +1,12 @@ +{ + "flavor": { + "OS-FLV-EXT-DATA:ephemeral": 30, + "disk": 10, + "id": "666", + "name": "flavortest", + "ram": 1024, + "rxtx_factor": 2, + "swap": 5, + "vcpus": 2 + } +}
\ No newline at end of file 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 new file mode 100644 index 000000000..ec1ec2e2b --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-req.xml.tpl @@ -0,0 +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" + ram="1024" + vcpus="2" + disk="10" + id="666" + swap="5" + rxtx_factor="2" + OS-FLV-EXT-DATA:ephemeral="30" />
\ No newline at end of file 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 new file mode 100644 index 000000000..9eb2c77ff --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.json.tpl @@ -0,0 +1,20 @@ +{ + "flavor": { + "OS-FLV-EXT-DATA:ephemeral": 30, + "disk": 10, + "id": "666", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/flavors/666", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/flavors/666", + "rel": "bookmark" + } + ], + "name": "flavortest", + "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 new file mode 100644 index 000000000..c877553a1 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-FLV-EXT-DATA/flavors-extra-data-post-resp.xml.tpl @@ -0,0 +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 diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 0c1bfdd3f..bc559df2d 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -511,3 +511,41 @@ class ServerStartStopJsonTest(ServersSampleBase): class ServerStartStopXmlTest(ServerStartStopJsonTest): ctype = 'xml' + + +class FlavorsExtraDataJsonTest(ApiSampleTestBase): + extension_name = ('nova.api.openstack.compute.contrib.flavorextradata.' + 'Flavorextradata') + + def _get_flags(self): + f = super(FlavorsExtraDataJsonTest, self)._get_flags() + f['osapi_compute_extension'] = FLAGS.osapi_compute_extension[:] + # Flavorextradata extension also needs Flavormanage to be loaded. + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.flavormanage.Flavormanage') + return f + + def test_flavors_extra_data_get(self): + response = self._do_get('flavors/1') + subs = 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') + subs = self._get_regexes() + return self._verify_response('flavors-extra-data-list-resp', subs, + response) + + def test_flavors_extra_data_post(self): + response = self._do_post('flavors', + 'flavors-extra-data-post-req', + {}) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + return self._verify_response('flavors-extra-data-post-resp', + subs, response) + + +class FlavorsExtraDataXmlTest(FlavorsExtraDataJsonTest): + ctype = 'xml' |
