You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@apache.org on 2013/11/19 06:51:57 UTC

git commit: updated refs/heads/master to 67b071b

Updated Branches:
  refs/heads/master 2587e42db -> 67b071bea


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/67b071be
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/67b071be
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/67b071be

Branch: refs/heads/master
Commit: 67b071beaac34eb5c4427f120ed3f0d5baabb75b
Parents: 2587e42
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Tue Nov 19 11:18:33 2013 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Tue Nov 19 11:21:33 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/67b071be/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 14b6dac..d397ec4 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
 
@@ -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)