mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4647: Fixed snapshot_gc test case and common util function is_snapshot_on_nfs
Signed-off-by: Prasanna Santhanam <tsp@apache.org> (cherry picked from commit 0bbe5684981cf21d30455de4f12dd1c2e58d94ea)
This commit is contained in:
parent
2ef566e9ea
commit
0dabc6a651
|
|
@ -148,7 +148,6 @@ class TestAccountSnapshotClean(cloudstackTestCase):
|
|||
)
|
||||
|
||||
cls.services["account"] = cls.account.name
|
||||
cls._cleanup.append(cls.account)
|
||||
|
||||
if cls.zone.localstorageenabled:
|
||||
cls.services["service_offering"]["storagetype"] = "local"
|
||||
|
|
@ -156,7 +155,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
|
|||
cls.api_client,
|
||||
cls.services["service_offering"]
|
||||
)
|
||||
cls._cleanup.append(cls.service_offering)
|
||||
|
||||
cls.virtual_machine = VirtualMachine.create(
|
||||
cls.api_client,
|
||||
cls.services["server"],
|
||||
|
|
@ -165,7 +164,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
|
|||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls._cleanup.append(cls.virtual_machine)
|
||||
|
||||
# Get the Root disk of VM
|
||||
volumes = list_volumes(
|
||||
cls.api_client,
|
||||
|
|
@ -177,13 +176,10 @@ class TestAccountSnapshotClean(cloudstackTestCase):
|
|||
|
||||
# Create a snapshot from the ROOTDISK
|
||||
cls.snapshot = Snapshot.create(cls.api_client, volumes[0].id)
|
||||
cls._cleanup.append(cls.snapshot)
|
||||
except Exception, e:
|
||||
cls.tearDownClass()
|
||||
unittest.SkipTest("setupClass fails for %s" % cls.__name__)
|
||||
raise e
|
||||
else:
|
||||
cls._cleanup.remove(cls.account)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
|
|
@ -296,15 +292,12 @@ class TestAccountSnapshotClean(cloudstackTestCase):
|
|||
|
||||
# Wait for account cleanup interval
|
||||
wait_for_cleanup(self.apiclient, configs=["account.cleanup.interval"])
|
||||
accounts = list_accounts(
|
||||
|
||||
with self.assertRaises(Exception):
|
||||
accounts = list_accounts(
|
||||
self.apiclient,
|
||||
id=self.account.id
|
||||
)
|
||||
self.assertEqual(
|
||||
accounts,
|
||||
None,
|
||||
"List accounts should return empty list after account deletion"
|
||||
)
|
||||
|
||||
self.assertFalse(is_snapshot_on_nfs(self.apiclient, self.dbclient, self.config, self.zone.id, self.snapshot.id),
|
||||
"Snapshot was still found on NFS after account gc")
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
|
@ -269,30 +269,32 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
|
|||
)
|
||||
|
||||
assert isinstance(qresultset, list), "Invalid db query response for snapshot %s" % snapshotid
|
||||
assert len(qresultset) != 0, "No such snapshot %s found in the cloudstack db" % snapshotid
|
||||
|
||||
if len(qresultset) == 0:
|
||||
#Snapshot does not exist
|
||||
return False
|
||||
|
||||
snapshotPath = qresultset[0][0]
|
||||
|
||||
nfsurl = secondaryStore.url
|
||||
# parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
|
||||
from urllib2 import urlparse
|
||||
parse_url = urlparse.urlsplit(nfsurl, scheme='nfs')
|
||||
host, path = parse_url.netloc, parse_url.path
|
||||
|
||||
if not config.mgtSvr:
|
||||
raise Exception("Your marvin configuration does not contain mgmt server credentials")
|
||||
host, user, passwd = config.mgtSvr[0].mgtSvrIp, config.mgtSvr[0].user, config.mgtSvr[0].passwd
|
||||
mgtSvr, user, passwd = config.mgtSvr[0].mgtSvrIp, config.mgtSvr[0].user, config.mgtSvr[0].passwd
|
||||
|
||||
try:
|
||||
ssh_client = remoteSSHClient(
|
||||
host,
|
||||
mgtSvr,
|
||||
22,
|
||||
user,
|
||||
passwd,
|
||||
passwd
|
||||
)
|
||||
cmds = [
|
||||
"mkdir -p %s /mnt/tmp",
|
||||
"mount -t %s %s:%s /mnt/tmp" % (
|
||||
"mount -t %s %s%s /mnt/tmp" % (
|
||||
'nfs',
|
||||
host,
|
||||
path,
|
||||
|
|
@ -314,5 +316,5 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
|
|||
ssh_client.execute(c)
|
||||
except Exception as e:
|
||||
raise Exception("SSH failed for management server: %s - %s" %
|
||||
(config[0].mgtSvrIp, e))
|
||||
(config.mgtSvr[0].mgtSvrIp, e))
|
||||
return 'snapshot exists' in result
|
||||
|
|
|
|||
Loading…
Reference in New Issue