From e473e9aa6699b88b40070dba40ca59138ee5c3f8 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 23 Jul 2013 21:03:26 -0700 Subject: [PATCH] Automation: Fix clean up in tearDown We shouldn't clean up class-scope resources(_cleanup). We should create local ones(cleanup) then clean it. So: cls._cleanup would be used for class-scope resources. self.cleanup would be used for each unit. --- test/integration/component/test_accounts.py | 2 +- .../integration/component/test_asa1000v_fw.py | 4 +- .../component/test_project_resources.py | 2 +- .../component/test_redundant_router.py | 20 +++-- .../test_redundant_router_cleanups.py | 5 +- ...st_redundant_router_deployment_planning.py | 5 +- .../test_redundant_router_network_rules.py | 5 +- .../test_redundant_router_services.py | 4 +- .../test_redundant_router_upgrades.py | 5 +- test/integration/component/test_routers.py | 34 ++++---- test/integration/component/test_vpc.py | 57 ++++++------- .../integration/component/test_vpc_network.py | 81 ++++++++++--------- .../component/test_vpc_network_lbrules.py | 10 +-- .../test_vpc_network_staticnatrule.py | 10 +-- .../component/test_vpc_offerings.py | 35 ++++---- 15 files changed, 146 insertions(+), 133 deletions(-) diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py index 92f7a6fa8b9..726df42ba74 100644 --- a/test/integration/component/test_accounts.py +++ b/test/integration/component/test_accounts.py @@ -1827,7 +1827,7 @@ class TestDomainForceRemove(cloudstackTestCase): self.services["domain"], parentdomainid=self.domain.id ) - self._cleanup.append(domain) + self.cleanup.append(domain) self.debug("Domain: %s is created successfully." % domain.name) self.debug( "Checking if the created domain is listed in list domains API") diff --git a/test/integration/component/test_asa1000v_fw.py b/test/integration/component/test_asa1000v_fw.py index cd29fdadcc9..643fc1db28f 100644 --- a/test/integration/component/test_asa1000v_fw.py +++ b/test/integration/component/test_asa1000v_fw.py @@ -107,13 +107,13 @@ class TestASASetup(cloudstackTestCase): self.clusters = Cluster.list(self.apiclient, hypervisor='VMware') self.assertNotEqual(len(self.clusters), 0, "Check if the list cluster API returns a non-empty response") + self.cleanup = [] return def tearDown(self): try: self.debug("Cleaning up the resources") - # Cleanup - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) self.debug("Cleanup complete!") except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/component/test_project_resources.py b/test/integration/component/test_project_resources.py index 02de854bdde..01aa1338f27 100644 --- a/test/integration/component/test_project_resources.py +++ b/test/integration/component/test_project_resources.py @@ -485,7 +485,7 @@ class TestNetwork(cloudstackTestCase): networkofferingid=network_offering.id, zoneid=self.zone.id ) - self._cleanup.append(domain_network) + self.cleanup.append(domain_network) self.debug("Created network with ID: %s" % domain_network.id) virtual_machine = VirtualMachine.create( diff --git a/test/integration/component/test_redundant_router.py b/test/integration/component/test_redundant_router.py index 55f07108e89..d723c187fcb 100644 --- a/test/integration/component/test_redundant_router.py +++ b/test/integration/component/test_redundant_router.py @@ -283,12 +283,13 @@ class TestCreateRvRNetwork(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -481,12 +482,13 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -688,12 +690,13 @@ class TestRVRInternals(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -1008,12 +1011,13 @@ class TestRvRRedundancy(cloudstackTestCase): networkids=[str(self.network.id)] ) self.debug("Deployed VM in network: %s" % self.network.id) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return diff --git a/test/integration/component/test_redundant_router_cleanups.py b/test/integration/component/test_redundant_router_cleanups.py index b7ef3557465..9459d46cf33 100644 --- a/test/integration/component/test_redundant_router_cleanups.py +++ b/test/integration/component/test_redundant_router_cleanups.py @@ -189,12 +189,13 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup=[] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/component/test_redundant_router_deployment_planning.py b/test/integration/component/test_redundant_router_deployment_planning.py index d4d00caffe2..744be12e914 100644 --- a/test/integration/component/test_redundant_router_deployment_planning.py +++ b/test/integration/component/test_redundant_router_deployment_planning.py @@ -188,12 +188,13 @@ class TestRvRDeploymentPlanning(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/component/test_redundant_router_network_rules.py b/test/integration/component/test_redundant_router_network_rules.py index 92889d08dc7..d89a29b1c91 100644 --- a/test/integration/component/test_redundant_router_network_rules.py +++ b/test/integration/component/test_redundant_router_network_rules.py @@ -188,12 +188,13 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) diff --git a/test/integration/component/test_redundant_router_services.py b/test/integration/component/test_redundant_router_services.py index 59f9edcc3fd..ced54871325 100644 --- a/test/integration/component/test_redundant_router_services.py +++ b/test/integration/component/test_redundant_router_services.py @@ -190,12 +190,12 @@ class TestEnableVPNOverRvR(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return diff --git a/test/integration/component/test_redundant_router_upgrades.py b/test/integration/component/test_redundant_router_upgrades.py index e67507acaec..e9303c0126d 100644 --- a/test/integration/component/test_redundant_router_upgrades.py +++ b/test/integration/component/test_redundant_router_upgrades.py @@ -189,12 +189,13 @@ class TestRvRUpgradeDowngrade(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py index bc33d754260..5caf4183ddc 100644 --- a/test/integration/component/test_routers.py +++ b/test/integration/component/test_routers.py @@ -139,7 +139,7 @@ class TestRouterServices(cloudstackTestCase): domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) - cls.cleanup = [ + cls._cleanup = [ cls.account, cls.service_offering ] @@ -150,7 +150,7 @@ class TestRouterServices(cloudstackTestCase): try: cls.api_client = super(TestRouterServices, cls).getClsTestClient().getApiClient() #Clean up, terminate the created templates - cleanup_resources(cls.api_client, cls.cleanup) + cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -158,14 +158,14 @@ class TestRouterServices(cloudstackTestCase): def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return def setUp(self): self.apiclient = self.testClient.getApiClient() - self._cleanup = [] + self.cleanup = [] return @attr(tags = ["advanced"]) @@ -470,7 +470,7 @@ class TestRouterServices(cloudstackTestCase): router.state )) # Cleanup Vm_2 - Not required for further tests - self._cleanup.append(self.vm_2) + self.cleanup.append(self.vm_2) return @attr(tags = ["advanced"]) @@ -619,7 +619,7 @@ class TestRouterStopCreatePF(cloudstackTestCase): domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) - cls.cleanup = [ + cls._cleanup = [ cls.account, cls.service_offering ] @@ -630,7 +630,7 @@ class TestRouterStopCreatePF(cloudstackTestCase): try: cls.api_client = super(TestRouterStopCreatePF, cls).getClsTestClient().getApiClient() # Clean up, terminate the created resources - cleanup_resources(cls.api_client, cls.cleanup) + cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -639,14 +639,14 @@ class TestRouterStopCreatePF(cloudstackTestCase): def tearDown(self): try: # Clean up, terminate the created resources - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return def setUp(self): self.apiclient = self.testClient.getApiClient() - self._cleanup = [] + self.cleanup = [] return @attr(tags = ["advanced", "advancedns"]) @@ -831,7 +831,7 @@ class TestRouterStopCreateLB(cloudstackTestCase): domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) - cls.cleanup = [ + cls._cleanup = [ cls.account, cls.service_offering ] @@ -842,7 +842,7 @@ class TestRouterStopCreateLB(cloudstackTestCase): try: cls.api_client = super(TestRouterStopCreateLB, cls).getClsTestClient().getApiClient() #Clean up, terminate the created resources - cleanup_resources(cls.api_client, cls.cleanup) + cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -850,14 +850,14 @@ class TestRouterStopCreateLB(cloudstackTestCase): def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return def setUp(self): self.apiclient = self.testClient.getApiClient() - self._cleanup = [] + self.cleanup = [] return @attr(tags = ["advanced", "advancedns"]) @@ -1042,7 +1042,7 @@ class TestRouterStopCreateFW(cloudstackTestCase): domainid=cls.account.domainid, serviceofferingid=cls.service_offering.id ) - cls.cleanup = [ + cls._cleanup = [ cls.account, cls.service_offering ] @@ -1053,7 +1053,7 @@ class TestRouterStopCreateFW(cloudstackTestCase): try: cls.api_client = super(TestRouterStopCreateFW, cls).getClsTestClient().getApiClient() #Clean up, terminate the created templates - cleanup_resources(cls.api_client, cls.cleanup) + cleanup_resources(cls.api_client, cls._cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -1061,14 +1061,14 @@ class TestRouterStopCreateFW(cloudstackTestCase): def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return def setUp(self): self.apiclient = self.testClient.getApiClient() - self._cleanup = [] + self.cleanup = [] return @attr(tags = ["advanced", "advancedns"]) diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py index 08bfb5c6b1b..9997ca41984 100644 --- a/test/integration/component/test_vpc.py +++ b/test/integration/component/test_vpc.py @@ -223,12 +223,13 @@ class TestVPC(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) @@ -525,7 +526,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -554,7 +555,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering_no_lb.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering_no_lb) + self.cleanup.append(self.network_offering_no_lb) gateway = '10.1.2.1' # New network -> different gateway self.debug("Creating network with network offering: %s" % @@ -652,7 +653,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -681,7 +682,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering_no_lb.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering_no_lb) + self.cleanup.append(self.network_offering_no_lb) gateway = '10.1.2.1' # New network -> different gateway self.debug("Creating network with network offering: %s" % @@ -765,7 +766,7 @@ class TestVPC(cloudstackTestCase): self.apiclient, self.services["account"], ) - self._cleanup.append(self.user) + self.cleanup.append(self.user) self.services["vpc"]["cidr"] = "10.1.1.1/16" self.debug("creating a VPC network in the account: %s" % @@ -841,7 +842,7 @@ class TestVPC(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -867,7 +868,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) self.network_offering_no_lb = NetworkOffering.create( self.apiclient, @@ -876,7 +877,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering_no_lb.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering_no_lb) + self.cleanup.append(self.network_offering_no_lb) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -1186,7 +1187,7 @@ class TestVPC(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1212,7 +1213,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) self.network_offering_no_lb = NetworkOffering.create( self.apiclient, @@ -1221,7 +1222,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering_no_lb.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering_no_lb) + self.cleanup.append(self.network_offering_no_lb) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -1674,7 +1675,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -1821,7 +1822,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -1877,7 +1878,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -1926,7 +1927,7 @@ class TestVPC(cloudstackTestCase): self.services["account"] ) self.debug("Created account: %s" % user.name) - self._cleanup.append(user) + self.cleanup.append(user) self.services["vpc"]["cidr"] = "10.1.1.1/16" self.debug("creating a VPC network in the account: %s" % @@ -1953,7 +1954,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -2007,7 +2008,7 @@ class TestVPC(cloudstackTestCase): self.services["account"] ) self.debug("Created account: %s" % user.name) - self._cleanup.append(user) + self.cleanup.append(user) self.services["vpc"]["cidr"] = "10.1.1.1/16" self.debug("creating a VPC network in the account: %s" % @@ -2034,7 +2035,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -2083,7 +2084,7 @@ class TestVPC(cloudstackTestCase): self.services["account"] ) self.debug("Created account: %s" % user.name) - self._cleanup.append(user) + self.cleanup.append(user) self.services["vpc"]["cidr"] = "10.1.1.1/16" self.debug("creating a VPC network in the account: %s" % @@ -2111,7 +2112,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -2167,7 +2168,7 @@ class TestVPC(cloudstackTestCase): self.services["domain_admin"] ) self.debug("Created account: %s" % domain_admin.name) - self._cleanup.append(domain_admin) + self.cleanup.append(domain_admin) da_apiclient = self.testClient.getUserApiClient( account=domain_admin.name, domain=domain_admin.domain, @@ -2178,7 +2179,7 @@ class TestVPC(cloudstackTestCase): self.services["account"] ) self.debug("Created account: %s" % user.name) - self._cleanup.append(user) + self.cleanup.append(user) self.services["vpc"]["cidr"] = "10.1.1.1/16" self.debug("creating a VPC network in the account: %s" % @@ -2218,7 +2219,7 @@ class TestVPC(cloudstackTestCase): self.services["domain_admin"] ) self.debug("Created account: %s" % domain_admin.name) - self._cleanup.append(domain_admin) + self.cleanup.append(domain_admin) da_apiclient = self.testClient.getUserApiClient( account=domain_admin.name, domain=self.services["domain"]["name"], @@ -2229,7 +2230,7 @@ class TestVPC(cloudstackTestCase): self.services["account"] ) self.debug("Created account: %s" % user.name) - self._cleanup.append(user) + self.cleanup.append(user) self.services["vpc"]["cidr"] = "10.1.1.1/16" self.debug("creating a VPC network in the account: %s" % @@ -2256,7 +2257,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -2367,7 +2368,7 @@ class TestVPC(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway diff --git a/test/integration/component/test_vpc_network.py b/test/integration/component/test_vpc_network.py index 8b43dcd170f..517751c7a63 100644 --- a/test/integration/component/test_vpc_network.py +++ b/test/integration/component/test_vpc_network.py @@ -227,12 +227,13 @@ class TestVPCNetwork(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) @@ -311,7 +312,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -337,7 +338,7 @@ class TestVPCNetwork(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -404,7 +405,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -434,7 +435,7 @@ class TestVPCNetwork(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -474,7 +475,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -500,7 +501,7 @@ class TestVPCNetwork(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -565,7 +566,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -591,7 +592,7 @@ class TestVPCNetwork(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -670,7 +671,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -721,7 +722,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -754,7 +755,7 @@ class TestVPCNetwork(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -798,7 +799,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -824,7 +825,7 @@ class TestVPCNetwork(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -867,7 +868,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -929,7 +930,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -957,7 +958,7 @@ class TestVPCNetwork(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug( @@ -999,7 +1000,7 @@ class TestVPCNetwork(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1083,12 +1084,13 @@ class TestVPCNetworkRanges(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) @@ -1160,7 +1162,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1187,7 +1189,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network outside of the VPC's network") @@ -1222,7 +1224,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1249,7 +1251,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network outside of the VPC's network") @@ -1284,7 +1286,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1311,7 +1313,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network inside of the VPC's network") @@ -1352,7 +1354,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1379,7 +1381,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -1473,7 +1475,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1500,7 +1502,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) self.debug( "Creating the new account to create new network in VPC: %s" % @@ -1586,12 +1588,13 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) @@ -1671,7 +1674,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1697,7 +1700,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): ) # Enable Network offering nw_off.update(self.apiclient, state='Enabled') - self._cleanup.append(nw_off) + self.cleanup.append(nw_off) self.services["network_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,UserData,Lb,StaticNat,NetworkACL' self.services["network_offering"]["serviceProviderList"] = { @@ -1718,7 +1721,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): ) # Enable Network offering nw_off_no_pf.update(self.apiclient, state='Enabled') - self._cleanup.append(nw_off_no_pf) + self.cleanup.append(nw_off_no_pf) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % @@ -2019,7 +2022,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -2045,7 +2048,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): ) # Enable Network offering nw_off.update(self.apiclient, state='Enabled') - self._cleanup.append(nw_off) + self.cleanup.append(nw_off) self.services["network_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,UserData,Lb,StaticNat' self.services["network_offering"]["serviceProviderList"] = { @@ -2066,7 +2069,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): ) # Enable Network offering nw_off_vr.update(self.apiclient, state='Enabled') - self._cleanup.append(nw_off_vr) + self.cleanup.append(nw_off_vr) # Creating network using the network offering created self.debug("Creating network with network offering: %s" % nw_off.id) diff --git a/test/integration/component/test_vpc_network_lbrules.py b/test/integration/component/test_vpc_network_lbrules.py index d3c5ce1dee1..a650cbc2f96 100644 --- a/test/integration/component/test_vpc_network_lbrules.py +++ b/test/integration/component/test_vpc_network_lbrules.py @@ -225,14 +225,14 @@ class TestVPCNetworkLBRules(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup = [self.account] + self.cleanup = [self.account] self.debug("Creating a VPC offering..") self.vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) - self._cleanup.append(self.vpc_off) + self.cleanup.append(self.vpc_off) self.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') @@ -251,7 +251,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): def tearDown(self): try: #Clean up, terminate the created network offerings - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) @@ -405,7 +405,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.debug("Enabling the VPC offering created") vpc_off.update(self.apiclient, state='Enabled') @@ -431,7 +431,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase): ) # Enable Network offering nw_off.update(self.apiclient, state='Enabled') - self._cleanup.append(nw_off) + self.cleanup.append(nw_off) self.debug('Created and Enabled NetworkOffering') self.services["network"]["name"] = "NETWORK-" + str(gateway) diff --git a/test/integration/component/test_vpc_network_staticnatrule.py b/test/integration/component/test_vpc_network_staticnatrule.py index 0d23d0325bc..28c065d70a0 100644 --- a/test/integration/component/test_vpc_network_staticnatrule.py +++ b/test/integration/component/test_vpc_network_staticnatrule.py @@ -224,14 +224,14 @@ class TestVPCNetworkPFRules(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup = [self.account] + self.cleanup = [self.account] self.debug("Creating a VPC offering..") self.vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) - self._cleanup.append(self.vpc_off) + self.cleanup.append(self.vpc_off) self.debug("Enabling the VPC offering created") self.vpc_off.update(self.apiclient, state='Enabled') @@ -250,7 +250,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): def tearDown(self): try: #Clean up, terminate the created network offerings - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: self.debug("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e) @@ -405,7 +405,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(self.vpc_off) + self.cleanup.append(self.vpc_off) self.debug("Enabling the VPC offering created") vpc_off.update(self.apiclient, state='Enabled') @@ -431,7 +431,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase): ) # Enable Network offering nw_off.update(self.apiclient, state='Enabled') - self._cleanup.append(nw_off) + self.cleanup.append(nw_off) self.debug('Created and Enabled NetworkOffering') self.services["network"]["name"] = "NETWORK-" + str(gateway) diff --git a/test/integration/component/test_vpc_offerings.py b/test/integration/component/test_vpc_offerings.py index d1d7c6c96fa..a32bd686131 100644 --- a/test/integration/component/test_vpc_offerings.py +++ b/test/integration/component/test_vpc_offerings.py @@ -180,12 +180,13 @@ class TestVPCOffering(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self._cleanup.insert(0, self.account) + self.cleanup = [] + self.cleanup.insert(0, self.account) return def tearDown(self): try: - cleanup_resources(self.apiclient, self._cleanup) + cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -250,7 +251,7 @@ class TestVPCOffering(cloudstackTestCase): ) self.debug("Check if the VPC offering is created successfully?") - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) return @@ -277,7 +278,7 @@ class TestVPCOffering(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -302,7 +303,7 @@ class TestVPCOffering(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -551,14 +552,14 @@ class TestVPCOffering(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -670,14 +671,14 @@ class TestVPCOffering(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -791,14 +792,14 @@ class TestVPCOffering(cloudstackTestCase): ) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self._cleanup.append(self.network_offering) + self.cleanup.append(self.network_offering) vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -911,7 +912,7 @@ class TestVPCOffering(cloudstackTestCase): ) self.validate_vpc_offering(vpc_off) # Appending to cleanup to delete after test - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) except Exception as e: self.fail("Failed to create the VPC offering - %s" % e) return @@ -935,7 +936,7 @@ class TestVPCOffering(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.debug("Enabling the VPC offering created") @@ -1031,7 +1032,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["vpc_offering"] ) - self._cleanup.append(vpc_off_1) + self.cleanup.append(vpc_off_1) self.validate_vpc_offering(vpc_off_1) self.debug("Disabling the VPC offering created") vpc_off_1.update(self.apiclient, state='Disabled') @@ -1041,7 +1042,7 @@ class TestVPCOffering(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off_2) + self.cleanup.append(vpc_off_2) self.validate_vpc_offering(vpc_off_2) self.debug("Enabling the VPC offering created") vpc_off_2.update(self.apiclient, state='Enabled') @@ -1051,7 +1052,7 @@ class TestVPCOffering(cloudstackTestCase): self.services["vpc_offering"] ) - self._cleanup.append(vpc_off_3) + self.cleanup.append(vpc_off_3) self.validate_vpc_offering(vpc_off_3) self.debug("Enabling the VPC offering created") vpc_off_3.update(self.apiclient, state='Enabled') @@ -1060,7 +1061,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["vpc_offering"] ) - self._cleanup.append(vpc_off_4) + self.cleanup.append(vpc_off_4) self.debug("Enabling the VPC offering created") vpc_off_4.update(self.apiclient, state='Enabled')