diff --git a/tempest/manager.py b/tempest/manager.py index 92caf57c46..513e5d9aaa 100644 --- a/tempest/manager.py +++ b/tempest/manager.py @@ -54,7 +54,7 @@ SecurityGroupsClient = security_groups_client.SecurityGroupsClientJSON 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 @@ class ComputeFuzzClientAltManager(Manager): 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 @@ class ComputeFuzzClientAdminManager(Manager): 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 01b4cc1849..0bb17522e8 100644 --- a/tempest/openstack.py +++ b/tempest/openstack.py @@ -36,7 +36,7 @@ from tempest.services.compute.json.quotas_client import QuotasClient 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.security_groups_client \ 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 @@ SECURITY_GROUPS_CLIENT = { "xml": SecurityGroupsClientXML, } +CONSOLE_OUTPUT_CLIENT = { + "json": ConsoleOutputsClientJSON, + "xml": ConsoleOutputsClientXML, +} + class Manager(object): @@ -182,10 +189,11 @@ class Manager(object): 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 0c3ba598e7..9d37de7148 100644 --- a/tempest/services/compute/json/console_output_client.py +++ b/tempest/services/compute/json/console_output_client.py @@ -20,11 +20,12 @@ import json 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 0000000000..e618d637c6 --- /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 e88aac9fca..ce1047f6b7 100644 --- a/tempest/tests/compute/servers/test_console_output.py +++ b/tempest/tests/compute/servers/test_console_output.py @@ -20,14 +20,13 @@ import unittest2 as unittest 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 @@ class ConsoleOutputTest(BaseComputeTest): 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 @@ class ConsoleOutputTest(BaseComputeTest): 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()