cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gir...@apache.org
Subject git commit: updated refs/heads/master to 942fc98
Date Wed, 18 Jun 2014 07:38:13 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master e65b746b3 -> 942fc9884


CLOUDSTACK-6887: Code enhancement to ensure better cleanup


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/942fc988
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/942fc988
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/942fc988

Branch: refs/heads/master
Commit: 942fc98848855c5ff2f177b251a44b1f2b971a57
Parents: e65b746
Author: Gaurav Aradhye <gaurav.aradhye@clogeny.com>
Authored: Wed Jun 18 13:06:55 2014 +0530
Committer: Girish Shilamkar <girish@clogeny.com>
Committed: Wed Jun 18 13:08:02 2014 +0530

----------------------------------------------------------------------
 test/integration/component/test_accounts.py     | 83 +++++++++++---------
 .../component/test_add_remove_network.py        | 68 +++++++++-------
 .../component/test_affinity_groups.py           | 64 ++++++---------
 test/integration/component/test_portable_ip.py  | 22 +++---
 test/integration/component/test_vpc_network.py  | 10 +--
 5 files changed, 125 insertions(+), 122 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/942fc988/test/integration/component/test_accounts.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py
index f71dea5..a60a5be 100644
--- a/test/integration/component/test_accounts.py
+++ b/test/integration/component/test_accounts.py
@@ -272,8 +272,8 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
                             cls.services["account"]
                             )
 
-        cls._cleanup = [
-                        cls.service_offering,
+        cls._cleanup =  [cls.account,
+                         cls.service_offering,
                         ]
         return
 
@@ -774,6 +774,13 @@ class TestTemplateHierarchy(cloudstackTestCase):
                             domainid=cls.domain_2.id
                             )
 
+        cls._cleanup = [
+                        cls.account_2,
+                        cls.domain_2,
+                        cls.account_1,
+                        cls.domain_1,
+                        ]
+
         builtin_info = get_builtin_template_info(cls.api_client, cls.zone.id)
         cls.services["template"]["url"] = builtin_info[0] 
         cls.services["template"]["hypervisor"] = builtin_info[1]     
@@ -794,14 +801,6 @@ class TestTemplateHierarchy(cloudstackTestCase):
 
         # Wait for template status to be changed across
         time.sleep(60)
-
-        cls._cleanup = [
-                        cls.account_2,
-                        cls.domain_2,
-                        cls.template,
-                        cls.account_1,
-                        cls.domain_1,
-                        ]
         return
 
     @classmethod
@@ -927,6 +926,13 @@ class TestAddVmToSubDomain(cloudstackTestCase):
                                     cls.services["service_offering"],
                                     domainid=cls.domain.id
                                     )
+
+        cls._cleanup = [
+                        cls.account_2,
+                        cls.account_1,
+                        cls.sub_domain,
+                        cls.service_offering
+                        ]
         cls.template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -950,12 +956,6 @@ class TestAddVmToSubDomain(cloudstackTestCase):
                                     domainid=cls.account_2.domainid,
                                     serviceofferingid=cls.service_offering.id
                                     )
-        cls._cleanup = [
-                        cls.account_2,
-                        cls.account_1,
-                        cls.sub_domain,
-                        cls.service_offering
-                        ]
         return
 
     @classmethod
@@ -1574,16 +1574,17 @@ class TestDomainForceRemove(cloudstackTestCase):
                                      domainid=domain.id
                                      )
 
