Skip to content

Commit 0a8bce5

Browse files
Gaurav AradhyePrasanna Santhanam
authored andcommitted
CLOUDSTACK-4647: Fixed snapshot_gc test case and common util function is_snapshot_on_nfs
Signed-off-by: Prasanna Santhanam <tsp@apache.org>
1 parent 7b5daae commit 0a8bce5

2 files changed

Lines changed: 16 additions & 21 deletions

File tree

‎test/integration/component/test_snapshot_gc.py‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,14 @@ def setUpClass(cls):
148148
)
149149

150150
cls.services["account"] = cls.account.name
151-
cls._cleanup.append(cls.account)
152151

153152
if cls.zone.localstorageenabled:
154153
cls.services["service_offering"]["storagetype"] = "local"
155154
cls.service_offering = ServiceOffering.create(
156155
cls.api_client,
157156
cls.services["service_offering"]
158157
)
159-
cls._cleanup.append(cls.service_offering)
158+
160159
cls.virtual_machine = VirtualMachine.create(
161160
cls.api_client,
162161
cls.services["server"],
@@ -165,7 +164,7 @@ def setUpClass(cls):
165164
domainid=cls.account.domainid,
166165
serviceofferingid=cls.service_offering.id
167166
)
168-
cls._cleanup.append(cls.virtual_machine)
167+
169168
# Get the Root disk of VM
170169
volumes = list_volumes(
171170
cls.api_client,
@@ -177,13 +176,10 @@ def setUpClass(cls):
177176

178177
# Create a snapshot from the ROOTDISK
179178
cls.snapshot = Snapshot.create(cls.api_client, volumes[0].id)
180-
cls._cleanup.append(cls.snapshot)
181179
except Exception, e:
182180
cls.tearDownClass()
183181
unittest.SkipTest("setupClass fails for %s" % cls.__name__)
184182
raise e
185-
else:
186-
cls._cleanup.remove(cls.account)
187183
return
188184

189185
@classmethod
@@ -296,15 +292,12 @@ def test_02_accountSnapshotClean(self):
296292

297293
# Wait for account cleanup interval
298294
wait_for_cleanup(self.apiclient, configs=["account.cleanup.interval"])
299-
accounts = list_accounts(
295+
296+
with self.assertRaises(Exception):
297+
accounts = list_accounts(
300298
self.apiclient,
301299
id=self.account.id
302300
)
303-
self.assertEqual(
304-
accounts,
305-
None,
306-
"List accounts should return empty list after account deletion"
307-
)
308301

309302
self.assertFalse(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, self.snapshot.id),
310303
"Snapshot was still found on NFS after account gc")

‎tools/marvin/marvin/integration/lib/utils.py‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -269,30 +269,32 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
269269
)
270270

271271
assert isinstance(qresultset, list), "Invalid db query response for snapshot %s" % snapshotid
272-
assert len(qresultset) != 0, "No such snapshot %s found in the cloudstack db" % snapshotid
272+
273+
if len(qresultset) == 0:
274+
#Snapshot does not exist
275+
return False
273276

274277
snapshotPath = qresultset[0][0]
275278

276279
nfsurl = secondaryStore.url
277-
# parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
278280
from urllib2 import urlparse
279281
parse_url = urlparse.urlsplit(nfsurl, scheme='nfs')
280282
host, path = parse_url.netloc, parse_url.path
281283

282284
if not config.mgtSvr:
283285
raise Exception("Your marvin configuration does not contain mgmt server credentials")
284-
host, user, passwd = config.mgtSvr[0].mgtSvrIp, config.mgtSvr[0].user, config.mgtSvr[0].passwd
286+
mgtSvr, user, passwd = config.mgtSvr[0].mgtSvrIp, config.mgtSvr[0].user, config.mgtSvr[0].passwd
285287

286288
try:
287289
ssh_client = remoteSSHClient(
288-
host,
290+
mgtSvr,
289291
22,
290292
user,
291-
passwd,
293+
passwd
292294
)
293295
cmds = [
294296
"mkdir -p %s /mnt/tmp",
295-
"mount -t %s %s:%s /mnt/tmp" % (
297+
"mount -t %s %s%s /mnt/tmp" % (
296298
'nfs',
297299
host,
298300
path,
@@ -314,5 +316,5 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
314316
ssh_client.execute(c)
315317
except Exception as e:
316318
raise Exception("SSH failed for management server: %s - %s" %
317-
(config[0].mgtSvrIp, e))
319+
(config.mgtSvr[0].mgtSvrIp, e))
318320
return 'snapshot exists' in result

0 commit comments

Comments
 (0)