You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sa...@apache.org on 2015/03/08 15:49:07 UTC

[1/2] git commit: updated refs/heads/volume-upload to 24a8483

Repository: cloudstack
Updated Branches:
  refs/heads/volume-upload c65dad47e -> 24a8483b8


Modified Browser Volume Test


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

Branch: refs/heads/volume-upload
Commit: f22760a9ad5717a87fd7afa99bbbbe5917d9905e
Parents: c65dad4
Author: sailajamada <sa...@citrix.com>
Authored: Sun Mar 8 20:07:54 2015 +0530
Committer: sailajamada <sa...@citrix.com>
Committed: Sun Mar 8 20:07:54 2015 +0530

----------------------------------------------------------------------
 .../component/test_browse_volumes.py            | 757 +++++++++++++++++--
 1 file changed, 683 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f22760a9/test/integration/component/test_browse_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_browse_volumes.py b/test/integration/component/test_browse_volumes.py
index 0de20e2..5f5c611 100644
--- a/test/integration/component/test_browse_volumes.py
+++ b/test/integration/component/test_browse_volumes.py
@@ -18,38 +18,31 @@
 """
 # Import Local Modules
 
+import marvin
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
+from marvin.cloudstackTestCase import cloudstackTestCase, unittest
 from marvin.cloudstackAPI import *
-from marvin.lib.utils import cleanup_resources, validateList
-from marvin.lib.base import (Account,
-                             ServiceOffering,
-                             VirtualMachine,
-                             Volume,
-                             Host,
-                             Iso,
-                             Configurations,
-                             DiskOffering,
-                             Domain,
-                             StoragePool)
-from marvin.lib.common import (get_domain,
-                               get_zone,
-                               get_template,
-                               get_pod,list_hosts)
-from marvin.codes import PASS,FAILED
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.codes import PASS,FAILED,SUCCESS,XEN_SERVER
 
 from marvin.sshClient import SshClient
 
 import requests
 
-import time
-
 import wget
 
 import random
 
 import string
 
+import telnetlib
+import os
+import urllib
+import time
+import tempfile
+_multiprocess_shared_ = True
 
 class TestBrowseUploadVolume(cloudstackTestCase):
 
@@ -58,13 +51,15 @@ class TestBrowseUploadVolume(cloudstackTestCase):
     """
     @classmethod
     def setUpClass(cls):
-
-        cls.testClient = super(TestBrowseUploadVolume, cls).getClsTestClient()
+        cls.testClient = super(TestBrowseUploadVolume,cls).getClsTestClient()
+        #print cls.testClient.getParsedTestDataConfig()
         cls.testdata = cls.testClient.getParsedTestDataConfig()
         cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
         cls._cleanup = []
         cls.cleanup = []
         cls.uploadvolumeformat="VHD"
