Skip to content

Commit f61723d

Browse files
Priti SarapGaurav Aradhye
authored andcommitted
CLOUDSTACK-8547: Modify hypervisor check in testpath_snapshot_hardning.py
Signed-off-by: Gaurav Aradhye <gaurav.aradhye@clogeny.com> This closes apache#378
1 parent 7ba2f22 commit f61723d

1 file changed

Lines changed: 37 additions & 30 deletions

File tree

‎test/integration/testpaths/testpath_snapshot_hadrning.py‎

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ def test_01_snapshot_hardning_kvm(self):
476476
in progress attach the volume to A VM verify that volume
477477
gets attached successfully also check integrity of snapshot
478478
"""
479-
if self.hypervisor == "xenserver":
480-
self.skipTest("Skip test for XenServer")
479+
if self.hypervisor.lower() != "kvm":
480+
self.skipTest("Skip test for Hypervisor other than KVM")
481481

482482
# Step 1
483483

@@ -1384,6 +1384,11 @@ def setUpClass(cls):
13841384

13851385
cls._cleanup = []
13861386

1387+
configs = Configurations.list(
1388+
cls.apiclient,
1389+
name="snapshot.delta.max")
1390+
cls.delta_max = configs[0].value
1391+
13871392
clusterid_tag_mapping = {}
13881393
cwps_no = 0
13891394
cls.unsupportedHypervisor = False
@@ -1473,6 +1478,12 @@ def setUpClass(cls):
14731478

14741479
cls._cleanup.append(cls.service_offering_cluster1)
14751480

1481+
cls.service_offering = ServiceOffering.create(
1482+
cls.apiclient,
1483+
cls.testdata["service_offering"]
1484+
)
1485+
cls._cleanup.append(cls.service_offering)
1486+
14761487
# Create Disk offering
14771488
cls.disk_offering_cluster1 = DiskOffering.create(
14781489
cls.apiclient,
@@ -1576,6 +1587,13 @@ def CreateSnapshot(self, root_volume, is_recurring):
15761587
self.exceptionList.append(e)
15771588
return
15781589

1590+
def CreateDeltaSnapshot(self, volume):
1591+
for i in range(int(self.delta_max)):
1592+
Snapshot.create(
1593+
self.apiclient,
1594+
volume.id)
1595+
return
1596+
15791597
def GetUpdatedRootVolume(self):
15801598
"""
15811599
Return Updated Root Volume.
@@ -1683,7 +1701,7 @@ def test_06_hardening(self):
16831701
"""
16841702

16851703
# Get ROOT Volume
1686-
root_volume = self.GetUpdatedRootVolume(self)
1704+
root_volume = self.GetUpdatedRootVolume()
16871705

16881706
checksum_root = createChecksum(
16891707
service=self.testdata,
@@ -1700,8 +1718,6 @@ def test_06_hardening(self):
17001718
diskofferingid=self.disk_offering_cluster1.id
17011719
)
17021720

1703-
self.cleanup.append(data_volume_created)
1704-
17051721
self.vm.attach_volume(
17061722
self.apiclient,
17071723
data_volume_created
@@ -1730,7 +1746,7 @@ def test_06_hardening(self):
17301746

17311747
self.vm.reboot(self.apiclient)
17321748

1733-
current_storagepool_tag = self.GetStoragePoolTag(self, root_volume)
1749+
current_storagepool_tag = self.GetStoragePoolTag(root_volume)
17341750

17351751
# Create VM on CWPS
17361752
vm_in_cluster2 = VirtualMachine.create(
@@ -1746,28 +1762,9 @@ def test_06_hardening(self):
17461762

17471763
# Step 1
17481764

1749-
try:
1750-
create_snapshot_thread = Thread(
1751-
target=self.CreateSnapshot,
1752-
args=(
1753-
data_volume,
1754-
False))
1765+
self.CreateSnapshot(data_volume, False)
17551766

1756-
attach_volume_thread = Thread(
1757-
target=vm_in_cluster2.attach_volume,
1758-
args=(
1759-
self.apiclient,
1760-
data_volume))
1761-
1762-
create_snapshot_thread.start()
1763-
attach_volume_thread.start()
1764-
create_snapshot_thread.join()
1765-
attach_volume_thread.join()
1766-
1767-
except Exception as e:
1768-
raise Exception(
1769-
"Warning: Exception unable to start thread : %s" %
1770-
e)
1767+
vm_in_cluster2.attach_volume(self.apiclient, data_volume)
17711768

17721769
vm_in_cluster2.reboot(self.apiclient)
17731770

@@ -1789,13 +1786,14 @@ def test_06_hardening(self):
17891786
"check if volume is detached"
17901787
)
17911788

1792-
self.CreateSnapshot(self,
1793-
data_volume,
1789+
self.CreateDeltaSnapshot(data_volume)
1790+
1791+
self.CreateSnapshot(data_volume,
17941792
False)
17951793

17961794
snapshots_list = list_snapshots(
17971795
self.apiclient,
1798-
volumeid=data_volume.id,
1796+
volumeid=data_volume_list[0].id,
17991797
listall=True)
18001798

18011799
status = validateList(snapshots_list)
@@ -1817,6 +1815,14 @@ def test_06_hardening(self):
18171815
checksum_data,
18181816
disk_type="data")
18191817

1818+
# Detach DATA Volume
1819+
vm_in_cluster2.detach_volume(
1820+
self.apiclient,
1821+
data_volume_list[0]
1822+
)
1823+
1824+
vm_in_cluster2.reboot(self.apiclient)
1825+
18201826
# Step 2
18211827
self.CreateSnapshot(self,
18221828
root_volume,
@@ -2098,4 +2104,5 @@ def test_06_hardening(self):
20982104
checksum_root,
20992105
disk_type="root")
21002106

2107+
data_volume_created.delete(self.apiclient)
21012108
return

0 commit comments

Comments
 (0)