You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/04/16 20:03:51 UTC

[18/50] [abbrv] git commit: updated refs/heads/ui-new-project-switcher to a748988

CLOUDSTACK-1995: Enhance resize volume tests to support xenserver hypervisor and fix few test flow errors

Signed-off-by: Prasanna Santhanam <ts...@apache.org>


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

Branch: refs/heads/ui-new-project-switcher
Commit: 0abfe240c31e410e286169ac1f75aa564f267280
Parents: 48c1c00
Author: Talluri <Sr...@citrix.com>
Authored: Mon Apr 15 16:47:34 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Mon Apr 15 12:00:08 2013 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_volumes.py |   55 ++++++++++++++++++++++-----
 1 files changed, 45 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0abfe240/test/integration/smoke/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py
index 36eb5de..7d910d4 100644
--- a/test/integration/smoke/test_volumes.py
+++ b/test/integration/smoke/test_volumes.py
@@ -78,13 +78,13 @@ class Services:
                         "password": "password",
                         "ssh_port": 22,
                         "diskname": "TestDiskServ",
-                        "hypervisor": 'XenServer',
+                        "hypervisor": 'KVM',
                         "privateport": 22,
                         "publicport": 22,
                         "protocol": 'TCP',
                         "diskdevice": "/dev/xvdb",
-                        "ostype": 'CentOS 5.3 (64-bit)',
-                        "mode": 'basic',
+                        "ostype": 'CentOS 5.5 (64-bit)',
+                        "mode": 'advanced',
                         "sleep": 10,
                         "timeout": 600,
                     }
@@ -358,6 +358,12 @@ class TestVolumes(cloudstackTestCase):
     def setUp(self):
         self.apiClient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
+        self.cleanup = []
+
+    def tearDown(self):
+        #Clean up, terminate the created volumes
+        cleanup_resources(self.apiClient, self.cleanup)
+        return
 
     @attr(tags = ["advanced", "advancedns", "smoke"])
     def test_02_attach_volume(self):
@@ -535,9 +541,13 @@ class TestVolumes(cloudstackTestCase):
         try:
             response = self.apiClient.resizeVolume(cmd)
         except Exception as ex:
-            if str(ex) == "HTTP Error 431: 431":
+            #print str(ex)
+            if "HTTP Error 431:" in str(ex):
                 success = True
-        self.assertEqual(success, True, "ResizeVolume - verify invalid id is handled appropriately")
+        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
@@ -546,16 +556,29 @@ class TestVolumes(cloudstackTestCase):
         try:
             response = self.apiClient.resizeVolume(cmd)
         except Exception as ex:
-            if "need to specify a disk offering" in str(ex):
+            if "HTTP Error 431:" in str(ex):
                 success = True
-        self.assertEqual(success, True, "ResizeVolume - verify disk offering is handled appropriately")
-
+        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.debug(
+                "Attaching volume (ID: %s) to VM (ID: %s)" % (
+                                                    self.volume.id,
+                                                    self.virtual_machine.id)
+                 )
+        #attach the volume
+        self.virtual_machine.attach_volume(self.apiClient, self.volume)
+        #stop the vm if it is on xenserver
+        if self.services['hypervisor'].lower() == "xenserver":
+            self.virtual_machine.stop(self.apiClient)
+
         self.apiClient.resizeVolume(cmd)
         count = 0
         success = True
@@ -566,7 +589,7 @@ class TestVolumes(cloudstackTestCase):
                                                 type='DATADISK'
                                                 )
             for vol in list_volume_response:
-                if vol.id == self.volume.id and vol.size != currentSize:
+                if vol.id == self.volume.id and vol.size != currentSize and vol.state != "Resizing":
                     success = False
             if success:
                 break
@@ -579,12 +602,21 @@ class TestVolumes(cloudstackTestCase):
                          True,
                          "Verify the volume did not resize"
                          )
-
+        self.virtual_machine.detach_volume(self.apiClient, self.volume)
+        self.cleanup.append(self.volume)
 
     @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(
+                "Attaching volume (ID: %s) to VM (ID: %s)" % (
+                                                    self.volume.id,
+                                                    self.virtual_machine.id
+                                                    ))
+        self.virtual_machine.attach_volume(self.apiClient, self.volume)
+        if self.services['hypervisor'].lower() == "xenserver":
+            self.virtual_machine.stop(self.apiClient)
         self.debug("Resize Volume ID: %s" % self.volume.id)
 
         cmd                = resizeVolume.resizeVolumeCmd()
@@ -616,6 +648,9 @@ class TestVolumes(cloudstackTestCase):
                          "Check if the volume resized appropriately"
                          )
 
+        self.virtual_machine.detach_volume(self.apiClient, self.volume)
+        self.cleanup.append(self.volume)
+
     @attr(tags = ["advanced", "advancedns", "smoke"])
     def test_09_delete_detached_volume(self):
         """Delete a Volume unattached to an VM