From 7d6b4a4a97ff6c2b7cfa956e765f18b40bc10da0 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Wed, 19 Jun 2013 16:52:45 +0530 Subject: [PATCH] Fix vpc network tests and reduce delay by removing wait for cleanup CIDR dictionary changes in the test causing the subsequent test to fail. Reinitialize the dictionary at the beginning of the test Signed-off-by: Prasanna Santhanam --- test/integration/component/test_vpc.py | 24 +++--- .../integration/component/test_vpc_network.py | 78 +++---------------- 2 files changed, 20 insertions(+), 82 deletions(-) diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py index 742f6ae11eb..63c10aacdb2 100644 --- a/test/integration/component/test_vpc.py +++ b/test/integration/component/test_vpc.py @@ -202,7 +202,6 @@ class TestVPC(cloudstackTestCase): cls.vpc_off.update(cls.api_client, state='Enabled') cls._cleanup = [ cls.service_offering, - cls.vpc_off ] return @@ -435,7 +434,7 @@ class TestVPC(cloudstackTestCase): @attr(tags=["advanced", "intervlan"]) def test_04_delete_vpc_with_networks(self): - """ Test delete VPC having with networks + """ Test delete VPC having networks """ # Validate the following @@ -757,7 +756,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" % @@ -1841,7 +1840,7 @@ class TestVPC(cloudstackTestCase): @attr(tags=["advanced", "intervlan"]) def test_13_deploy_vm_with_vpc_netdomain(self): - """ Test deployment of vm in a VPC with netdomain + """ Test deployment of vm in a VPC with network domain """ # 1. Create VPC with providing networkDomain. @@ -1918,7 +1917,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" % @@ -1999,7 +1998,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" % @@ -2075,7 +2074,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" % @@ -2159,7 +2158,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, @@ -2170,7 +2169,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" % @@ -2194,8 +2193,7 @@ class TestVPC(cloudstackTestCase): @attr(tags=["advanced", "intervlan"]) def test_18_create_net_for_user_diff_domain_by_doadmin(self): - """ Test creation of network by domain admin for user from different - domain. + """ Test creation of network by domain admin for user from different domain """ #1. As domain admin account , Create VPC(name,zoneId,cidr,vpcOfferingId,networkDomain) without passing Account/domain ID. @@ -2211,7 +2209,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"], @@ -2222,7 +2220,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" % diff --git a/test/integration/component/test_vpc_network.py b/test/integration/component/test_vpc_network.py index 9d5081f8e95..d76996ae85b 100644 --- a/test/integration/component/test_vpc_network.py +++ b/test/integration/component/test_vpc_network.py @@ -72,7 +72,6 @@ class Services: }, "serviceCapabilityList": { "SourceNat": {"SupportedSourceNatTypes": "peraccount"}, - "Lb": {"lbSchemes": "public", "SupportedLbIsolation": "dedicated"} }, }, "network_off_netscaler": { @@ -95,7 +94,6 @@ class Services: }, "serviceCapabilityList": { "SourceNat": {"SupportedSourceNatTypes": "peraccount"}, - "Lb": {"lbSchemes": "public", "SupportedLbIsolation": "dedicated"} }, }, "network_off_shared": { @@ -229,25 +227,7 @@ class TestVPCNetwork(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self.cleanup = [self.account] - return - - def tearDown(self): - try: - #Clean up, terminate the created network offerings - cleanup_resources(self.apiclient, self.cleanup) - interval = list_configurations( - self.apiclient, - name='network.gc.interval' - ) - wait = list_configurations( - self.apiclient, - name='network.gc.wait' - ) - # Sleep to ensure that all resources are deleted - time.sleep(int(interval[0].value) + int(wait[0].value)) - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) + self._cleanup.insert(0, self.account) return def validate_vpc_offering(self, vpc_offering): @@ -394,7 +374,7 @@ class TestVPCNetwork(cloudstackTestCase): @attr(tags=["advanced", "intervlan"]) def test_02_create_network_fail(self): - """ Test create network in VPC + """ Test create network in VPC mismatched services (Should fail) """ # Validate the following @@ -712,7 +692,7 @@ class TestVPCNetwork(cloudstackTestCase): @attr(tags=["advanced", "intervlan"]) def test_06_create_network_with_rvr(self): - """ Test create network with eredundant router capability + """ Test create network with redundant router capability """ # Validate the following @@ -1094,25 +1074,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self.cleanup = [self.account] - return - - def tearDown(self): - try: - #Clean up, terminate the created network offerings - cleanup_resources(self.apiclient, self.cleanup) - interval = list_configurations( - self.apiclient, - name='network.gc.interval' - ) - wait = list_configurations( - self.apiclient, - name='network.gc.wait' - ) - # Sleep to ensure that all resources are deleted - time.sleep(int(interval[0].value) + int(wait[0].value)) - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) + self._cleanup.insert(0, self.account) return def validate_vpc_offering(self, vpc_offering): @@ -1365,6 +1327,7 @@ class TestVPCNetworkRanges(cloudstackTestCase): # 3. Add network2 with cidr - 10.1.1.1/24 to this VPC # 4. Add network3 with cidr - 10.1.1.1/26 to this VPC # 5. Network creation in step 3 & 4 should fail. + self.services = Services().services self.debug("Creating a VPC offering") vpc_off = VpcOffering.create( @@ -1606,19 +1569,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): admin=True, domainid=self.domain.id ) - self.cleanup = [self.account] - return - - def tearDown(self): - try: - #Clean up, terminate the created network offerings - cleanup_resources(self.apiclient, self.cleanup) - wait_for_cleanup(self.apiclient, [ - "network.gc.interval", - "network.gc.wait"]) - - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) + self._cleanup.insert(0, self.account) return def validate_vpc_offering(self, vpc_offering): @@ -1673,8 +1624,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): @attr(tags=["advanced", "intervlan"]) def test_01_network_services_upgrade(self): - """ Test update Network that is part of a VPC to a network offering - that has more services. + """ Test update Network that is part of a VPC to a network offering that has more services """ # Validate the following @@ -2027,8 +1977,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): @attr(tags=["advanced", "intervlan"]) def test_02_network_vpcvr2vr_upgrade(self): - """ Test update Network that is NOT part of a VPC to a nw offering - that has services that are provided by VPCVR and vice versa. + """ Test update Network that is NOT part of a VPC to a nw offering that has services that are provided by VPCVR and vice versa """ # Validate the following @@ -2298,7 +2247,6 @@ class TestVPCNetworkGc(cloudstackTestCase): cmd = stopVirtualMachine.stopVirtualMachineCmd() cmd.id = vm.id self.apiclient.stopVirtualMachine(cmd) - self.cleanup = [] return def tearDown(self): @@ -2311,15 +2259,7 @@ class TestVPCNetworkGc(cloudstackTestCase): ) for vm in vms: if vm.state == "Stopped": - cmd = startVirtualMachine.startVirtualMachineCmd() - cmd.id = vm.id - self.apiclient.startVirtualMachine(cmd) - - try: - #Clean up, terminate the created network offerings - cleanup_resources(self.apiclient, self.cleanup) - except Exception as e: - raise Exception("Warning: Exception during cleanup : %s" % e) + vm.start(self.apiclient) return def validate_vpc_offering(self, vpc_offering):