Skip to content

Commit 8b23b45

Browse files
author
Daan Hoogland
committed
cleanup ss_max_limits and fix for float vs int problem in API
1 parent b509556 commit 8b23b45

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

test/integration/component/test_ss_max_limits.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def setUpClass(cls):
5454
cls.domain = get_domain(cls.api_client)
5555
cls.zone = get_zone(cls.api_client, cloudstackTestClient.getZoneForTests())
5656
cls.services["mode"] = cls.zone.networktype
57+
cls._cleanup = []
5758

5859
cls.template = get_template(
5960
cls.api_client,
@@ -65,17 +66,12 @@ def setUpClass(cls):
6566
cls.services["virtual_machine"]["template"] = cls.template.id
6667
cls.services["volume"]["zoneid"] = cls.zone.id
6768
cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
68-
cls._cleanup = [cls.service_offering]
69+
cls._cleanup.append(cls.service_offering)
6970
return
7071

7172
@classmethod
7273
def tearDownClass(cls):
73-
try:
74-
# Cleanup resources used
75-
cleanup_resources(cls.api_client, cls._cleanup)
76-
except Exception as e:
77-
raise Exception("Warning: Exception during cleanup : %s" % e)
78-
return
74+
super(TestMaxSecondaryStorageLimits, cls).tearDownClass()
7975

8076
def setUp(self):
8177
self.apiclient = self.testClient.getApiClient()
@@ -84,12 +80,7 @@ def setUp(self):
8480
return
8581

8682
def tearDown(self):
87-
try:
88-
# Clean up, terminate the created instance, volumes and snapshots
89-
cleanup_resources(self.apiclient, self.cleanup)
90-
except Exception as e:
91-
raise Exception("Warning: Exception during cleanup : %s" % e)
92-
return
83+
super(TestMaxSecondaryStorageLimits, self).tearDown()
9384

9485
def registerTemplate(self, inProject=False):
9586
"""Register and download template by default in the account/domain,
@@ -107,6 +98,7 @@ def registerTemplate(self, inProject=False):
10798
account=self.child_do_admin.name if not inProject else None,
10899
domainid=self.child_do_admin.domainid if not inProject else None,
109100
projectid=self.project.id if inProject else None)
101+
self.cleanup.append(template)
110102

111103
template.download(self.apiclient)
112104

@@ -127,9 +119,11 @@ def setupAccounts(self):
127119
try:
128120
self.child_domain = Domain.create(self.apiclient,services=self.services["domain"],
129121
parentdomainid=self.domain.id)
122+
self.cleanup.append(self.child_domain)
130123

131124
self.child_do_admin = Account.create(self.apiclient, self.services["account"], admin=True,
132125
domainid=self.child_domain.id)
126+
self.cleanup.append(self.child_do_admin)
133127

134128
self.userapiclient = self.testClient.getUserApiClient(
135129
UserName=self.child_do_admin.name,
@@ -139,13 +133,8 @@ def setupAccounts(self):
139133
self.project = Project.create(self.apiclient, self.services["project"],
140134
account=self.child_do_admin.name,
141135
domainid=self.child_do_admin.domainid)
142-
143-
# Cleanup created project at end of test
144136
self.cleanup.append(self.project)
145137

146-
# Cleanup accounts created
147-
self.cleanup.append(self.child_do_admin)
148-
self.cleanup.append(self.child_domain)
149138
except Exception as e:
150139
return [FAIL, e]
151140
return [PASS, None]
@@ -156,16 +145,16 @@ def updateSecondaryStorageLimits(self, accountLimit=None, domainLimit=None, proj
156145
# Update resource limits for account
157146
if accountLimit is not None:
158147
Resources.updateLimit(self.apiclient, resourcetype=11,
159-
max=accountLimit, account=self.child_do_admin.name,
148+
max=int(accountLimit), account=self.child_do_admin.name,
160149
domainid=self.child_do_admin.domainid)
161150

162151
if projectLimit is not None:
163152
Resources.updateLimit(self.apiclient, resourcetype=11,
164-
max=projectLimit, projectid=self.project.id)
153+
max=int(projectLimit), projectid=self.project.id)
165154

166155
if domainLimit is not None:
167156
Resources.updateLimit(self.apiclient, resourcetype=11,
168-
max=domainLimit, domainid=self.child_domain.id)
157+
max=int(domainLimit), domainid=self.child_domain.id)
169158
except Exception as e:
170159
return [FAIL, e]
171160
return [PASS, None]

0 commit comments

Comments
 (0)