Skip to content

Commit a348afe

Browse files
DaanHooglandDaan Hoogland
andauthored
default teardown methods with reversed() handling (#4289)
Co-authored-by: Daan Hoogland <dahn@onecht.net>
1 parent fb78fb2 commit a348afe

File tree

9 files changed

+153
-277
lines changed

9 files changed

+153
-277
lines changed

test/integration/component/test_volumes.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,11 +1454,7 @@ def setUpClass(cls):
14541454

14551455
@classmethod
14561456
def tearDownClass(cls):
1457-
try:
1458-
cleanup_resources(cls.api_client, cls._cleanup)
1459-
except Exception as e:
1460-
raise Exception("Warning: Exception during cleanup : %s" % e)
1461-
return
1457+
super(TestMigrateVolume,cls).tearDownClass()
14621458

14631459
def setUp(self):
14641460
self.apiclient = self.testClient.getApiClient()
@@ -1470,8 +1466,7 @@ def setUp(self):
14701466
return
14711467

14721468
def tearDown(self):
1473-
cleanup_resources(self.apiclient, self.cleanup)
1474-
return
1469+
super(TestMigrateVolume,self).tearDown()
14751470

14761471
@attr(tags=["advanced", "sg", "advancedsg"], required_hardware='true')
14771472
def test_01_migrateVolume(self):

test/integration/smoke/test_accounts.py

Lines changed: 24 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,7 @@ def setUpClass(cls):
153153

154154
@classmethod
155155
def tearDownClass(cls):
156-
try:
157-
# Cleanup resources used
158-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
159-
except Exception as e:
160-
raise Exception("Warning: Exception during cleanup : %s" % e)
161-
return
156+
super(TestAccounts,cls).tearDownClass()
162157

163158
def setUp(self):
164159
self.apiclient = self.testClient.getApiClient()
@@ -167,12 +162,7 @@ def setUp(self):
167162
return
168163

169164
def tearDown(self):
170-
try:
171-
# Clean up, terminate the created accounts, domains etc
172-
cleanup_resources(self.apiclient, reversed(self.cleanup))
173-
except Exception as e:
174-
raise Exception("Warning: Exception during cleanup : %s" % e)
175-
return
165+
super(TestAccounts,self).tearDown()
176166

177167
@attr(
178168
tags=[
@@ -352,12 +342,7 @@ def setUpClass(cls):
352342

353343
@classmethod
354344
def tearDownClass(cls):
355-
try:
356-
# Cleanup resources used
357-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
358-
except Exception as e:
359-
raise Exception("Warning: Exception during cleanup : %s" % e)
360-
return
345+
super(TestRemoveUserFromAccount,cls).tearDownClass()
361346

362347
def setUp(self):
363348
self.apiclient = self.testClient.getApiClient()
@@ -366,12 +351,7 @@ def setUp(self):
366351
return
367352

368353
def tearDown(self):
369-
try:
370-
# Clean up, terminate the created instance, users etc
371-
cleanup_resources(self.apiclient, reversed(self.cleanup))
372-
except Exception as e:
373-
raise Exception("Warning: Exception during cleanup : %s" % e)
374-
return
354+
super(TestRemoveUserFromAccount,self).tearDown()
375355

376356
@attr(
377357
tags=[
@@ -513,12 +493,7 @@ def setUpClass(cls):
513493

514494
@classmethod
515495
def tearDownClass(cls):
516-
try:
517-
# Cleanup resources used
518-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
519-
except Exception as e:
520-
raise Exception("Warning: Exception during cleanup : %s" % e)
521-
return
496+
super(TestNonRootAdminsPrivileges,cls).tearDownClass()
522497

523498
def setUp(self):
524499
self.apiclient = self.testClient.getApiClient()
@@ -527,12 +502,7 @@ def setUp(self):
527502
return
528503

529504
def tearDown(self):
530-
try:
531-
# Clean up, terminate the created accounts
532-
cleanup_resources(self.apiclient, reversed(self.cleanup))
533-
except Exception as e:
534-
raise Exception("Warning: Exception during cleanup : %s" % e)
535-
return
505+
super(TestNonRootAdminsPrivileges,self).tearDown()
536506

537507
@attr(
538508
tags=[
@@ -642,12 +612,7 @@ def setUpClass(cls):
642612

643613
@classmethod
644614
def tearDownClass(cls):
645-
try:
646-
# Cleanup resources used
647-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
648-
except Exception as e:
649-
raise Exception("Warning: Exception during cleanup : %s" % e)
650-
return
615+
super(TestServiceOfferingSiblings,cls).tearDownClass()
651616

652617
def setUp(self):
653618
self.apiclient = self.testClient.getApiClient()
@@ -656,12 +621,7 @@ def setUp(self):
656621
return
657622

658623
def tearDown(self):
659-
try:
660-
# Clean up, terminate the created domains, accounts
661-
cleanup_resources(self.apiclient, reversed(self.cleanup))
662-
except Exception as e:
663-
raise Exception("Warning: Exception during cleanup : %s" % e)
664-
return
624+
super(TestServiceOfferingSiblings,self).tearDown()
665625

666626
@attr(
667627
tags=[
@@ -766,12 +726,7 @@ def setUpClass(cls):
766726

767727
@classmethod
768728
def tearDownClass(cls):
769-
try:
770-
# Cleanup resources used
771-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
772-
except Exception as e:
773-
raise Exception("Warning: Exception during cleanup : %s" % e)
774-
return
729+
super(TestServiceOfferingHierarchy,cls).tearDownClass()
775730

776731
def setUp(self):
777732
self.apiclient = self.testClient.getApiClient()
@@ -780,12 +735,7 @@ def setUp(self):
780735
return
781736

782737
def tearDown(self):
783-
try:
784-
# Clean up, terminate the created instance, volumes and snapshots
785-
cleanup_resources(self.apiclient, reversed(self.cleanup))
786-
except Exception as e:
787-
raise Exception("Warning: Exception during cleanup : %s" % e)
788-
return
738+
super(TestServiceOfferingHierarchy,self).tearDown()
789739

790740
@attr(
791741
tags=[
@@ -908,12 +858,7 @@ def setUpClass(cls):
908858

909859
@classmethod
910860
def tearDownClass(cls):
911-
try:
912-
# Cleanup resources used
913-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
914-
except Exception as e:
915-
raise Exception("Warning: Exception during cleanup : %s" % e)
916-
return
861+
super(TestTemplateHierarchy,cls).tearDownClass()
917862

918863
def setUp(self):
919864
self.apiclient = self.testClient.getApiClient()
@@ -922,12 +867,7 @@ def setUp(self):
922867
return
923868

924869
def tearDown(self):
925-
try:
926-
# Clean up, terminate the created instance, volumes and snapshots
927-
cleanup_resources(self.apiclient, reversed(self.cleanup))
928-
except Exception as e:
929-
raise Exception("Warning: Exception during cleanup : %s" % e)
930-
return
870+
super(TestTemplateHierarchy,self).tearDown()
931871

932872
@attr(tags=["advanced", "basic", "eip", "advancedns", "sg"], required_hardware="true")
933873
def test_01_template_hierarchy(self):
@@ -1064,12 +1004,7 @@ def setUpClass(cls):
10641004

10651005
@classmethod
10661006
def tearDownClass(cls):
1067-
try:
1068-
# Clean up, terminate the created resources
1069-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
1070-
except Exception as e:
1071-
raise Exception("Warning: Exception during cleanup : %s" % e)
1072-
return
1007+
super(TestAddVmToSubDomain,cls).tearDownClass()
10731008

10741009
def setUp(self):
10751010
self.apiclient = self.testClient.getApiClient()
@@ -1078,12 +1013,7 @@ def setUp(self):
10781013
return
10791014

10801015
def tearDown(self):
1081-
try:
1082-
# Clean up, terminate the created resources
1083-
cleanup_resources(self.apiclient, reversed(self.cleanup))
1084-
except Exception as e:
1085-
raise Exception("Warning: Exception during cleanup : %s" % e)
1086-
return
1016+
super(TestAddVmToSubDomain,self).tearDown()
10871017

10881018
@attr(
10891019
tags=[
@@ -1160,12 +1090,7 @@ def setUpClass(cls):
11601090

11611091
@classmethod
11621092
def tearDownClass(cls):
1163-
try:
1164-
# Cleanup resources used
1165-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
1166-
except Exception as e:
1167-
raise Exception("Warning: Exception during cleanup : %s" % e)
1168-
return
1093+
super(TestUserDetails,cls).tearDownClass()
11691094

11701095
def setUp(self):
11711096
self.apiclient = self.testClient.getApiClient()
@@ -1174,12 +1099,7 @@ def setUp(self):
11741099
return
11751100

11761101
def tearDown(self):
1177-
try:
1178-
# Clean up, terminate the created network offerings
1179-
cleanup_resources(self.apiclient, reversed(self.cleanup))
1180-
except Exception as e:
1181-
raise Exception("Warning: Exception during cleanup : %s" % e)
1182-
return
1102+
super(TestUserDetails,self).tearDown()
11831103

11841104
@attr(tags=[
11851105
"role",
@@ -1459,12 +1379,7 @@ def setUpClass(cls):
14591379

14601380
@classmethod
14611381
def tearDownClass(cls):
1462-
try:
1463-
# Cleanup resources used
1464-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
1465-
except Exception as e:
1466-
raise Exception("Warning: Exception during cleanup : %s" % e)
1467-
return
1382+
super(TestUserLogin,cls).tearDownClass()
14681383

14691384
def setUp(self):
14701385
self.apiclient = self.testClient.getApiClient()
@@ -1473,12 +1388,7 @@ def setUp(self):
14731388
return
14741389

14751390
def tearDown(self):
1476-
try:
1477-
# Clean up, terminate the created network offerings
1478-
cleanup_resources(self.apiclient, reversed(self.cleanup))
1479-
except Exception as e:
1480-
raise Exception("Warning: Exception during cleanup : %s" % e)
1481-
return
1391+
super(TestUserLogin,self).tearDown()
14821392

14831393
@attr(tags=["login", "accounts", "simulator", "advanced",
14841394
"advancedns", "basic", "eip", "sg"])
@@ -1716,12 +1626,7 @@ def setUpClass(cls):
17161626

17171627
@classmethod
17181628
def tearDownClass(cls):
1719-
try:
1720-
# Cleanup resources used
1721-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
1722-
except Exception as e:
1723-
raise Exception("Warning: Exception during cleanup : %s" % e)
1724-
return
1629+
super(TestUserAPIKeys,cls).tearDownClass()
17251630

17261631
def setUp(self):
17271632
self.apiclient = self.testClient.getApiClient()
@@ -1730,12 +1635,7 @@ def setUp(self):
17301635
return
17311636

17321637
def tearDown(self):
1733-
try:
1734-
# Clean up, terminate the created network offerings
1735-
cleanup_resources(self.apiclient, reversed(self.cleanup))
1736-
except Exception as e:
1737-
raise Exception("Warning: Exception during cleanup : %s" % e)
1738-
return
1638+
super(TestUserAPIKeys,self).tearDown()
17391639

17401640
@attr(tags=[
17411641
"role",
@@ -1868,13 +1768,7 @@ def setUpClass(cls):
18681768

18691769
@classmethod
18701770
def tearDownClass(cls):
1871-
try:
1872-
# Clean up, terminate the created resources
1873-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
1874-
except Exception as e:
1875-
1876-
raise Exception("Warning: Exception during cleanup : %s" % e)
1877-
return
1771+
super(TestDomainForceRemove,cls).tearDownClass()
18781772

18791773
def setUp(self):
18801774
self.apiclient = self.testClient.getApiClient()
@@ -1883,12 +1777,7 @@ def setUp(self):
18831777
return
18841778

18851779
def tearDown(self):
1886-
try:
1887-
# Clean up, terminate the created resources
1888-
cleanup_resources(self.apiclient, reversed(self.cleanup))
1889-
except Exception as e:
1890-
raise Exception("Warning: Exception during cleanup : %s" % e)
1891-
return
1780+
super(TestDomainForceRemove,self).tearDown()
18921781

18931782
@attr(
18941783
tags=[
@@ -2247,13 +2136,7 @@ def setUpClass(cls):
22472136

22482137
@classmethod
22492138
def tearDownClass(cls):
2250-
try:
2251-
# Clean up, terminate the created resources
2252-
cleanup_resources(cls.api_client, reversed(cls._cleanup))
2253-
except Exception as e:
2254-
2255-
raise Exception("Warning: Exception during cleanup : %s" % e)
2256-
return
2139+
super(TestMoveUser,cls).tearDownClass()
22572140

22582141
def setUp(self):
22592142
self.apiclient = self.testClient.getApiClient()
@@ -2284,12 +2167,7 @@ def setUp(self):
22842167
return
22852168

22862169
def tearDown(self):
2287-
try:
2288-
# Clean up, terminate the created resources
2289-
cleanup_resources(self.apiclient, reversed(self.cleanup))
2290-
except Exception as e:
2291-
raise Exception("Warning: Exception during cleanup : %s" % e)
2292-
return
2170+
super(TestMoveUser,self).tearDownClass()
22932171

22942172
@attr(tags=["domains", "advanced", "advancedns", "simulator","dvs"], required_hardware="false")
22952173
def test_move_user_to_accountID(self):

0 commit comments

Comments
 (0)