Skip to content

Commit 49b44e4

Browse files
author
Sheng Yang
committed
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.
1 parent 09b898a commit 49b44e4

11 files changed

Lines changed: 130 additions & 11 deletions

‎test/integration/component/test_blocker_bugs.py‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ def setUp(self):
103103

104104
def tearDown(self):
105105
try:
106-
#Clean up, terminate the created templates
107106
cleanup_resources(self.apiclient, self.cleanup)
108-
109107
except Exception as e:
110108
raise Exception("Warning: Exception during cleanup : %s" % e)
111109
return
@@ -285,6 +283,13 @@ def setUp(self):
285283
self.cleanup = []
286284
return
287285

286+
def tearDown(self):
287+
try:
288+
cleanup_resources(self.apiclient, self.cleanup)
289+
except Exception as e:
290+
raise Exception("Warning: Exception during cleanup : %s" % e)
291+
return
292+
288293
@classmethod
289294
def tearDownClass(cls):
290295
try:
@@ -293,10 +298,6 @@ def tearDownClass(cls):
293298
except Exception as e:
294299
raise Exception("Warning: Exception during cleanup : %s" % e)
295300

296-
def tearDown(self):
297-
cleanup_resources(self.apiclient, self.cleanup)
298-
return
299-
300301
@attr(tags = ["advanced"])
301302
def test_01_firewall_rules_port_fw(self):
302303
""""Checking firewall rules deletion after static NAT disable"""
@@ -493,7 +494,6 @@ def setUp(self):
493494

494495
def tearDown(self):
495496
try:
496-
#Clean up, terminate the created instance, users etc
497497
cleanup_resources(self.apiclient, self.cleanup)
498498
except Exception as e:
499499
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -610,6 +610,13 @@ def setUp(self):
610610
self.apiclient = self.testClient.getApiClient()
611611
return
612612

613+
def tearDown(self):
614+
try:
615+
cleanup_resources(self.apiclient, self.cleanup)
616+
except Exception as e:
617+
raise Exception("Warning: Exception during cleanup : %s" % e)
618+
return
619+
613620
@attr(tags = ["advanced", "basic", "sg", "advancedns", "eip"])
614621
def test_01_restart_network_cleanup(self):
615622
"""TS_BUG_008-Test restart network

‎test/integration/component/test_redundant_router.py‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ def setUp(self):
165165

166166
def tearDown(self):
167167
try:
168-
#Clean up, terminate the created network offerings
169168
cleanup_resources(self.apiclient, self.cleanup)
170169
except Exception as e:
171170
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -287,6 +286,13 @@ def setUp(self):
287286
self._cleanup.insert(0, self.account)
288287
return
289288

289+
def tearDown(self):
290+
try:
291+
cleanup_resources(self.apiclient, self.cleanup)
292+
except Exception as e:
293+
raise Exception("Warning: Exception during cleanup : %s" % e)
294+
return
295+
290296
@attr(tags=["advanced", "advancedns", "ssh"])
291297
def test_createRvRNetwork(self):
292298
"""Test create network with redundant routers
@@ -478,6 +484,13 @@ def setUp(self):
478484
self._cleanup.insert(0, self.account)
479485
return
480486

487+
def tearDown(self):
488+
try:
489+
cleanup_resources(self.apiclient, self.cleanup)
490+
except Exception as e:
491+
raise Exception("Warning: Exception during cleanup : %s" % e)
492+
return
493+
481494
@attr(tags=["advanced", "advancedns"])
482495
def test_createRvRNetwork(self):
483496
"""Test create network with non-default guest cidr with redundant routers
@@ -678,6 +691,13 @@ def setUp(self):
678691
self._cleanup.insert(0, self.account)
679692
return
680693

694+
def tearDown(self):
695+
try:
696+
cleanup_resources(self.apiclient, self.cleanup)
697+
except Exception as e:
698+
raise Exception("Warning: Exception during cleanup : %s" % e)
699+
return
700+
681701
@attr(tags=["advanced", "advancedns", "ssh"])
682702
def test_redundantVR_internals(self):
683703
"""Test redundant router internals
@@ -991,6 +1011,13 @@ def setUp(self):
9911011
self._cleanup.insert(0, self.account)
9921012
return
9931013

1014+
def tearDown(self):
1015+
try:
1016+
cleanup_resources(self.apiclient, self.cleanup)
1017+
except Exception as e:
1018+
raise Exception("Warning: Exception during cleanup : %s" % e)
1019+
return
1020+
9941021
@attr(tags=["advanced", "advancedns", "ssh"])
9951022
def test_stopMasterRvR(self):
9961023
"""Test stop master RVR

‎test/integration/component/test_redundant_router_cleanups.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ def setUp(self):
192192
self._cleanup.insert(0, self.account)
193193
return
194194

195+
def tearDown(self):
196+
try:
197+
cleanup_resources(self.apiclient, self._cleanup)
198+
except Exception as e:
199+
self.debug("Warning: Exception during cleanup : %s" % e)
200+
#raise Exception("Warning: Exception during cleanup : %s" % e)
201+
return
202+
195203
@attr(tags=["advanced", "advancedns", "ssh"])
196204
def test_restart_ntwk_no_cleanup(self):
197205
"""Test restarting RvR network without cleanup
@@ -672,4 +680,4 @@ def test_network_gc(self):
672680
"Stopped",
673681
"Router should be in stopped state"
674682
)
675-
return
683+
return

‎test/integration/component/test_redundant_router_deployment_planning.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ def setUp(self):
191191
self._cleanup.insert(0, self.account)
192192
return
193193

