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.
This commit is contained in:
Sheng Yang 2013-07-23 12:05:42 -07:00
parent 2cf8ecd3e2
commit 5b238fa4af
11 changed files with 130 additions and 11 deletions

View File

@ -103,9 +103,7 @@ class TestTemplate(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
#Clean up, terminate the created templates
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@ -285,6 +283,13 @@ class TestNATRules(cloudstackTestCase):
self.cleanup = [] self.cleanup = []
return 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 @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: try:
@ -293,10 +298,6 @@ class TestNATRules(cloudstackTestCase):
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
def tearDown(self):
cleanup_resources(self.apiclient, self.cleanup)
return
@attr(tags = ["advanced"]) @attr(tags = ["advanced"])
def test_01_firewall_rules_port_fw(self): def test_01_firewall_rules_port_fw(self):
""""Checking firewall rules deletion after static NAT disable""" """"Checking firewall rules deletion after static NAT disable"""
@ -493,7 +494,6 @@ class TestRouters(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
#Clean up, terminate the created instance, users etc
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -610,6 +610,13 @@ class TestRouterRestart(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
return 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"]) @attr(tags = ["advanced", "basic", "sg", "advancedns", "eip"])
def test_01_restart_network_cleanup(self): def test_01_restart_network_cleanup(self):
"""TS_BUG_008-Test restart network """TS_BUG_008-Test restart network

View File

@ -165,7 +165,6 @@ class TestCreateRvRNetworkOffering(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
#Clean up, terminate the created network offerings
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -287,6 +286,13 @@ class TestCreateRvRNetwork(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_createRvRNetwork(self): def test_createRvRNetwork(self):
"""Test create network with redundant routers """Test create network with redundant routers
@ -478,6 +484,13 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns"])
def test_createRvRNetwork(self): def test_createRvRNetwork(self):
"""Test create network with non-default guest cidr with redundant routers """Test create network with non-default guest cidr with redundant routers
@ -678,6 +691,13 @@ class TestRVRInternals(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_redundantVR_internals(self): def test_redundantVR_internals(self):
"""Test redundant router internals """Test redundant router internals
@ -991,6 +1011,13 @@ class TestRvRRedundancy(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_stopMasterRvR(self): def test_stopMasterRvR(self):
"""Test stop master RVR """Test stop master RVR

View File

@ -192,6 +192,14 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_restart_ntwk_no_cleanup(self): def test_restart_ntwk_no_cleanup(self):
"""Test restarting RvR network without cleanup """Test restarting RvR network without cleanup
@ -672,4 +680,4 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase):
"Stopped", "Stopped",
"Router should be in stopped state" "Router should be in stopped state"
) )
return return

View File

@ -191,6 +191,14 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns"])
def test_RvR_multipods(self): def test_RvR_multipods(self):
"""Test RvR with multi pods """Test RvR with multi pods
@ -1003,4 +1011,4 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
cmd.id = cluster.id cmd.id = cluster.id
cmd.allocationstate = 'Enabled' cmd.allocationstate = 'Enabled'
self.apiclient.updateCluster(cmd) self.apiclient.updateCluster(cmd)
return return

View File

@ -191,6 +191,14 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase):
self._clean.insert(0, self.account) self._clean.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_applyNetworkRules_MasterDown_deleteNetworkRules(self): def test_applyNetworkRules_MasterDown_deleteNetworkRules(self):
"""Test apply network rules when master & backup routers rebooted """Test apply network rules when master & backup routers rebooted
@ -1413,4 +1421,4 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase):
"Running", "Running",
"Router state should be running" "Router state should be running"
) )
return return

View File

@ -193,6 +193,13 @@ class TestEnableVPNOverRvR(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_enableVPNOverRvR(self): def test_enableVPNOverRvR(self):
"""Test redundant router internals """Test redundant router internals

View File

@ -192,6 +192,13 @@ class TestRvRUpgradeDowngrade(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_upgradeVR_to_redundantVR(self): def test_upgradeVR_to_redundantVR(self):
"""Test upgrade virtual router to redundant virtual router """Test upgrade virtual router to redundant virtual router

View File

@ -160,6 +160,14 @@ class TestAttachVolume(cloudstackTestCase):
self.dbclient = self.testClient.getDbConnection() self.dbclient = self.testClient.getDbConnection()
self.cleanup = [] 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"]) @attr(tags = ["advanced", "advancedns"])
def test_01_volume_attach(self): def test_01_volume_attach(self):
"""Test Attach volumes (max capacity) """Test Attach volumes (max capacity)

View File

@ -226,6 +226,14 @@ class TestVPC(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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): def validate_vpc_offering(self, vpc_offering):
"""Validates the VPC offering""" """Validates the VPC offering"""

View File

@ -230,6 +230,14 @@ class TestVPCNetwork(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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): def validate_vpc_offering(self, vpc_offering):
"""Validates the VPC offering""" """Validates the VPC offering"""
@ -1078,6 +1086,14 @@ class TestVPCNetworkRanges(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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): def validate_vpc_offering(self, vpc_offering):
"""Validates the VPC offering""" """Validates the VPC offering"""
@ -1573,6 +1589,14 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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): def validate_vpc_offering(self, vpc_offering):
"""Validates the VPC offering""" """Validates the VPC offering"""

View File

@ -183,6 +183,13 @@ class TestVPCOffering(cloudstackTestCase):
self._cleanup.insert(0, self.account) self._cleanup.insert(0, self.account)
return 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): def validate_vpc_offering(self, vpc_offering):
"""Validates the VPC offering""" """Validates the VPC offering"""