mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-2478: Fix test_volumes.py script for BVT failures
removed storage type in compute offering and disk offering Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
parent
4d0cea6626
commit
55d304a5bb
@ -53,19 +53,17 @@ class Services:
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # in MHz
|
||||
"memory": 128, # In MBs
|
||||
"storagetype": "local"
|
||||
"memory": 260 # In MBs
|
||||
|
||||
},
|
||||
"disk_offering": {
|
||||
"displaytext": "Small",
|
||||
"name": "Small",
|
||||
"storagetype": "local",
|
||||
"disksize": 1
|
||||
},
|
||||
'resized_disk_offering': {
|
||||
"displaytext": "Resized",
|
||||
"name": "Resized",
|
||||
"storagetype": "local",
|
||||
"disksize": 3
|
||||
},
|
||||
"volume_offerings": {
|
||||
@ -152,7 +150,7 @@ class TestCreateVolume(cloudstackTestCase):
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = []
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic"])
|
||||
def test_01_create_volume(self):
|
||||
"""Test Volume creation for all Disk Offerings (incl. custom)
|
||||
"""
|
||||
@ -346,8 +344,9 @@ class TestVolumes(cloudstackTestCase):
|
||||
cls.custom_resized_disk_offering,
|
||||
cls.service_offering,
|
||||
cls.disk_offering,
|
||||
cls.volume,
|
||||
cls.account
|
||||
]
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@ -359,14 +358,17 @@ class TestVolumes(cloudstackTestCase):
|
||||
def setUp(self):
|
||||
self.apiClient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.attached = False
|
||||
self.cleanup = []
|
||||
|
||||
def tearDown(self):
|
||||
#Clean up, terminate the created volumes
|
||||
if self.attached:
|
||||
self.virtual_machine.detach_volume(self.apiClient, self.volume)
|
||||
cleanup_resources(self.apiClient, self.cleanup)
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic"])
|
||||
def test_02_attach_volume(self):
|
||||
"""Attach a created Volume to a Running VM
|
||||
"""
|
||||
@ -381,7 +383,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
self.virtual_machine.id
|
||||
))
|
||||
self.virtual_machine.attach_volume(self.apiClient, self.volume)
|
||||
|
||||
self.attached = True
|
||||
list_volume_response = list_volumes(
|
||||
self.apiClient,
|
||||
id=self.volume.id
|
||||
@ -412,7 +414,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
(self.virtual_machine.ipaddress, e))
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic"])
|
||||
def test_03_download_attached_volume(self):
|
||||
"""Download a Volume attached to a VM
|
||||
"""
|
||||
@ -423,6 +425,8 @@ class TestVolumes(cloudstackTestCase):
|
||||
|
||||
self.debug("Extract attached Volume ID: %s" % self.volume.id)
|
||||
|
||||
self.virtual_machine.attach_volume(self.apiClient, self.volume)
|
||||
self.attached = True
|
||||
cmd = extractVolume.extractVolumeCmd()
|
||||
cmd.id = self.volume.id
|
||||
cmd.mode = "HTTP_DOWNLOAD"
|
||||
@ -432,7 +436,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
with self.assertRaises(Exception):
|
||||
self.apiClient.extractVolume(cmd)
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic"])
|
||||
def test_04_delete_attached_volume(self):
|
||||
"""Delete a Volume attached to a VM
|
||||
"""
|
||||
@ -444,19 +448,16 @@ class TestVolumes(cloudstackTestCase):
|
||||
|
||||
self.debug("Trying to delete attached Volume ID: %s" %
|
||||
self.volume.id)
|
||||
|
||||
self.virtual_machine.attach_volume(self.apiClient, self.volume)
|
||||
self.attached = True
|
||||
cmd = deleteVolume.deleteVolumeCmd()
|
||||
cmd.id = self.volume.id
|
||||
#Proper exception should be raised; deleting attach VM is not allowed
|
||||
#with self.assertRaises(Exception):
|
||||
result = self.apiClient.deleteVolume(cmd)
|
||||
self.assertEqual(
|
||||
result,
|
||||
None,
|
||||
"Check for delete download error while volume is attached"
|
||||
)
|
||||
with self.assertRaises(Exception):
|
||||
self.apiClient.deleteVolume(cmd)
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic"])
|
||||
def test_05_detach_volume(self):
|
||||
"""Detach a Volume attached to a VM
|
||||
"""
|
||||
@ -470,8 +471,9 @@ class TestVolumes(cloudstackTestCase):
|
||||
self.volume.id,
|
||||
self.virtual_machine.id
|
||||
))
|
||||
|
||||
self.virtual_machine.attach_volume(self.apiClient, self.volume)
|
||||
self.virtual_machine.detach_volume(self.apiClient, self.volume)
|
||||
self.attached = False
|
||||
#Sleep to ensure the current state will reflected in other calls
|
||||
time.sleep(self.services["sleep"])
|
||||
list_volume_response = list_volumes(
|
||||
@ -497,7 +499,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
)
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic"])
|
||||
def test_06_download_detached_volume(self):
|
||||
"""Download a Volume unattached to an VM
|
||||
"""
|
||||
@ -506,6 +508,10 @@ class TestVolumes(cloudstackTestCase):
|
||||
|
||||
self.debug("Extract detached Volume ID: %s" % self.volume.id)
|
||||
|
||||
self.virtual_machine.attach_volume(self.apiClient, self.volume)
|
||||
self.virtual_machine.detach_volume(self.apiClient, self.volume)
|
||||
self.attached = False
|
||||
|
||||
cmd = extractVolume.extractVolumeCmd()
|
||||
cmd.id = self.volume.id
|
||||
cmd.mode = "HTTP_DOWNLOAD"
|
||||
@ -528,7 +534,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
% (extract_vol.url, self.volume.id)
|
||||
)
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic"])
|
||||
def test_07_resize_fail(self):
|
||||
"""Verify invalid options fail to Resize a volume"""
|
||||
# Verify the size is the new size is what we wanted it to be.
|
||||
@ -543,7 +549,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
response = self.apiClient.resizeVolume(cmd)
|
||||
except Exception as ex:
|
||||
#print str(ex)
|
||||
if "HTTP Error 431:" in str(ex):
|
||||
if "invalid" in str(ex):
|
||||
success = True
|
||||
self.assertEqual(
|
||||
success,
|
||||
@ -557,7 +563,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
try:
|
||||
response = self.apiClient.resizeVolume(cmd)
|
||||
except Exception as ex:
|
||||
if "HTTP Error 431:" in str(ex):
|
||||
if "invalid" in str(ex):
|
||||
success = True
|
||||
self.assertEqual(
|
||||
success,
|
||||
@ -576,6 +582,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
)
|
||||
#attach the volume
|
||||
self.virtual_machine.attach_volume(self.apiClient, self.volume)
|
||||
self.attached = True
|
||||
#stop the vm if it is on xenserver
|
||||
if self.services['hypervisor'].lower() == "xenserver":
|
||||
self.virtual_machine.stop(self.apiClient)
|
||||
@ -603,10 +610,11 @@ class TestVolumes(cloudstackTestCase):
|
||||
True,
|
||||
"Verify the volume did not resize"
|
||||
)
|
||||
self.virtual_machine.detach_volume(self.apiClient, self.volume)
|
||||
self.cleanup.append(self.volume)
|
||||
if self.services['hypervisor'].lower() == "xenserver":
|
||||
self.virtual_machine.start(self.apiClient)
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic"])
|
||||
def test_08_resize_volume(self):
|
||||
"""Resize a volume"""
|
||||
# Verify the size is the new size is what we wanted it to be.
|
||||
@ -616,6 +624,8 @@ class TestVolumes(cloudstackTestCase):
|
||||
self.virtual_machine.id
|
||||
))
|
||||
self.virtual_machine.attach_volume(self.apiClient, self.volume)
|
||||
self.attached = True
|
||||
|
||||
if self.services['hypervisor'].lower() == "xenserver":
|
||||
self.virtual_machine.stop(self.apiClient)
|
||||
self.debug("Resize Volume ID: %s" % self.volume.id)
|
||||
@ -635,7 +645,7 @@ class TestVolumes(cloudstackTestCase):
|
||||
type='DATADISK'
|
||||
)
|
||||
for vol in list_volume_response:
|
||||
if vol.id == self.volume.id and vol.size == 3221225472L:
|
||||
if vol.id == self.volume.id and vol.size == 3221225472L and vol.state == 'Ready':
|
||||
success = True
|
||||
if success:
|
||||
break
|
||||
@ -649,10 +659,10 @@ class TestVolumes(cloudstackTestCase):
|
||||
"Check if the volume resized appropriately"
|
||||
)
|
||||
|
||||
self.virtual_machine.detach_volume(self.apiClient, self.volume)
|
||||
self.cleanup.append(self.volume)
|
||||
if self.services['hypervisor'].lower() == "xenserver":
|
||||
self.virtual_machine.start(self.apiClient)
|
||||
|
||||
@attr(tags = ["advanced", "advancedns", "smoke"])
|
||||
@attr(tags = ["advanced", "advancedns", "smoke","basic"])
|
||||
def test_09_delete_detached_volume(self):
|
||||
"""Delete a Volume unattached to an VM
|
||||
"""
|
||||
@ -665,13 +675,23 @@ class TestVolumes(cloudstackTestCase):
|
||||
|
||||
self.debug("Delete Volume ID: %s" % self.volume.id)
|
||||
|
||||
self.volume_1 = Volume.create(
|
||||
self.api_client,
|
||||
self.services,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
|
||||
self.virtual_machine.attach_volume(self.apiClient, self.volume_1)
|
||||
self.virtual_machine.detach_volume(self.apiClient, self.volume_1)
|
||||
|
||||
cmd = deleteVolume.deleteVolumeCmd()
|
||||
cmd.id = self.volume.id
|
||||
cmd.id = self.volume_1.id
|
||||
self.apiClient.deleteVolume(cmd)
|
||||
|
||||
list_volume_response = list_volumes(
|
||||
self.apiClient,
|
||||
id=self.volume.id,
|
||||
id=self.volume_1.id,
|
||||
type='DATADISK'
|
||||
)
|
||||
self.assertEqual(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user