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 --- .../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 ++++++++++ 9 files changed, 187 insertions(+) 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 (limited to 'nova') 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