From 4ded9f057d0dbf6e97f8b6384cac174c666bcccc Mon Sep 17 00:00:00 2001 From: Masayuki Igawa Date: Mon, 17 Feb 2014 15:05:59 +0900 Subject: [PATCH] Prepare for enabling H302 rule (scenario) We can use H302 rule but ignore it now. This commit prepares for enabling H302 rule. But this commit modifies tempest/scenario only and excludes some violations[1] because if we fix all of them at one time, it's hard to merge this commit. [1] tempest.test.attr tempest.common.rest_client.RestClient tempest.common.rest_client.RestClientXML tempest.services.compute.xml.common.xml_to_json tempest.services.compute.xml.common.Element tempest.services.compute.xml.common.Document tempest.services.compute.xml.common.Text tempest.services.compute.xml.common.XMLNS_11 tempest.services.compute.xml.common.XMLNS_V3 tempest/clients.py Change-Id: I57c26ef681120a9ee826b9cef26d1aaa734d69e5 --- tempest/scenario/manager.py | 4 ++-- .../scenario/orchestration/test_autoscaling.py | 15 ++++++--------- tempest/scenario/test_aggregates_basic_ops.py | 6 +++--- tempest/scenario/test_dashboard_basic_ops.py | 4 ++-- tempest/scenario/test_large_ops.py | 4 ++-- tempest/scenario/test_minimum_basic.py | 4 ++-- .../scenario/test_security_groups_basic_ops.py | 18 ++++++++---------- tempest/scenario/test_server_advanced_ops.py | 6 +++--- tempest/scenario/test_server_basic_ops.py | 4 ++-- tempest/scenario/test_snapshot_pattern.py | 4 ++-- tempest/scenario/test_swift_basic_ops.py | 13 +++++++------ tempest/scenario/test_volume_boot_pattern.py | 4 ++-- 12 files changed, 41 insertions(+), 45 deletions(-) diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py index b4fb6ab483..6757da6c2b 100644 --- a/tempest/scenario/manager.py +++ b/tempest/scenario/manager.py @@ -26,7 +26,7 @@ from tempest.api.network import common as net_common from tempest import clients from tempest.common import isolated_creds from tempest.common.utils import data_utils -from tempest.common.utils.linux.remote_client import RemoteClient +from tempest.common.utils.linux import remote_client from tempest import config from tempest import exceptions from tempest.openstack.common import log @@ -358,7 +358,7 @@ class OfficialClientTest(tempest.test.BaseTestCase): username = CONF.scenario.ssh_user if private_key is None: private_key = self.keypair.private_key - return RemoteClient(ip, username, pkey=private_key) + return remote_client.RemoteClient(ip, username, pkey=private_key) def _log_console_output(self, servers=None): if not servers: diff --git a/tempest/scenario/orchestration/test_autoscaling.py b/tempest/scenario/orchestration/test_autoscaling.py index cd7a2b203e..82ba3c5fbe 100644 --- a/tempest/scenario/orchestration/test_autoscaling.py +++ b/tempest/scenario/orchestration/test_autoscaling.py @@ -15,10 +15,7 @@ import time from tempest import config from tempest.scenario import manager -from tempest.test import attr -from tempest.test import call_until_true -from tempest.test import services -from tempest.test import skip_because +from tempest import test CONF = config.CONF @@ -64,9 +61,9 @@ class AutoScalingTest(manager.OrchestrationScenarioTest): if not CONF.orchestration.keypair_name: self.set_resource('stack', self.stack) - @skip_because(bug="1257575") - @attr(type='slow') - @services('orchestration', 'compute') + @test.skip_because(bug="1257575") + @test.attr(type='slow') + @test.services('orchestration', 'compute') def test_scale_up_then_down(self): self.assign_keypair() @@ -98,8 +95,8 @@ class AutoScalingTest(manager.OrchestrationScenarioTest): return self.server_count def assertScale(from_servers, to_servers): - call_until_true(lambda: server_count() == to_servers, - timeout, interval) + test.call_until_true(lambda: server_count() == to_servers, + timeout, interval) self.assertEqual(to_servers, self.server_count, 'Failed scaling from %d to %d servers. ' 'Current server count: %s' % ( diff --git a/tempest/scenario/test_aggregates_basic_ops.py b/tempest/scenario/test_aggregates_basic_ops.py index f2b681e108..8e34c16849 100644 --- a/tempest/scenario/test_aggregates_basic_ops.py +++ b/tempest/scenario/test_aggregates_basic_ops.py @@ -14,7 +14,7 @@ # under the License. from tempest.common import tempest_fixtures as fixtures -from tempest.common.utils.data_utils import rand_name +from tempest.common.utils import data_utils from tempest.openstack.common import log as logging from tempest.scenario import manager from tempest import test @@ -107,7 +107,7 @@ class TestAggregatesBasicOps(manager.OfficialClientTest): def test_aggregate_basic_ops(self): self.useFixture(fixtures.LockFixture('availability_zone')) az = 'foo_zone' - aggregate_name = rand_name('aggregate-scenario') + aggregate_name = data_utils.rand_name('aggregate-scenario') aggregate = self._create_aggregate(name=aggregate_name, availability_zone=az) @@ -119,7 +119,7 @@ class TestAggregatesBasicOps(manager.OfficialClientTest): self._check_aggregate_details(aggregate, aggregate_name, az, [host], metadata) - aggregate_name = rand_name('renamed-aggregate-scenario') + aggregate_name = data_utils.rand_name('renamed-aggregate-scenario') aggregate = self._update_aggregate(aggregate, aggregate_name, None) additional_metadata = {'foo': 'bar'} diff --git a/tempest/scenario/test_dashboard_basic_ops.py b/tempest/scenario/test_dashboard_basic_ops.py index 19996e57df..6418a735a4 100644 --- a/tempest/scenario/test_dashboard_basic_ops.py +++ b/tempest/scenario/test_dashboard_basic_ops.py @@ -19,7 +19,7 @@ from lxml import html from tempest import config from tempest.scenario import manager -from tempest.test import services +from tempest import test CONF = config.CONF @@ -69,7 +69,7 @@ class TestDashboardBasicOps(manager.OfficialClientTest): response = self.opener.open(CONF.dashboard.dashboard_url) self.assertIn('Overview', response.read()) - @services('dashboard') + @test.services('dashboard') def test_basic_scenario(self): self.check_login_page() self.user_login() diff --git a/tempest/scenario/test_large_ops.py b/tempest/scenario/test_large_ops.py index 7667515e59..b7a30f8c52 100644 --- a/tempest/scenario/test_large_ops.py +++ b/tempest/scenario/test_large_ops.py @@ -17,7 +17,7 @@ from tempest.common.utils import data_utils from tempest import config from tempest.openstack.common import log as logging from tempest.scenario import manager -from tempest.test import services +from tempest import test CONF = config.CONF @@ -63,7 +63,7 @@ class TestLargeOpsScenario(manager.NetworkScenarioTest): self.set_resource(server.name, server) self._wait_for_server_status('ACTIVE') - @services('compute', 'image') + @test.services('compute', 'image') def test_large_ops_scenario(self): if CONF.scenario.large_ops_number < 1: return diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py index f2ee3b4e09..39b776045b 100644 --- a/tempest/scenario/test_minimum_basic.py +++ b/tempest/scenario/test_minimum_basic.py @@ -17,7 +17,7 @@ from tempest.common import debug from tempest import config from tempest.openstack.common import log as logging from tempest.scenario import manager -from tempest.test import services +from tempest import test CONF = config.CONF @@ -112,7 +112,7 @@ class TestMinimumBasicScenario(manager.OfficialClientTest): volume = self.volume_client.volumes.get(self.volume.id) self.assertEqual('available', volume.status) - @services('compute', 'volume', 'image', 'network') + @test.services('compute', 'volume', 'image', 'network') def test_minimum_basic_scenario(self): self.glance_image_create() self.nova_keypair_add() diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py index 1ddba9ede8..8e4192d0b8 100644 --- a/tempest/scenario/test_security_groups_basic_ops.py +++ b/tempest/scenario/test_security_groups_basic_ops.py @@ -20,9 +20,7 @@ from tempest import config from tempest import exceptions from tempest.openstack.common import log as logging from tempest.scenario import manager -from tempest.test import attr -from tempest.test import call_until_true -from tempest.test import services +from tempest import test CONF = config.CONF @@ -355,9 +353,9 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): return not should_succeed return should_succeed - return call_until_true(ping_remote, - CONF.compute.ping_timeout, - 1) + return test.call_until_true(ping_remote, + CONF.compute.ping_timeout, + 1) def _check_connectivity(self, access_point, ip, should_succeed=True): if should_succeed: @@ -460,8 +458,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): subnet_id = tenant.subnet.id self.assertIn((subnet_id, server_ip, mac_addr), port_detail_list) - @attr(type='smoke') - @services('compute', 'network') + @test.attr(type='smoke') + @test.services('compute', 'network') def test_cross_tenant_traffic(self): try: # deploy new tenant @@ -479,8 +477,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest): self._log_console_output(servers=tenant.servers) raise - @attr(type='smoke') - @services('compute', 'network') + @test.attr(type='smoke') + @test.services('compute', 'network') def test_in_tenant_traffic(self): try: self._create_tenant_servers(self.primary_tenant, num=1) diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py index 9626157e3c..c0eb6e774b 100644 --- a/tempest/scenario/test_server_advanced_ops.py +++ b/tempest/scenario/test_server_advanced_ops.py @@ -16,7 +16,7 @@ from tempest import config from tempest.openstack.common import log as logging from tempest.scenario import manager -from tempest.test import services +from tempest import test CONF = config.CONF @@ -47,7 +47,7 @@ class TestServerAdvancedOps(manager.OfficialClientTest): msg = "Skipping test - flavor_ref and flavor_ref_alt are identical" raise cls.skipException(msg) - @services('compute') + @test.services('compute') def test_resize_server_confirm(self): # We create an instance for use in this test instance = self.create_server() @@ -65,7 +65,7 @@ class TestServerAdvancedOps(manager.OfficialClientTest): self.status_timeout( self.compute_client.servers, instance_id, 'ACTIVE') - @services('compute') + @test.services('compute') def test_server_sequence_suspend_resume(self): # We create an instance for use in this test instance = self.create_server() diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py index 73ff6b40a6..1144414adb 100644 --- a/tempest/scenario/test_server_basic_ops.py +++ b/tempest/scenario/test_server_basic_ops.py @@ -18,7 +18,7 @@ from tempest.common.utils import test_utils from tempest import config from tempest.openstack.common import log as logging from tempest.scenario import manager -from tempest.test import services +from tempest import test import testscenarios @@ -162,7 +162,7 @@ class TestServerBasicOps(manager.OfficialClientTest): self._log_console_output() raise - @services('compute', 'network') + @test.services('compute', 'network') def test_server_basicops(self): self.add_keypair() self.create_security_group() diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py index 2bb3d84348..37beb070c2 100644 --- a/tempest/scenario/test_snapshot_pattern.py +++ b/tempest/scenario/test_snapshot_pattern.py @@ -16,7 +16,7 @@ from tempest import config from tempest.openstack.common import log from tempest.scenario import manager -from tempest.test import services +from tempest import test CONF = config.CONF @@ -69,7 +69,7 @@ class TestSnapshotPattern(manager.OfficialClientTest): def _set_floating_ip_to_server(self, server, floating_ip): server.add_floating_ip(floating_ip) - @services('compute', 'network', 'image') + @test.services('compute', 'network', 'image') def test_snapshot_pattern(self): # prepare for booting a instance self._add_keypair() diff --git a/tempest/scenario/test_swift_basic_ops.py b/tempest/scenario/test_swift_basic_ops.py index 60df606ef7..86e0867ac9 100644 --- a/tempest/scenario/test_swift_basic_ops.py +++ b/tempest/scenario/test_swift_basic_ops.py @@ -14,11 +14,11 @@ # under the License. -from tempest.common.utils.data_utils import rand_name +from tempest.common.utils import data_utils from tempest import config from tempest.openstack.common import log as logging from tempest.scenario import manager -from tempest.test import services +from tempest import test CONF = config.CONF @@ -53,7 +53,8 @@ class TestSwiftBasicOps(manager.OfficialClientTest): LOG.debug('Swift status information obtained successfully') def _create_container(self, container_name=None): - name = container_name or rand_name('swift-scenario-container') + name = container_name or data_utils.rand_name( + 'swift-scenario-container') self.object_storage_client.put_container(name) # look for the container to assure it is created self._list_and_check_container_objects(name) @@ -65,9 +66,9 @@ class TestSwiftBasicOps(manager.OfficialClientTest): LOG.debug('Container %s deleted' % (container_name)) def _upload_object_to_container(self, container_name, obj_name=None): - obj_name = obj_name or rand_name('swift-scenario-object') + obj_name = obj_name or data_utils.rand_name('swift-scenario-object') self.object_storage_client.put_object(container_name, obj_name, - rand_name('obj_data'), + data_utils.rand_name('obj_data'), content_type='text/plain') return obj_name @@ -93,7 +94,7 @@ class TestSwiftBasicOps(manager.OfficialClientTest): for obj in not_present_obj: self.assertNotIn(obj, object_list) - @services('object_storage') + @test.services('object_storage') def test_swift_basic_ops(self): self._get_swift_stat() container_name = self._create_container() diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py index 7b002eb322..9a250d708f 100644 --- a/tempest/scenario/test_volume_boot_pattern.py +++ b/tempest/scenario/test_volume_boot_pattern.py @@ -14,7 +14,7 @@ from tempest.common.utils import data_utils from tempest import config from tempest.openstack.common import log from tempest.scenario import manager -from tempest.test import services +from tempest import test CONF = config.CONF @@ -127,7 +127,7 @@ class TestVolumeBootPattern(manager.OfficialClientTest): actual = self._get_content(ssh_client) self.assertEqual(expected, actual) - @services('compute', 'volume', 'image') + @test.services('compute', 'volume', 'image') def test_volume_boot_pattern(self): keypair = self.create_keypair() self._create_loginable_secgroup_rule_nova()