From 5b238fa4af45e92224a9562de556bb67be9edee9 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Tue, 23 Jul 2013 12:05:42 -0700 Subject: [PATCH] Automation: Fix enormous missing tearDown() for test cases This result in countless test case failure because many test case units didn't clean up after it. The regression test result should be improved quite a bit after this change. --- .../component/test_blocker_bugs.py | 21 +++++++++----- .../component/test_redundant_router.py | 29 ++++++++++++++++++- .../test_redundant_router_cleanups.py | 10 ++++++- ...st_redundant_router_deployment_planning.py | 10 ++++++- .../test_redundant_router_network_rules.py | 10 ++++++- .../test_redundant_router_services.py | 7 +++++ .../test_redundant_router_upgrades.py | 7 +++++ test/integration/component/test_volumes.py | 8 +++++ test/integration/component/test_vpc.py | 8 +++++ .../integration/component/test_vpc_network.py | 24 +++++++++++++++ .../component/test_vpc_offerings.py | 7 +++++ 11 files changed, 130 insertions(+), 11 deletions(-) diff --git a/test/integration/component/test_blocker_bugs.py b/test/integration/component/test_blocker_bugs.py index 1f7ac97afb3..8a73b910477 100644 --- a/test/integration/component/test_blocker_bugs.py +++ b/test/integration/component/test_blocker_bugs.py @@ -103,9 +103,7 @@ class TestTemplate(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created templates cleanup_resources(self.apiclient, self.cleanup) - except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) return @@ -285,6 +283,13 @@ class TestNATRules(cloudstackTestCase): self.cleanup = [] return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @classmethod def tearDownClass(cls): try: @@ -293,10 +298,6 @@ class TestNATRules(cloudstackTestCase): except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) - def tearDown(self): - cleanup_resources(self.apiclient, self.cleanup) - return - @attr(tags = ["advanced"]) def test_01_firewall_rules_port_fw(self): """"Checking firewall rules deletion after static NAT disable""" @@ -493,7 +494,6 @@ class TestRouters(cloudstackTestCase): def tearDown(self): try: - #Clean up, terminate the created instance, users etc cleanup_resources(self.apiclient, self.cleanup) except Exception as e: raise Exception("Warning: Exception during cleanup : %s" % e) @@ -610,6 +610,13 @@ class TestRouterRestart(cloudstackTestCase): self.apiclient = self.testClient.getApiClient() return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @attr(tags = ["advanced", "basic", "sg", "advancedns", "eip"]) def test_01_restart_network_cleanup(self): """TS_BUG_008-Test restart network diff --git a/test/integration/component/test_redundant_router.py b/test/integration/component/test_redundant_router.py index 8414d2f9642..08abd093fe9 100644 --- a/test/integration/component/test_redundant_router.py +++ b/test/integration/component/test_redundant_router.py @@ -165,7 +165,6 @@ class TestCreateRvRNetworkOffering(cloudstackTestCase): def tearDown(self): 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) @@ -287,6 +286,13 @@ class TestCreateRvRNetwork(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @attr(tags=["advanced", "advancedns", "ssh"]) def test_createRvRNetwork(self): """Test create network with redundant routers @@ -478,6 +484,13 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @attr(tags=["advanced", "advancedns"]) def test_createRvRNetwork(self): """Test create network with non-default guest cidr with redundant routers @@ -678,6 +691,13 @@ class TestRVRInternals(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @attr(tags=["advanced", "advancedns", "ssh"]) def test_redundantVR_internals(self): """Test redundant router internals @@ -991,6 +1011,13 @@ class TestRvRRedundancy(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @attr(tags=["advanced", "advancedns", "ssh"]) def test_stopMasterRvR(self): """Test stop master RVR diff --git a/test/integration/component/test_redundant_router_cleanups.py b/test/integration/component/test_redundant_router_cleanups.py index 694db862876..b7ef3557465 100644 --- a/test/integration/component/test_redundant_router_cleanups.py +++ b/test/integration/component/test_redundant_router_cleanups.py @@ -192,6 +192,14 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + 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) + return + @attr(tags=["advanced", "advancedns", "ssh"]) def test_restart_ntwk_no_cleanup(self): """Test restarting RvR network without cleanup @@ -672,4 +680,4 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase): "Stopped", "Router should be in stopped state" ) - return \ No newline at end of file + return diff --git a/test/integration/component/test_redundant_router_deployment_planning.py b/test/integration/component/test_redundant_router_deployment_planning.py index cd37fa658cb..d4d00caffe2 100644 --- a/test/integration/component/test_redundant_router_deployment_planning.py +++ b/test/integration/component/test_redundant_router_deployment_planning.py @@ -191,6 +191,14 @@ class TestRvRDeploymentPlanning(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + 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) + return + @attr(tags=["advanced", "advancedns"]) def test_RvR_multipods(self): """Test RvR with multi pods @@ -1003,4 +1011,4 @@ class TestRvRDeploymentPlanning(cloudstackTestCase): cmd.id = cluster.id cmd.allocationstate = 'Enabled' self.apiclient.updateCluster(cmd) - return \ No newline at end of file + return diff --git a/test/integration/component/test_redundant_router_network_rules.py b/test/integration/component/test_redundant_router_network_rules.py index d2d63b48873..d54b470bfc5 100644 --- a/test/integration/component/test_redundant_router_network_rules.py +++ b/test/integration/component/test_redundant_router_network_rules.py @@ -191,6 +191,14 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase): self._clean.insert(0, self.account) return + def tearDown(self): + try: + 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) + return + @attr(tags=["advanced", "advancedns", "ssh"]) def test_applyNetworkRules_MasterDown_deleteNetworkRules(self): """Test apply network rules when master & backup routers rebooted @@ -1413,4 +1421,4 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase): "Running", "Router state should be running" ) - return \ No newline at end of file + return diff --git a/test/integration/component/test_redundant_router_services.py b/test/integration/component/test_redundant_router_services.py index cc4d367e016..d5afe2938ef 100644 --- a/test/integration/component/test_redundant_router_services.py +++ b/test/integration/component/test_redundant_router_services.py @@ -193,6 +193,13 @@ class TestEnableVPNOverRvR(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @attr(tags=["advanced", "advancedns", "ssh"]) def test_enableVPNOverRvR(self): """Test redundant router internals diff --git a/test/integration/component/test_redundant_router_upgrades.py b/test/integration/component/test_redundant_router_upgrades.py index 654faeb03be..da3b9b00b58 100644 --- a/test/integration/component/test_redundant_router_upgrades.py +++ b/test/integration/component/test_redundant_router_upgrades.py @@ -192,6 +192,13 @@ class TestRvRUpgradeDowngrade(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + @attr(tags=["advanced", "advancedns", "ssh"]) def test_upgradeVR_to_redundantVR(self): """Test upgrade virtual router to redundant virtual router diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py index e06bac9f543..b894b1fb9a7 100644 --- a/test/integration/component/test_volumes.py +++ b/test/integration/component/test_volumes.py @@ -160,6 +160,14 @@ class TestAttachVolume(cloudstackTestCase): self.dbclient = self.testClient.getDbConnection() self.cleanup = [] + def tearDown(self): + try: + 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) + return + @attr(tags = ["advanced", "advancedns"]) def test_01_volume_attach(self): """Test Attach volumes (max capacity) diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py index 3a661d59b8e..08bfb5c6b1b 100644 --- a/test/integration/component/test_vpc.py +++ b/test/integration/component/test_vpc.py @@ -226,6 +226,14 @@ class TestVPC(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + 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) + return + def validate_vpc_offering(self, vpc_offering): """Validates the VPC offering""" diff --git a/test/integration/component/test_vpc_network.py b/test/integration/component/test_vpc_network.py index 477c79e58e8..8b43dcd170f 100644 --- a/test/integration/component/test_vpc_network.py +++ b/test/integration/component/test_vpc_network.py @@ -230,6 +230,14 @@ class TestVPCNetwork(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + 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) + return + def validate_vpc_offering(self, vpc_offering): """Validates the VPC offering""" @@ -1078,6 +1086,14 @@ class TestVPCNetworkRanges(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + 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) + return + def validate_vpc_offering(self, vpc_offering): """Validates the VPC offering""" @@ -1573,6 +1589,14 @@ class TestVPCNetworkUpgrade(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + 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) + return + def validate_vpc_offering(self, vpc_offering): """Validates the VPC offering""" diff --git a/test/integration/component/test_vpc_offerings.py b/test/integration/component/test_vpc_offerings.py index cf37d907d5e..28af16a9ff2 100644 --- a/test/integration/component/test_vpc_offerings.py +++ b/test/integration/component/test_vpc_offerings.py @@ -183,6 +183,13 @@ class TestVPCOffering(cloudstackTestCase): self._cleanup.insert(0, self.account) return + def tearDown(self): + try: + cleanup_resources(self.apiclient, self.cleanup) + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" % e) + return + def validate_vpc_offering(self, vpc_offering): """Validates the VPC offering"""