diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-12-05 13:31:09 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-12-05 13:31:09 +0000 |
| commit | 5770146195ed9fcbb381faafffdb423432f6929d (patch) | |
| tree | 7d951f06b2f3b1db302d23470a68e4e6d067fc06 /nova | |
| parent | 6a70741508b8ec66c78acd0ff57fdd9f441e81a3 (diff) | |
| parent | 530b48386b9b2d4a0ad85095d6a929cdd0153274 (diff) | |
| download | nova-5770146195ed9fcbb381faafffdb423432f6929d.tar.gz nova-5770146195ed9fcbb381faafffdb423432f6929d.tar.xz nova-5770146195ed9fcbb381faafffdb423432f6929d.zip | |
Merge "Added sample tests to extended status API."
Diffstat (limited to 'nova')
9 files changed, 187 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<server xmlns="http://docs.openstack.org/compute/api/v1.1" imageRef="%(host)s/openstack/images/%(image_id)s" flavorRef="%(host)s/openstack/flavors/1" name="new-server-test"> + <metadata> + <meta key="My Server Name">Apache1</meta> + </metadata> + <personality> + <file path="/etc/banner.txt"> + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + </file> + </personality> +</server> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="%(id)s" adminPass="%(password)s"> + <metadata/> + <atom:link href="%(host)s/v2/openstack/servers/%(uuid)s" rel="self"/> + <atom:link href="%(host)s/openstack/servers/%(uuid)s" rel="bookmark"/> +</server> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<servers xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1"> + <server xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s" OS-EXT-STS:vm_state="active" OS-EXT-STS:task_state="None" OS-EXT-STS:power_state="1" > + <image id="%(uuid)s"> + <atom:link href="%(host)s/openstack/images/%(uuid)s" rel="bookmark"/> + </image> + <flavor id="1"> + <atom:link href="%(host)s/openstack/flavors/1" rel="bookmark"/> + </flavor> + <metadata> + <meta key="My Server Name">Apache1</meta> + </metadata> + <addresses> + <network id="private"> + <ip version="4" addr="%(ip)s"/> + </network> + </addresses> + <atom:link href="%(host)s/v2/openstack/servers/%(id)s" rel="self"/> + <atom:link href="%(host)s/openstack/servers/%(id)s" rel="bookmark"/> + </server> +</servers> 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 @@ +<?xml version='1.0' encoding='UTF-8'?> +<servers xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1"> + <server name="new-server-test" id="%(id)s"> + <atom:link href="%(host)s/v2/openstack/servers/%(id)s" rel="self"/> + <atom:link href="%(host)s/openstack/servers/%(id)s" rel="bookmark"/> + </server> +</servers> 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' |
