diff options
| author | Dan Smith <danms@us.ibm.com> | 2012-09-05 11:33:49 -0700 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2012-09-07 15:17:21 -0700 |
| commit | 4fe722abcf88671bd0800adf0dd32efb5a3d34e2 (patch) | |
| tree | e92eb7bf961fabba698a98f9ea423c1b09bd4be9 /nova | |
| parent | 85923aa53d9b0aa3bba9082d8e0b5046a57f502e (diff) | |
| download | nova-4fe722abcf88671bd0800adf0dd32efb5a3d34e2.tar.gz nova-4fe722abcf88671bd0800adf0dd32efb5a3d34e2.tar.xz nova-4fe722abcf88671bd0800adf0dd32efb5a3d34e2.zip | |
Add ServerStartStop extension API test
Change-Id: I1671805e10ebc9c5d8037f67b78c47fbf8373ce9
Diffstat (limited to 'nova')
7 files changed, 87 insertions, 0 deletions
diff --git a/nova/tests/integrated/api_samples/os-server-start-stop/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-req.json.tpl new file mode 100644 index 000000000..d3916d1aa --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/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-server-start-stop/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-req.xml.tpl new file mode 100644 index 000000000..f92614984 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/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-server-start-stop/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-resp.json.tpl new file mode 100644 index 000000000..d5f030c87 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/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-server-start-stop/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-resp.xml.tpl new file mode 100644 index 000000000..3bb13e69b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/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-server-start-stop/server_start_stop.json.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.json.tpl new file mode 100644 index 000000000..a993b3f68 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.json.tpl @@ -0,0 +1,3 @@ +{ + "%(action)s" : null +} diff --git a/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.xml.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.xml.tpl new file mode 100644 index 000000000..35cc3c204 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.xml.tpl @@ -0,0 +1,2 @@ +<?xml version="1.0" encoding="UTF-8"?> +<%(action)s/> diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 3786e2975..d51240871 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -476,3 +476,28 @@ class LimitsSampleJsonTest(ApiSampleTestBase): class LimitsSampleXmlTest(LimitsSampleJsonTest): ctype = 'xml' + + +class ServerStartStopJsonTest(ServersSampleBase): + extension_name = "nova.api.openstack.compute.contrib" + \ + ".server_start_stop.Server_start_stop" + + def _test_server_action(self, uuid, action): + response = self._do_post('servers/%s/action' % uuid, + 'server_start_stop', + {'action': action}) + self.assertEqual(response.status, 202) + self.assertEqual(response.read(), "") + + def test_server_start(self): + uuid = self._post_server() + self._test_server_action(uuid, 'os-stop') + self._test_server_action(uuid, 'os-start') + + def test_server_stop(self): + uuid = self._post_server() + self._test_server_action(uuid, 'os-stop') + + +class ServerStartStopXmlTest(ServerStartStopJsonTest): + ctype = 'xml' |
