Skip to content

Commit c151ad5

Browse files
author
Daan Hoogland
committed
use cleanup mechs on TestNetworkMigration
1 parent e90e436 commit c151ad5

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

test/integration/smoke/test_migration.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ def setUpClass(cls):
109109
cls.api_client,
110110
cls.test_data["service_offerings"]["tiny"]
111111
)
112+
cls._cleanup.append(cls.service_offering)
112113

113114
# Create Network offering without userdata
114115
cls.network_offering_nouserdata = NetworkOffering.create(
115116
cls.api_client,
116117
cls.test_data["network_offering"]
117118
)
119+
cls._cleanup.append(cls.network_offering_nouserdata)
118120
# Enable Network offering
119121
cls.network_offering_nouserdata.update(cls.api_client,
120122
state='Enabled')
@@ -124,54 +126,39 @@ def setUpClass(cls):
124126
cls.api_client,
125127
cls.test_data["isolated_network_offering"]
126128
)
129+
cls._cleanup.append(cls.network_offering_all)
127130
# Enable Network offering
128131
cls.network_offering_all.update(cls.api_client, state='Enabled')
129132

130133
cls.native_vpc_network_offering = NetworkOffering.create(
131134
cls.api_client,
132135
cls.test_data["nw_offering_isolated_vpc"],
133136
conservemode=False)
137+
cls._cleanup.append(cls.native_vpc_network_offering)
134138
cls.native_vpc_network_offering.update(cls.api_client,
135139
state='Enabled')
136140

137-
cls._cleanup = [
138-
cls.service_offering,
139-
cls.network_offering_nouserdata,
140-
cls.network_offering_all,
141-
cls.native_vpc_network_offering
142-
]
143-
144141
def setUp(self):
145142
self.apiclient = self.testClient.getApiClient()
146143
self.hypervisor = self.testClient.getHypervisorInfo()
147144
self.dbclient = self.testClient.getDbConnection()
145+
self.cleanup = []
148146
if not self.hypervisorNotSupported:
149147
self.account = Account.create(
150148
self.apiclient,
151149
self.test_data["account"],
152150
admin=True,
153151
domainid=self.domain.id
154152
)
155-
self.cleanup = []
153+
self.cleanup.append(self.account)
156154
return
157155

158156
def tearDown(self):
159-
try:
160-
if not self.hypervisorNotSupported:
161-
self.account.delete(self.apiclient)
162-
cleanup_resources(self.apiclient, self.cleanup)
163-
except Exception as e:
164-
raise Exception("Warning: Exception during cleanup : %s" % e)
165-
return
157+
super(TestNetworkMigration, self).tearDown()
166158

167159
@classmethod
168160
def tearDownClass(cls):
169-
try:
170-
# Cleanup resources used
171-
cleanup_resources(cls.api_client, cls._cleanup)
172-
173-
except Exception as e:
174-
raise Exception("Warning: Exception during cleanup : %s" % e)
161+
super(TestNetworkMigration, cls).tearDownClass()
175162

176163
def migrate_network(self, nw_off, network, resume=False):
177164
return network.migrate(self.api_client, nw_off.id, resume)
@@ -204,6 +191,7 @@ def test_01_native_to_native_network_migration(self):
204191
networkofferingid=self.network_offering_all.id,
205192
zoneid=self.zone.id
206193
)
194+
self.cleanup.append(isolated_network)
207195

208196
self.migrate_network(
209197
self.network_offering_nouserdata,
@@ -223,6 +211,8 @@ def test_01_native_to_native_network_migration(self):
223211
templateid=self.template.id,
224212
zoneid=self.zone.id
225213
)
214+
self.cleanup.append(deployVmResponse)
215+
226216
vms = list_virtual_machines(
227217
self.apiclient,
228218
account=self.account.name,
@@ -262,6 +252,7 @@ def test_02_native_to_native_vpc_migration(self):
262252
native_vpc_off = VpcOffering.create(
263253
self.apiclient,
264254
self.test_data["vpc_offering_reduced"])
255+
self.cleanup.append(native_vpc_off)
265256

266257
self.debug("Enabling the VPC offering created")
267258
native_vpc_off.update(self.apiclient, state='Enabled')
@@ -277,13 +268,16 @@ def test_02_native_to_native_vpc_migration(self):
277268
account=self.account.name,
278269
domainid=self.account.domainid
279270
)
271+
self.cleanup.append(vpc)
272+
280273
self.debug("Creating native VPC Network Tier offering "
281274
"with Static NAT service provider as VPCVR")
282275
native_tiernet_off = \
283276
NetworkOffering.create(self.apiclient,
284277
self.test_data
285278
["nw_offering_reduced_vpc"],
286279
conservemode=False)
280+
self.cleanup.append(native_tiernet_off)
287281
native_tiernet_off.update(self.apiclient, state='Enabled')
288282

289283
self.debug("Creating a VPC tier network with Static NAT service")
@@ -296,6 +290,7 @@ def test_02_native_to_native_vpc_migration(self):
296290
gateway='10.1.1.1',
297291
vpcid=vpc.id if vpc else self.vpc.id
298292
)
293+
self.cleanup.append(vpc_tier)
299294
self.debug("Created network with ID: %s" % vpc_tier.id)
300295

301296
network_offering_map = \
@@ -323,6 +318,7 @@ def test_02_native_to_native_vpc_migration(self):
323318
templateid=self.template.id,
324319
zoneid=self.zone.id
325320
)
321+
self.cleanup.append(vm)
326322
self.debug('Created VM=%s in network=%s' %
327323
(vm.id, native_tiernet_off.name))
328324

0 commit comments

Comments
 (0)