mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-9128: Testcase to verify if snapshot_store_ref table stores actual size of back snapshot in secondary storage
This commit is contained in:
parent
3d9919ecfb
commit
f8c2c955e6
@ -31,10 +31,13 @@ from marvin.lib.base import (Account,
|
||||
)
|
||||
from marvin.lib.common import (get_domain,
|
||||
get_zone,
|
||||
get_template
|
||||
get_template,
|
||||
createChecksum,
|
||||
list_volumes
|
||||
)
|
||||
|
||||
from marvin.codes import (BACKED_UP, PASS, FAIL)
|
||||
from marvin.codes import (BACKED_UP, PASS, FAIL, ROOT)
|
||||
import time
|
||||
|
||||
|
||||
class TestStorageSnapshotsLimits(cloudstackTestCase):
|
||||
@ -99,6 +102,7 @@ class TestStorageSnapshotsLimits(cloudstackTestCase):
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
zoneid=cls.zone.id,
|
||||
mode=cls.zone.networktype
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
@ -137,7 +141,6 @@ class TestStorageSnapshotsLimits(cloudstackTestCase):
|
||||
PASS,
|
||||
"DATA Volume List Validation Failed")
|
||||
|
||||
if data_volumes_list:
|
||||
self.vm.detach_volume(
|
||||
self.userapiclient,
|
||||
data_volumes_list[0]
|
||||
@ -359,3 +362,129 @@ class TestStorageSnapshotsLimits(cloudstackTestCase):
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "basic"], required_hardware="true")
|
||||
def test_02_snapshot_size_check(self):
|
||||
""" Check Snapshots size in database
|
||||
1. Create file on ROOT disk of deployed VM.
|
||||
2. Create Snapshot of ROOT disk.
|
||||
3. Check if physiacal_size parameter of snapshot_store_ref table
|
||||
has physical size of snapshot
|
||||
"""
|
||||
if self.hypervisor.lower() not in ["xenserver", "vmware"]:
|
||||
self.skipTest("Test not to be run on %s" % self.hypervisor)
|
||||
|
||||
root_volumes_list = list_volumes(
|
||||
self.apiclient,
|
||||
virtualmachineid=self.vm.id,
|
||||
type=ROOT,
|
||||
listall=True
|
||||
)
|
||||
|
||||
status = validateList(root_volumes_list)
|
||||
self.assertEqual(
|
||||
status[0],
|
||||
PASS,
|
||||
"Check listVolumes response for ROOT Disk")
|
||||
|
||||
root_volume = root_volumes_list[0]
|
||||
|
||||
# Get Secondary Storage Value from Database
|
||||
qryresult_before_snapshot = self.dbclient.execute(
|
||||
" select id, account_name, secondaryStorageTotal\
|
||||
from account_view where account_name = '%s';" %
|
||||
self.account.name)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(qryresult_before_snapshot),
|
||||
0,
|
||||
"Check sql query to return SecondaryStorageTotal of account")
|
||||
|
||||
storage_qry_result_old = qryresult_before_snapshot[0]
|
||||
secondary_storage_old = storage_qry_result_old[2]
|
||||
|
||||
createChecksum(
|
||||
self.testdata,
|
||||
self.vm,
|
||||
root_volume,
|
||||
"rootdiskdevice")
|
||||
|
||||
time.sleep(30)
|
||||
|
||||
root_vol_snapshot = Snapshot.create(
|
||||
self.apiclient,
|
||||
root_volume.id)
|
||||
|
||||
snapshots_list = Snapshot.list(self.apiclient,
|
||||
id=root_vol_snapshot.id)
|
||||
|
||||
status = validateList(snapshots_list)
|
||||
self.assertEqual(status[0], PASS, "Check listSnapshots response")
|
||||
# Verify Snapshot state
|
||||
self.assertEqual(
|
||||
snapshots_list[0].state.lower() in [
|
||||
BACKED_UP,
|
||||
],
|
||||
True,
|
||||
"Snapshot state is not as expected. It is %s" %
|
||||
snapshots_list[0].state
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
snapshots_list[0].volumeid,
|
||||
root_volume.id,
|
||||
"Snapshot volume id is not matching with the vm's volume id")
|
||||
|
||||
qryresult_snp_id = self.dbclient.execute(
|
||||
"select id\
|
||||
from snapshots where uuid = '%s';" %
|
||||
snapshots_list[0].id)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(qryresult_snp_id),
|
||||
0,
|
||||
"Check sql query to return physical size of the snapshot")
|
||||
|
||||
snp_id_result = qryresult_snp_id[0]
|
||||
snp_id = snp_id_result[0]
|
||||
|
||||
qryresult_physical_size = self.dbclient.execute(
|
||||
" select id, store_id, physical_size\
|
||||
from snapshot_store_ref where snapshot_id = '%s' \
|
||||
and store_role='Image';" %
|
||||
snp_id)
|
||||
|
||||
self.assertNotEqual(
|
||||
len(qryresult_physical_size),
|
||||
0,
|
||||
"Check sql query to return SecondaryStorageTotal of account")
|
||||
|
||||
snapshot_physical_size_result = qryresult_physical_size[0]
|
||||
snapshot_physical_size = snapshot_physical_size_result[
|
||||
2]
|
||||
|
||||
# Step 3
|
||||
qryresult_after_snapshot = self.dbclient.execute(
|
||||
" select id, account_name, secondaryStorageTotal\
|
||||
from account_view where account_name = '%s';" %
|
||||
self.account.name)
|
||||
self.assertNotEqual(
|
||||
len(qryresult_after_snapshot),
|
||||
0,
|
||||
"Check sql query to return SecondaryStorageTotal of account")
|
||||
|
||||
storage_qry_result_from_database = qryresult_after_snapshot[0]
|
||||
secondary_storage_new = storage_qry_result_from_database[
|
||||
2]
|
||||
|
||||
secondary_storage_after_snapshot = secondary_storage_new - \
|
||||
secondary_storage_old
|
||||
|
||||
self.assertEqual(
|
||||
snapshot_physical_size,
|
||||
secondary_storage_after_snapshot,
|
||||
"Check if physical_size attribute of snapshot_store_ref table \
|
||||
stores correct value"
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user