194+
def tearDown(self):
195+
try:
196+
cleanup_resources(self.apiclient, self._cleanup)
197+
except Exception as e:
198+
self.debug("Warning: Exception during cleanup : %s" % e)
199+
#raise Exception("Warning: Exception during cleanup : %s" % e)
200+
return
201+
194202
@attr(tags=["advanced", "advancedns"])
195203
def test_RvR_multipods(self):
196204
"""Test RvR with multi pods
@@ -1003,4 +1011,4 @@ def test_RvR_multihosts(self):
10031011
cmd.id = cluster.id
10041012
cmd.allocationstate = 'Enabled'
10051013
self.apiclient.updateCluster(cmd)
1006-
return
1014+
return

‎test/integration/component/test_redundant_router_network_rules.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ def setUp(self):
191191
self._clean.insert(0, self.account)
192192
return
193193

194+
def tearDown(self):
195+
try:
196+
cleanup_resources(self.apiclient, self._cleanup)
197+
except Exception as e:
198+
self.debug("Warning: Exception during cleanup : %s" % e)
199+
#raise Exception("Warning: Exception during cleanup : %s" % e)
200+
return
201+
194202
@attr(tags=["advanced", "advancedns", "ssh"])
195203
def test_applyNetworkRules_MasterDown_deleteNetworkRules(self):
196204
"""Test apply network rules when master & backup routers rebooted
@@ -1413,4 +1421,4 @@ def test_applyNetworkRules_MasterDown_deleteNetworkRules(self):
14131421
"Running",
14141422
"Router state should be running"
14151423
)
1416-
return
1424+
return

‎test/integration/component/test_redundant_router_services.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ def setUp(self):
193193
self._cleanup.insert(0, self.account)
194194
return
195195

196+
def tearDown(self):
197+
try:
198+
cleanup_resources(self.apiclient, self.cleanup)
199+
except Exception as e:
200+
raise Exception("Warning: Exception during cleanup : %s" % e)
201+
return
202+
196203
@attr(tags=["advanced", "advancedns", "ssh"])
197204
def test_enableVPNOverRvR(self):
198205
"""Test redundant router internals

‎test/integration/component/test_redundant_router_upgrades.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ def setUp(self):
192192
self._cleanup.insert(0, self.account)
193193
return
194194

195+
def tearDown(self):
196+
try:
197+
cleanup_resources(self.apiclient, self.cleanup)
198+
except Exception as e:
199+
raise Exception("Warning: Exception during cleanup : %s" % e)
200+
return
201+
195202
@attr(tags=["advanced", "advancedns", "ssh"])
196203
def test_upgradeVR_to_redundantVR(self):
197204
"""Test upgrade virtual router to redundant virtual router

‎test/integration/component/test_volumes.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ def setUp(self):
160160
self.dbclient = self.testClient.getDbConnection()
161161
self.cleanup = []
162162

163+
def tearDown(self):
164+
try:
165+
cleanup_resources(self.apiclient, self._cleanup)
166+
except Exception as e:
167+
self.debug("Warning: Exception during cleanup : %s" % e)
168+
#raise Exception("Warning: Exception during cleanup : %s" % e)
169+
return
170+
163171
@attr(tags = ["advanced", "advancedns"])
164172
def test_01_volume_attach(self):
165173
"""Test Attach volumes (max capacity)

‎test/integration/component/test_vpc.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ def setUp(self):
226226
self._cleanup.insert(0, self.account)
227227
return
228228

229+
def tearDown(self):
230+
try:
231+
cleanup_resources(self.apiclient, self._cleanup)
232+
except Exception as e:
233+
self.debug("Warning: Exception during cleanup : %s" % e)
234+
#raise Exception("Warning: Exception during cleanup : %s" % e)
235+
return
236+
229237
def validate_vpc_offering(self, vpc_offering):
230238
"""Validates the VPC offering"""
231239

‎test/integration/component/test_vpc_network.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ def setUp(self):
230230
self._cleanup.insert(0, self.account)
231231
return
232232

233+
def tearDown(self):
234+
try:
235+
cleanup_resources(self.apiclient, self._cleanup)
236+
except Exception as e:
237+
self.debug("Warning: Exception during cleanup : %s" % e)
238+
#raise Exception("Warning: Exception during cleanup : %s" % e)
239+
return
240+
233241
def validate_vpc_offering(self, vpc_offering):
234242
"""Validates the VPC offering"""
235243

@@ -1078,6 +1086,14 @@ def setUp(self):
10781086
self._cleanup.insert(0, self.account)
10791087
return
10801088

1089+
def tearDown(self):
1090+
try:
1091+
cleanup_resources(self.apiclient, self._cleanup)
1092+
except Exception as e:
1093+
self.debug("Warning: Exception during cleanup : %s" % e)
1094+
#raise Exception("Warning: Exception during cleanup : %s" % e)
1095+
return
1096+
10811097
def validate_vpc_offering(self, vpc_offering):
10821098
"""Validates the VPC offering"""
10831099

@@ -1573,6 +1589,14 @@ def setUp(self):
15731589
self._cleanup.insert(0, self.account)
15741590
return
15751591

1592+
def tearDown(self):
1593+
try:
1594+
cleanup_resources(self.apiclient, self._cleanup)
1595+
except Exception as e:
1596+
self.debug("Warning: Exception during cleanup : %s" % e)
1597+
#raise Exception("Warning: Exception during cleanup : %s" % e)
1598+
return
1599+
15761600
def validate_vpc_offering(self, vpc_offering):
15771601
"""Validates the VPC offering"""
15781602

0 commit comments

Comments
 (0)