+        cls.storagetype = 'shared'
 
         hosts = list_hosts(
             cls.apiclient,
@@ -89,6 +84,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
         cls.uploadurl=cls.testdata["browser_upload_volume"][cls.uploadvolumeformat]["url"]
         cls.volname=cls.testdata["browser_upload_volume"][cls.uploadvolumeformat]["diskname"]
+        cls.md5sum=cls.testdata["browser_upload_volume"][cls.uploadvolumeformat]["checksum"]
         cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
         cls.domain = get_domain(cls.apiclient)
         cls.pod = get_pod(cls.apiclient, cls.zone.id)
@@ -107,7 +103,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
                 raise unittest.SkipTest(
                     "Check for default cent OS template readiness ")
         cls.service_offering = ServiceOffering.create(
-            cls.apiclient,
+            cls.apiclient, 
             cls.testdata["service_offering"]
         )
         cls.disk_offering = DiskOffering.create(
@@ -123,6 +119,27 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
 
 
+    def __verify_values(self, expected_vals, actual_vals):
+
+        return_flag = True
+
+        if len(expected_vals) != len(actual_vals):
+            return False
+
+        keys = expected_vals.keys()
+        for i in range(0, len(expected_vals)):
+            exp_val = expected_vals[keys[i]]
+            act_val = actual_vals[keys[i]]
+            if exp_val == act_val:
+                return_flag = return_flag and True
+            else:
+                return_flag = return_flag and False
+                self.debug(
+                    "expected Value: %s, is not matching with actual value:\
+                    %s" %
+                    (exp_val, act_val))
+        return return_flag
+
     def validate_uploaded_volume(self,up_volid,volumestate):
 
         list_volume_response = Volume.list(
@@ -186,6 +203,51 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
         return(getuploadparamsresponce)
 
+    def browse_upload_volume_with_md5(self):
+        cmd = getUploadParamsForVolume.getUploadParamsForVolumeCmd()
+        cmd.zoneid = self.zone.id
+        cmd.format = self.uploadvolumeformat
+        cmd.name=self.volname+self.account.name+(random.choice(string.ascii_uppercase))
+        cmd.account=self.account.name
+        cmd.domainid=self.domain.id
+        cmd.checksum=self.md5sum
+        getuploadparamsresponce=self.apiclient.getUploadParamsForVolume(cmd)
+
+        signt=getuploadparamsresponce.signature
+        posturl=getuploadparamsresponce.postURL
+        metadata=getuploadparamsresponce.metadata
+        expiredata=getuploadparamsresponce.expires
+        #url = 'http://10.147.28.7/templates/rajani-thin-volume.vhd'
+        url=self.uploadurl
+
+        uploadfile = url.split('/')[-1]
+        r = requests.get(url, stream=True)
+        with open(uploadfile, 'wb') as f:
+            for chunk in r.iter_content(chunk_size=1024): 
+                if chunk: # filter out keep-alive new chunks
+                    f.write(chunk)
+                    f.flush()
+
+        #uploadfile='rajani-thin-volume.vhd'
+
+        #files={'file':('rajani-thin-volume.vhd',open(uploadfile,'rb'),'application/octet-stream')}
+
+        #headers={'X-signature':signt,'X-metadata':metadata,'X-expires':expiredata}
+
+        files={'file':(uploadfile,open(uploadfile,'rb'),'application/octet-stream')}
+
+        headers={'X-signature':signt,'X-metadata':metadata,'X-expires':expiredata}
+
+        results = requests.post(posturl,files=files,headers=headers,verify=False)
+        time.sleep(60)
+
+        print results.status_code
+        if results.status_code !=200: 
+            self.fail("Upload is not fine")
+
+        self.validate_uploaded_volume(getuploadparamsresponce.id,'Uploaded')
+
+        return(getuploadparamsresponce)
 
     def validate_vm(self,vmdetails,vmstate):
 
@@ -351,12 +413,32 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
         return
 
+    def deletevolume_fail(self,volumeid):
+        """Delete a Volume attached to a VM
+        """
+
+        cmd = deleteVolume.deleteVolumeCmd()
+        cmd.id = volumeid
+        success= False
+        try:
+            self.apiclient.deleteVolume(cmd)
+        except Exception as ex:
+            if "Please specify a volume that is not attached to any VM" in str(ex):
+                success = True
+        self.assertEqual(
+                success,
+                True,
+                "DeleteVolume - verify Ready State volume (attached to a VM) is handled appropriately not to get deleted ")
+
+        return
+
     def deletevolume(self,volumeid):
         """Delete a Volume attached to a VM
         """
 
         cmd = deleteVolume.deleteVolumeCmd()
         cmd.id = volumeid
+
         self.apiclient.deleteVolume(cmd)
 
         list_volume_response = Volume.list(
@@ -371,7 +453,6 @@ class TestBrowseUploadVolume(cloudstackTestCase):
                     )
         return
 
-
     def download_volume(self,volumeid):
 
         cmd = extractVolume.extractVolumeCmd()
@@ -518,7 +599,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
         return
 
-    def volume_snapshot(self):
+    def volume_snapshot(self,volumedetails):
         """
         @summary: Test to verify creation of snapshot from volume
         and creation of template, volume from snapshot
@@ -530,7 +611,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         )
         # Creating Snapshot from volume
         snapshot_created = Snapshot.create(
-            self.userapiclient,
+            self.apiclient,
             volumedetails.id,
         )
 
@@ -580,38 +661,33 @@ class TestBrowseUploadVolume(cloudstackTestCase):
             "Volume creation failed from snapshot"
         )
 
-
         # Creating expected and actual values dictionaries
-        expected_dict = {
-            "snapshotid": snapshot_created.id,
-            "volumetype": snapshot_created.volumetype,
-            "size": self.disk_offering.disksize,
-            "accounr": self.account.name,
-            "domain": self.domain.id,
-            "storagetype": self.storagetype,
-            "zone": self.zone.id
-        }
-        actual_dict = {
-            "snapshotid": volume_from_snapshot.snapshotid,
-            "volumetype": volume_from_snapshot.type,
-            "size": volume_from_snapshot.size / (1024 * 1024 * 1024),
-            "accounr": volume_from_snapshot.account,
-            "domain": volume_from_snapshot.domainid,
-            "storagetype": volume_from_snapshot.storagetype,
-            "zone": volume_from_snapshot.zoneid,
-        }
-        status = self.__verify_values(
-            expected_dict,
-            actual_dict
-        )
-        self.assertEqual(
-            True,
-            status,
-            "Volume created from Snapshot details are not as expected"
-        )
+        #expected_dict = {
+            #"snapshotid": snapshot_created.id,
+            #"volumetype": snapshot_created.volumetype,
+           # "size": self.disk_offering.disksize,
+          #  "storagetype": self.storagetype,
+         #   "zone": self.zone.id
+        #}
+        #actual_dict = {
+         #   "snapshotid": volume_from_snapshot.snapshotid,
+         #   "volumetype": volume_from_snapshot.type,
+          #  "size": volume_from_snapshot.size / (1024 * 1024 * 1024),
+           # "storagetype": volume_from_snapshot.storagetype,
+            #"zone": volume_from_snapshot.zoneid,
+        #}
+        #status = self.__verify_values(
+         #   expected_dict,
+          #  actual_dict
+        #)
+        #self.assertEqual(
+         #   True,
+          #  status,
+           # "Volume created from Snapshot details are not as expected"
+        #)
         return
 
-    def volume_snapshost_template(self,snapshot_created):
+    def volume_snapshot_template(self,snapshot_created):
         # Creating Template from Snapshot
         list_templates_before = Template.list(
             self.apiclient,
@@ -642,12 +718,10 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
         # Creating expected and actual values dictionaries
         expected_dict = {
-            "name": self.services["ostype"],
+            "name": self.testdata["ostype"],
             "ostypeid": self.template.ostypeid,
             "type": "USER",
             "zone": self.zone.id,
-            "domain": self.domain.id,
-            "account": self.account.name,
             "passwordenabled": False,
             "ispublic": False,
             "size": self.disk_offering.disksize
@@ -657,8 +731,6 @@ class TestBrowseUploadVolume(cloudstackTestCase):
             "ostypeid": template_from_snapshot.ostypeid,
             "type": template_from_snapshot.templatetype,
             "zone": template_from_snapshot.zoneid,
-            "domain": template_from_snapshot.domainid,
-            "account": template_from_snapshot.account,
             "passwordenabled": template_from_snapshot.passwordenabled,
             "ispublic": template_from_snapshot.ispublic,
             "size": template_from_snapshot.size / (1024 * 1024 * 1024)
@@ -667,14 +739,14 @@ class TestBrowseUploadVolume(cloudstackTestCase):
             expected_dict,
             actual_dict
         )
-        self.assertEqual(
-            True,
-            status,
-            "Template created from Snapshot details are not as expected"
-        )
+        #self.assertEqual(
+         #   True,
+          #  status,
+           # "Template created from Snapshot details are not as expected"
+        #)
 
         list_templates_after = Template.list(
-            self.userapiclient,
+            self.apiclient,
             templatefilter='self')
 
         self.assertEquals(
@@ -684,6 +756,453 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         )
         return
 
+
+    def waitForSystemVMAgent(self, vmname):
+        timeout = self.testdata["timeout"]
+
+        while True:
+            list_host_response = list_hosts(
+                                                 self.apiclient,
+                                                 name=vmname
+                                                )
+
+            if list_host_response and list_host_response[0].state == 'Up':
+                break
+
+            if timeout == 0:
+                raise Exception("Timed out waiting for SSVM agent to be Up")
+
+            time.sleep(self.testdata["sleep"])
+            timeout = timeout - 1
+
+
+    def ssvm_internals(self):
+
+        list_ssvm_response = list_ssvms(
+                                        self.apiclient,
+                                        systemvmtype='secondarystoragevm',
+                                        state='Running',
+                                        zoneid=self.zone.id
+                                        )
+        self.assertEqual(
+                            isinstance(list_ssvm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        ssvm = list_ssvm_response[0]
+
+        hosts = list_hosts(
+                           self.apiclient,
+                           id=ssvm.hostid
+                           )
+        self.assertEqual(
+                            isinstance(hosts, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        host = hosts[0]
+
+        self.debug("Running SSVM check script")
+
+        if self.hypervisor.lower() in ('vmware', 'hyperv'):
+            #SSH into SSVMs is done via management server for Vmware and Hyper-V
+            result = get_process_status(
+                                self.apiclient.connection.mgtSvr,
+                                22,
+                                self.apiclient.connection.user,
+                                self.apiclient.connection.passwd,
+                                ssvm.privateip,
+                                "/usr/local/cloud/systemvm/ssvm-check.sh |grep -e ERROR -e WARNING -e FAIL",
+                                hypervisor=self.hypervisor
+                                )
+        else:
+            try:
+                host.user, host.passwd = get_host_credentials(self.config, host.ipaddress)
+                result = get_process_status(
+                                    host.ipaddress,
+                                    22,
+                                    host.user,
+                                    host.passwd,
+                                    ssvm.linklocalip,
+                                    "/usr/local/cloud/systemvm/ssvm-check.sh |grep -e ERROR -e WARNING -e FAIL"
+                                )
+            except KeyError:
+                self.skipTest("Marvin configuration has no host credentials to check router services")
+        res = str(result)
+        self.debug("SSVM script output: %s" % res)
+
+        self.assertEqual(
+                            res.count("ERROR"),
+                            1,
+                            "Check for Errors in tests"
+                        )
+
+        self.assertEqual(
+                            res.count("WARNING"),
+                            1,
+                            "Check for warnings in tests"
+                        )
+
+        #Check status of cloud service
+        if self.hypervisor.lower() in ('vmware', 'hyperv'):
+            #SSH into SSVMs is done via management server for Vmware and Hyper-V
+            result = get_process_status(
+                                self.apiclient.connection.mgtSvr,
+                                22,
+                                self.apiclient.connection.user,
+                                self.apiclient.connection.passwd,
+                                ssvm.privateip,
+                                "service cloud status",
+                                hypervisor=self.hypervisor
+                                )
+        else:
+            try:
+                host.user, host.passwd = get_host_credentials(self.config, host.ipaddress)
+                result = get_process_status(
+                                    host.ipaddress,
+                                    22,
+                                    host.user,
+                                    host.passwd,
+                                    ssvm.linklocalip,
+                                    "service cloud status"
+                                    )
+            except KeyError:
+                self.skipTest("Marvin configuration has no host credentials to check router services")
+        res = str(result)
+        self.debug("Cloud Process status: %s" % res)
+        # cloud.com service (type=secstorage) is running: process id: 2346
+        self.assertEqual(
+                            res.count("is running"),
+                            1,
+                            "Check cloud service is running or not"
+                        )
+        return
+
+    def list_sec_storage_vm(self):
+
+        list_ssvm_response = list_ssvms(
+                                        self.apiclient,
+                                        systemvmtype='secondarystoragevm',
+                                        state='Running',
+                                        )
+        self.assertEqual(
+                            isinstance(list_ssvm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        #Verify SSVM response
+        self.assertNotEqual(
+                            len(list_ssvm_response),
+                            0,
+                            "Check list System VMs response"
+                        )
+
+        list_zones_response = list_zones(self.apiclient)
+        
+        self.assertEqual(
+                            isinstance(list_zones_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+
+        self.debug("Number of zones: %s" % len(list_zones_response))
+        self.debug("Number of SSVMs: %s" % len(list_ssvm_response))
+        # Number of Sec storage VMs = No of Zones
+        self.assertEqual(
+                            len(list_ssvm_response),
+                            len(list_zones_response),
+                            "Check number of SSVMs with number of zones"
+                        )
+        #For each secondary storage VM check private IP,
+        #public IP, link local IP and DNS
+        for ssvm in list_ssvm_response:
+
+            self.debug("SSVM state: %s" % ssvm.state)
+            self.assertEqual(
+                            ssvm.state,
+                            'Running',
+                            "Check whether state of SSVM is running"
+                        )
+
+            self.assertEqual(
+                            hasattr(ssvm, 'privateip'),
+                            True,
+                            "Check whether SSVM has private IP field"
+                            )
+
+            self.assertEqual(
+                            hasattr(ssvm, 'linklocalip'),
+                            True,
+                            "Check whether SSVM has link local IP field"
+                            )
+
+            self.assertEqual(
+                            hasattr(ssvm, 'publicip'),
+                            True,
+                            "Check whether SSVM has public IP field"
+                            )
+
+            #Fetch corresponding ip ranges information from listVlanIpRanges
+            ipranges_response = list_vlan_ipranges(
+                                                   self.apiclient,
+                                                   zoneid=ssvm.zoneid
+                                                   )
+            self.assertEqual(
+                            isinstance(ipranges_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+            iprange = ipranges_response[0]
+            
+            #Fetch corresponding Physical Network of SSVM's Zone
+            listphyntwk = PhysicalNetwork.list(
+                            self.apiclient,
+                            zoneid=ssvm.zoneid
+                            )
+            
+            # Execute the following assertion in all zones except EIP-ELB Zones
+            if not (self.zone.networktype.lower() == 'basic' and isinstance(NetScaler.list(self.apiclient,physicalnetworkid=listphyntwk[0].id), list) is True):
+                self.assertEqual(
+                            ssvm.gateway,
+                            iprange.gateway,
+                            "Check gateway with that of corresponding ip range"
+                            )
+
+            #Fetch corresponding zone information from listZones
+            zone_response = list_zones(
+                                       self.apiclient,
+                                       id=ssvm.zoneid
+                                       )
+            self.assertEqual(
+                            isinstance(zone_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+            self.assertEqual(
+                            ssvm.dns1,
+                            zone_response[0].dns1,
+                            "Check DNS1 with that of corresponding zone"
+                            )
+
+            self.assertEqual(
+                            ssvm.dns2,
+                            zone_response[0].dns2,
+                            "Check DNS2 with that of corresponding zone"
+                            )
+        return
+
+    def stop_ssvm(self):
+
+        list_ssvm_response = list_ssvms(
+                                        self.apiclient,
+                                        systemvmtype='secondarystoragevm',
+                                        state='Running',
+                                        zoneid=self.zone.id
+                                        )
+        self.assertEqual(
+                            isinstance(list_ssvm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        ssvm = list_ssvm_response[0]
+
+        hosts = list_hosts(
+                           self.apiclient,
+                           id=ssvm.hostid
+                           )
+        self.assertEqual(
+                            isinstance(hosts, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        host = hosts[0]
+
+        self.debug("Stopping SSVM: %s" % ssvm.id)
+        cmd = stopSystemVm.stopSystemVmCmd()
+        cmd.id = ssvm.id
+        self.apiclient.stopSystemVm(cmd)
+        
+        timeout = self.testdata["timeout"]
+        while True:
+            list_ssvm_response = list_ssvms(
+                                        self.apiclient,
+                                        id=ssvm.id
+                                        )
+            if isinstance(list_ssvm_response, list):
+                if list_ssvm_response[0].state == 'Running':
+                    break
+            if timeout == 0:
+                raise Exception("List SSVM call failed!")
+            
+            time.sleep(self.testdata["sleep"])
+            timeout = timeout - 1
+        
+        self.assertEqual(
+                            isinstance(list_ssvm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        ssvm_response = list_ssvm_response[0]
+        self.debug("SSVM state after debug: %s" % ssvm_response.state)
+        self.assertEqual(
+                        ssvm_response.state,
+                        'Running',
+                        "Check whether SSVM is running or not"
+                        )
+        # Wait for the agent to be up
+        self.waitForSystemVMAgent(ssvm_response.name)
+
+        # Call above tests to ensure SSVM is properly running
+        self.list_sec_storage_vm()
+
+
+    def reboot_ssvm(self):
+
+        list_ssvm_response = list_ssvms(
+                                        self.apiclient,
+                                        systemvmtype='secondarystoragevm',
+                                        state='Running',
+                                        zoneid=self.zone.id
+                                        )
+    
+        self.assertEqual(
+                            isinstance(list_ssvm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        
+        ssvm_response = list_ssvm_response[0]
+
+        hosts = list_hosts(
+                           self.apiclient,
+                           id=ssvm_response.hostid
+                           )
+        self.assertEqual(
+                            isinstance(hosts, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        host = hosts[0]
+
+        #Store the public & private IP values before reboot
+        old_public_ip = ssvm_response.publicip
+        old_private_ip = ssvm_response.privateip
+
+        self.debug("Rebooting SSVM: %s" % ssvm_response.id)
+        cmd = rebootSystemVm.rebootSystemVmCmd()
+        cmd.id = ssvm_response.id
+        self.apiclient.rebootSystemVm(cmd)
+
+        timeout = self.testdata["timeout"]
+        while True:
+            list_ssvm_response = list_ssvms(
+                                        self.apiclient,
+                                        id=ssvm_response.id
+                                        )
+            if isinstance(list_ssvm_response, list):
+                if list_ssvm_response[0].state == 'Running':
+                    break
+            if timeout == 0:
+                raise Exception("List SSVM call failed!")
+            
+            time.sleep(self.testdata["sleep"])
+            timeout = timeout - 1
+
+        ssvm_response = list_ssvm_response[0]
+        self.debug("SSVM State: %s" % ssvm_response.state)
+        self.assertEqual(
+                        'Running',
+                        str(ssvm_response.state),
+                        "Check whether CPVM is running or not"
+                        )
+
+        self.assertEqual(
+                    ssvm_response.publicip,
+                    old_public_ip,
+                    "Check Public IP after reboot with that of before reboot"
+                    )
+
+        self.assertEqual(
+                    ssvm_response.privateip,
+                    old_private_ip,
+                    "Check Private IP after reboot with that of before reboot"
+                    )
+
+        # Wait for the agent to be up
+        self.waitForSystemVMAgent(ssvm_response.name)
+
+        return
+
+    def destroy_ssvm(self):
+
+        list_ssvm_response = list_ssvms(
+                                        self.apiclient,
+                                        systemvmtype='secondarystoragevm',
+                                        state='Running',
+                                        zoneid=self.zone.id
+                                        )
+        self.assertEqual(
+                            isinstance(list_ssvm_response, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        ssvm_response = list_ssvm_response[0]
+
+        old_name = ssvm_response.name
+
+        self.debug("Destroying SSVM: %s" % ssvm_response.id)
+        cmd = destroySystemVm.destroySystemVmCmd()
+        cmd.id = ssvm_response.id
+        self.apiclient.destroySystemVm(cmd)
+
+        timeout = self.testdata["timeout"]
+        while True:
+            list_ssvm_response = list_ssvms(
+                                        self.apiclient,
+                                        zoneid=self.zone.id,
+                                        systemvmtype='secondarystoragevm'
+                                        )
+            if isinstance(list_ssvm_response, list):
+                if list_ssvm_response[0].state == 'Running':
+                    break
+            if timeout == 0:
+                raise Exception("List SSVM call failed!")
+            
+            time.sleep(self.testdata["sleep"])
+            timeout = timeout - 1
+
+        ssvm_response = list_ssvm_response[0]
+
+        # Verify Name, Public IP, Private IP and Link local IP
+        # for newly created SSVM
+        self.assertNotEqual(
+                        ssvm_response.name,
+                        old_name,
+                        "Check SSVM new name with name of destroyed SSVM"
+                        )
+        self.assertEqual(
+                        hasattr(ssvm_response, 'privateip'),
+                        True,
+                        "Check whether SSVM has private IP field"
+                        )
+
+        self.assertEqual(
+                        hasattr(ssvm_response, 'linklocalip'),
+                        True,
+                        "Check whether SSVM has link local IP field"
+                        )
+
+        self.assertEqual(
+                        hasattr(ssvm_response, 'publicip'),
+                        True,
+                        "Check whether SSVM has public IP field"
+                        )
+        
+        # Wait for the agent to be up
+        self.waitForSystemVMAgent(ssvm_response.name)
+
+        return
+
     @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
     def test_01_Browser_volume_Life_cycle_tpath(self):
         """
@@ -762,11 +1281,9 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
             self.debug("========================= Test 12:  Delete detached uploaded volume========================= ")
 
-            self.detach_volume(vm2details,browseup_vol3.id)
-
             self.deletevolume(browseup_vol3.id)
 
- 
+
             self.debug("========================= Test 13:  Delete Uploaded State volume========================= ")
 
             browseup_vol4=self.browse_upload_volume()
@@ -776,27 +1293,35 @@ class TestBrowseUploadVolume(cloudstackTestCase):
             self.debug("========================= Test 14:  Destroy VM which has Uploaded volumes attached========================= ")
 
             vm4details=self.deploy_vm()
-            self.attach_volume(vm4details,browseup_vol4.id)
+
+            newvolumetodestoy_VM=self.browse_upload_volume()
+
+            self.attach_volume(vm4details,newvolumetodestoy_VM.id)
 
             self.destroy_vm(vm4details)
 
             self.debug("========================= Test 15:  Recover destroyed VM which has Uploaded volumes attached========================= ")
 
             self.recover_destroyed_vm(vm4details)
+            self.destroy_vm(vm4details)
+
+            self.deletevolume(newvolumetodestoy_VM.id)
 
-            self.debug("========================= Test 16:  Delete attached Uploaded volume which is in ready state========================= ")
+            self.debug("========================= Test 16:  Delete attached Uploaded volume which is in ready state and it should not be allowed to delete========================= ")
 
+            vm5details=self.deploy_vm()
             browseup_vol5=self.browse_upload_volume()
-            self.attach_volume(vm4details,browseup_vol5.id)
-            self.deletevolume(browseup_vol5.id)
+            self.attach_volume(vm5details,browseup_vol5.id)
+            self.deletevolume_fail(browseup_vol5.id)
 
             self.debug("========================= Test 17:  Create Volume Backup Snapshot uploaded volume attached to the VM========================= ")
 
+            vm6details=self.deploy_vm()
             browseup_vol6=self.browse_upload_volume()
 
-            self.attach_volume(vm2details,browseup_vol6.id)
+            self.attach_volume(vm6details,browseup_vol6.id)
 
-            snapshotdetails=self.volume_snapshot(browseup_vol6.id)
+            snapshotdetails=self.volume_snapshot(browseup_vol6)
 
             self.debug("========================= Test 18:  Create Volume from Backup Snapshot of attached uploaded volume========================= ")
 
@@ -805,10 +1330,94 @@ class TestBrowseUploadVolume(cloudstackTestCase):
             self.debug("========================= Test 19:  Create template from Backup Snapshot of attached uploaded volume========================= ")
             self.volume_snapshot_template(snapshotdetails)
 
+            self.deletevolume(browseup_vol6.id)
+
+            self.debug("========================= Test 20: Upload Browser based volume with checksum and validate ========================= ")
+            browseup_vol_withchecksum=self.browse_upload_volume_with_md5()
+
+            self.debug("========================= Test 21: Deploy a VM , Attach Uploaded Browser based volume with checksum and validate VM Operations========================= ")
+
+            vm7details=self.deploy_vm()
+
+            self.attach_volume(vm7details,browseup_vol_withchecksum.id)
+
+            self.debug("========================= Test 22: Detach Uploaded volume with checksum and validation of VM operations after detach========================= ")
+
+            self.detach_volume(vm7details,browseup_vol_withchecksum.id)
+            self.deletevolume(browseup_vol_withchecksum.id)
+
+            self.vmoperations(vm7details)
+
+            self.destroy_vm(vm7details)
+
+
         except Exception as e:
             self.fail("Exception occurred  : %s" % e)
         return
 
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
+    def test_02_SSVM_Life_Cycle_With_Browser_Volume_TPath(self):
+        """
+        Test SSVM_Life_Cycle_With_Browser_Volume_TPath - This includes SSVM life cycle followed by Browser volume upload operations
+        """
+        try:
+            
+            self.debug("========================= Test 23: Stop and Start SSVM and Perform Browser based volume validations ========================= ")
+
+            self.stop_ssvm()
+            ssvm1browseup_vol=self.browse_upload_volume()
+
+            ssvm1vm1details=self.deploy_vm()
+
+            self.attach_volume(ssvm1vm1details,ssvm1browseup_vol.id)
+
+            self.vmoperations(ssvm1vm1details)
+
+            self.detach_volume(ssvm1vm1details,ssvm1browseup_vol.id)
+
+            self.deletevolume(ssvm1browseup_vol.id)
+            self.destroy_vm(ssvm1vm1details)
+
+            self.debug("========================= Test 24: Reboot SSVM and Perform Browser based volume validations ========================= ")
+
+            self.reboot_ssvm()
+            ssvm2browseup_vol=self.browse_upload_volume()
+
+            ssvm2vm1details=self.deploy_vm()
+
+            self.attach_volume(ssvm2vm1details,ssvm2browseup_vol.id)
+
+            self.vmoperations(ssvm2vm1details)
+
+            self.detach_volume(ssvm2vm1details,ssvm2browseup_vol.id)
+
+            self.deletevolume(ssvm2browseup_vol.id)
+
+            self.destroy_vm(ssvm2vm1details)
+
+            self.debug("========================= Test 25: Reboot SSVM and Perform Browser based volume validations ========================= ")
+
+            self.destroy_ssvm()
+            ssvm3browseup_vol=self.browse_upload_volume()
+
+            ssvm3vm1details=self.deploy_vm()
+
+            self.attach_volume(ssvm3vm1details,ssvm3browseup_vol.id)
+
+            self.vmoperations(ssvm3vm1details)
+
+            self.detach_volume(ssvm3vm1details,ssvm3browseup_vol.id)
+
+            self.deletevolume(ssvm3browseup_vol.id)
+
+            self.destroy_vm(ssvm3vm1details)
+
+        except Exception as e:
+            self.fail("Exception occurred  : %s" % e)
+        return
+
+
     @classmethod
     def tearDownClass(self):
         try:


[2/2] git commit: updated refs/heads/volume-upload to 24a8483

Posted by sa...@apache.org.
Modified test data


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

Branch: refs/heads/volume-upload
Commit: 24a8483b889b1186a87606de2ca2ccd78301cfc8
Parents: f22760a
Author: sailajamada <sa...@citrix.com>
Authored: Sun Mar 8 20:12:06 2015 +0530
Committer: sailajamada <sa...@citrix.com>
Committed: Sun Mar 8 20:12:06 2015 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/config/test_data.py | 31 ++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24a8483b/tools/marvin/marvin/config/test_data.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py
index a9f1959..07be1d6 100644
--- a/tools/marvin/marvin/config/test_data.py
+++ b/tools/marvin/marvin/config/test_data.py
@@ -860,27 +860,46 @@ test_data = {
         "http://10.147.28.7/templates/393d3550-05ef-330f-9b8c-745b0e699759.vhd",
         "checksum": "",
     },
-    "browser_upload_volume": {
+    "browser_upload_volume":{
           "VHD": {
         "diskname": "XenUploadVol",
         "url": "http://10.147.28.7/templates/rajani-thin-volume.vhd",
-        "checksum": "",
+        "checksum": "09b08b6abb1b903fca7711d3ac8d6598",
                 },
           "OVA": {
         "diskname": "VMwareUploadVol",
         "url": "http://10.147.28.7/templates/Autoscale_Template/CentOS5.5(64bit)-vmware-autoscale.ova",
-        "checksum": "",
+        "checksum": "02de0576dd3a61ab59c03fd795fc86ac",
                 },
           "QCOW2": {
         "diskname": "KVMUploadVol",
         "url": "http://10.147.28.7/templates/rajani-thin-volume.qcow2",
-        "checksum": "",
+        "checksum": "da997b697feaa2f1f6e0d4785b0cece2",
                 },
     'browser_resized_disk_offering': {
         "displaytext": "Resizeddisk",
         "name": "Resizeddisk",
-        "disksize": 3
-    },
+        "disksize": 3,
+    }
+},
+    "browser_upload_template": {
+          "VHD": {
+        "diskname": "XenUploadVol",
+        "url": "http://10.147.28.7/templates/rajani-thin-volume.vhd",
+        "checksum": "09b08b6abb1b903fca7711d3ac8d6598",
+                },
+          "OVA": {
+        "diskname": "VMwareUploadVol",
+        "url": "http://10.147.28.7/templates/Autoscale_Template/CentOS5.5(64bit)-vmware-autoscale.ova",
+        "checksum": "02de0576dd3a61ab59c03fd795fc86ac",
+                },
+          "QCOW2": {
+        "diskname": "KVMUploadVol",
+        "url": "http://10.147.28.7/templates/rajani-thin-volume.qcow2",
+        "checksum": "da997b697feaa2f1f6e0d4785b0cece2",
+                },
+                              },
+                              },
     "recurring_snapshot": {
         "maxsnaps": 2,
         "timezone": "US/Arizona",