Updated Branches: refs/heads/4.3 9a97c064b -> 85d3be79d
CLOUDSTACK-5194: portable ip - Improving cleanup code to avoid cascading failures Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/85d3be79 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/85d3be79 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/85d3be79 Branch: refs/heads/4.3 Commit: 85d3be79d0665e1cca050d64982e64fb4008dd0b Parents: 9a97c06 Author: Gaurav Aradhye <gaurav.arad...@clogeny.com> Authored: Tue Nov 19 11:18:33 2013 +0530 Committer: Girish Shilamkar <gir...@clogeny.com> Committed: Tue Nov 19 11:20:37 2013 +0530 ---------------------------------------------------------------------- test/integration/component/test_portable_ip.py | 40 ++++++++++----------- 1 file changed, 18 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85d3be79/test/integration/component/test_portable_ip.py ---------------------------------------------------------------------- diff --git a/test/integration/component/test_portable_ip.py b/test/integration/component/test_portable_ip.py index a532b36..dda6555 100644 --- a/test/integration/component/test_portable_ip.py +++ b/test/integration/component/test_portable_ip.py @@ -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 @@ -817,14 +818,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"]) @@ -860,7 +862,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, @@ -868,6 +870,7 @@ class TestAssociatePublicIp(cloudstackTestCase): networkid=self.network.id, isportable=True ) + portableipaddress.delete(self.apiclient) self.debug("Associating portable ip address failed") @@ -1340,7 +1343,6 @@ class TestDeleteAccount(cloudstackTestCase): return - class TestPortableIpTransferAcrossNetworks(cloudstackTestCase): """Test Transfer Portable IP Across Networks """ @@ -1392,7 +1394,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"], @@ -1542,11 +1543,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)