You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2016/03/22 12:44:06 UTC

[09/50] [abbrv] git commit: updated refs/heads/4.9-mvn-upgrade to 7617117

CLOUDSTACK-9128: Testcase to verify if snapshot_store_ref table stores actual size of back snapshot in secondary storage


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f8c2c955
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f8c2c955
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f8c2c955

Branch: refs/heads/4.9-mvn-upgrade
Commit: f8c2c955e665b32d7ae972450d77e6f6714833fc
Parents: 3d9919e
Author: Priti Sarap <pr...@clogeny.com>
Authored: Wed Dec 9 15:04:50 2015 +0530
Committer: Priti Sarap <pr...@clogeny.com>
Committed: Wed Feb 10 15:11:47 2016 +0530

----------------------------------------------------------------------
 .../testpaths/testpath_snapshot_limits.py       | 135 ++++++++++++++++++-
 1 file changed, 132 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8c2c955/test/integration/testpaths/testpath_snapshot_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/testpaths/testpath_snapshot_limits.py b/test/integration/testpaths/testpath_snapshot_limits.py
index 855d3a2..7a27feb 100644
--- a/test/integration/testpaths/testpath_snapshot_limits.py
+++ b/test/integration/testpaths/testpath_snapshot_limits.py
@@ -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