Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: Update Cockpit lib to e8cf93050356f; fix adding disks to transient VM, and lots of test bugs #1778

Merged
merged 5 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ COCKPIT_REPO_FILES = \
$(NULL)

COCKPIT_REPO_URL = https://github.com/cockpit-project/cockpit.git
COCKPIT_REPO_COMMIT = 0b1585bde7321039f635a73a92fe57ff16096e20 # 322 + 80 commits
COCKPIT_REPO_COMMIT = e8cf93050356f3cecdc229f170e5c4a72825ef80 # 323 + 4 commits

$(COCKPIT_REPO_FILES): $(COCKPIT_REPO_STAMP)
COCKPIT_REPO_TREE = '$(strip $(COCKPIT_REPO_COMMIT))^{tree}'
Expand Down
2 changes: 1 addition & 1 deletion src/components/vm/disks/diskAdd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export const AddDiskModalBody = ({ disk, idPrefix, isMediaInsertion, vm, vms, su
size: 1,
unit: units.GiB.name,
volumeName: "",
permanent: true,
permanent: vm.persistent,
});
const [mode, setMode] = useState(isMediaInsertion ? CUSTOM_PATH : CREATE_NEW);
const [validate, setValidate] = useState(false);
Expand Down
6 changes: 6 additions & 0 deletions test/check-machines-create
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,9 @@ vnc_password= "{vnc_passwd}"
# Check only RHEL >= 8 is shown
b.wait_visible(f"#os-select li button:contains('{TestMachinesCreate.TestCreateConfig.RHEL_8_1}')")
b.wait_not_present(f"#os-select li button:contains('{TestMachinesCreate.TestCreateConfig.RHEL_7_1}')")
# make the select list go away to not obscure other elements
b.click("#os-select-group .pf-v5-c-select__toggle-button")
b.wait_not_present("#os-select li")

return self

Expand All @@ -1205,6 +1208,9 @@ vnc_password= "{vnc_passwd}"
next_os = b.text(f"#os-select-group li:contains({sorted_list[0]}) + li")
# The next neighbour should contain the second OS from the sorted list
self.assertEqual(next_os, sorted_list[1])
# make the select list go away to not obscure other elements
b.click("#os-select-group .pf-v5-c-select__toggle-button")
b.wait_not_present("#os-select li")
return self

def checkPXENotAvailableSession(self):
Expand Down
32 changes: 23 additions & 9 deletions test/check-machines-disks
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
b.wait_in_text("#vm-subVmTest1-system-state", "Running")

self.goToVmPage("subVmTest1")
self.waitDisks(["vda", "vde", "vdf", "vdg"])

# Test non-persistent disks are not configurable
b.wait_not_present("#vm-subVmTest1-disks-vdf-edit")
Expand Down Expand Up @@ -182,6 +183,8 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
m.execute(f"virsh attach-disk --domain subVmTest1 --source {p1}/mydisk4 --target sdb --targetbus sata --persistent")
b.reload()
b.enter_page('/machines')
# expected devices after bus type change
self.waitDisks(["sda", "sdb", "vda", "vdg"])
openDialog("sdb")
b.set_checked("#vm-subVmTest1-disks-sdb-edit-readonly", True)
save("sdb", xfail="readonly sata disks are not supported")
Expand All @@ -196,6 +199,9 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
# virsh attach-disk want send an event for offline VM changes
b.reload()
b.enter_page('/machines')
# expected devices after bus type change
self.waitDisks(["hda", "sdb", "vda", "vdg"])

openDialog("hda")
b._wait_present("#vm-subVmTest1-disks-hda-edit-bus-type option[value=sata]")
self.assertFalse(b.is_present("#vm-subVmTest1-disks-hda-edit-bus-type option[value=virtio]"))
Expand All @@ -214,6 +220,8 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
openDialog("sda")
b.wait_visible("#vm-subVmTest1-disks-sda-edit-bus-type:disabled")
b.wait_visible("#vm-subVmTest1-disks-sda-edit-cache-mode:disabled")
b.click("#vm-subVmTest1-disks-sda-edit-dialog button[aria-label='Close']")
b.wait_not_present("#vm-subVmTest1-disks-sda-edit-dialog")

# Disks on non-persistent VM cannot be edited
m.execute("virsh undefine subVmTest1")
Expand All @@ -222,6 +230,7 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
self.goToMainPage()
self.createVm("subVmTest2", running=False, os="unknown")
self.goToVmPage("subVmTest2")
self.waitDisks(["hda"], vm="subVmTest2")

b.wait_in_text("#vm-subVmTest2-disks-hda-bus", "ide")

Expand Down Expand Up @@ -294,7 +303,7 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
print("Restarting vm-subVmTest1, might take a while")
self.performAction("subVmTest1", "forceReboot")

b.wait_visible("#vm-subVmTest1-disks-vda-device")
self.waitDisks(["vda"])
b.wait_not_present("#vm-subVmTest1-disks-vdc-device")

# Check when no storage pool and adding existed disk
Expand Down Expand Up @@ -631,8 +640,12 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
b.select_from_dropdown(f"#vm-{self.vm_name}-disks-adddisk-existing-select-volume", self.volume_name)

