Test Automation Scripts for Browser Bases Upload volumes and templates with testdata config changes

This commit is contained in:
sailajamada 2015-03-10 21:39:55 +05:30
parent 24a8483b88
commit db7964fb11
3 changed files with 1449 additions and 12 deletions

File diff suppressed because it is too large Load Diff

View File

@ -543,12 +543,43 @@ class TestBrowseUploadVolume(cloudstackTestCase):
def destroy_vm(self,vmdetails):
success = False
vmdetails.delete(self.apiclient, expunge=False)
try:
list_vm_response1 = VirtualMachine.list(
self.apiclient,
id=vmdetails.id
)
except Exception as ex:
if "Unable to find a virtual machine with specified vmId" in str(ex):
success = True
if success == "True":
self.debug("VM is already expunged")
return
list_vm_response1 = VirtualMachine.list(
self.apiclient,
id=vmdetails.id
)
if list_vm_response1 is None:
self.debug("VM already expunged")
return
if list_vm_response1[0].state=="Expunging":
self.debug("VM already getting expunged")
return
list_vm_response = VirtualMachine.list(
self.apiclient,
id=vmdetails.id
)
if list_vm_response is None:
self.debug("VM already expunged")
return
self.assertEqual(
isinstance(list_vm_response, list),
True,
@ -571,10 +602,34 @@ class TestBrowseUploadVolume(cloudstackTestCase):
def recover_destroyed_vm(self,vmdetails):
list_vm_response1 = VirtualMachine.list(
self.apiclient,
id=vmdetails.id
)
if list_vm_response1 is None:
self.debug("VM already expunged")
return
cmd = recoverVirtualMachine.recoverVirtualMachineCmd()
cmd.id = vmdetails.id
self.apiclient.recoverVirtualMachine(cmd)
list_vm_response1 = VirtualMachine.list(
self.apiclient,
id=vmdetails.id
)
if list_vm_response1 is None:
self.debug("VM already expunged")
return
list_vm_response1 = VirtualMachine.list(
self.apiclient,
id=vmdetails.id
)
if list_vm_response1[0].state=="Expunging":
self.debug("VM already getting expunged")
return
list_vm_response = VirtualMachine.list(
self.apiclient,
id=vmdetails.id
@ -599,6 +654,46 @@ class TestBrowseUploadVolume(cloudstackTestCase):
return
def expunge_vm(self,vmdetails):
self.debug("Expunge VM-ID: %s" % vmdetails.id)
cmd = destroyVirtualMachine.destroyVirtualMachineCmd()
cmd.id = vmdetails.id
self.apiclient.destroyVirtualMachine(cmd)
config = Configurations.list(
self.apiclient,
name='expunge.delay'
)
expunge_delay = int(config[0].value)
time.sleep(expunge_delay * 2)
#VM should be destroyed unless expunge thread hasn't run
#Wait for two cycles of the expunge thread
config = Configurations.list(
self.apiclient,
name='expunge.interval'
)
expunge_cycle = int(config[0].value)
wait_time = expunge_cycle * 4
while wait_time >= 0:
list_vm_response = VirtualMachine.list(
self.apiclient,
id=vmdetails.id
)
if not list_vm_response:
break
self.debug("Waiting for VM to expunge")
time.sleep(expunge_cycle)
wait_time = wait_time - expunge_cycle
self.debug("listVirtualMachines response: %s" % list_vm_response)
self.assertEqual(list_vm_response,None,"Check Expunged virtual machine is in listVirtualMachines response")
return
def volume_snapshot(self,volumedetails):
"""
@summary: Test to verify creation of snapshot from volume
@ -1231,6 +1326,8 @@ class TestBrowseUploadVolume(cloudstackTestCase):
self.vmoperations(vm1details)
self.destroy_vm(vm1details)
self.debug("========================= Test 5: Deploy New VM,Attach the detached Uploaded volume and validate VM operations after attach========================= ")
vm2details=self.deploy_vm()
@ -1250,6 +1347,9 @@ class TestBrowseUploadVolume(cloudstackTestCase):
self.attach_volume(vm2details,browseup_vol.id)
self.vmoperations(vm2details)
self.detach_volume(vm2details,browseup_vol.id)
self.deletevolume(browseup_vol.id)
self.debug("========================= Test 8: Try resizing uploaded state volume and validate the error scenario========================= ")
@ -1281,8 +1381,12 @@ class TestBrowseUploadVolume(cloudstackTestCase):
self.debug("========================= Test 12: Delete detached uploaded volume========================= ")
self.deletevolume(browseup_vol3.id)
self.debug("========================= Deletion of UnUsed VM's after test is complete========================= ")
self.expunge_vm(vm2details)
self.debug("========================= Test 13: Delete Uploaded State volume========================= ")
@ -1331,6 +1435,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
self.volume_snapshot_template(snapshotdetails)
self.deletevolume(browseup_vol6.id)
self.expunge_vm(vm6details)
self.debug("========================= Test 20: Upload Browser based volume with checksum and validate ========================= ")
browseup_vol_withchecksum=self.browse_upload_volume_with_md5()
@ -1348,7 +1453,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
self.vmoperations(vm7details)
self.destroy_vm(vm7details)
self.expunge_vm(vm7details)
except Exception as e:
@ -1357,7 +1462,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
@attr(tags = ["advanced", "advancedns", "smoke", "basic"], required_hardware="true")
def test_02_SSVM_Life_Cycle_With_Browser_Volume_TPath(self):
def xtest_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
"""
@ -1377,7 +1482,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
self.detach_volume(ssvm1vm1details,ssvm1browseup_vol.id)
self.deletevolume(ssvm1browseup_vol.id)
self.destroy_vm(ssvm1vm1details)
self.expunge_vm(ssvm1vm1details)
self.debug("========================= Test 24: Reboot SSVM and Perform Browser based volume validations ========================= ")
@ -1394,7 +1499,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
self.deletevolume(ssvm2browseup_vol.id)
self.destroy_vm(ssvm2vm1details)
self.expunge_vm(ssvm2vm1details)
self.debug("========================= Test 25: Reboot SSVM and Perform Browser based volume validations ========================= ")
@ -1411,7 +1516,7 @@ class TestBrowseUploadVolume(cloudstackTestCase):
self.deletevolume(ssvm3browseup_vol.id)
self.destroy_vm(ssvm3vm1details)
self.expunge_vm(ssvm3vm1details)
except Exception as e:
self.fail("Exception occurred : %s" % e)

View File

@ -884,22 +884,30 @@ test_data = {
},
"browser_upload_template": {
"VHD": {
"diskname": "XenUploadVol",
"url": "http://10.147.28.7/templates/rajani-thin-volume.vhd",
"templatename": "XenUploadtemplate",
"displaytext": "XenUploadtemplate",
"url": "http://10.147.28.7/templates/builtin/centos56-x86_64.vhd.bz2",
"hypervisor":"XenServer",
"checksum": "09b08b6abb1b903fca7711d3ac8d6598",
"ostypeid":"74affaea-c658-11e4-ad38-a6d1374244b4"
},
"OVA": {
"diskname": "VMwareUploadVol",
"url": "http://10.147.28.7/templates/Autoscale_Template/CentOS5.5(64bit)-vmware-autoscale.ova",
"templatename": "VMwareUploadtemplate",
"displaytext": "VMwareUploadtemplate",
"url": "http://nfs1.lab.vmops.com/templates/vmware/CentOS5.3-x86_64.ova",
"checksum": "02de0576dd3a61ab59c03fd795fc86ac",
"hypervisor":"VMware",
"ostypeid":"74affaea-c658-11e4-ad38-a6d1374244b4"
},
"QCOW2": {
"diskname": "KVMUploadVol",
"url": "http://10.147.28.7/templates/rajani-thin-volume.qcow2",
"templatename": "KVMUploadtemplate",
"displaytext": "VMwareUploadtemplate",
"url": "http://10.147.28.7/templates/builtin/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2",
"checksum": "da997b697feaa2f1f6e0d4785b0cece2",
"hypervisor":"KVM",
"ostypeid":"74affaea-c658-11e4-ad38-a6d1374244b4"
},
},
},
"recurring_snapshot": {
"maxsnaps": 2,
"timezone": "US/Arizona",