From ebb15f265e10bf95e3b76e05b92b5d6aa107dd42 Mon Sep 17 00:00:00 2001 From: guo yunxian Date: Tue, 1 Nov 2016 21:03:35 +0800 Subject: [PATCH] Delete TimeoutException in tempest/exceptions.py Delete TimeoutException in tempest/exceptions.py because it repeats in tempest/lib.exceptions.py Change-Id: I4242d8156dcba7d8e893975de62c82547625afbc --- tempest/api/baremetal/admin/test_nodestates.py | 2 +- .../compute/servers/test_attach_interfaces.py | 7 +++---- .../stacks/test_neutron_resources.py | 2 +- tempest/common/waiters.py | 16 ++++++++-------- tempest/exceptions.py | 4 ---- tempest/scenario/manager.py | 4 ++-- tempest/scenario/test_network_basic_ops.py | 2 +- tempest/scenario/test_stamp_pattern.py | 3 +-- .../orchestration/json/orchestration_client.py | 2 +- tempest/tests/common/test_waiters.py | 3 ++- 10 files changed, 20 insertions(+), 25 deletions(-) diff --git a/tempest/api/baremetal/admin/test_nodestates.py b/tempest/api/baremetal/admin/test_nodestates.py index 1ffea25871..e74dd04c6d 100644 --- a/tempest/api/baremetal/admin/test_nodestates.py +++ b/tempest/api/baremetal/admin/test_nodestates.py @@ -15,7 +15,7 @@ from oslo_utils import timeutils from tempest.api.baremetal.admin import base -from tempest import exceptions +from tempest.lib import exceptions from tempest import test diff --git a/tempest/api/compute/servers/test_attach_interfaces.py b/tempest/api/compute/servers/test_attach_interfaces.py index a8c59cac71..fc6a20f379 100644 --- a/tempest/api/compute/servers/test_attach_interfaces.py +++ b/tempest/api/compute/servers/test_attach_interfaces.py @@ -20,7 +20,6 @@ from tempest.common import compute from tempest.common.utils import net_utils from tempest.common import waiters from tempest import config -from tempest import exceptions from tempest.lib import decorators from tempest.lib import exceptions as lib_exc from tempest import test @@ -71,7 +70,7 @@ class AttachInterfacesTestJSON(base.BaseV2ComputeTest): '(current %s) within the required time (%s s).' % (port_id, status, interface_status, self.build_timeout)) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) return body @@ -99,7 +98,7 @@ class AttachInterfacesTestJSON(base.BaseV2ComputeTest): message = ('Port %s failed to detach (device_id %s) within ' 'the required time (%s s).' % (port_id, device_id, self.build_timeout)) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) return port @@ -197,7 +196,7 @@ class AttachInterfacesTestJSON(base.BaseV2ComputeTest): if len(ifs) == len(_ifs) and timed_out: message = ('Failed to delete interface within ' 'the required time: %s sec.' % self.build_timeout) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) self.assertNotIn(iface['port_id'], [i['port_id'] for i in _ifs]) return _ifs diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py index 3f45634317..a3792b49bc 100644 --- a/tempest/api/orchestration/stacks/test_neutron_resources.py +++ b/tempest/api/orchestration/stacks/test_neutron_resources.py @@ -18,7 +18,7 @@ import netaddr from tempest.api.orchestration import base from tempest.common.utils import data_utils from tempest import config -from tempest import exceptions +from tempest.lib import exceptions from tempest import test CONF = config.CONF diff --git a/tempest/common/waiters.py b/tempest/common/waiters.py index c1942d6b9b..92bce5f49e 100644 --- a/tempest/common/waiters.py +++ b/tempest/common/waiters.py @@ -92,7 +92,7 @@ def wait_for_server_status(client, server_id, status, ready_wait=True, caller = test_utils.find_test_caller() if caller: message = '(%s) %s' % (caller, message) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) old_status = server_status old_task_state = task_state @@ -111,7 +111,7 @@ def wait_for_server_termination(client, server_id, ignore_error=False): raise exceptions.BuildErrorException(server_id=server_id) if int(time.time()) - start_time >= client.build_timeout: - raise exceptions.TimeoutException + raise lib_exc.TimeoutException time.sleep(client.build_interval) @@ -163,7 +163,7 @@ def wait_for_image_status(client, image_id, status): caller = test_utils.find_test_caller() if caller: message = '(%s) %s' % (caller, message) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) def wait_for_volume_status(client, volume_id, status): @@ -186,7 +186,7 @@ def wait_for_volume_status(client, volume_id, status): 'within the required time (%s s).' % (volume_id, status, volume_status, client.build_timeout)) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) def wait_for_snapshot_status(client, snapshot_id, status): @@ -207,7 +207,7 @@ def wait_for_snapshot_status(client, snapshot_id, status): 'within the required time (%s s).' % (snapshot_id, status, snapshot_status, client.build_timeout)) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) def wait_for_backup_status(client, backup_id, status): @@ -228,7 +228,7 @@ def wait_for_backup_status(client, backup_id, status): '(current %s) within the required time (%s s).' % (backup_id, status, backup_status, client.build_timeout)) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) def wait_for_bm_node_status(client, node_id, attr, status): @@ -257,7 +257,7 @@ def wait_for_bm_node_status(client, node_id, attr, status): caller = test_utils.find_test_caller() if caller: message = '(%s) %s' % (caller, message) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) def wait_for_qos_operations(client, qos_id, operation, args=None): @@ -288,5 +288,5 @@ def wait_for_qos_operations(client, qos_id, operation, args=None): raise lib_exc.UnprocessableEntity(msg) if int(time.time()) - start_time >= client.build_timeout: - raise exceptions.TimeoutException + raise lib_exc.TimeoutException time.sleep(client.build_interval) diff --git a/tempest/exceptions.py b/tempest/exceptions.py index 727d54e48f..43f919a3ce 100644 --- a/tempest/exceptions.py +++ b/tempest/exceptions.py @@ -21,10 +21,6 @@ class InvalidServiceTag(exceptions.TempestException): message = "Invalid service tag" -class TimeoutException(exceptions.TempestException): - message = "Request timed out" - - class BuildErrorException(exceptions.TempestException): message = "Server %(server_id)s failed to build and is in ERROR status" diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py index ab388c2750..6ec30b8451 100644 --- a/tempest/scenario/manager.py +++ b/tempest/scenario/manager.py @@ -1273,7 +1273,7 @@ class BaremetalScenarioTest(ScenarioTest): check_state, timeout, interval): msg = ("Timed out waiting for node %s to reach %s state(s) %s" % (node_id, state_attr, target_states)) - raise exceptions.TimeoutException(msg) + raise lib_exc.TimeoutException(msg) def wait_provisioning_state(self, node_id, state, timeout): self._node_state_timeout( @@ -1297,7 +1297,7 @@ class BaremetalScenarioTest(ScenarioTest): _get_node, CONF.baremetal.association_timeout, 1): msg = ('Timed out waiting to get Ironic node by instance id %s' % instance_id) - raise exceptions.TimeoutException(msg) + raise lib_exc.TimeoutException(msg) def get_node(self, node_id=None, instance_id=None): if node_id: diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py index a295b6adb7..e3f878515b 100644 --- a/tempest/scenario/test_network_basic_ops.py +++ b/tempest/scenario/test_network_basic_ops.py @@ -22,9 +22,9 @@ import testtools from tempest.common.utils import data_utils from tempest.common import waiters from tempest import config -from tempest import exceptions from tempest.lib.common.utils import test_utils from tempest.lib import decorators +from tempest.lib import exceptions from tempest.scenario import manager from tempest import test diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py index 5fd934c3e8..0f2c78c974 100644 --- a/tempest/scenario/test_stamp_pattern.py +++ b/tempest/scenario/test_stamp_pattern.py @@ -21,7 +21,6 @@ import testtools from tempest.common.utils import data_utils from tempest.common import waiters from tempest import config -from tempest import exceptions from tempest.lib.common.utils import test_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc @@ -93,7 +92,7 @@ class TestStampPattern(manager.ScenarioTest): if not test_utils.call_until_true(_func, CONF.compute.build_timeout, CONF.compute.build_interval): - raise exceptions.TimeoutException + raise lib_exc.TimeoutException @decorators.skip_because(bug="1205344") @test.idempotent_id('10fd234a-515c-41e5-b092-8323060598c5') diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py index ea5dbe58ed..9fec5482bc 100644 --- a/tempest/services/orchestration/json/orchestration_client.py +++ b/tempest/services/orchestration/json/orchestration_client.py @@ -178,7 +178,7 @@ class OrchestrationClient(rest_client.RestClient): 'within the required time (%s s).' % (stack_name, status, stack_status, self.build_timeout)) - raise exceptions.TimeoutException(message) + raise lib_exc.TimeoutException(message) time.sleep(self.build_interval) def show_resource_metadata(self, stack_identifier, resource_name): diff --git a/tempest/tests/common/test_waiters.py b/tempest/tests/common/test_waiters.py index a8263372a6..b113c04ceb 100644 --- a/tempest/tests/common/test_waiters.py +++ b/tempest/tests/common/test_waiters.py @@ -18,6 +18,7 @@ import mock from tempest.common import waiters from tempest import exceptions +from tempest.lib import exceptions as lib_exc from tempest.lib.services.volume.v2 import volumes_client from tempest.tests import base import tempest.tests.utils as utils @@ -43,7 +44,7 @@ class TestImageWaiters(base.TestCase): time_mock.side_effect = utils.generate_timeout_series(1) self.client.show_image.return_value = ({'status': 'saving'}) - self.assertRaises(exceptions.TimeoutException, + self.assertRaises(lib_exc.TimeoutException, waiters.wait_for_image_status, self.client, 'fake_image_id', 'active')