CLOUDSTACK-5194: portable ip - Improving cleanup code to

avoid cascading failures
This commit is contained in:
Gaurav Aradhye 2013-11-19 11:18:33 +05:30 committed by Girish Shilamkar
parent 04807f2b51
commit 465ac16258
1 changed files with 18 additions and 22 deletions

View File

@ -235,8 +235,9 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
self.debug("Trying to create portable ip range with non root-admin api client, should raise exception")
with self.assertRaises(Exception):
PortablePublicIpRange.create(self.api_client_user,
portable_ip_range = PortablePublicIpRange.create(self.api_client_user,
portable_ip_range_services)
self.cleanup.append(portable_ip_range)
return
@ -258,8 +259,9 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
self.debug("Trying to create portable ip range with wrong region id")
with self.assertRaises(Exception):
PortablePublicIpRange.create(self.apiclient,
portable_ip_range = PortablePublicIpRange.create(self.apiclient,
portable_ip_range_services)
self.cleanup.append(portable_ip_range)
return
@ -687,8 +689,6 @@ class TestAssociatePublicIp(cloudstackTestCase):
self.debug("Associated default public ip address: %s" % publicipaddress.ipaddress.ipaddress)
self.debug("Associating public ip address with network: %s with isportable=False" % self.network.id)
publicipaddressnotportable = PublicIPAddress.create(
self.apiclient,
@ -727,7 +727,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
self.debug("Trying to associate portable public ip with invalid zone id, this should fail")
with self.assertRaises(Exception):
PublicIPAddress.create(
publicipaddress = PublicIPAddress.create(
self.apiclient,
accountid=self.account.name,
zoneid = -1,
@ -735,6 +735,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
regionid = self.region.id,
isportable=True
)
publicipaddress.delete(self.apiclient)
self.debug("Associating ip address failed")
return
@ -815,14 +816,15 @@ class TestAssociatePublicIp(cloudstackTestCase):
except Exception as e:
self.fail("Exception while SSHing : %s" % e)
self.debug("Deleting firewall rule")
fw_rule.delete(self.apiclient)
finally:
self.debug("Deleting firewall rule")
fw_rule.delete(self.apiclient)
self.debug("Deleting NAT rule")
nat_rule.delete(self.apiclient)
self.debug("Deleting NAT rule")
nat_rule.delete(self.apiclient)
self.debug("disassocoating portable ip: %s" % portableip.ipaddress.ipaddress)
portableip.delete(self.apiclient)
self.debug("disassocoating portable ip: %s" % portableip.ipaddress.ipaddress)
portableip.delete(self.apiclient)
return
@attr(tags=["advanced"])
@ -858,7 +860,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
self.debug("Trying to associate portable public ip when no free ips available, this should fail")
with self.assertRaises(Exception):
PublicIPAddress.create(
portableipaddress = PublicIPAddress.create(
self.apiclient,
accountid=self.account.name,
zoneid=self.zone.id,
@ -866,6 +868,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
networkid=self.network.id,
isportable=True
)
portableipaddress.delete(self.apiclient)
self.debug("Associating portable ip address failed")
@ -1338,7 +1341,6 @@ class TestDeleteAccount(cloudstackTestCase):
return
class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
"""Test Transfer Portable IP Across Networks
"""
@ -1390,7 +1392,6 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
cls.services["service_offering"]
)
cls.debug("creating networks and virtual machines in each network for portable ip transfer tests: ")
cls.network1 = Network.create(
cls.api_client,
cls.services["network1"],
@ -1538,11 +1539,6 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
except Exception as e:
self.fail("Exception while SSHing : %s" % e)
self.debug("disassociating portable ip: %s" % portableip.ipaddress.ipaddress)
portableip.delete(self.apiclient)
finally:
self.debug("disassociating portable ip: %s" % portableip.ipaddress.ipaddress)
portableip.delete(self.apiclient)