From 8c168dd4fd55aed89b62eec5a0506299dd0d0438 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 12 Sep 2012 10:37:22 -0700 Subject: [PATCH] Adds more servers list and servers details samples This moves the servers detail test into the base servers test so it runs with all_extensions as well. It also renames the results to be consistent with the other tests. Finally it adds test for servers-list both with and without extensions. Change-Id: I6eed3932fa594f1a39faa55453461680781e6a9f --- .../all_extensions/servers-details-resp.json | 69 ++++++++++++++++++ .../all_extensions/servers-details-resp.xml | 24 +++++++ .../all_extensions/servers-list-resp.json | 18 +++++ .../all_extensions/servers-list-resp.xml | 7 ++ ...et-resp.json => servers-details-resp.json} | 0 ...-get-resp.xml => servers-details-resp.xml} | 0 doc/api_samples/servers-list-resp.json | 18 +++++ doc/api_samples/servers-list-resp.xml | 7 ++ .../all_extensions/server-get-resp.json.tpl | 6 +- .../all_extensions/server-get-resp.xml.tpl | 4 +- .../servers-details-resp.json.tpl | 70 +++++++++++++++++++ .../servers-details-resp.xml.tpl | 24 +++++++ .../all_extensions/servers-list-resp.json.tpl | 18 +++++ .../all_extensions/servers-list-resp.xml.tpl | 7 ++ .../api_samples/server-get-resp.json.tpl | 6 +- .../api_samples/server-get-resp.xml.tpl | 4 +- ...json.tpl => servers-details-resp.json.tpl} | 6 +- ...p.xml.tpl => servers-details-resp.xml.tpl} | 4 +- .../api_samples/servers-list-resp.json.tpl | 18 +++++ .../api_samples/servers-list-resp.xml.tpl | 7 ++ nova/tests/integrated/test_api_samples.py | 22 +++--- 21 files changed, 315 insertions(+), 24 deletions(-) create mode 100644 doc/api_samples/all_extensions/servers-details-resp.json create mode 100644 doc/api_samples/all_extensions/servers-details-resp.xml create mode 100644 doc/api_samples/all_extensions/servers-list-resp.json create mode 100644 doc/api_samples/all_extensions/servers-list-resp.xml rename doc/api_samples/{server-detail-get-resp.json => servers-details-resp.json} (100%) rename doc/api_samples/{server-detail-get-resp.xml => servers-details-resp.xml} (100%) create mode 100644 doc/api_samples/servers-list-resp.json create mode 100644 doc/api_samples/servers-list-resp.xml create mode 100644 nova/tests/integrated/api_samples/all_extensions/servers-details-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/all_extensions/servers-details-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/all_extensions/servers-list-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/all_extensions/servers-list-resp.xml.tpl rename nova/tests/integrated/api_samples/{server-detail-get-resp.json.tpl => servers-details-resp.json.tpl} (89%) rename nova/tests/integrated/api_samples/{server-detail-get-resp.xml.tpl => servers-details-resp.xml.tpl} (84%) create mode 100644 nova/tests/integrated/api_samples/servers-list-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/servers-list-resp.xml.tpl diff --git a/doc/api_samples/all_extensions/servers-details-resp.json b/doc/api_samples/all_extensions/servers-details-resp.json new file mode 100644 index 000000000000..dc2698fec3c6 --- /dev/null +++ b/doc/api_samples/all_extensions/servers-details-resp.json @@ -0,0 +1,69 @@ +{ + "servers": [ + { + "OS-DCF:diskConfig": "AUTO", + "OS-EXT-SRV-ATTR:host": "1ed961df12f5434a8e54e0efd1049fa5", + "OS-EXT-SRV-ATTR:hypervisor_hostname": null, + "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", + "OS-EXT-STS:power_state": 1, + "OS-EXT-STS:task_state": null, + "OS-EXT-STS:vm_state": "active", + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "192.168.0.3", + "version": 4 + } + ] + }, + "config_drive": "", + "created": "2012-09-12T17:16:15Z", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "c161a6e3edcd047317a6cfbe599d7711850fd871210b62fdd2f6479e", + "id": "1d0f60bc-8c90-425d-8c64-cdaa49cd2303", + "image": { + "id": "70a599e0-31e7-49b7-b260-868f441e862b", + "links": [ + { + "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", + "rel": "bookmark" + } + ] + }, + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/1d0f60bc-8c90-425d-8c64-cdaa49cd2303", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/1d0f60bc-8c90-425d-8c64-cdaa49cd2303", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "security_groups": [ + { + "name": "default" + } + ], + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "2012-09-12T17:16:15Z", + "user_id": "fake" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/all_extensions/servers-details-resp.xml b/doc/api_samples/all_extensions/servers-details-resp.xml new file mode 100644 index 000000000000..c769c8ec17e1 --- /dev/null +++ b/doc/api_samples/all_extensions/servers-details-resp.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + Apache1 + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/api_samples/all_extensions/servers-list-resp.json b/doc/api_samples/all_extensions/servers-list-resp.json new file mode 100644 index 000000000000..99b9b1dcce41 --- /dev/null +++ b/doc/api_samples/all_extensions/servers-list-resp.json @@ -0,0 +1,18 @@ +{ + "servers": [ + { + "id": "eb51f4a9-8192-4cd0-be78-d8e2c834dbc4", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/eb51f4a9-8192-4cd0-be78-d8e2c834dbc4", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/eb51f4a9-8192-4cd0-be78-d8e2c834dbc4", + "rel": "bookmark" + } + ], + "name": "new-server-test" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/all_extensions/servers-list-resp.xml b/doc/api_samples/all_extensions/servers-list-resp.xml new file mode 100644 index 000000000000..34e7d90f8284 --- /dev/null +++ b/doc/api_samples/all_extensions/servers-list-resp.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/doc/api_samples/server-detail-get-resp.json b/doc/api_samples/servers-details-resp.json similarity index 100% rename from doc/api_samples/server-detail-get-resp.json rename to doc/api_samples/servers-details-resp.json diff --git a/doc/api_samples/server-detail-get-resp.xml b/doc/api_samples/servers-details-resp.xml similarity index 100% rename from doc/api_samples/server-detail-get-resp.xml rename to doc/api_samples/servers-details-resp.xml diff --git a/doc/api_samples/servers-list-resp.json b/doc/api_samples/servers-list-resp.json new file mode 100644 index 000000000000..2cc75eef195f --- /dev/null +++ b/doc/api_samples/servers-list-resp.json @@ -0,0 +1,18 @@ +{ + "servers": [ + { + "id": "616fb98f-46ca-475e-917e-2563e5a8cd19", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/616fb98f-46ca-475e-917e-2563e5a8cd19", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/616fb98f-46ca-475e-917e-2563e5a8cd19", + "rel": "bookmark" + } + ], + "name": "new-server-test" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/servers-list-resp.xml b/doc/api_samples/servers-list-resp.xml new file mode 100644 index 000000000000..cbd7892e7303 --- /dev/null +++ b/doc/api_samples/servers-list-resp.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.json.tpl index c4e2ecf7844a..2c44cdfc038c 100644 --- a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.json.tpl @@ -29,7 +29,7 @@ ] }, "hostId": "%(hostid)s", - "id": "%(uuid)s", + "id": "%(id)s", "image": { "id": "%(uuid)s", "links": [ @@ -42,11 +42,11 @@ "key_name": null, "links": [ { - "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "href": "%(host)s/v2/openstack/servers/%(id)s", "rel": "self" }, { - "href": "%(host)s/openstack/servers/%(uuid)s", + "href": "%(host)s/openstack/servers/%(id)s", "rel": "bookmark" } ], diff --git a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl index 8211a3e0a4fd..d910a7e239ba 100644 --- a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl @@ -14,8 +14,8 @@ - - + + diff --git a/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.json.tpl b/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.json.tpl new file mode 100644 index 000000000000..21185c5d5cc6 --- /dev/null +++ b/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.json.tpl @@ -0,0 +1,70 @@ +{ + "servers": [ + { + "OS-DCF:diskConfig": "AUTO", + "OS-EXT-SRV-ATTR:host": "%(compute_host)s", + "OS-EXT-SRV-ATTR:hypervisor_hostname": null, + "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", + "OS-EXT-STS:power_state": 1, + "OS-EXT-STS:task_state": null, + "OS-EXT-STS:vm_state": "active", + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "config_drive": "", + "created": "%(timestamp)s", + "flavor": { + "id": "1", + "links": [ + { + "href": "%(host)s/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "%(hostid)s", + "id": "%(id)s", + "image": { + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/openstack/images/%(uuid)s", + "rel": "bookmark" + } + ] + }, + "key_name": null, + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "security_groups": [ + { + "name": "default" + } + ], + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } + ] +} diff --git a/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.xml.tpl new file mode 100644 index 000000000000..eb7bed92d845 --- /dev/null +++ b/nova/tests/integrated/api_samples/all_extensions/servers-details-resp.xml.tpl @@ -0,0 +1,24 @@ + + + + + + + + + + + Apache1 + + + + + + + + + + + + + diff --git a/nova/tests/integrated/api_samples/all_extensions/servers-list-resp.json.tpl b/nova/tests/integrated/api_samples/all_extensions/servers-list-resp.json.tpl new file mode 100644 index 000000000000..8b97dc28d7df --- /dev/null +++ b/nova/tests/integrated/api_samples/all_extensions/servers-list-resp.json.tpl @@ -0,0 +1,18 @@ +{ + "servers": [ + { + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "name": "new-server-test" + } + ] +} diff --git a/nova/tests/integrated/api_samples/all_extensions/servers-list-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/servers-list-resp.xml.tpl new file mode 100644 index 000000000000..03bee03a6ea0 --- /dev/null +++ b/nova/tests/integrated/api_samples/all_extensions/servers-list-resp.xml.tpl @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nova/tests/integrated/api_samples/server-get-resp.json.tpl b/nova/tests/integrated/api_samples/server-get-resp.json.tpl index 76907e6c3a1b..86e39aedc6f7 100644 --- a/nova/tests/integrated/api_samples/server-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/server-get-resp.json.tpl @@ -21,7 +21,7 @@ ] }, "hostId": "%(hostid)s", - "id": "%(uuid)s", + "id": "%(id)s", "image": { "id": "%(uuid)s", "links": [ @@ -33,11 +33,11 @@ }, "links": [ { - "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "href": "%(host)s/v2/openstack/servers/%(id)s", "rel": "self" }, { - "href": "%(host)s/openstack/servers/%(uuid)s", + "href": "%(host)s/openstack/servers/%(id)s", "rel": "bookmark" } ], diff --git a/nova/tests/integrated/api_samples/server-get-resp.xml.tpl b/nova/tests/integrated/api_samples/server-get-resp.xml.tpl index f3e4b4bd0466..adc8a5c1b7bc 100644 --- a/nova/tests/integrated/api_samples/server-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/server-get-resp.xml.tpl @@ -14,6 +14,6 @@ - - + + diff --git a/nova/tests/integrated/api_samples/server-detail-get-resp.json.tpl b/nova/tests/integrated/api_samples/servers-details-resp.json.tpl similarity index 89% rename from nova/tests/integrated/api_samples/server-detail-get-resp.json.tpl rename to nova/tests/integrated/api_samples/servers-details-resp.json.tpl index 921bfdf88883..e244ea0dfad4 100644 --- a/nova/tests/integrated/api_samples/server-detail-get-resp.json.tpl +++ b/nova/tests/integrated/api_samples/servers-details-resp.json.tpl @@ -22,7 +22,7 @@ ] }, "hostId": "%(hostid)s", - "id": "%(uuid)s", + "id": "%(id)s", "image": { "id": "%(uuid)s", "links": [ @@ -34,11 +34,11 @@ }, "links": [ { - "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "href": "%(host)s/v2/openstack/servers/%(id)s", "rel": "self" }, { - "href": "%(host)s/openstack/servers/%(uuid)s", + "href": "%(host)s/openstack/servers/%(id)s", "rel": "bookmark" } ], diff --git a/nova/tests/integrated/api_samples/server-detail-get-resp.xml.tpl b/nova/tests/integrated/api_samples/servers-details-resp.xml.tpl similarity index 84% rename from nova/tests/integrated/api_samples/server-detail-get-resp.xml.tpl rename to nova/tests/integrated/api_samples/servers-details-resp.xml.tpl index 4465f68d7faa..568807ecb334 100644 --- a/nova/tests/integrated/api_samples/server-detail-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/servers-details-resp.xml.tpl @@ -15,7 +15,7 @@ - - + + diff --git a/nova/tests/integrated/api_samples/servers-list-resp.json.tpl b/nova/tests/integrated/api_samples/servers-list-resp.json.tpl new file mode 100644 index 000000000000..8b97dc28d7df --- /dev/null +++ b/nova/tests/integrated/api_samples/servers-list-resp.json.tpl @@ -0,0 +1,18 @@ +{ + "servers": [ + { + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "name": "new-server-test" + } + ] +} diff --git a/nova/tests/integrated/api_samples/servers-list-resp.xml.tpl b/nova/tests/integrated/api_samples/servers-list-resp.xml.tpl new file mode 100644 index 000000000000..03bee03a6ea0 --- /dev/null +++ b/nova/tests/integrated/api_samples/servers-list-resp.xml.tpl @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 0c1bfdd3ff79..c03d7d8a3dee 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -236,7 +236,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase): class VersionsSampleJsonTest(ApiSampleTestBase): - def test_servers_get(self): + def test_versions_get(self): response = self._do_get('', strip_version=True) subs = self._get_regexes() return self._verify_response('versions-get-resp', subs, response) @@ -267,24 +267,28 @@ class ServersSampleJsonTest(ServersSampleBase): response = self._do_get('servers/%s' % uuid) subs = self._get_regexes() subs['hostid'] = '[a-f0-9]+' + subs['id'] = uuid return self._verify_response('server-get-resp', subs, response) + def test_servers_list(self): + uuid = self._post_server() + response = self._do_get('servers') + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['id'] = uuid + return self._verify_response('servers-list-resp', subs, response) -class ServersSampleXmlTest(ServersSampleJsonTest): - ctype = 'xml' - - -class ServersDetailJsonTest(ServersSampleBase): - def test_servers_detail_get(self): + def test_servers_details(self): uuid = self._post_server() response = self._do_get('servers/detail') self.assertEqual(response.status, 200) subs = self._get_regexes() subs['hostid'] = '[a-f0-9]+' - return self._verify_response('server-detail-get-resp', subs, response) + subs['id'] = uuid + return self._verify_response('servers-details-resp', subs, response) -class ServersDetailXmlTest(ServersDetailJsonTest): +class ServersSampleXmlTest(ServersSampleJsonTest): ctype = 'xml'