From 530b48386b9b2d4a0ad85095d6a929cdd0153274 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Tue, 27 Nov 2012 21:19:53 +0000 Subject: Added sample tests to extended status API. Partially implements blueprint nova-api-samples Fixes bug 1070160 Change-Id: Ide7119a308a03ded101ae76faf8204352ffc8566 --- doc/api_samples/OS-EXT-STS/server-post-req.json | 16 ++++++ doc/api_samples/OS-EXT-STS/server-post-req.xml | 19 +++++++ doc/api_samples/OS-EXT-STS/server-post-resp.json | 16 ++++++ doc/api_samples/OS-EXT-STS/server-post-resp.xml | 6 +++ .../OS-EXT-STS/servers-detail-resp.json | 59 ++++++++++++++++++++++ doc/api_samples/OS-EXT-STS/servers-detail-resp.xml | 21 ++++++++ doc/api_samples/OS-EXT-STS/servers-list-resp.json | 18 +++++++ doc/api_samples/OS-EXT-STS/servers-list-resp.xml | 7 +++ .../OS-EXT-STS/server-post-req.json.tpl | 16 ++++++ .../api_samples/OS-EXT-STS/server-post-req.xml.tpl | 19 +++++++ .../OS-EXT-STS/server-post-resp.json.tpl | 16 ++++++ .../OS-EXT-STS/server-post-resp.xml.tpl | 6 +++ .../OS-EXT-STS/servers-detail-resp.json.tpl | 58 +++++++++++++++++++++ .../OS-EXT-STS/servers-detail-resp.xml.tpl | 21 ++++++++ .../OS-EXT-STS/servers-list-resp.json.tpl | 18 +++++++ .../OS-EXT-STS/servers-list-resp.xml.tpl | 7 +++ nova/tests/integrated/test_api_samples.py | 26 ++++++++++ 17 files changed, 349 insertions(+) create mode 100644 doc/api_samples/OS-EXT-STS/server-post-req.json create mode 100644 doc/api_samples/OS-EXT-STS/server-post-req.xml create mode 100644 doc/api_samples/OS-EXT-STS/server-post-resp.json create mode 100644 doc/api_samples/OS-EXT-STS/server-post-resp.xml create mode 100644 doc/api_samples/OS-EXT-STS/servers-detail-resp.json create mode 100644 doc/api_samples/OS-EXT-STS/servers-detail-resp.xml create mode 100644 doc/api_samples/OS-EXT-STS/servers-list-resp.json create mode 100644 doc/api_samples/OS-EXT-STS/servers-list-resp.xml create mode 100644 nova/tests/integrated/api_samples/OS-EXT-STS/server-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-EXT-STS/server-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-EXT-STS/server-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-EXT-STS/server-post-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/OS-EXT-STS/servers-list-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/OS-EXT-STS/servers-list-resp.xml.tpl diff --git a/doc/api_samples/OS-EXT-STS/server-post-req.json b/doc/api_samples/OS-EXT-STS/server-post-req.json new file mode 100644 index 000000000..09366b4c9 --- /dev/null +++ b/doc/api_samples/OS-EXT-STS/server-post-req.json @@ -0,0 +1,16 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", + "flavorRef" : "http://openstack.example.com/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/doc/api_samples/OS-EXT-STS/server-post-req.xml b/doc/api_samples/OS-EXT-STS/server-post-req.xml new file mode 100644 index 000000000..077dd7618 --- /dev/null +++ b/doc/api_samples/OS-EXT-STS/server-post-req.xml @@ -0,0 +1,19 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + diff --git a/doc/api_samples/OS-EXT-STS/server-post-resp.json b/doc/api_samples/OS-EXT-STS/server-post-resp.json new file mode 100644 index 000000000..db9ed3d6d --- /dev/null +++ b/doc/api_samples/OS-EXT-STS/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "MVk5HPrazHcG", + "id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/5bbcc3c4-1da2-4437-a48a-66f15b1b13f9", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/5bbcc3c4-1da2-4437-a48a-66f15b1b13f9", + "rel": "bookmark" + } + ] + } +} diff --git a/doc/api_samples/OS-EXT-STS/server-post-resp.xml b/doc/api_samples/OS-EXT-STS/server-post-resp.xml new file mode 100644 index 000000000..68f0933c7 --- /dev/null +++ b/doc/api_samples/OS-EXT-STS/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/doc/api_samples/OS-EXT-STS/servers-detail-resp.json b/doc/api_samples/OS-EXT-STS/servers-detail-resp.json new file mode 100644 index 000000000..6764bd883 --- /dev/null +++ b/doc/api_samples/OS-EXT-STS/servers-detail-resp.json @@ -0,0 +1,59 @@ +{ + "servers": [ + { + "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 + } + ] + }, + "created": "2012-12-05T07:34:10Z", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "585aa01f94eca692eff9f77ffe3eab866d8a819e97397e28c5c7df12", + "id": "030758aa-5c41-41c6-8fb4-29d44eb96a85", + "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/030758aa-5c41-41c6-8fb4-29d44eb96a85", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/030758aa-5c41-41c6-8fb4-29d44eb96a85", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "2012-12-05T07:34:10Z", + "user_id": "fake" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-STS/servers-detail-resp.xml b/doc/api_samples/OS-EXT-STS/servers-detail-resp.xml new file mode 100644 index 000000000..e4dafd70b --- /dev/null +++ b/doc/api_samples/OS-EXT-STS/servers-detail-resp.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + Apache1 + + + + + + + + + + \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-STS/servers-list-resp.json b/doc/api_samples/OS-EXT-STS/servers-list-resp.json new file mode 100644 index 000000000..d0309cc1f --- /dev/null +++ b/doc/api_samples/OS-EXT-STS/servers-list-resp.json @@ -0,0 +1,18 @@ +{ + "servers": [ + { + "id": "a5dd5b16-552c-441c-8a03-f19c4da9e6f5", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/a5dd5b16-552c-441c-8a03-f19c4da9e6f5", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/a5dd5b16-552c-441c-8a03-f19c4da9e6f5", + "rel": "bookmark" + } + ], + "name": "new-server-test" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/OS-EXT-STS/servers-list-resp.xml b/doc/api_samples/OS-EXT-STS/servers-list-resp.xml new file mode 100644 index 000000000..f1c3cabf4 --- /dev/null +++ b/doc/api_samples/OS-EXT-STS/servers-list-resp.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-req.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-req.json.tpl new file mode 100644 index 000000000..d3916d1aa --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-req.json.tpl @@ -0,0 +1,16 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-req.xml.tpl new file mode 100644 index 000000000..f92614984 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-req.xml.tpl @@ -0,0 +1,19 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-resp.json.tpl new file mode 100644 index 000000000..d5f030c87 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "%(password)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(uuid)s", + "rel": "bookmark" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-resp.xml.tpl new file mode 100644 index 000000000..3bb13e69b --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/server-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.json.tpl new file mode 100644 index 000000000..48df845f1 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.json.tpl @@ -0,0 +1,58 @@ +{ + "servers": [ + { + "status": "ACTIVE", + "updated": "%(timestamp)s", + "OS-EXT-STS:task_state": null, + "user_id": "fake", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "created": "%(timestamp)s", + "name": "new-server-test", + "image": { + "id": "%(uuid)s", + "links": [ + { + "href": "%(host)s/openstack/images/%(uuid)s", + "rel": "bookmark" + } + ] + }, + "id": "%(uuid)s", + "accessIPv4": "", + "accessIPv6": "", + "OS-EXT-STS:vm_state": "active", + "tenant_id": "openstack", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "flavor": { + "id": "1", + "links": [ + { + "href": "%(host)s/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "%(hostid)s", + "metadata": { + "My Server Name": "Apache1" + } + }] +} diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.xml.tpl new file mode 100644 index 000000000..cf273a6bf --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/servers-detail-resp.xml.tpl @@ -0,0 +1,21 @@ + + + + + + + + + + + Apache1 + + + + + + + + + + diff --git a/nova/tests/integrated/api_samples/OS-EXT-STS/servers-list-resp.json.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/servers-list-resp.json.tpl new file mode 100644 index 000000000..8b97dc28d --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/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/OS-EXT-STS/servers-list-resp.xml.tpl b/nova/tests/integrated/api_samples/OS-EXT-STS/servers-list-resp.xml.tpl new file mode 100644 index 000000000..03bee03a6 --- /dev/null +++ b/nova/tests/integrated/api_samples/OS-EXT-STS/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 4936ff2cb..1fbf16fd3 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -1722,3 +1722,29 @@ class QuotasSampleJsonTests(ApiSampleTestBase): class QuotasSampleXmlTests(QuotasSampleJsonTests): ctype = "xml" + + +class ExtendedStatusSampleJsonTests(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib" + ".extended_status.Extended_status") + + def test_show(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) + + def test_detail(self): + uuid = self._post_server() + response = self._do_get('servers/detail') + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['id'] = uuid + subs['hostid'] = '[a-f0-9]+' + return self._verify_response('servers-detail-resp', subs, response) + + +class ExtendedStatusSampleXmlTests(ExtendedStatusSampleJsonTests): + ctype = 'xml' -- cgit