cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [33/50] git commit: updated refs/heads/master to 0b83559
Date Wed, 29 Apr 2015 05:44:17 GMT
Automation script changes with additional cases


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

Branch: refs/heads/master
Commit: 736f7042f33446b0c4b73c2f10e50d2f21f3edd0
Parents: eac8d4b
Author: sailajamada <sailaja.mada@citrix.com>
Authored: Thu Apr 2 09:31:34 2015 +0530
Committer: sailajamada <sailaja.mada@citrix.com>
Committed: Thu Apr 2 09:31:34 2015 +0530

----------------------------------------------------------------------
 .../component/test_browse_templates.py          |  51 +-
 .../component/test_browse_volumes.py            | 646 ++++++++++++++++++-
 tools/marvin/marvin/config/test_data.py         |  12 +
 3 files changed, 650 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/736f7042/test/integration/component/test_browse_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_browse_templates.py b/test/integration/component/test_browse_templates.py
index c1acf3c..d469446 100644
--- a/test/integration/component/test_browse_templates.py
+++ b/test/integration/component/test_browse_templates.py
@@ -81,13 +81,12 @@ class TestBrowseUploadVolume(cloudstackTestCase):
                      break
                  else:
                      break
-
-        cls.uploadurl=cls.testdata["browser_upload_template"][cls.uploadtemplateformat]["url"]
-        cls.templatename=cls.testdata["browser_upload_template"][cls.uploadtemplateformat]["templatename"]
-        cls.md5sum=cls.testdata["browser_upload_template"][cls.uploadtemplateformat]["checksum"]
-        cls.templatedisplaytext=cls.testdata["browser_upload_template"][cls.uploadtemplateformat]["displaytext"]
-        cls.templatehypervisor=cls.testdata["browser_upload_template"][cls.uploadtemplateformat]["hypervisor"]
-        cls.templateostypeid=cls.testdata["browser_upload_template"][cls.uploadtemplateformat]["ostypeid"]
+        cls.uploadurl=cls.testdata["configurableData"]["browser_upload_template"][cls.uploadtemplateformat]["url"]
+        cls.templatename=cls.testdata["configurableData"]["browser_upload_template"][cls.uploadtemplateformat]["templatename"]
+        cls.md5sum=cls.testdata["configurableData"]["browser_upload_template"][cls.uploadtemplateformat]["checksum"]
+        cls.templatedisplaytext=cls.testdata["configurableData"]["browser_upload_template"][cls.uploadtemplateformat]["displaytext"]
+        cls.templatehypervisor=cls.testdata["configurableData"]["browser_upload_template"][cls.uploadtemplateformat]["hypervisor"]
+        cls.templateostypeid=cls.testdata["configurableData"]["browser_upload_template"][cls.uploadtemplateformat]["ostypeid"]
         cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
         cls.domain = get_domain(cls.apiclient)
         cls.pod = get_pod(cls.apiclient, cls.zone.id)