# Configure persistency - by default the check box is checked
if not self.permanent:
b.set_checked(f"#vm-{self.vm_name}-disks-adddisk-permanent", False)
if self.persistent_vm:
if not self.permanent:
b.set_checked(f"#vm-{self.vm_name}-disks-adddisk-permanent", False)
else:
# checkbox not shown at all for transient VM
b.wait_not_present(f"#vm-{self.vm_name}-disks-adddisk-permanent")

# Check non-persistent VM cannot have permanent disk attached
if not self.persistent_vm:
Expand Down Expand Up @@ -1044,8 +1057,7 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
release_target(used_targets, target)

permanent_targets = [t for t in used_targets if t not in transient_targets]
for target in permanent_targets:
b.wait_visible(f"#vm-subVmTest1-disks-{target}-device")
self.waitDisks(permanent_targets)

# Check that creating a new volume in default_tmp does not by
# accident use the defaults from defaultVol.iso. Those
Expand Down Expand Up @@ -1099,7 +1111,9 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
b.click("#vm-subVmTest1-system-run")
b.wait_in_text("#vm-subVmTest1-system-state", "Running")
# Test disk attachment to non-persistent VM
b.wait_visible(".vm-top-panel[data-vm-transient=false]")
m.execute("virsh undefine subVmTest1")
b.wait_visible(".vm-top-panel[data-vm-transient=true]")
self.VMAddDiskDialog(
self,
pool_name='myPoolOne',
Expand Down Expand Up @@ -1513,6 +1527,7 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
# Test detaching non permanent disk of a running domain
b.wait_in_text("#vm-subVmTest1-system-state", "Running")
self.goToVmPage("subVmTest1")
self.waitDisks(["vda", "vdc", "vdd", "vde"])

self.deleteDisk("vdc", expect_path=vdc_path)
# Wait for underlying VM's OS to detach the disk
Expand Down Expand Up @@ -1551,10 +1566,7 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
b.reload()
b.enter_page('/machines')
self.waitPageInit()
b.wait_visible("#vm-subVmTest1-disks-sda-device")
b.wait_visible("#vm-subVmTest1-disks-sdb-device")
b.wait_visible("#vm-subVmTest1-disks-sdc-device")
b.wait_visible("#vm-subVmTest1-disks-vda-device")
self.waitDisks(["sda", "sdb", "sdc", "vda"])

def removeDiskAndChecks(target, path, removeFile=False, removeFileFail=False, removeFileNotPresent=False):
self.dropdownAction(f"#vm-subVmTest1-disks-{target}-action-kebab",
Expand Down Expand Up @@ -1649,6 +1661,8 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):

b.wait_in_text("#vm-subVmTest1-system-state", "Running")
self.goToVmPage("subVmTest1")
# wait until Disks have initialized; otherwise the kebabs jump around
self.waitDisks(["sda", "vda"])

self.VMInsertMediaDialog(
self,
Expand Down
2 changes: 2 additions & 0 deletions test/check-machines-lifecycle
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ class TestMachinesLifecycle(machineslib.VirtualMachinesCase):
b.set_input_text("#rename-dialog-new-name", "new")
b.click("#rename-dialog-confirm")
b.wait_in_text(".pf-v5-c-modal-box__body .pf-v5-c-alert.pf-m-danger", "Can't rename domain to itself")
b.click(".pf-v5-c-modal-box button:contains('Cancel')")
b.wait_not_present(".pf-v5-c-modal-box")

self.goToVmPage("new")
self.performAction("new", "rename")
Expand Down
2 changes: 2 additions & 0 deletions test/check-machines-settings
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ class TestMachinesSettings(machineslib.VirtualMachinesCase):
# Verify that unit conversions work
b.select_from_dropdown("#vm-subVmTest1-memory-modal-memory-unit-select", "GiB")
b.wait_attr("#vm-subVmTest1-memory-modal-memory", "value", "0")
b.click("#vm-memory-modal button[aria-label='Close']")
b.wait_not_present("#vm-memory-modal")

# Run VM
b.click("#vm-subVmTest1-system-run")
Expand Down
2 changes: 2 additions & 0 deletions test/check-machines-storage-pools
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ class TestMachinesStoragePools(machineslib.VirtualMachinesCase):
self.goToMainPage()
self.waitVmRow("subVmTest1")
self.goToVmPage("subVmTest1")
self.waitDisks(["vda", "vdc"])

self.deleteDisk("vdc")
self.goToMainPage()
b.click(".pf-v5-c-card .pf-v5-c-card__header button:contains(Storage pools)")
Expand Down
11 changes: 11 additions & 0 deletions test/machineslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,17 @@ def waitLogFile(self, logfile, expected_text):
def waitGuestBooted(self, logfile):
self.waitLogFile(logfile, "Welcome to Alpine Linux")

def waitDisks(self, expected_disks: list[str], vm="subVmTest1"):
"""Wait until Disks table initialized on the details

This prevents the kebabs from jumping around during re-renders, which
makes trying to click on them racy.
"""
for disk in expected_disks:
self.browser.wait_visible(f"#vm-{vm}-disks-{disk}-device") # type: ignore[attr-defined]
# HACK: we need to wait on *something* else, but no idea what..
time.sleep(0.5)


class VirtualMachinesCase(testlib.MachineCase, VirtualMachinesCaseHelpers, storagelib.StorageHelpers, netlib.NetworkHelpers):
def setUp(self):
Expand Down