summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorNikola Dipanov <ndipanov@redhat.com>2012-09-19 14:45:40 +0200
committerNikola Dipanov <ndipanov@redhat.com>2012-09-20 09:55:01 +0200
commitb456a862ad85578bf4cf8e861be56aa5e728f9f4 (patch)
tree1dde2eb51cf14b7c2c759f63fb0b18a6a72e4db1 /nova
parent59ad151a296c22d8be053e408d9377acebb5ad15 (diff)
Adds API sample testing for rescue API extension
Adds tests and templates for testing of the server rescue API extension. Tests both json and XML API functionality. Change-Id: Icb241e96ebedde0b6385f8ba60eebd0e768f22da
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl53
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.xml.tpl19
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl54
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.xml.tpl19
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-post-req.json.tpl16
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-post-req.xml.tpl19
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-post-resp.json.tpl16
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-post-resp.xml.tpl6
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-rescue-req.json.tpl5
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-rescue-req.xml.tpl3
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-rescue.json.tpl3
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-rescue.xml.tpl2
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.json.tpl3
-rw-r--r--nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.xml.tpl2
-rw-r--r--nova/tests/integrated/test_api_samples.py51
15 files changed, 271 insertions, 0 deletions
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl
new file mode 100644
index 000000000..011ed6396
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl
@@ -0,0 +1,53 @@
+{
+ "server": {
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "addresses": {
+ "private": [
+ {
+ "addr": "%(ip)s",
+ "version": 4
+ }
+ ]
+ },
+ "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"
+ }
+ ]
+ },
+ "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",
+ "status": "%(status)s",
+ "tenant_id": "openstack",
+ "updated": "%(timestamp)s",
+ "user_id": "fake"
+ }
+}
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.xml.tpl
new file mode 100644
index 000000000..d1d9b7c2c
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.xml.tpl
@@ -0,0 +1,19 @@
+<?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" status="%(status)s" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" id="%(id)s">
+ <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> \ No newline at end of file
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl
new file mode 100644
index 000000000..bc483c6da
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl
@@ -0,0 +1,54 @@
+{
+ "server": {
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "addresses": {
+ "private": [
+ {
+ "addr": "%(ip)s",
+ "version": 4
+ }
+ ]
+ },
+ "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"
+ }
+ ]
+ },
+ "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,
+ "status": "%(status)s",
+ "tenant_id": "openstack",
+ "updated": "%(timestamp)s",
+ "user_id": "fake"
+ }
+}
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.xml.tpl
new file mode 100644
index 000000000..e87ba47f1
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.xml.tpl
@@ -0,0 +1,19 @@
+<?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" status="%(status)s" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s">
+ <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> \ No newline at end of file
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-post-req.json.tpl
new file mode 100644
index 000000000..d3916d1aa
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/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-rescue/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-post-req.xml.tpl
new file mode 100644
index 000000000..f92614984
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/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-rescue/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-post-resp.json.tpl
new file mode 100644
index 000000000..d5f030c87
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/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-rescue/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-post-resp.xml.tpl
new file mode 100644
index 000000000..3bb13e69b
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/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-rescue/server-rescue-req.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.json.tpl
new file mode 100644
index 000000000..d71234753
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.json.tpl
@@ -0,0 +1,5 @@
+{
+ "rescue": {
+ "adminPass": "%(password)s"
+ }
+} \ No newline at end of file
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.xml.tpl
new file mode 100644
index 000000000..09acae072
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.xml.tpl
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rescue xmlns="http://docs.openstack.org/compute/api/v1.1"
+ adminPass="%(password)s"/> \ No newline at end of file
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-rescue.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-rescue.json.tpl
new file mode 100644
index 000000000..1922e4db1
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-rescue.json.tpl
@@ -0,0 +1,3 @@
+{
+ "adminPass": "%(password)s"
+} \ No newline at end of file
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-rescue.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-rescue.xml.tpl
new file mode 100644
index 000000000..b3b95fdde
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-rescue.xml.tpl
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<adminPass>%(password)s</adminPass> \ No newline at end of file
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.json.tpl
new file mode 100644
index 000000000..cafc9b13a
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.json.tpl
@@ -0,0 +1,3 @@
+{
+ "unrescue": null
+} \ No newline at end of file
diff --git a/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.xml.tpl
new file mode 100644
index 000000000..6a87f8fb2
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.xml.tpl
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<unrescue xmlns="http://docs.openstack.org/compute/api/v1.1"/> \ No newline at end of file
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index a1304c55a..9beb8c880 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -917,3 +917,54 @@ class KeyPairsSampleJsonTest(ApiSampleTestBase):
class KeyPairsSampleXmlTest(KeyPairsSampleJsonTest):
ctype = 'xml'
+
+
+class RescueJsonTest(ServersSampleBase):
+ extension_name = ("nova.api.openstack.compute.contrib"
+ ".rescue.Rescue")
+
+ def _rescue(self, uuid):
+ req_subs = {
+ 'password': 'MySecretPass'
+ }
+ response = self._do_post('servers/%s/action' % uuid,
+ 'server-rescue-req', req_subs)
+ self._verify_response('server-rescue', req_subs, response)
+
+ def _unrescue(self, uuid):
+ response = self._do_post('servers/%s/action' % uuid,
+ 'server-unrescue-req', {})
+ self.assertEqual(response.status, 202)
+
+ def test_server_rescue(self):
+ uuid = self._post_server()
+
+ self._rescue(uuid)
+
+ # Do a server get to make sure that the 'RESCUE' state is set
+ response = self._do_get('servers/%s' % uuid)
+ subs = self._get_regexes()
+ subs['hostid'] = '[a-f0-9]+'
+ subs['id'] = uuid
+ subs['status'] = 'RESCUE'
+
+ self._verify_response('server-get-resp-rescue', subs, response)
+
+ def test_server_unrescue(self):
+ uuid = self._post_server()
+
+ self._rescue(uuid)
+ self._unrescue(uuid)
+
+ # Do a server get to make sure that the 'ACTIVE' state is back
+ response = self._do_get('servers/%s' % uuid)
+ subs = self._get_regexes()
+ subs['hostid'] = '[a-f0-9]+'
+ subs['id'] = uuid
+ subs['status'] = 'ACTIVE'
+
+ self._verify_response('server-get-resp-unrescue', subs, response)
+
+
+class RescueXmlTest(RescueJsonTest):
+ ctype = 'xml'