-        self.debug("Creating a tiny service offering for VM deployment")
-        self.service_offering = ServiceOffering.create(
+        try:
+            self.debug("Creating a tiny service offering for VM deployment")
+            self.service_offering = ServiceOffering.create(
                                     self.apiclient,
                                     self.services["service_offering"],
                                     domainid=self.domain.id
                                     )
 
-        self.debug("Deploying virtual machine in account 1: %s" %
+            self.debug("Deploying virtual machine in account 1: %s" %
                                                 self.account_1.name)
-        vm_1 = VirtualMachine.create(
+            vm_1 = VirtualMachine.create(
                                     self.apiclient,
                                     self.services["virtual_machine"],
                                     templateid=self.template.id,
@@ -1592,9 +1593,9 @@ class TestDomainForceRemove(cloudstackTestCase):
                                     serviceofferingid=self.service_offering.id
                                     )
 
-        self.debug("Deploying virtual machine in account 2: %s" %
+            self.debug("Deploying virtual machine in account 2: %s" %
                                                 self.account_2.name)
-        vm_2 = VirtualMachine.create(
+            VirtualMachine.create(
                                     self.apiclient,
                                     self.services["virtual_machine"],
                                     templateid=self.template.id,
@@ -1603,22 +1604,22 @@ class TestDomainForceRemove(cloudstackTestCase):
                                     serviceofferingid=self.service_offering.id
                                     )
 
-        networks = Network.list(
+            networks = Network.list(
                                 self.apiclient,
                                 account=self.account_1.name,
                                 domainid=self.account_1.domainid,
                                 listall=True
                                 )
-        self.assertEqual(
+            self.assertEqual(
                          isinstance(networks, list),
                          True,
                          "List networks should return a valid response"
                          )
-        network_1 = networks[0]
-        self.debug("Default network in account 1: %s is %s" % (
+            network_1 = networks[0]
+            self.debug("Default network in account 1: %s is %s" % (
                                                 self.account_1.name,
                                                 network_1.name))
-        src_nat_list = PublicIPAddress.list(
+            src_nat_list = PublicIPAddress.list(
                                     self.apiclient,
                                     associatednetworkid=network_1.id,
                                     account=self.account_1.name,
@@ -1626,44 +1627,48 @@ class TestDomainForceRemove(cloudstackTestCase):
                                     listall=True,
                                     issourcenat=True,
                                     )
-        self.assertEqual(
+            self.assertEqual(
                          isinstance(src_nat_list, list),
                          True,
                          "List Public IP should return a valid source NAT"
                          )
-        self.assertNotEqual(
+            self.assertNotEqual(
                     len(src_nat_list),
                     0,
                     "Length of response from listPublicIp should not be 0"
                     )
 
-        src_nat = src_nat_list[0]
+            src_nat = src_nat_list[0]
 
-        self.debug(
-            "Trying to create a port forwarding rule in source NAT: %s" %
+            self.debug(
+                      "Trying to create a port forwarding rule in source NAT: %s" %
                                                             src_nat.ipaddress)
-        #Create NAT rule
-        nat_rule = NATRule.create(
+            #Create NAT rule
+            nat_rule = NATRule.create(
                                   self.apiclient,
                                   vm_1,
                                   self.services["natrule"],
                                   ipaddressid=src_nat.id
                            )
-        self.debug("Created PF rule on source NAT: %s" % src_nat.ipaddress)
+            self.debug("Created PF rule on source NAT: %s" % src_nat.ipaddress)
 
-        nat_rules = NATRule.list(self.apiclient, id=nat_rule.id)
+            nat_rules = NATRule.list(self.apiclient, id=nat_rule.id)
 
-        self.assertEqual(
+            self.assertEqual(
                          isinstance(nat_rules, list),
                          True,
                          "List NAT should return a valid port forwarding rules"
                          )
 
-        self.assertNotEqual(
+            self.assertNotEqual(
                     len(nat_rules),
                     0,
                     "Length of response from listLbRules should not be 0"
                     )
+        except Exception as e:
+            self.clenaup.append(self.account_1)
+            self.cleanup.append(self.account_2)
+            self.fail(e)
 
         self.debug("Deleting domain with force option")
         try:
@@ -1760,7 +1765,7 @@ class TestDomainForceRemove(cloudstackTestCase):
 
         self.debug("Deploying virtual machine in account 2: %s" %
                                                 self.account_2.name)
-        vm_2 = VirtualMachine.create(
+        VirtualMachine.create(
                                     self.apiclient,
                                     self.services["virtual_machine"],
                                     templateid=self.template.id,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/942fc988/test/integration/component/test_add_remove_network.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_add_remove_network.py b/test/integration/component/test_add_remove_network.py
index 7479cee..4222f7a 100644
--- a/test/integration/component/test_add_remove_network.py
+++ b/test/integration/component/test_add_remove_network.py
@@ -196,10 +196,13 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
         # Create Accounts & networks
         cls.services["isolated_network"]["zoneid"] = cls.zone.id
         cls.services["shared_network"]["zoneid"] = cls.zone.id
+        cls._cleanup = []
 
         cls.account = Account.create(cls.api_client, cls.services["account"], domainid =
cls.domain.id)
+        cls._cleanup.append(cls.account)
 
         cls.service_offering = ServiceOffering.create(cls.api_client,cls.services["service_offering"])
+        cls._cleanup.append(cls.service_offering)
 
         cls.virtual_machine = VirtualMachine.create(cls.api_client, cls.services["virtual_machine"],accountid=cls.account.name,
                                                     domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id,
@@ -207,6 +210,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
 
         # Create Shared Network Offering
         cls.isolated_network_offering = NetworkOffering.create(cls.api_client, cls.services["isolated_network_offering"])
+        cls._cleanup.append(cls.isolated_network_offering)
         # Enable Isolated Network offering
         cls.isolated_network_offering.update(cls.api_client, state='Enabled')
 
@@ -230,9 +234,8 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
 
         cls.shared_network = Network.create(cls.api_client,cls.services["shared_network"],cls.account.name,
                                             cls.account.domainid,networkofferingid=cls.shared_network_offering.id)
-
-        cls._cleanup = [cls.account,cls.service_offering,cls.shared_network,cls.isolated_network_offering,
-                        cls.shared_network_offering]
+        cls._cleanup.append(cls.shared_network)
+        cls._cleanup.append(cls.shared_network_offering)
         return
 
     def setUp(self):
@@ -600,37 +603,40 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
 
         network = None #The network which we are adding to the vm
 
-        self.child_domain_1 = Domain.create(self.apiclient,
+        try:
+            tempCleanupList = []
+            self.child_domain_1 = Domain.create(self.apiclient,
                                             services=self.services["domain"],
                                             parentdomainid=self.domain.id)
+            tempCleanupList.append(self.child_domain_1)
 
-        self.child_do_admin_1 = Account.create(
+            self.child_do_admin_1 = Account.create(
                                 self.apiclient,
                                 self.services["account"],
                                 admin=True,
                                 domainid=self.child_domain_1.id
                                 )
+            tempCleanupList.append(self.child_do_admin_1)
 
-        self.debug("Creating a domain under: %s" % self.domain.name)
-
-        self.child_domain_2 = Domain.create(self.apiclient,
+            self.child_domain_2 = Domain.create(self.apiclient,
                                               services=self.services["domain"],
                                               parentdomainid=self.domain.id)
+            tempCleanupList.append(self.child_domain_2)
 
-        self.child_do_admin_2 = Account.create(
+            self.child_do_admin_2 = Account.create(
                                     self.apiclient,
                                     self.services["account"],
                                     admin=True,
                                     domainid=self.child_domain_2.id)
+            tempCleanupList.append(self.child_do_admin_2)
+        except Exception as e:
+            tempCleanupList.reverse()
+            self.cleanup += tempCleanupList
+            self.fail(e)
 
         network = Network.create(self.api_client,self.services["isolated_network"],self.child_do_admin_1.name,
                                      self.child_do_admin_1.domainid,networkofferingid=self.isolated_network_offering.id)
 
-        self.cleanup.append(self.child_do_admin_1)
-        self.cleanup.append(self.child_domain_1)
-        self.cleanup.append(self.child_do_admin_2)
-        self.cleanup.append(self.child_domain_2)
-
         virtual_machine = VirtualMachine.create(self.apiclient, self.services["virtual_machine"],accountid=self.child_do_admin_2.name,
                                                     domainid=self.child_do_admin_2.domainid,
serviceofferingid=self.service_offering.id,
                                                     mode=self.zone.networktype)
@@ -661,12 +667,9 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
                                 self.services["account"],
                                 domainid=self.domain.id
                                 )
-        self.debug("create account %s" % account_1.name)
-
         self.cleanup.append(account_1)
 
         self.debug("setting network limit of account: %s as 1" % account_1.name)
-
         update_resource_limit(
                               self.apiclient,
                               6, # Network
@@ -742,22 +745,25 @@ class TestRemoveNetworkFromVirtualMachine(cloudstackTestCase):
         # Create Accounts & networks
         cls.services["isolated_network"]["zoneid"] = cls.zone.id
         cls.services["shared_network"]["zoneid"] = cls.zone.id
+        cls._cleanup = []
 
         cls.account = Account.create(cls.api_client,cls.services["account"],domainid = cls.domain.id)
+        cls._cleanup.append(cls.account)
 
         cls.service_offering = ServiceOffering.create(cls.api_client,cls.services["service_offering"])
+        cls._cleanup.append(cls.service_offering)
 
         cls.virtual_machine = VirtualMachine.create(cls.api_client,cls.services["virtual_machine"],accountid=cls.account.name,
                                                     domainid=cls.account.domainid,serviceofferingid=cls.service_offering.id,
                                                     mode=cls.zone.networktype)
         # Create Shared Network Offering
         cls.isolated_network_offering = NetworkOffering.create(cls.api_client,cls.services["isolated_network_offering"])
+        cls._cleanup.append(cls.isolated_network_offering)
+
         # Enable Isolated Network offering
         cls.isolated_network_offering.update(cls.api_client, state='Enabled')
         cls.isolated_network = Network.create(cls.api_client,cls.services["isolated_network"],cls.account.name,
                                               cls.account.domainid,networkofferingid=cls.isolated_network_offering.id)
-
-        cls._cleanup = [cls.account,cls.service_offering,cls.isolated_network_offering,]
         return
 
     def setUp(self):
@@ -1139,21 +1145,25 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase):
         cls.services["virtual_machine"]["template"] = template.id
         # Create Accounts & networks
         cls.services["isolated_network"]["zoneid"] = cls.zone.id
+        cls._cleanup = []
         cls.account = Account.create(cls.api_client,cls.services["account"],domainid = cls.domain.id)
+        cls._cleanup.append(cls.account)
+
         cls.service_offering = ServiceOffering.create(cls.api_client,cls.services["service_offering"])
+        cls._cleanup.append(cls.service_offering)
 
         cls.virtual_machine = VirtualMachine.create(cls.api_client,cls.services["virtual_machine"],
                                                     accountid=cls.account.name,domainid=cls.account.domainid,
                                                     serviceofferingid=cls.service_offering.id,mode=cls.zone.networktype)
         # Create Shared Network Offering
         cls.isolated_network_offering = NetworkOffering.create(cls.api_client,cls.services["isolated_network_offering"],)
+        cls._cleanup.append(cls.isolated_network_offering)
+
         # Enable Isolated Network offering
         cls.isolated_network_offering.update(cls.api_client, state='Enabled')
 
         cls.isolated_network = Network.create(cls.api_client,cls.services["isolated_network"],cls.account.name,
                                               cls.account.domainid,networkofferingid=cls.isolated_network_offering.id)
-
-        cls._cleanup = [cls.account,cls.service_offering,cls.isolated_network_offering,]
         return
 
     def setUp(self):
@@ -1376,9 +1386,14 @@ class TestFailureScenariosRemoveNicFromVM(cloudstackTestCase):
         # Create Accounts & networks
         cls.services["isolated_network"]["zoneid"] = cls.zone.id
         cls.services["shared_network"]["zoneid"] = cls.zone.id
+        cls._cleanup = []
 
         cls.account = Account.create(cls.api_client,cls.services["account"],domainid = cls.domain.id)
+        cls.append(cls.account)
+
         cls.service_offering = ServiceOffering.create(cls.api_client,cls.services["service_offering"])
+        cls._cleanup.append(cls.service_offering)
+
         cls.virtual_machine = VirtualMachine.create(cls.api_client,cls.services["virtual_machine"],
                                                     accountid=cls.account.name,domainid=cls.account.domainid,
                                                     serviceofferingid=cls.service_offering.id,
@@ -1386,6 +1401,7 @@ class TestFailureScenariosRemoveNicFromVM(cloudstackTestCase):
 
         # Create Shared Network Offering
         cls.isolated_network_offering = NetworkOffering.create(cls.api_client, cls.services["isolated_network_offering"],)
+        cls._cleanup.append(cls.isolated_network_offering)
         # Enable Isolated Network offering
         cls.isolated_network_offering.update(cls.api_client, state='Enabled')
         cls.isolated_network = Network.create(cls.api_client,cls.services["isolated_network"],cls.account.name,
@@ -1393,8 +1409,6 @@ class TestFailureScenariosRemoveNicFromVM(cloudstackTestCase):
 
         # Add network to VM
         cls.virtual_machine.add_nic(cls.api_client, cls.isolated_network.id)
-
-        cls._cleanup = [cls.account,cls.service_offering,cls.isolated_network_offering,]
         return
 
     def setUp(self):
@@ -1556,10 +1570,13 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
         # Create Accounts & networks
         cls.services["isolated_network"]["zoneid"] = cls.zone.id
         cls.services["shared_network"]["zoneid"] = cls.zone.id
+        cls._cleanup = []
 
         cls.account = Account.create(cls.api_client, cls.services["account"], domainid =
cls.domain.id)
+        cls._cleanup.append(cls.account)
 
         cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
+        cls._cleanup.append(cls.service_offering)
 
         cls.virtual_machine = VirtualMachine.create(cls.api_client,cls.services["virtual_machine"],
                                                     accountid=cls.account.name,domainid=cls.account.domainid,
@@ -1569,6 +1586,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
 
         # Create Shared Network Offering
         cls.isolated_network_offering = NetworkOffering.create(cls.api_client, cls.services["isolated_network_offering"],)
+        cls._cleanup.append(cls.isolated_network_offering)
         # Enable Isolated Network offering
         cls.isolated_network_offering.update(cls.api_client, state='Enabled')
 
@@ -1576,8 +1594,6 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
                                               cls.account.name,cls.account.domainid,
                                               networkofferingid=cls.isolated_network_offering.id)
         cls.virtual_machine.add_nic(cls.api_client, cls.isolated_network.id)
-        cls._cleanup = [cls.account,cls.service_offering,
-                        cls.isolated_network_offering,]
         return
 
     def setUp(self):
@@ -1711,8 +1727,6 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
 
         self.debug("Creating new account")
         account = Account.create(self.apiclient,self.services["account"],domainid = self.domain.id)
-        self.debug("Created account %s" % account.name)
-
         self.cleanup.append(account)
 
         self.debug("Creating virtual machine in the account %s" % account.name)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/942fc988/test/integration/component/test_affinity_groups.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_affinity_groups.py b/test/integration/component/test_affinity_groups.py
index d0fa2f7..de5f007 100644
--- a/test/integration/component/test_affinity_groups.py
+++ b/test/integration/component/test_affinity_groups.py
@@ -113,11 +113,14 @@ class TestCreateAffinityGroup(cloudstackTestCase):
         cls.services["template"] = cls.template.id
         cls.services["zoneid"] = cls.zone.id
 
+        cls._cleanup = []
+
         cls.account = Account.create(
             cls.api_client,
             cls.services["account"],
             domainid=cls.domain.id
         )
+        cls._cleanup.append(cls.account)
 
         cls.services["account"] = cls.account.name
         cls.services["domainid"] = cls.domain.id
@@ -126,11 +129,7 @@ class TestCreateAffinityGroup(cloudstackTestCase):
             cls.api_client,
             cls.services["service_offering"]
         )
-
-        cls._cleanup = [
-            cls.service_offering,
-            cls.account,
-        ]
+        cls._cleanup.append(cls.service_offering)
         return
 
     def setUp(self):
@@ -221,10 +220,9 @@ class TestCreateAffinityGroup(cloudstackTestCase):
 
         self.user = Account.create(self.api_client, self.services["new_account"],
                                   domainid=self.domain.id)
+        self.cleanup.append(self.user)
 
         userapiclient = self.testClient.getUserApiClient(self.user.name, self.domain.name)
-
-        self.cleanup.append(self.user)
         aff_grp = self.create_aff_grp(api_client=userapiclient, aff_grp=self.services["host_anti_affinity"],
                             acc=self.user.name, domainid=self.domain.id)
         aff_grp.delete(userapiclient)
@@ -309,11 +307,14 @@ class TestListAffinityGroups(cloudstackTestCase):
         cls.services["template"] = cls.template.id
         cls.services["zoneid"] = cls.zone.id
 
+        cls._cleanup = []
+
         cls.account = Account.create(
             cls.api_client,
             cls.services["account"],
             domainid=cls.domain.id
         )
+        cls._cleanup.append(cls.account)
 
         cls.services["account"] = cls.account.name
         cls.services["domainid"] = cls.domain.id
@@ -322,12 +323,7 @@ class TestListAffinityGroups(cloudstackTestCase):
             cls.api_client,
             cls.services["service_offering"]
         )
-
-        cls.__cleanup = [
-            cls.service_offering,
-            cls.account,
-        ]
-
+        cls._cleanup.append(cls.service_offering)
         # Create multiple Affinity Groups
         return
 
@@ -558,11 +554,14 @@ class TestDeleteAffinityGroups(cloudstackTestCase):
         cls.services["template"] = cls.template.id
         cls.services["zoneid"] = cls.zone.id
 
+        cls._cleanup = []
+
         cls.account = Account.create(
             cls.api_client,
             cls.services["account"],
             domainid=cls.domain.id
         )
+        cls._cleanup.append(cls.account)
 
         cls.services["account"] = cls.account.name
         cls.services["domainid"] = cls.domain.id
@@ -571,12 +570,7 @@ class TestDeleteAffinityGroups(cloudstackTestCase):
             cls.api_client,
             cls.services["service_offering"]
         )
-
-        cls.__cleanup = [
-            cls.service_offering,
-            cls.account,
-        ]
-
+        cls._cleanup.append(cls.service_offering)
         # Create multiple Affinity Groups
         return
 
@@ -831,11 +825,14 @@ class TestUpdateVMAffinityGroups(cloudstackTestCase):
         cls.services["template"] = cls.template.id
         cls.services["zoneid"] = cls.zone.id
 
+        cls._cleanup = []
+
         cls.account = Account.create(
             cls.api_client,
             cls.services["account"],
             domainid=cls.domain.id
         )
+        cls._cleanup.append(cls.account)
 
         cls.services["account"] = cls.account.name
         cls.services["domainid"] = cls.domain.id
@@ -844,12 +841,7 @@ class TestUpdateVMAffinityGroups(cloudstackTestCase):
             cls.api_client,
             cls.services["service_offering"]
         )
-
-        cls.__cleanup = [
-            cls.service_offering,
-            cls.account,
-        ]
-
+        cls._cleanup.append(cls.service_offering)
         # Create multiple Affinity Groups
         return
 
@@ -1118,11 +1110,14 @@ class TestDeployVMAffinityGroups(cloudstackTestCase):
         cls.services["template"] = cls.template.id
         cls.services["zoneid"] = cls.zone.id
 
+        cls._cleanup = []
+
         cls.account = Account.create(
             cls.api_client,
             cls.services["account"],
             domainid=cls.domain.id
         )
+        cls._cleanup.append(cls.account)
 
         cls.services["account"] = cls.account.name
         cls.services["domainid"] = cls.domain.id
@@ -1131,13 +1126,7 @@ class TestDeployVMAffinityGroups(cloudstackTestCase):
             cls.api_client,
             cls.services["service_offering"]
         )
-
-        cls.__cleanup = [
-            cls.service_offering,
-            cls.account,
-        ]
-
-        # Create multiple Affinity Groups
+        cls._cleanup.append(cls.service_offering)
         return
 
     def setUp(self):
@@ -1468,11 +1457,14 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
         cls.services["template"] = cls.template.id
         cls.services["zoneid"] = cls.zone.id
 
+        cls._cleanup = []
+
         cls.account = Account.create(
             cls.api_client,
             cls.services["account"],
             domainid=cls.domain.id
         )
+        cls._cleanup.append(cls.account)
 
         cls.services["account"] = cls.account.name
         cls.services["domainid"] = cls.domain.id
@@ -1481,13 +1473,7 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
             cls.api_client,
             cls.services["service_offering"]
         )
-
-        cls.__cleanup = [
-            cls.service_offering,
-            cls.account,
-        ]
-
-        # Create multiple Affinity Groups
+        cls._cleanup.append(cls.service_offering)
         return
 
     def setUp(self):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/942fc988/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 538318d..b9c9059 100644
--- a/test/integration/component/test_portable_ip.py
+++ b/test/integration/component/test_portable_ip.py
@@ -235,6 +235,7 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
                             self.services["account"],
                             domainid=self.domain.id
                             )
+            self.cleanup.append(self.account)
 
             self.api_client_user = self.testClient.getUserApiClient(
                                             UserName=self.account.name,
@@ -597,6 +598,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
                             domainid=cls.domain.id,
                             admin=True
                             )
+        cls._cleanup = [cls.account, ]
 
         cls.network_offering = NetworkOffering.create(
                                             cls.api_client,
@@ -615,8 +617,6 @@ class TestAssociatePublicIp(cloudstackTestCase):
                                     networkofferingid=cls.network_offering.id,
                                     zoneid=cls.zone.id
                                     )
-
-        cls._cleanup = [cls.account]
         return
 
     @classmethod
@@ -907,6 +907,7 @@ class TestDisassociatePublicIp(cloudstackTestCase):
         # Set Zones and disk offerings
         cls.services["small"]["zoneid"] = cls.zone.id
         cls.services["small"]["template"] = template.id
+        cls._cleanup = []
 
         cls.account = Account.create(
                             cls.api_client,
@@ -914,11 +915,13 @@ class TestDisassociatePublicIp(cloudstackTestCase):
                             domainid=cls.domain.id,
                             admin=True
                             )
+        cls._cleanup.append(cls.account)
 
         cls.service_offering = ServiceOffering.create(
             cls.api_client,
             cls.services["service_offering"]
         )
+        cls._cleanup.append(cls.service_offering)
 
         cls.network_offering = NetworkOffering.create(
                                             cls.api_client,
@@ -928,6 +931,7 @@ class TestDisassociatePublicIp(cloudstackTestCase):
 
         # Enable Network offering
         cls.network_offering.update(cls.api_client, state='Enabled')
+        cls._cleanup.append(cls.network_offering)
 
         cls.network = Network.create(
                                     cls.api_client,
@@ -947,12 +951,6 @@ class TestDisassociatePublicIp(cloudstackTestCase):
                                                     networkids = [cls.network.id],
                                                     mode=cls.services['mode']
                                                     )
-
-        cls._cleanup = [
-                        cls.account,
-                        cls.service_offering,
-                        cls.network_offering
-                       ]
         return
 
     @classmethod
@@ -1177,6 +1175,7 @@ class TestDeleteAccount(cloudstackTestCase):
                             domainid=self.domain.id,
                             admin=True
                             )
+            self.cleanup.append(self.account)
             portable_ip_range_services["regionid"] = self.region.id
             #create new portable ip range
             new_portable_ip_range = PortablePublicIpRange.create(self.apiclient,
@@ -1200,7 +1199,6 @@ class TestDeleteAccount(cloudstackTestCase):
                                     )
             self.cleanup.append(self.network_offering)
         except Exception as e:
-            self.cleanup.append(self.account)
             self.fail("Exception in setupClass: %s" % e)
         return
 
@@ -1353,6 +1351,8 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
         cls.services["vm2"]["zoneid"] = cls.zone.id
         cls.services["vm2"]["template"] = template.id
 
+        cls._cleanup = []
+
         # Set Zones and Network offerings
         cls.account = Account.create(
                             cls.api_client,
@@ -1360,12 +1360,14 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
                             domainid=cls.domain.id,
                             admin=True
                             )
+        cls._cleanup.append(cls.account)
 
         cls.network_offering = NetworkOffering.create(
                                             cls.api_client,
                                             cls.services["network_offering"],
                                             conservemode=False
                                             )
+        cls._cleanup.append(cls.network_offering)
 
         # Enable Network offering
         cls.network_offering.update(cls.api_client, state='Enabled')
@@ -1407,8 +1409,6 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
                                             serviceofferingid=cls.service_offering.id,
                                             networkids = [cls.network2.id],
                                             )
-        cls._cleanup = [cls.account, cls.network_offering]
-
         return
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/942fc988/test/integration/component/test_vpc_network.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network.py b/test/integration/component/test_vpc_network.py
index a449948..c5d9da6 100644
--- a/test/integration/component/test_vpc_network.py
+++ b/test/integration/component/test_vpc_network.py
@@ -294,8 +294,7 @@ class TestVPCNetwork(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        self.cleanup.insert(0, self.account)
+        self.cleanup = [self.account, ]
         return
 
     def tearDown(self):
@@ -1056,8 +1055,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        self.cleanup.insert(0, self.account)
+        self.cleanup = [self.account, ]
         return
 
     def tearDown(self):
@@ -1516,6 +1514,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                 )
+        self.cleanup.append(account)
 
         # Creating network using the network offering created
         self.debug("Creating network from diff account than VPC")
@@ -1584,8 +1583,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        self.cleanup.insert(0, self.account)
+        self.cleanup = [self.account, ]
         return
 
     def tearDown(self):


Mime
View raw message