Skip to content

Commit c1bfe51

Browse files
author
pritisarap12
committed
CLOUDSTACK-8308: Updating automation testcases for Delta Snapshot testpath
1 parent b300d4e commit c1bfe51

File tree

2 files changed

+44
-17
lines changed

2 files changed

+44
-17
lines changed

test/integration/testpaths/testpath_delta_snapshots.py

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,32 @@
3838
compareChecksum
3939
)
4040
from marvin.sshClient import SshClient
41-
from marvin.codes import (FAIL)
41+
from marvin.codes import (PASS, FAIL, BACKED_UP, ROOT, DATA)
4242
import time
4343

4444

4545
def checkIntegrityOfSnapshot(
46-
self, snapshotsToRestore, checksumToCompare, disk_type="root"):
46+
self, snapshotsToRestore, checksumToCompare, disk_type=ROOT):
47+
"""
48+
Check integrity of snapshot created of ROOT or DATA Disk:
4749
48-
if disk_type == "root":
50+
If ROOT Disk: Deploy a Vm from a template created from the snapshot
51+
and checking the contents of the ROOT disk.
52+
If DATA Disk: Users can create a volume from the snapshot.
53+
The volume can then be mounted to a VM and files
54+
recovered as needed.
55+
56+
Inputs:
57+
1. snapshotsToRestore: Snapshots whose integrity is
58+
to be checked.
59+
60+
2. checksumToCompare: The contents of ROOT Disk to be compared.
61+
62+
3. disk_type: The type of disk - ROOT or DATA Disk
63+
of which snapshot was created.
64+
65+
"""
66+
if disk_type == ROOT:
4967
# Create template from snapshot
5068
template_from_snapshot = Template.create_from_snapshot(
5169
self.apiclient,
@@ -58,8 +76,6 @@ def checkIntegrityOfSnapshot(
5876
"Check if result exists in list item call"
5977
)
6078

61-
time.sleep(60)
62-
6379
# Deploy VM
6480
vm_from_temp = VirtualMachine.create(
6581
self.apiclient,
@@ -77,7 +93,7 @@ def checkIntegrityOfSnapshot(
7793
None,
7894
"Check if result exists in list item call"
7995
)
80-
time.sleep(60)
96+
8197
# Verify contents of ROOT disk match with snapshot
8298

8399
compareChecksum(
@@ -153,6 +169,10 @@ def setUpClass(cls):
153169
cls._cleanup = []
154170

155171
cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
172+
cls.skiptest = False
173+
174+
if cls.hypervisor.lower() not in ["xenserver"]:
175+
cls.skiptest = True
156176

157177
try:
158178

@@ -218,6 +238,10 @@ def tearDownClass(cls):
218238
raise Exception("Warning: Exception during cleanup : %s" % e)
219239

220240
def setUp(self):
241+
if self.skiptest:
242+
self.skipTest(
243+
"Storage migration not supported on %s" %
244+
self.hypervisor)
221245
self.apiclient = self.testClient.getApiClient()
222246
self.dbclient = self.testClient.getDbConnection()
223247
self.cleanup = []
@@ -247,7 +271,7 @@ def RestartServer(cls):
247271
return
248272

249273
@attr(tags=["advanced", "basic"], required_hardware="true")
250-
def test_02_delta_snapshots(self):
274+
def test_01_delta_snapshots(self):
251275
""" Delta Snapshots
252276
1. Create file on ROOT disk of deployed VM.
253277
2. Create Snapshot of ROOT disk.
@@ -258,6 +282,8 @@ def test_02_delta_snapshots(self):
258282
6. Delete full snapshot and verify it is deleted from\
259283
secondary storage.
260284
"""
285+
if self.hypervisor.lower() in ["hyperv", "lxc"]:
286+
self.skipTest("Skip test case for %s" % self.hypervisor.lower())
261287

262288
checksum_created = []
263289
full_snapshot_count = 0
@@ -271,14 +297,14 @@ def test_02_delta_snapshots(self):
271297
root_volumes_list = list_volumes(
272298
self.apiclient,
273299
virtualmachineid=self.vm.id,
274-
type='ROOT',
300+
type=ROOT,
275301
listall=True
276302
)
277303

278304
status = validateList(root_volumes_list)
279305
self.assertEqual(
280306
status[0],
281-
FAIL,
307+
PASS,
282308
"Check listVolumes response for ROOT Disk")
283309

284310
root_volume = root_volumes_list[0]
@@ -322,12 +348,12 @@ def test_02_delta_snapshots(self):
322348
id=root_vol_snapshot.id)
323349

324350
status = validateList(snapshots_list)
325-
self.assertEqual(status[0], FAIL, "Check listSnapshots response")
351+
self.assertEqual(status[0], PASS, "Check listSnapshots response")
326352

327353
# Verify Snapshot state
328354
self.assertEqual(
329-
snapshots_list[0].state in [
330-
'BackedUp',
355+
snapshots_list[0].state.lower() in [
356+
BACKED_UP,
331357
],
332358
True,
333359
"Snapshot state is not as expected. It is %s" %
@@ -380,7 +406,7 @@ def test_02_delta_snapshots(self):
380406
self,
381407
snapshots_list[0],
382408
checksum_root,
383-
disk_type="data")
409+
disk_type=DATA)
384410

385411
else:
386412

@@ -389,7 +415,6 @@ def test_02_delta_snapshots(self):
389415
delta_snapshot_size = snapshot_size
390416

391417
# Check secondary storage count for Delta Snapshots
392-
393418
self.assertTrue(delta_snapshot_size < full_snapshot_size,
394419
"Delta Snapshot size should be less than\
395420
Full Snapshot.")
@@ -430,12 +455,13 @@ def test_02_delta_snapshots(self):
430455
self,
431456
self.snapshots_created[0],
432457
checksum_created[0],
433-
disk_type="data")
458+
disk_type=DATA)
459+
434460
checkIntegrityOfSnapshot(
435461
self,
436462
self.snapshots_created[2],
437463
checksum_created[2],
438-
disk_type="data")
464+
disk_type=DATA)
439465

440466
# Delete S3
441467

@@ -471,7 +497,7 @@ def test_02_delta_snapshots(self):
471497
self,
472498
self.snapshots_created[0],
473499
checksum_created[0],
474-
disk_type="data")
500+
disk_type=DATA)
475501

476502
# Step 6
477503
# Delete S1

tools/marvin/marvin/codes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
DISABLE = "Disable"
6060
NETWORK_OFFERING = "network_offering"
6161
ROOT = "ROOT"
62+
DATA = "DATA"
6263
INVALID_INPUT = "INVALID INPUT"
6364
EMPTY_LIST = "EMPTY_LIST"
6465
FAIL = 0

0 commit comments

Comments
 (0)