CLOUDSTACK-5630: Fixed snapshots' test cases

This commit is contained in:
Gaurav Aradhye 2014-01-08 17:16:06 +05:30 committed by Girish Shilamkar
parent 5dc0c60239
commit b98c0ee809
2 changed files with 26 additions and 21 deletions

View File

@ -523,10 +523,11 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.assertEqual(
snapshot_1.state in [
'BackedUp',
'CreatedOnPrimary'
'CreatedOnPrimary',
'Allocated'
],
True,
"Check Snapshot state is Running or not"
"Snapshot state is not valid, it is %s" % snapshot_1.state
)
# Exception should be raised for second snapshot (account_1)
@ -563,10 +564,11 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.assertEqual(
snapshot_2.state in [
'BackedUp',
'CreatedOnPrimary'
'CreatedOnPrimary',
'Allocated'
],
True,
"Check Snapshot state is Running or not"
"Snapshot state is not valid, it is %s" % snapshot_2.state
)
self.debug("Creating snapshot from volume: %s" % volumes[0].id)
@ -581,10 +583,11 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.assertEqual(
snapshot_3.state in [
'BackedUp',
'CreatedOnPrimary'
'CreatedOnPrimary',
'Allocated'
],
True,
"Check Snapshot state is Running or not"
"Snapshot state is not valid, it is %s" % snapshot_3.state
)
return
@ -1168,10 +1171,11 @@ class TestResourceLimitsDomain(cloudstackTestCase):
self.assertEqual(
snapshot_1.state in [
'BackedUp',
'CreatedOnPrimary'
'CreatedOnPrimary',
'Allocated'
],
True,
"Check Snapshot state is Running or not"
"Snapshot state is not valid, it is %s" % snapshot_1.state
)
# Exception should be raised for second snapshot

View File

@ -268,18 +268,6 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
"kvm": "",
"xenserver": ".vhd"}
from base import ImageStore
secondaryStores = ImageStore.list(apiclient, zoneid=zoneid)
assert isinstance(secondaryStores, list), "Not a valid response for listImageStores"
assert len(secondaryStores) != 0, "No image stores found in zone %s" % zoneid
secondaryStore = secondaryStores[0]
if str(secondaryStore.providername).lower() != "nfs":
raise Exception(
"is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str(secondaryStore.providername))
qresultset = dbconn.execute(
"select id from snapshots where uuid = '%s';" \
% str(snapshotid)
@ -291,7 +279,7 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
snapshotid = qresultset[0][0]
qresultset = dbconn.execute(
"select install_path from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
"select install_path,store_id from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
)
assert isinstance(qresultset, list), "Invalid db query response for snapshot %s" % snapshotid
@ -300,6 +288,19 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
#Snapshot does not exist
return False
from base import ImageStore
#pass store_id to get the exact storage pool where snapshot is stored
secondaryStores = ImageStore.list(apiclient, zoneid=zoneid, id=int(qresultset[0][1]))
assert isinstance(secondaryStores, list), "Not a valid response for listImageStores"
assert len(secondaryStores) != 0, "No image stores found in zone %s" % zoneid
secondaryStore = secondaryStores[0]
if str(secondaryStore.providername).lower() != "nfs":
raise Exception(
"is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str(secondaryStore.providername))
hypervisor = get_hypervisor_type(apiclient)
# append snapshot extension based on hypervisor, to the snapshot path
snapshotPath = str(qresultset[0][0]) + snapshot_extensions[str(hypervisor).lower()]