incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mlsoren...@apache.org
Subject git commit: Summary: Adding integration test for resizing of volumes
Date Wed, 16 Jan 2013 17:43:01 GMT
Updated Branches:
  refs/heads/resizevolume d8056c931 -> ac15f932d


Summary: Adding integration test for resizing of volumes

Submitted-by: Ryan Dietrich <ryan@betterservers.com
Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1358358209 -0700


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

Branch: refs/heads/resizevolume
Commit: ac15f932d940e82706b96c3bd48be66639b374ad
Parents: d8056c9
Author: Marcus Sorensen <marcus@betterservers.com>
Authored: Wed Jan 16 10:43:29 2013 -0700
Committer: Marcus Sorensen <marcus@betterservers.com>
Committed: Wed Jan 16 10:43:29 2013 -0700

----------------------------------------------------------------------
 test/integration/smoke/test_volumes.py      |  125 +++++++++++++++++++++-
 tools/marvin/marvin/integration/lib/base.py |    6 +
 2 files changed, 127 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ac15f932/test/integration/smoke/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py
index 2d0cd49..fe36e4a 100644
--- a/test/integration/smoke/test_volumes.py
+++ b/test/integration/smoke/test_volumes.py
@@ -54,12 +54,20 @@ class Services:
                                     "cpunumber": 1,
                                     "cpuspeed": 100,    # in MHz
                                     "memory": 64,       # In MBs
+                                    "storagetype": "local"
                         },
                         "disk_offering": {
                                     "displaytext": "Small",
                                     "name": "Small",
+                                    "storagetype": "local",
                                     "disksize": 1
                         },
+                        'resized_disk_offering': {
+                                    "displaytext": "Resized",
+                                    "name": "Resized",
+                                    "storagetype": "local",
+                                    "disksize": 3
+                        },
                         "volume_offerings": {
                             0: {
                                 "diskname": "TestDiskServ",
@@ -77,8 +85,8 @@ class Services:
                         "diskdevice": "/dev/xvdb",
                         "ostype": 'CentOS 5.3 (64-bit)',
                         "mode": 'basic',
-                        "sleep": 60,
-                        "timeout": 10,
+                        "sleep": 10,
+                        "timeout": 600,
                     }
 
 
@@ -237,7 +245,7 @@ class TestCreateVolume(cloudstackTestCase):
                 ssh = self.virtual_machine.get_ssh_client(
                                                       reconnect=True
                                                       )
-                c = "fdisk -l"
+                c = "/sbin/fdisk -l"
                 res = ssh.execute(c)
 
             except Exception as e:
@@ -283,6 +291,16 @@ class TestVolumes(cloudstackTestCase):
                                     cls.api_client,
                                     cls.services["disk_offering"]
                                     )
