Addition of XML support to test_console_output.py
Added logic to test_console_output.py file so as to support XML calls.
Hence added exclusive client file for XML. Also modified JSON client
file and openstack.py according to new addition of XML support.
Change-Id: Ib1fab3e3dc97d3b61ceb60e0d846c4b36f472932
Implements: blueprint add-xml-support
diff --git a/tempest/manager.py b/tempest/manager.py
index 92caf57..513e5d9 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -54,7 +54,7 @@
KeyPairsClient = keypairs_client.KeyPairsClientJSON
VolumesExtensionsClient = volumes_extensions_client.VolumesExtensionsClientJSON
VolumesClient = volumes_client.VolumesClientJSON
-ConsoleOutputsClient = console_output_client.ConsoleOutputsClient
+ConsoleOutputsClient = console_output_client.ConsoleOutputsClientJSON
QuotasClient = quotas_client.QuotasClient
LOG = logging.getLogger(__name__)
@@ -258,9 +258,9 @@
def __init__(self):
conf = tempest.config.TempestConfig()
super(ComputeFuzzClientAltManager, self).__init__(
- conf.compute.alt_username,
- conf.compute.alt_password,
- conf.compute.alt_tenant_name)
+ conf.compute.alt_username,
+ conf.compute.alt_password,
+ conf.compute.alt_tenant_name)
class ComputeFuzzClientAdminManager(Manager):
@@ -273,6 +273,6 @@
def __init__(self):
conf = tempest.config.TempestConfig()
super(ComputeFuzzClientAdminManager, self).__init__(
- conf.compute_admin.username,
- conf.compute_admin.password,
- conf.compute_admin.tenant_name)
+ conf.compute_admin.username,
+ conf.compute_admin.password,
+ conf.compute_admin.tenant_name)
diff --git a/tempest/openstack.py b/tempest/openstack.py
index 01b4cc1..0bb1752 100644
--- a/tempest/openstack.py
+++ b/tempest/openstack.py
@@ -36,7 +36,7 @@
from tempest.services.compute.json.volumes_extensions_client import \
VolumesExtensionsClientJSON
from tempest.services.compute.json.console_output_client import \
- ConsoleOutputsClient
+ ConsoleOutputsClientJSON
from tempest.services.compute.xml.extensions_client import ExtensionsClientXML
from tempest.services.compute.xml.flavors_client import FlavorsClientXML
from tempest.services.compute.xml.floating_ips_client import \
@@ -49,6 +49,8 @@
from tempest.services.compute.xml.servers_client import ServersClientXML
from tempest.services.compute.xml.volumes_extensions_client import \
VolumesExtensionsClientXML
+from tempest.services.compute.xml.console_output_client import \
+ ConsoleOutputsClientXML
from tempest.services.identity.json.admin_client import AdminClientJSON
from tempest.services.identity.json.admin_client import TokenClientJSON
from tempest.services.identity.xml.admin_client import AdminClientXML
@@ -125,6 +127,11 @@
"xml": SecurityGroupsClientXML,
}
+CONSOLE_OUTPUT_CLIENT = {
+ "json": ConsoleOutputsClientJSON,
+ "xml": ConsoleOutputsClientXML,
+}
+
class Manager(object):
@@ -182,10 +189,11 @@
self.token_client = TOKEN_CLIENT[interface](self.config)
self.security_groups_client = \
SECURITY_GROUPS_CLIENT[interface](*client_args)
+ self.console_outputs_client = \
+ CONSOLE_OUTPUT_CLIENT[interface](*client_args)
except KeyError:
msg = "Unsupported interface type `%s'" % interface
raise exceptions.InvalidConfiguration(msg)
- self.console_outputs_client = ConsoleOutputsClient(*client_args)
self.quotas_client = QuotasClient(*client_args)
self.network_client = NetworkClient(*client_args)
self.account_client = AccountClient(*client_args)
diff --git a/tempest/services/compute/json/console_output_client.py b/tempest/services/compute/json/console_output_client.py
index 0c3ba59..9d37de7 100644
--- a/tempest/services/compute/json/console_output_client.py
+++ b/tempest/services/compute/json/console_output_client.py
@@ -20,11 +20,12 @@
from tempest.common.rest_client import RestClient
-class ConsoleOutputsClient(RestClient):
+class ConsoleOutputsClientJSON(RestClient):
def __init__(self, config, username, password, auth_url, tenant_name=None):
- super(ConsoleOutputsClient, self).__init__(config, username, password,
- auth_url, tenant_name)
+ super(ConsoleOutputsClientJSON, self).__init__(config, username,
+ password,
+ auth_url, tenant_name)
self.service = self.config.compute.catalog_type
def get_console_output(self, server_id, length):
diff --git a/tempest/services/compute/xml/console_output_client.py b/tempest/services/compute/xml/console_output_client.py
new file mode 100644
index 0000000..e618d63
--- /dev/null
+++ b/tempest/services/compute/xml/console_output_client.py
@@ -0,0 +1,41 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2012 IBM
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+
+from lxml import etree
+from tempest.common.rest_client import RestClientXML
+from tempest.services.compute.xml.common import Document
+from tempest.services.compute.xml.common import Element
+from tempest.services.compute.xml.common import Text
+from tempest.services.compute.xml.common import xml_to_json
+
+
+class ConsoleOutputsClientXML(RestClientXML):
+
+ def __init__(self, config, username, password, auth_url, tenant_name=None):
+ super(ConsoleOutputsClientXML, self).__init__(config, username,
+ password,
+ auth_url, tenant_name)
+ self.service = self.config.compute.catalog_type
+
+ def get_console_output(self, server_id, length):
+ post_body = Element("os-getConsoleOutput", length=length)
+ resp, body = self.post("/servers/%s/action" % server_id,
+ headers=self.headers,
+ body=str(Document(post_body)))
+ body = xml_to_json(etree.fromstring(body))
+ return resp, body
diff --git a/tempest/tests/compute/servers/test_console_output.py b/tempest/tests/compute/servers/test_console_output.py
index e88aac9..ce1047f 100644
--- a/tempest/tests/compute/servers/test_console_output.py
+++ b/tempest/tests/compute/servers/test_console_output.py
@@ -20,14 +20,13 @@
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
-from tempest.tests.compute.base import BaseComputeTest
+from tempest.tests.compute import base
-class ConsoleOutputTest(BaseComputeTest):
+class ConsoleOutputTest(object):
@classmethod
- def setUpClass(cls):
- super(ConsoleOutputTest, cls).setUpClass()
+ def setUpClass(self, cls):
cls.client = cls.console_outputs_client
cls.servers_client = cls.servers_client
cls.name = rand_name('server')
@@ -39,9 +38,8 @@
cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE')
@classmethod
- def tearDownClass(cls):
+ def tearDownClass(self, cls):
cls.servers_client.delete_server(cls.server_id)
- super(ConsoleOutputTest, cls).tearDownClass()
@attr(type='positive')
def test_get_console_output(self):
@@ -92,3 +90,31 @@
finally:
self.servers_client.wait_for_server_status(self.server_id,
'ACTIVE')
+
+
+@attr(type='smoke')
+class ConsoleOutputTestJSON(base.BaseComputeTestJSON,
+ ConsoleOutputTest):
+ @classmethod
+ def setUpClass(cls):
+ super(ConsoleOutputTestJSON, cls).setUpClass()
+ ConsoleOutputTest.setUpClass(cls)
+
+ @classmethod
+ def tearDownClass(cls):
+ ConsoleOutputTest.tearDownClass(cls)
+ super(ConsoleOutputTestJSON, cls).tearDownClass()
+
+
+@attr(type='smoke')
+class ConsoleOutputTestXML(base.BaseComputeTestXML,
+ ConsoleOutputTest):
+ @classmethod
+ def setUpClass(cls):
+ super(ConsoleOutputTestXML, cls).setUpClass()
+ ConsoleOutputTest.setUpClass(cls)
+
+ @classmethod
+ def tearDownClass(cls):
+ ConsoleOutputTest.tearDownClass(cls)
+ super(ConsoleOutputTestXML, cls).tearDownClass()