Raise specific exceptions on tearDownClass failure
This commit removes the exception handling from the base network api
test case tearDownClass(). Previously every delete operation that was
used in tearDownClass() was inside a try except block that would log
any exception, and the continue with the rest of the cleanup until the
end of the function where it would raise another exception without
any information. This approach just masked errors when they happened
and makes it harder to debug what is failing. Instead the exception
should just be raised directly.
Change-Id: I20b7219bdf2f1e06445e5bde3abe144089fc06e2
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index b6c2679..159c4f5 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -68,75 +68,39 @@
@classmethod
def tearDownClass(cls):
- has_exception = False
+ # Clean up vpn services
for vpnservice in cls.vpnservices:
- try:
- cls.client.delete_vpn_service(vpnservice['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
-
+ cls.client.delete_vpn_service(vpnservice['id'])
+ # Clean up routers
for router in cls.routers:
- try:
- resp, body = cls.client.list_router_interfaces(router['id'])
- interfaces = body['ports']
- for i in interfaces:
- cls.client.remove_router_interface_with_subnet_id(
- router['id'], i['fixed_ips'][0]['subnet_id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
- try:
- cls.client.delete_router(router['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
-
+ resp, body = cls.client.list_router_interfaces(router['id'])
+ interfaces = body['ports']
+ for i in interfaces:
+ cls.client.remove_router_interface_with_subnet_id(
+ router['id'], i['fixed_ips'][0]['subnet_id'])
+ cls.client.delete_router(router['id'])
+ # Clean up health monitors
for health_monitor in cls.health_monitors:
- try:
- cls.client.delete_health_monitor(health_monitor['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
+ cls.client.delete_health_monitor(health_monitor['id'])
+ # Clean up members
for member in cls.members:
- try:
- cls.client.delete_member(member['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
+ cls.client.delete_member(member['id'])
+ # Clean up vips
for vip in cls.vips:
- try:
- cls.client.delete_vip(vip['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
+ cls.client.delete_vip(vip['id'])
+ # Clean up pools
for pool in cls.pools:
- try:
- cls.client.delete_pool(pool['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
+ cls.client.delete_pool(pool['id'])
+ # Clean up ports
for port in cls.ports:
- try:
- cls.client.delete_port(port['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
+ cls.client.delete_port(port['id'])
+ # Clean up subnets
for subnet in cls.subnets:
- try:
- cls.client.delete_subnet(subnet['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
+ cls.client.delete_subnet(subnet['id'])
+ # Clean up networks
for network in cls.networks:
- try:
- cls.client.delete_network(network['id'])
- except Exception as exc:
- LOG.exception(exc)
- has_exception = True
+ cls.client.delete_network(network['id'])
super(BaseNetworkTest, cls).tearDownClass()
- if has_exception:
- raise exceptions.TearDownException()
@classmethod
def create_network(cls, network_name=None):