@@ -111,7 +110,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         )
         cls.disk_offering = DiskOffering.create(
             cls.apiclient,
-            cls.testdata["browser_upload_volume"]["browser_resized_disk_offering"],
+            cls.testdata["configurableData"]["browser_upload_volume"]["browser_resized_disk_offering"],
             custom=True
         )
         cls._cleanup = [
@@ -145,6 +144,14 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
     def validate_uploaded_template(self,up_templateid,templatestate):
 
+        config = Configurations.list(
+                                     self.apiclient,
+                                     name='upload.operation.timeout'
+                                     )
+
+        uploadtimeout = int(config[0].value)
+        time.sleep(uploadtimeout*60)
+
         list_template_response = Template.list(
                     self.apiclient,
                     id=up_templateid,
@@ -174,7 +181,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         cmd.displaytext=self.templatename+self.account.name+(random.choice(string.ascii_uppercase))
         cmd.hypervisor=self.templatehypervisor
         cmd.ostypeid=self.templateostypeid
-        cmd.isdynamicallyscalable="false"
+        #cmd.isdynamicallyscalable="false"
         #cmd.type="template"
         getuploadparamsresponce=self.apiclient.getUploadParamsForTemplate(cmd)
 
@@ -204,7 +211,6 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         headers={'X-signature':signt,'X-metadata':metadata,'X-expires':expiredata}
 
         results = requests.post(posturl,files=files,headers=headers,verify=False)
-        time.sleep(600)
 
         print results.status_code
         if results.status_code !=200: 
@@ -1121,24 +1127,21 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
     def delete_template(self,templatedetails):
 
-        print templatedetails
+        self.debug(templatedetails)
         list_template_response = Template.list(
                                     self.apiclient,
                                     templatefilter="all",
                                     id=templatedetails.id,
                                     zoneid=self.zone.id)
-        print list_template_response
+        self.debug(list_template_response[0])
+
         self.assertEqual(
-                        isinstance(list_template_response, list),
+                        isinstance(list_template_response[0], list),
                         True,
                         "Check for list template response return valid list"
                         )
 
-        self.assertNotEqual(
-                            len(list_template_response),
-                            0,
-                            "Check template available in List Templates"
-                        )
+
         template_response = list_template_response[0]
 
         self.assertEqual(
@@ -1220,7 +1223,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
             vm1details=self.deploy_vm(browseup_template)
 
-            #vm1details=self.deploy_vm(self.template)
+            vm1details=self.deploy_vm(self.template)
 
             self.vmoperations(vm1details)
 
@@ -1230,8 +1233,6 @@ class TestBrowseUploadVolume(cloudstackTestCase):
             self.attach_data_volume(cvolume, vm1details)
             self.vmoperations(vm1details)
 
-
-
             self.debug("========================= Test 4: Restore VM created with Uploaded
template========================= ")
 
             self.restore_vm(vm1details)
@@ -1250,7 +1251,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
             self.debug("========================= Test 7:  Destroy VM =========================
")
 
-            #vm2details=self.deploy_vm(self.template)
+            vm2details=self.deploy_vm(self.template)
 
             vm2details=self.deploy_vm(browseup_template)
             self.destroy_vm(vm2details)
@@ -1260,9 +1261,9 @@ class TestBrowseUploadVolume(cloudstackTestCase):
             self.recover_destroyed_vm(vm2details)
             self.expunge_vm(vm2details)
 
-            self.debug("========================= Test 9:  Delete the Uploaded Template=========================
")
-            print browseup_template
-            self.delete_template(browseup_template)
+            #self.debug("========================= Test 9:  Delete the Uploaded Template=========================
")
+            #self.debug(browseup_template)
+            #self.delete_template(browseup_template)
 
             self.debug("========================= Test 10:  Upload Multiple templates=========================
")
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/736f7042/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 9067e2f..929cea8 100644
--- a/test/integration/component/test_browse_volumes.py
+++ b/test/integration/component/test_browse_volumes.py
@@ -60,6 +60,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         cls.cleanup = []
         cls.uploadvolumeformat="VHD"
         cls.storagetype = 'shared'
+        cls.globalurl="http://url"
 
         hosts = list_hosts(
             cls.apiclient,
@@ -89,6 +90,8 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         cls.domain = get_domain(cls.apiclient)
         cls.pod = get_pod(cls.apiclient, cls.zone.id)
 
+        if cls.uploadvolumeformat=="QCOW2" or cls.uploadvolumeformat=="VHD": 
+                cls.extuploadurl=cls.testdata["configurableData"]["browser_upload_volume_extended"][cls.uploadvolumeformat]["url"]
         cls.account = Account.create(
             cls.apiclient,
             cls.testdata["account"],
@@ -142,6 +145,14 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
     def validate_uploaded_volume(self,up_volid,volumestate):
 
+        config = Configurations.list(
+                                     self.apiclient,
+                                     name='upload.operation.timeout'
+                                     )
+
+        uploadtimeout = int(config[0].value)
+        time.sleep(uploadtimeout*60)
+
         list_volume_response = Volume.list(
                     self.apiclient,
                     id=up_volid
@@ -171,6 +182,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         posturl=getuploadparamsresponce.postURL
         metadata=getuploadparamsresponce.metadata
         expiredata=getuploadparamsresponce.expires
+        self.globalurl=getuploadparamsresponce.postURL
         #url = 'http://10.147.28.7/templates/rajani-thin-volume.vhd'
         url=self.uploadurl
 
@@ -182,18 +194,11 @@ class TestBrowseUploadVolume(cloudstackTestCase):
                     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: 
@@ -203,6 +208,177 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
         return(getuploadparamsresponce)
 
+    def onlyupload(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
+        getuploadparamsresponce=self.apiclient.getUploadParamsForVolume(cmd)
+        return(getuploadparamsresponce)
+
+
+
+    def invalidupload(self):
+
+        success= False
+        try:
+            cmd = getUploadParamsForVolume.getUploadParamsForVolumeCmd()
+            cmd.zoneid = self.zone.id
+            cmd.format = "invalidformat"
+            cmd.name=self.volname+self.account.name+(random.choice(string.ascii_uppercase))
+            cmd.account=self.account.name
+            cmd.domainid=self.domain.id
+            getuploadparamsresponce=self.apiclient.getUploadParamsForVolume(cmd)
+
+        except Exception as ex:
+            if "No enum constant com.cloud.storage.Storage.ImageFormat" in str(ex):
+                success = True
+        self.assertEqual(
+                success,
+                True,
+                "Verify - Upload volume with invalid format is handled")
+
+        return
+
+
+    def invalidposturl(self):
+
+        success= False
+        try:
+            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
+            getuploadparamsresponce=self.apiclient.getUploadParamsForVolume(cmd)
+
+
+            signt=getuploadparamsresponce.signature
+            posturl="http://invalidposturl/2999834."+self.uploadvolumeformat
+            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()
+
+            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)
+
+            self.debug(results.status_code) 
+            if results.status_code !=200: 
+                self.fail("Upload is not fine")
+
+            self.validate_uploaded_volume(getuploadparamsresponce.id,'UploadedAbandoned')
+
+        except Exception as ex:
+                if "Max retries exceeded with url" in str(ex):
+                    success = True
+
+        self.assertEqual(
+                                 success,
+                                 True,
+                                 "Verify - Tampered Post URL is handled")
+
+        return(getuploadparamsresponce)
+
+
+    def reuse_url(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
+        getuploadparamsresponce=self.apiclient.getUploadParamsForVolume(cmd)
+
+        signt=getuploadparamsresponce.signature
+        posturl=self.globalurl
+        metadata=getuploadparamsresponce.metadata
+        expiredata=getuploadparamsresponce.expires
+        url=self.uploadurl
+        time.sleep(300)
+
+        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()
+
+        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 URL is allowed to reuse")
+
+        config = Configurations.list(
+                                     self.apiclient,
+                                     name='upload.operation.timeout'
+                                     )
+
+        uploadtimeout = int(config[0].value)
+        time.sleep(uploadtimeout*60)
+        self.validate_uploaded_volume(getuploadparamsresponce.id,'UploadAbandoned')
+        return
+
+    def validate_storage_cleanup(self,invalidpostvolume,cleanup_interval):
+
+        list_volume_response = Volume.list(
+                    self.apiclient,
+                    id=invalidpostvolume.id
+                )
+        self.assertNotEqual(
+                    list_volume_response,
+                    None,
+                    "Check if volume exists in ListVolumes"
+                )
+
+        config1 = Configurations.list(
+                                     self.apiclient,
+                                     name='upload.operation.timeout'
+                                     )
+        config2 = Configurations.list(
+                                     self.apiclient,
+                                     name='upload.monitoring.interval'
+                                     )
+        uploadtimeout = int(config1[0].value)
+        monitorinterval=int(config2[0].value)
+
+        if cleanup_interval >= ((uploadtimeout*60)+monitorinterval):
+            time.sleep(cleanup_interval)
+        else:
+            time.sleep(((uploadtimeout*60)+monitorinterval))
+
+        list_volume_response = Volume.list(
+                    self.apiclient,
+                    id=invalidpostvolume.id
+                )
+        self.assertEqual(
+                    list_volume_response,
+                    None,
+                    "Storage Cleanup - Verify UploadAbandoned volumes are deleted"
+                )
+
+
     def validate_max_vol_size(self,up_vol,volumestate):
 
         list_volume_response = Volume.list(
@@ -280,6 +456,52 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
         return(getuploadparamsresponce)
 
+    def browse_upload_volume_with_invalid_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="xxxxxxxx"
+        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):
 
         time.sleep(120 )
@@ -348,6 +570,25 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         self.validate_uploaded_volume(volid,'Ready')
 
 
+    def attach_deleted_volume(self,vmlist,volume):
+
+        success= False
+        try:
+            vmlist.attach_volume(
+                    self.apiclient,
+                    volume
+                )
+        except Exception as ex:
+            if "Please specify a volume with the valid type: DATADISK" in str(ex):
+                success = True
+        self.assertEqual(
+                success,
+                True,
+                "Attaching the Deleted Volume is handled appropriately not to get attached
the deleted uploaded volume")
+
+        return
+
+
     def reboot_vm(self,vmdetails):
         vmdetails.reboot(self.apiclient)
         self.validate_vm(vmdetails,'Running')
@@ -509,8 +750,6 @@ class TestBrowseUploadVolume(cloudstackTestCase):
                 % (extract_vol.url, volumeid)
             )
 
-
-
     def resize_fail(self,volumeid):
 
         cmd                = resizeVolume.resizeVolumeCmd()
@@ -795,30 +1034,6 @@ 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,
-          #  "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_snapshot_template(self,snapshot_created):
@@ -1337,6 +1552,243 @@ class TestBrowseUploadVolume(cloudstackTestCase):
 
         return
 
+
+
+    def uploadvol(self,getuploadparamsresponce):
+
+        signt=getuploadparamsresponce.signature
+        posturl=getuploadparamsresponce.postURL
+        metadata=getuploadparamsresponce.metadata
+        expiredata=getuploadparamsresponce.expires
+        success = False
+        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()
+
+        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)
+        list_volume_response = Volume.list(
+                    self.apiclient,
+                    id=getuploadparamsresponce.id
+                )
+        self.debug("======================Before SSVM Reboot==================")
+
+        self.reboot_ssvm()
+        self.debug("======================After SSVM Reboot==================")
+
+        config = Configurations.list(
+                                     self.apiclient,
+                                     name='upload.operation.timeout'
+                                     )
+
+        uploadtimeout = int(config[0].value)
+        time.sleep(uploadtimeout*60)
+
+        self.validate_uploaded_volume(getuploadparamsresponce.id,'UploadAbandoned')
+
+        return()
+
+
+
+    def uploadvolwithssvmreboot(self,getuploadparamsresponce):
+
+        signt=getuploadparamsresponce.signature
+        posturl=getuploadparamsresponce.postURL
+        metadata=getuploadparamsresponce.metadata
+        expiredata=getuploadparamsresponce.expires
+
+        self.debug("======================Before SSVM Reboot==================")
+        list_volume_response = Volume.list(
+                    self.apiclient,
+                    id=getuploadparamsresponce.id
+                )
+
+        self.debug(list_volume_response[0])
+        self.reboot_ssvm()
+
+        success = False
+        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()
+
+        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)
+        list_volume_response = Volume.list(
+                    self.apiclient,
+                    id=getuploadparamsresponce.id
+                )
+
+        self.debug("======================Upload After SSVM Reboot==================")
+        self.debug(list_volume_response[0])
+
+        self.validate_uploaded_volume(getuploadparamsresponce.id,'Uploaded')
+
+        return()
+
+    def uploadwithcustomoffering(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.diskofferingid=self.disk_offering.id
+        getuploadparamsresponce=self.apiclient.getUploadParamsForVolume(cmd)
+
+        signt=getuploadparamsresponce.signature
+        posturl=getuploadparamsresponce.postURL
+        metadata=getuploadparamsresponce.metadata
+        expiredata=getuploadparamsresponce.expires
+        self.globalurl=getuploadparamsresponce.postURL
+        #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()
+
+        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)
+
+        print results.status_code
+        if results.status_code !=200: 
+            self.fail("Upload is not fine")
+
+        self.validate_uploaded_volume(getuploadparamsresponce.id,'Uploaded')
+
+    def uploadwithsamedisplaytext(self,voldetails):
+
+
+        list_volume_response = Volume.list(
+                    self.apiclient,
+                    id=voldetails.id
+                )
+
+        success=True
+        cmd = getUploadParamsForVolume.getUploadParamsForVolumeCmd()
+        cmd.zoneid = self.zone.id
+        cmd.format = self.uploadvolumeformat
+        cmd.name=list_volume_response[0].name
+        cmd.account=self.account.name
+        cmd.domainid=self.domain.id
+        getuploadparamsresponce=self.apiclient.getUploadParamsForVolume(cmd)
+        list_volume_response1 = Volume.list(
+                  self.apiclient,
+                    id=getuploadparamsresponce.id
+                )
+        if list_volume_response1[0].name==voldetails.name:
+           success=False
+
+        self.assertEqual(
+                success,
+                False,
+                "Verify: Upload Multiple volumes with same name is handled")
+
+        return
+
+    def uploadvolwithmultissvm(self):
+
+        ssvmhosts = list_hosts(
+            self.apiclient,
+            type="SecondaryStorageVM"
+        )
+        self.debug("Total SSVMs are:")
+        self.debug(len(ssvmhosts))
+
+        if len(ssvmhosts)==1:
+            return(1)
+
+        config = Configurations.list(
+                                     self.apiclient,
+                                     name='secstorage.session.max'
+                                     )
+
+        multissvmvalue = int(config[0].value)
+        if multissvmvalue !=1:
+            return(0)
+
+        browseup_vol=self.browse_upload_volume()
+
+        vm1details=self.deploy_vm()
+
+        self.attach_volume(vm1details,browseup_vol.id)
+
+        self.vmoperations(vm1details)
+
+        self.destroy_vm(vm1details)
+
+        self.detach_volume(vm1details,browseup_vol.id)
+
+        self.deletevolume(browseup_vol.id)
+
+        return(2)
+
+
+    def uploadwithextendedfileextentions(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.diskofferingid=self.disk_offering.id
+        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.extuploadurl
+
+        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()
+
+        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)
+
+        print results.status_code
+        if results.status_code !=200: 
+            self.fail("Upload is not fine")
+
+        self.validate_uploaded_volume(getuploadparamsresponce.id,'Uploaded')
+
     @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
     def test_01_Browser_volume_Life_cycle_tpath(self):
         """
@@ -1570,15 +2022,141 @@ class TestBrowseUploadVolume(cloudstackTestCase):
         """
         try:
             
-            self.debug("========================= Test 1 Validate Storage.max.upload.size
========================= ")
+            self.debug("========================= Test 26 Validate Storage.max.upload.size
========================= ")
             globalconfig_browse_up_vol=self.browse_upload_volume()
             self.validate_max_vol_size(globalconfig_browse_up_vol,"Uploaded")
 
+
+        except Exception as e:
+            self.fail("Exception occurred  : %s" % e)
+        return
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
+    def test_04_Browser_Upload_Volume_Negative_Scenarios_TPath(self):
+        """
+        Test Browser_Upload_Volume_Negative_Scenarios
+        """
+        try:
+            self.debug("========================= Test 27 Reuse the POST URL after expiry
time========================= ")
+            reuse_browse_up_vol=self.browse_upload_volume()
+            self.reuse_url()
+            self.deletevolume(reuse_browse_up_vol.id)
+
+            self.debug("========================= Test 28 Reboot SSVM before upload is completed=========================")
+            browse_up_vol=self.onlyupload()
+            self.uploadvol(browse_up_vol)
+            self.deletevolume(browse_up_vol.id)
+
+            self.debug("========================= Test 29 Reboot SSVM after getting the upload
volume params and before initiating the upload=========================")
+            browse_up_vol=self.onlyupload()
+            self.uploadvolwithssvmreboot(browse_up_vol)
+            self.deletevolume(browse_up_vol.id)
+
+            self.debug("========================= Test 30 Attach Deleted Volume=========================")
+            deleted_browse_up_vol=self.browse_upload_volume()
+            self.deletevolume(deleted_browse_up_vol.id)
+            deletedvm1details=self.deploy_vm()
+            self.attach_deleted_volume(deletedvm1details, deleted_browse_up_vol)
+
+            self.debug("========================= Test 31 Upload Volume with Invalid Format=========================")
+            self.invalidupload()
+
+            self.debug("========================= Test 32 Upload Mutliple Volumes with same
display text=========================")
+            samedisplaytext_browse_up_vol=self.browse_upload_volume()
+            self.uploadwithsamedisplaytext(samedisplaytext_browse_up_vol)
+
+            self.debug("========================= Test 33 Upload Volume with custom offering
id=========================")
+            self.uploadwithcustomoffering()
+
+
+            self.debug("========================= Test 34 Upload Volume with tampered post
URL=========================")
+            invaliduploadvolume=self.invalidposturl()
+
         except Exception as e:
             self.fail("Exception occurred  : %s" % e)
         return
 
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
+    def test_05_Browser_Upload_Volume_MultiSSVM_Scenarios_TPath(self):
+        """
+        Test Browser_Upload_Volume_MultiSSVM_Scenarios
+        """
+        try:
+
+            self.debug("========================= Test 35 Upload volume with Multiple SSVM=========================")
+
+            testresult=self.uploadvolwithmultissvm()
+            if testresult==0:
+                raise unittest.SkipTest("secstorage.session.max global config is not set
to 1 which means Multiple SSVM's are not present")
+            elif testresult==1:
+                raise unittest.SkipTest("only one SSVM is present")
+
+        except Exception as e:
+            self.fail("Exception occurred  : %s" % e)
+        return
+
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
+    def test_06_Browser_Upload_Volume_with_extended_file_extenstions(self):
+        """
+        Test Browser_Upload_Volume_with_extended_file_extenstions
+        """
+
+        try:
+            self.debug("========================= Test 36 Upload volume with extended file
extenstions=========================")
+            if self.uploadvolumeformat=="OVA":
+                 raise unittest.SkipTest("This test is need not be executed on VMWARE")
+            self.uploadwithextendedfileextentions()
+
+        except Exception as e:
+            self.fail("Exception occurred  : %s" % e)
+        return
 
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
+    def test_07_Browser_Upload_Volume_Storage_Cleanup_Config_Validation(self):
+        """
+        Test Browser_Upload_Volume_Storage_Cleanup_Config_Validation
+        """
+        self.debug("========================= Test 37 Validate storage.cleanup.enabled and
storage.cleanup.interval ========================= ")
+        config1 = Configurations.list(
+                                     self.apiclient,
+                                     name='storage.cleanup.enabled'
+                                     )
+
+        config2 = Configurations.list(
+                                     self.apiclient,
+                                     name='storage.cleanup.interval'
+                                     )
+
+        cleanup_enabled=config1[0].value
+        cleanup_interval = int(config2[0].value)
+
+        if cleanup_enabled=="false":
+                raise unittest.SkipTest("storage.cleanup.enabled is not set to true")
+
+        if cleanup_interval>600:
+                raise unittest.SkipTest("storage.cleanup.interval is set to wait for more
than 10 mins before cleanup. Please reduce the interval to less than 10 mins")
+
+        invaliduploadvolume=self.invalidposturl()
+
+        self.validate_storage_cleanup(invaliduploadvolume,cleanup_interval)
+
+        return
+
+
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
+    def test_08_Browser_Upload_Volume_TamperedPostURL(self):
+        """
+        Test Browser_Upload_Volume_Negative_Scenarios
+        """
+        try:
+            self.debug("========================= Test 34 Upload Volume with tampered post
URL=========================")
+            invaliduploadvolume=self.invalidposturl()
+
+        except Exception as e:
+            self.fail("Exception occurred  : %s" % e)
+        return
     @classmethod
     def tearDownClass(self):
         try:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/736f7042/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 48053eb..5bbe4f2 100644
--- a/tools/marvin/marvin/config/test_data.py
+++ b/tools/marvin/marvin/config/test_data.py
@@ -1530,6 +1530,18 @@ test_data = {
         "disksize": 3,
     }
 },
+    "browser_upload_volume_extended":{
+          "VHD": {
+        "diskname": "XenUploadVol",
+        "url": "http://10.147.28.7/templates/builtin/centos56-x86_64.vhd.bz2",
+        "checksum": "09b08b6abb1b903fca7711d3ac8d6598",
+                },
+          "QCOW2": {
+        "diskname": "KVMUploadVol",
+        "url": "http://10.147.28.7/templates/builtin/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2",
+        "checksum": "02de0576dd3a61ab59c03fd795fc86ac",
+                },
+},
     "browser_upload_template": {
           "VHD": {
         "templatename": "XenUploadtemplate",


Mime
View raw message