Skip to content

Commit 4e0b44c

Browse files
Gaurav AradhyeGirish Shilamkar
authored andcommitted
CLOUDSTACK-5630: Fixed snapshots' test cases
1 parent 5aa0bc3 commit 4e0b44c

2 files changed

Lines changed: 26 additions & 21 deletions

File tree

‎test/integration/component/test_resource_limits.py‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,11 @@ def test_03_snapshots_per_account(self):
523523
self.assertEqual(
524524
snapshot_1.state in [
525525
'BackedUp',
526-
'CreatedOnPrimary'
526+
'CreatedOnPrimary',
527+
'Allocated'
527528
],
528529
True,
529-
"Check Snapshot state is Running or not"
530+
"Snapshot state is not valid, it is %s" % snapshot_1.state
530531
)
531532

532533
# Exception should be raised for second snapshot (account_1)
@@ -563,10 +564,11 @@ def test_03_snapshots_per_account(self):
563564
self.assertEqual(
564565
snapshot_2.state in [
565566
'BackedUp',
566-
'CreatedOnPrimary'
567+
'CreatedOnPrimary',
568+
'Allocated'
567569
],
568570
True,
569-
"Check Snapshot state is Running or not"
571+
"Snapshot state is not valid, it is %s" % snapshot_2.state
570572
)
571573

572574
self.debug("Creating snapshot from volume: %s" % volumes[0].id)
@@ -581,10 +583,11 @@ def test_03_snapshots_per_account(self):
581583
self.assertEqual(
582584
snapshot_3.state in [
583585
'BackedUp',
584-
'CreatedOnPrimary'
586+
'CreatedOnPrimary',
587+
'Allocated'
585588
],
586589
True,
587-
"Check Snapshot state is Running or not"
590+
"Snapshot state is not valid, it is %s" % snapshot_3.state
588591
)
589592
return
590593

@@ -1168,10 +1171,11 @@ def test_03_snapshots_per_domain(self):
11681171
self.assertEqual(
11691172
snapshot_1.state in [
11701173
'BackedUp',
1171-
'CreatedOnPrimary'
1174+
'CreatedOnPrimary',
1175+
'Allocated'
11721176
],
11731177
True,
1174-
"Check Snapshot state is Running or not"
1178+
"Snapshot state is not valid, it is %s" % snapshot_1.state
11751179
)
11761180

11771181
# Exception should be raised for second snapshot

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -268,18 +268,6 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
268268
"kvm": "",
269269
"xenserver": ".vhd"}
270270

271-
from base import ImageStore
272-
secondaryStores = ImageStore.list(apiclient, zoneid=zoneid)
273-
274-
assert isinstance(secondaryStores, list), "Not a valid response for listImageStores"
275-
assert len(secondaryStores) != 0, "No image stores found in zone %s" % zoneid
276-
277-
secondaryStore = secondaryStores[0]
278-
279-
if str(secondaryStore.providername).lower() != "nfs":
280-
raise Exception(
281-
"is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str(secondaryStore.providername))
282-
283271
qresultset = dbconn.execute(
284272
"select id from snapshots where uuid = '%s';" \
285273
% str(snapshotid)
@@ -291,7 +279,7 @@ def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
291279

292280
snapshotid = qresultset[0][0]
293281
qresultset = dbconn.execute(
294-
"select install_path from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
282+
"select install_path,store_id from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
295283
)
296284

297285
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):
300288
#Snapshot does not exist
301289
return False
302290

291+
from base import ImageStore
292+
#pass store_id to get the exact storage pool where snapshot is stored
293+
secondaryStores = ImageStore.list(apiclient, zoneid=zoneid, id=int(qresultset[0][1]))
294+
295+
assert isinstance(secondaryStores, list), "Not a valid response for listImageStores"
296+
assert len(secondaryStores) != 0, "No image stores found in zone %s" % zoneid
297+
298+
secondaryStore = secondaryStores[0]
299+
300+
if str(secondaryStore.providername).lower() != "nfs":
301+
raise Exception(
302+
"is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str(secondaryStore.providername))
303+
303304
hypervisor = get_hypervisor_type(apiclient)
304305
# append snapshot extension based on hypervisor, to the snapshot path
305306
snapshotPath = str(qresultset[0][0]) + snapshot_extensions[str(hypervisor).lower()]

0 commit comments

Comments
 (0)