+        cls.resized_disk_offering = DiskOffering.create(
+                                    cls.api_client,
+                                    cls.services["resized_disk_offering"]
+                                    )
+        cls.custom_resized_disk_offering = DiskOffering.create(
+                                    cls.api_client,
+                                    cls.services["resized_disk_offering"],
+                                    custom=True
+                                    )
+
         template = get_template(
                             cls.api_client,
                             cls.zone.id,
@@ -292,6 +310,8 @@ class TestVolumes(cloudstackTestCase):
         cls.services["zoneid"] = cls.zone.id
         cls.services["template"] = template.id
         cls.services["diskofferingid"] = cls.disk_offering.id
+        cls.services['resizeddiskofferingid'] = cls.resized_disk_offering.id
+        cls.services['customresizeddiskofferingid'] = cls.custom_resized_disk_offering.id
 
         # Create VMs, VMs etc
         cls.account = Account.create(
@@ -321,6 +341,8 @@ class TestVolumes(cloudstackTestCase):
                                    domainid=cls.account.account.domainid
                                    )
         cls._cleanup = [
+                        cls.resized_disk_offering,
+                        cls.custom_resized_disk_offering,
                         cls.service_offering,
                         cls.disk_offering,
                         cls.account
@@ -500,7 +522,102 @@ class TestVolumes(cloudstackTestCase):
             )
 
     @attr(tags = ["advanced", "advancedns", "smoke"])
-    def test_07_delete_detached_volume(self):
+    def test_07_resize_fail(self):
+        """Verify invalid options fail to Resize a volume"""
+        # Verify the size is the new size is what we wanted it to be.
+        self.debug("Fail Resize Volume ID: %s" % self.volume.id)
+
+        # first, an invalid id
+        cmd                = resizeVolume.resizeVolumeCmd()
+        cmd.id             = "invalid id"
+        cmd.diskofferingid = self.services['resizeddiskofferingid']
+        success            = False
+        try:
+            response = self.apiClient.resizeVolume(cmd)
+        except Exception as ex:
+            if str(ex) == "HTTP Error 431: 431":
+                success = True
+        self.assertEqual(success, True, "ResizeVolume - verify invalid id is handled appropriately")
+
+        # Next, we'll try an invalid disk offering id
+        cmd.id             = self.volume.id
+        cmd.diskofferingid = "invalid id"
+        success            = False
+        try:
+            response = self.apiClient.resizeVolume(cmd)
+        except Exception as ex:
+            if "need to specify a disk offering" in str(ex):
+                success = True
+        self.assertEqual(success, True, "ResizeVolume - verify disk offering is handled appropriately")
+
+        # Ok, now let's try and resize a volume that is not custom.
+        cmd.id             = self.volume.id
+        cmd.diskofferingid = self.services['diskofferingid']
+        cmd.size           = 4
+        currentSize        = self.volume.size
+
+        self.apiClient.resizeVolume(cmd)
+        count = 0
+        success = True
+        while count < 10:
+            list_volume_response = list_volumes(
+                                                self.apiClient,
+                                                id=self.volume.id,
+                                                type='DATADISK'
+                                                )
+            for vol in list_volume_response:
+                if vol.id == self.volume.id and vol.size != currentSize:
+                    success = False
+            if success:
+                break
+            else:
+                time.sleep(1)
+                count += 1
+
+        self.assertEqual(
+                         success,
+                         True,
+                         "Verify the volume did not resize"
+                         )
+
+
+    @attr(tags = ["advanced", "advancedns", "smoke"])
+    def test_08_resize_volume(self):
+        """Resize a volume"""
+        # Verify the size is the new size is what we wanted it to be.
+        self.debug("Resize Volume ID: %s" % self.volume.id)
+
+        cmd                = resizeVolume.resizeVolumeCmd()
+        cmd.id             = self.volume.id
+        cmd.diskofferingid = self.services['resizeddiskofferingid']
+
+        self.apiClient.resizeVolume(cmd)
+
+        count = 0
+        success = False
+        while count < 3:
+            list_volume_response = list_volumes(
+                                                self.apiClient,
+                                                id=self.volume.id,
+                                                type='DATADISK'
+                                                )
+            for vol in list_volume_response:
+                if vol.id == self.volume.id and vol.size == 3221225472L:
+                    success = True
+            if success:
+                break
+            else:
+                time.sleep(10)
+                count += 1
+
+        self.assertEqual(
+                         success,
+                         True,
+                         "Check if the volume resized appropriately"
+                         )
+
+    @attr(tags = ["advanced", "advancedns", "smoke"])
+    def test_09_delete_detached_volume(self):
         """Delete a Volume unattached to an VM
         """
         # Validate the following

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ac15f932/tools/marvin/marvin/integration/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py
index 0daea5d..446da83 100644
--- a/tools/marvin/marvin/integration/lib/base.py
+++ b/tools/marvin/marvin/integration/lib/base.py
@@ -509,6 +509,12 @@ class Volume:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.listVolumes(cmd))
 
+    def resize(cls, apiclient, **kwargs):
+        """Resize a volume"""
+        cmd = resizeVolume.resizeVolumeCmd()
+        cmd.id = self.id
+        [setattr(cmd, k, v) for k, v in kwargs.items()]
+        return(apiclient.resizeVolume(cmd))
 
 class Snapshot:
     """Manage Snapshot Lifecycle


Mime
View raw message