Skip to content

Commit ebd5649

Browse files
author
Daan Hoogland
committed
cleanup VMs to let offering go
1 parent 7e769db commit ebd5649

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

test/integration/smoke/test_affinity_groups_projects.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ def setUpClass(cls):
5656
cls.services["template"] = cls.template.id
5757
cls.services["zoneid"] = cls.zone.id
5858

59+
cls._cleanup = []
60+
5961
cls.account = Account.create(
6062
cls.apiclient,
6163
cls.services["account"],
6264
domainid=cls.domain.id
6365
)
66+
cls._cleanup.append(cls.account)
6467

6568
projectData = {
6669
"name": "Project",
@@ -73,6 +76,7 @@ def setUpClass(cls):
7376
account=cls.account.name,
7477
domainid=cls.account.domainid
7578
)
79+
cls._cleanup.append(cls.project)
7680

7781
# Add user to the project
7882
cls.project.addAccount(
@@ -84,17 +88,22 @@ def setUpClass(cls):
8488
cls.apiclient,
8589
cls.services["service_offerings"]["tiny"]
8690
)
91+
cls._cleanup.append(cls.service_offering)
8792

8893
cls.ag = AffinityGroup.create(cls.apiclient, cls.services["virtual_machine"]["affinity"],projectid=cls.project.id)
94+
cls._cleanup.append(cls.ag)
95+
96+
return
8997

90-
cls._cleanup = [
91-
cls.service_offering,
92-
cls.ag,
93-
cls.project,
94-
cls.account,
95-
]
98+
def setUp(self):
99+
self.apiclient = self.testClient.getApiClient()
100+
self.dbclient = self.testClient.getDbConnection()
101+
self.cleanup = []
96102
return
97103

104+
def tearDown(self):
105+
super(TestDeployVmWithAffinityGroup,self).tearDown()
106+
98107
@attr(tags=["basic", "advanced", "multihost"], required_hardware="false")
99108
def test_DeployVmAntiAffinityGroup_in_project(self):
100109
"""
@@ -112,6 +121,7 @@ def test_DeployVmAntiAffinityGroup_in_project(self):
112121
serviceofferingid=self.service_offering.id,
113122
affinitygroupnames=[self.ag.name]
114123
)
124+
self.cleanup.append(vm1)
115125

116126
list_vm1 = list_virtual_machines(
117127
self.apiclient,
@@ -149,6 +159,7 @@ def test_DeployVmAntiAffinityGroup_in_project(self):
149159
serviceofferingid=self.service_offering.id,
150160
affinitygroupnames=[self.ag.name]
151161
)
162+
self.cleanup.append(vm2)
152163
list_vm2 = list_virtual_machines(
153164
self.apiclient,
154165
id=vm2.id
@@ -182,8 +193,4 @@ def test_DeployVmAntiAffinityGroup_in_project(self):
182193

183194
@classmethod
184195
def tearDownClass(cls):
185-
try:
186-
#Clean up, terminate the created templates
187-
cleanup_resources(cls.apiclient, cls._cleanup)
188-
except Exception as e:
189-
raise Exception("Warning: Exception during cleanup : %s" % e)
196+
super(TestDeployVmWithAffinityGroup,cls).tearDownClass()

0 commit comments

Comments
 (0)