Skip to content

Commit

Permalink
test: add a case which are adding disks with all combianations of cac…
Browse files Browse the repository at this point in the history
…he, bus and format
  • Loading branch information
yunmingyang committed Sep 18, 2023
1 parent b6c2445 commit ac3e05f
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions test/check-machines-disks
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ class TestMachinesDisks(VirtualMachinesCase):
xwarning_object=None, xwarning_message=None,
pixel_test_ignore=None,
skip_add=False,
remove=False,
):
self.test_obj = test_obj
self.vm_name = vm_name
Expand Down Expand Up @@ -525,6 +526,8 @@ class TestMachinesDisks(VirtualMachinesCase):
self.xwarning_object = xwarning_object
self.xwarning_message = xwarning_message

self.remove = remove

@staticmethod
def getExpectedFormat(pool_type, expected_volume_format):
# Guess by the name of the pool it's format to avoid passing more parameters
Expand Down Expand Up @@ -552,6 +555,13 @@ class TestMachinesDisks(VirtualMachinesCase):
self.add_disk()
if not self.xfail:
self.verify_disk_added()
if self.remove:
self.test_obj.browser.click(f"#vm-{self.vm_name}-disks-{self.expected_target}-action-kebab button")
self.test_obj.browser.click(f"#delete-vm-{self.vm_name}-disks-{self.expected_target} a")
self.test_obj.browser.wait_visible("#delete-resource-modal")
self.test_obj.browser.click('#delete-resource-modal #delete-resource-modal-primary')
self.test_obj.browser.wait_not_present("#delete-resource-modal")
self.test_obj.browser.wait_not_present(f"#vm-{self.vm_name}-disks-{self.expected_target}-device")
else:
if self.xfail_object:
self.test_obj.browser.wait_in_text(f"{prefix}-{self.xfail_object}-helper.pf-m-error", self.xfail_error_message)
Expand Down Expand Up @@ -728,6 +738,14 @@ class TestMachinesDisks(VirtualMachinesCase):

if self.cache_mode:
b.wait_in_text(f"#vm-{self.vm_name}-disks-{self.expected_target}-cache", self.cache_mode)
self.test_obj.assertEqual(
f'cache="{self.cache_mode}"',
_get_disk_prop(self.expected_target, self.vm_name, "driver/@cache"))

if self.bus_type:
self.test_obj.assertEqual(
f'bus="{self.bus_type}"',
_get_disk_prop(self.expected_target, self.vm_name, "target/@bus"))

if self.expected_serial:
b.wait_in_text(f"#vm-{self.vm_name}-disks-{self.expected_target}-serial", self.expected_serial)
Expand Down Expand Up @@ -1654,6 +1672,86 @@ class TestMachinesDisks(VirtualMachinesCase):
force=True,
).execute()

def testAddDisksWithAllCombinations(self):
b = self.browser
m = self.machine

m.execute("virsh pool-define-as images --type dir --target /var/lib/libvirt/images; virsh pool-start images")

self.login_and_go("/machines")
b.wait_in_text("body", "Virtual machines")

self.createVm("subVmTest1", running=False)
self.goToVmPage("subVmTest1")

b.click("#vm-subVmTest1-disks-adddisk")
b.click('#vm-subVmTest1-disks-adddisk-dialog-modal-window span:contains("Show additional options")')

queryEleAnonymous = """(function (sel) {
var el = ph_find(sel).querySelectorAll('option');
var result = [];
for (i = 0; i < el.length; ++i)
result.push(el[i].textContent);
return result;})"""
disk_formats = b.call_js_func(queryEleAnonymous,
"#vm-subVmTest1-disks-adddisk-new-format")
cache_modes = b.call_js_func(queryEleAnonymous,
"#cache-mode")
bus_types = b.call_js_func(queryEleAnonymous,
"#vm-subVmTest1-disks-adddisk-bus-type")

b.click("#vm-subVmTest1-disks-adddisk-dialog-cancel")
b.wait_not_present("#vm-subVmTest1-disks-adddisk-dialog-modal-window")

count = 0
for format in disk_formats:
for mode in cache_modes:
for bus in bus_types:
volName = "test" + str(count)
target = "vdb" if bus == "virtio" else "sda"

self.VMAddDiskDialog(
self,
pool_name="images",
volume_name=volName,
volume_size=1,
volume_format=format,
cache_mode=None if mode == "default" else mode,
bus_type=bus,
serial="test",
expected_target=target,
remove=True,
).execute()

self.VMAddDiskDialog(
self,
mode="use-existing",
pool_name="images",
volume_name=volName,
volume_format=format,
cache_mode=None if mode == "default" else mode,
bus_type=bus,
serial="test",
expected_target=target,
remove=True,
).execute()

if format == "raw":
self.VMAddDiskDialog(
self,
mode='custom-path',
device='disk',
bus_type=bus,
cache_mode=None if mode == "default" else mode,
file_path='/var/lib/libvirt/images/' + volName,
serial="test",
expected_target=target,
expected_format=format,
remove=True,
).execute()

count += 1


if __name__ == '__main__':
test_main()

0 comments on commit ac3e05f

Please sign in to comment.