diff --git a/test/integration/component/test_vpc_offerings.py b/test/integration/component/test_vpc_offerings.py index e763e515cd4..e3af67ac18c 100644 --- a/test/integration/component/test_vpc_offerings.py +++ b/test/integration/component/test_vpc_offerings.py @@ -170,6 +170,7 @@ class TestVPCOffering(cloudstackTestCase): cls.testClient = super(TestVPCOffering, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() + cls._cleanup = [] cls.services = Services().services # Get Zone, Domain and templates @@ -187,9 +188,7 @@ class TestVPCOffering(cloudstackTestCase): cls.api_client, cls.services["service_offering"] ) - cls._cleanup = [ - cls.service_offering, - ] + cls._cleanup.append(cls.service_offering) return @classmethod @@ -300,6 +299,7 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["vpc_offering"] ) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) @@ -316,6 +316,7 @@ class TestVPCOffering(cloudstackTestCase): account=self.account.name, domainid=self.account.domainid ) + self.cleanup.append(vpc) self.validate_vpc_network(vpc) self.network_offering = NetworkOffering.create( @@ -323,6 +324,7 @@ class TestVPCOffering(cloudstackTestCase): self.services["network_offering"], conservemode=False ) + self.cleanup.append(self.network_offering) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') @@ -344,6 +346,7 @@ class TestVPCOffering(cloudstackTestCase): gateway=gateway, vpcid=vpc.id ) + self.cleanup.append(network) self.logger.debug("Created network with ID: %s" % network.id) # Spawn an instance in that network virtual_machine = VirtualMachine.create( @@ -354,6 +357,7 @@ class TestVPCOffering(cloudstackTestCase): serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) + self.cleanup.append(virtual_machine) self.logger.debug("Deployed VM in network: %s" % network.id) self.logger.debug("Associating public IP for network: %s" % network.name) @@ -365,6 +369,7 @@ class TestVPCOffering(cloudstackTestCase): networkid=network.id, vpcid=vpc.id ) + self.cleanup.append(public_ip) self.logger.debug("Associated %s with network %s" % ( public_ip.ipaddress.ipaddress, network.id @@ -382,6 +387,7 @@ class TestVPCOffering(cloudstackTestCase): vpcid=vpc.id, domainid=self.account.domainid ) + self.cleanup.append(lb_rule) self.logger.debug("Associating public IP for network: %s" % vpc.name) public_ip_2 = PublicIPAddress.create( @@ -392,6 +398,7 @@ class TestVPCOffering(cloudstackTestCase): networkid=network.id, vpcid=vpc.id ) + self.cleanup.append(public_ip_2) self.logger.debug("Associated %s with network %s" % ( public_ip_2.ipaddress.ipaddress, network.id @@ -406,6 +413,7 @@ class TestVPCOffering(cloudstackTestCase): networkid=network.id, vpcid=vpc.id ) + self.cleanup.append(nat_rule) self.logger.debug("Adding NetwrokACl rules to make PF and LB accessible") networkacl_1 = NetworkACL.create( @@ -414,6 +422,7 @@ class TestVPCOffering(cloudstackTestCase): services=self.services["natrule"], traffictype='Ingress' ) + self.cleanup.append(networkacl_1) networkacl_2 = NetworkACL.create( self.apiclient, @@ -421,6 +430,7 @@ class TestVPCOffering(cloudstackTestCase): services=self.services["lbrule"], traffictype='Ingress' ) + self.cleanup.append(networkacl_2) self.logger.debug("Checking if we can SSH into VM?") try: virtual_machine.get_ssh_client( @@ -440,6 +450,7 @@ class TestVPCOffering(cloudstackTestCase): networkid=network.id, vpcid=vpc.id ) + self.cleanup.append(public_ip_3) self.logger.debug("Associated %s with network %s" % ( public_ip_3.ipaddress.ipaddress, network.id @@ -515,22 +526,21 @@ class TestVPCOffering(cloudstackTestCase): self.services["network_offering"], conservemode=False ) + self.cleanup.append(self.network_offering) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self.cleanup.append(self.network_offering) vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.logger.debug("Enabling the VPC offering created") vpc_off.update(self.apiclient, state='Enabled') - self.cleanup.append(vpc_off) - self.logger.debug("creating a VPC network in the account: %s" % self.account.name) vpc = VPC.create( @@ -541,8 +551,8 @@ class TestVPCOffering(cloudstackTestCase): account=self.account.name, domainid=self.account.domainid ) - self.validate_vpc_network(vpc) self.cleanup.append(vpc) + self.validate_vpc_network(vpc) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -562,8 +572,8 @@ class TestVPCOffering(cloudstackTestCase): gateway=gateway, vpcid=vpc.id ) - self.logger.debug("Created network with ID: %s" % network.id) self.cleanup.append(network) + self.logger.debug("Created network with ID: %s" % network.id) self.logger.debug("Deploying virtual machines in network: %s" % vpc.name) # Spawn an instance in that network @@ -575,8 +585,8 @@ class TestVPCOffering(cloudstackTestCase): serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) - self.logger.debug("Deployed VM in network: %s" % network.id) self.cleanup.append(virtual_machine) + self.logger.debug("Deployed VM in network: %s" % network.id) self.logger.debug("Associating public IP for network: %s" % network.name) public_ip = PublicIPAddress.create( @@ -587,6 +597,7 @@ class TestVPCOffering(cloudstackTestCase): networkid=network.id, vpcid=vpc.id ) + self.cleanup.append(public_ip) self.logger.debug("Associated %s with network %s" % ( public_ip.ipaddress.ipaddress, vpc.id @@ -638,20 +649,20 @@ class TestVPCOffering(cloudstackTestCase): self.services["network_offering"], conservemode=False ) + self.cleanup.append(self.network_offering) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self.cleanup.append(self.network_offering) vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.logger.debug("Enabling the VPC offering created") vpc_off.update(self.apiclient, state='Enabled') - self.cleanup.append(vpc_off) self.logger.debug("creating a VPC network in the account: %s" % self.account.name) @@ -663,8 +674,8 @@ class TestVPCOffering(cloudstackTestCase): account=self.account.name, domainid=self.account.domainid ) - self.validate_vpc_network(vpc) self.cleanup.append(vpc) + self.validate_vpc_network(vpc) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -684,8 +695,8 @@ class TestVPCOffering(cloudstackTestCase): gateway=gateway, vpcid=vpc.id ) - self.logger.debug("Created network with ID: %s" % network.id) self.cleanup.append(network) + self.logger.debug("Created network with ID: %s" % network.id) self.logger.debug("Deploying virtual machines in network: %s" % vpc.name) # Spawn an instance in that network @@ -697,8 +708,8 @@ class TestVPCOffering(cloudstackTestCase): serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) - self.logger.debug("Deployed VM in network: %s" % network.id) self.cleanup.append(virtual_machine) + self.logger.debug("Deployed VM in network: %s" % network.id) self.logger.debug("Associating public IP for network: %s" % network.name) public_ip = PublicIPAddress.create( @@ -709,6 +720,7 @@ class TestVPCOffering(cloudstackTestCase): networkid=network.id, vpcid=vpc.id ) + self.cleanup.append(public_ip) self.logger.debug("Associated %s with network %s" % ( public_ip.ipaddress.ipaddress, network.id @@ -762,20 +774,20 @@ class TestVPCOffering(cloudstackTestCase): self.services["network_offering"], conservemode=False ) + self.cleanup.append(self.network_offering) # Enable Network offering self.network_offering.update(self.apiclient, state='Enabled') - self.cleanup.append(self.network_offering) vpc_off = VpcOffering.create( self.apiclient, self.services["vpc_offering"] ) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) self.logger.debug("Enabling the VPC offering created") vpc_off.update(self.apiclient, state='Enabled') - self.cleanup.append(vpc_off) self.logger.debug("creating a VPC network in the account: %s" % self.account.name) @@ -787,8 +799,8 @@ class TestVPCOffering(cloudstackTestCase): account=self.account.name, domainid=self.account.domainid ) - self.validate_vpc_network(vpc) self.cleanup.append(vpc) + self.validate_vpc_network(vpc) gateway = vpc.cidr.split('/')[0] # Split the cidr to retrieve gateway @@ -808,8 +820,8 @@ class TestVPCOffering(cloudstackTestCase): gateway=gateway, vpcid=vpc.id ) - self.logger.debug("Deploying virtual machines in network: %s" % vpc.name) self.cleanup.append(network) + self.logger.debug("Deploying virtual machines in network: %s" % vpc.name) # Spawn an instance in that network virtual_machine = VirtualMachine.create( @@ -820,8 +832,8 @@ class TestVPCOffering(cloudstackTestCase): serviceofferingid=self.service_offering.id, networkids=[str(network.id)] ) - self.logger.debug("Deployed VM in network: %s" % network.id) self.cleanup.append(virtual_machine) + self.logger.debug("Deployed VM in network: %s" % network.id) self.logger.debug("Associating public IP for network: %s" % network.name) public_ip = PublicIPAddress.create( @@ -874,9 +886,9 @@ class TestVPCOffering(cloudstackTestCase): self.apiclient, self.services["vpc_offering"] ) + self.cleanup.append(vpc_off) self.validate_vpc_offering(vpc_off) # Appending to cleanup to delete after test - self.cleanup.append(vpc_off) except Exception as e: self.fail("Failed to create the VPC offering - %s" % e) return @@ -931,6 +943,7 @@ class TestVPCOffering(cloudstackTestCase): account=self.account.name, domainid=self.account.domainid ) + self.cleanup.append(vpc) self.validate_vpc_network(vpc) self.logger.debug("Updating name & display text of the vpc offering created") @@ -1165,6 +1178,7 @@ class TestVPCOffering(cloudstackTestCase): account=self.account.name, domainid=self.account.domainid ) + self.cleanup.append(vpc) self.logger.debug("Validating Redundant VPC Nw creation") self.validate_vpc_network(vpc) diff --git a/test/integration/component/test_vpc_routers.py b/test/integration/component/test_vpc_routers.py index 7314b69baee..c223c842e16 100644 --- a/test/integration/component/test_vpc_routers.py +++ b/test/integration/component/test_vpc_routers.py @@ -218,10 +218,12 @@ class TestVPCRoutersBasic(cloudstackTestCase): cls.api_client, cls.services["service_offering"] ) + cls._cleanup.append(cls.service_offering) cls.vpc_off = VpcOffering.create( cls.api_client, cls.services["vpc_offering"] ) + cls._cleanup.append(cls.vpc_off) cls.vpc_off.update(cls.api_client, state='Enabled') cls.account = Account.create( cls.api_client, @@ -229,8 +231,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): admin=True, domainid=cls.domain.id ) - cls._cleanup = [cls.account] - cls._cleanup.append(cls.vpc_off) + cls._cleanup.append(cls.account) cls.vpc_off.update(cls.api_client, state='Enabled') cls.services["vpc"]["cidr"] = '10.1.1.1/16' @@ -242,8 +243,7 @@ class TestVPCRoutersBasic(cloudstackTestCase): account=cls.account.name, domainid=cls.account.domainid ) - - cls._cleanup.append(cls.service_offering) + cls._cleanup.append(cls.vpc) return @classmethod @@ -626,7 +626,6 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): @classmethod def setUpClass(cls): - cls._cleanup = [] cls.testClient = super(TestVPCRouterOneNetwork, cls).getClsTestClient() cls.api_client = cls.testClient.getApiClient() cls.hypervisor = cls.testClient.getHypervisorInfo() @@ -676,6 +675,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): account=cls.account.name, domainid=cls.account.domainid ) + cls._cleanup.append(cls.vpc) private_gateway = PrivateGateway.create( cls.api_client, @@ -685,6 +685,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): vlan=678, vpcid=cls.vpc.id ) + cls._cleanup.append(private_gateway) cls.gateways = PrivateGateway.list( cls.api_client, id=private_gateway.id, @@ -701,6 +702,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): id=static_route.id, listall=True ) + cls._cleanup.append(static_route) cls.nw_off = NetworkOffering.create( cls.api_client, @@ -722,6 +724,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): gateway='10.1.1.1', vpcid=cls.vpc.id ) + cls._cleanup.append(cls.network_1) # Spawn an instance in that network vm_1 = VirtualMachine.create( @@ -732,6 +735,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) + cls._cleanup.append(vm_1) vm_2 = VirtualMachine.create( cls.api_client, cls.services["virtual_machine"], @@ -740,6 +744,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) + cls._cleanup.append(vm_2) # Spawn an instance in that network vm_3 = VirtualMachine.create( @@ -750,6 +755,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): serviceofferingid=cls.service_offering.id, networkids=[str(cls.network_1.id)] ) + cls._cleanup.append(vm_3) VirtualMachine.list( cls.api_client, @@ -766,6 +772,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): networkid=cls.network_1.id, vpcid=cls.vpc.id ) + cls._cleanup.append(public_ip_1) NATRule.create( cls.api_client, @@ -792,6 +799,8 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): networkid=cls.network_1.id, vpcid=cls.vpc.id ) + cls._cleanup.append(public_ip_2) + try: StaticNATRule.enable( cls.api_client, @@ -819,6 +828,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase): networkid=cls.network_1.id, vpcid=cls.vpc.id ) + cls._cleanup.append(public_ip_3) lb_rule = LoadBalancerRule.create( cls.api_client,