Skip to content

Commit

Permalink
test: reduce line length to 150
Browse files Browse the repository at this point in the history
This is a middle step of moving the tons of long lines to a more
reasonable default.
  • Loading branch information
jelly committed Oct 3, 2024
1 parent ba92279 commit 7ecff4b
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 79 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exclude = [
"node_modules/",
]
# FIXME: we want 118, but needs fixing tests first
line-length = 183
line-length = 150
preview = true
src = []

Expand Down
5 changes: 4 additions & 1 deletion test/check-machines-consoles
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ fullscreen=0
ignore=[".pf-v5-c-console__vnc"], skip_layouts=["rtl"])

# Add a second serial console
m.execute("virsh destroy vmWithSerialConsole; virt-xml --add-device vmWithSerialConsole --console pty,target_type=virtio; virsh start vmWithSerialConsole")
m.execute("""
virsh destroy vmWithSerialConsole;
virt-xml --add-device vmWithSerialConsole --console pty,target_type=virtio;
virsh start vmWithSerialConsole""")
b.click("#pf-v5-c-console__type-selector")
b.wait_visible("#pf-v5-c-console__type-selector + .pf-v5-c-select__menu")
b.click("li:contains('Serial console (serial0)') button")
Expand Down
25 changes: 17 additions & 8 deletions test/check-machines-create
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class TestMachinesCreate(machineslib.VirtualMachinesCase):

# try to CREATE WITH DIALOG ERROR
# name
runner.checkDialogFormValidationTest(TestMachinesCreate.VmDialog(self, "", storage_size=1, os_name=None), {"vm-name": "Name must not be empty"})
runner.checkDialogFormValidationTest(TestMachinesCreate.VmDialog(self, "", storage_size=1, os_name=None),
{"vm-name": "Name must not be empty"})

# location
runner.checkDialogFormValidationTest(TestMachinesCreate.VmDialog(self, sourceType='url',
Expand Down Expand Up @@ -481,7 +482,8 @@ class TestMachinesCreate(machineslib.VirtualMachinesCase):
create_and_run=True, delete=False))

runner.checkDialogFormValidationTest(TestMachinesCreate.VmDialog(self, "existing-name", storage_size=1,
check_script_finished=False, env_is_empty=False), {"vm-name": "already exists"})
check_script_finished=False, env_is_empty=False),
{"vm-name": "already exists"})

@testlib.skipImage("TODO: fails in 50% of runs", "opensuse-tumbleweed")
def testCreatePXE(self):
Expand Down Expand Up @@ -1384,7 +1386,8 @@ vnc_password= "{vnc_passwd}"
if self.expected_os_name:
b.wait_attr("#os-select-group input", "value", self.expected_os_name)

if self.sourceType == "os" and self.os_name in [TestMachinesCreate.TestCreateConfig.RHEL_8_1, TestMachinesCreate.TestCreateConfig.RHEL_8_2]:
if self.sourceType == "os" and self.os_name in [TestMachinesCreate.TestCreateConfig.RHEL_8_1,
TestMachinesCreate.TestCreateConfig.RHEL_8_2]:
if not self.offline_token_autofilled:
b.set_input_text("#offline-token", self.offline_token)
b.wait_in_text("#offline-token", self.offline_token)
Expand Down Expand Up @@ -1848,7 +1851,9 @@ vnc_password= "{vnc_passwd}"
else:
raise AssertionError("Unknown disk device")
# New volume was created or existing volume was already chosen as destination
elif (dialog.storage_size is not None and dialog.storage_size > 0) or dialog.storage_pool not in [NO_STORAGE, NEW_VOLUME_QCOW2, NEW_VOLUME_RAW]:
elif (dialog.storage_size is not None and dialog.storage_size > 0) or dialog.storage_pool not in [NO_STORAGE,
NEW_VOLUME_QCOW2,
NEW_VOLUME_RAW]:
b.wait_visible(".disks-card table tbody:first-of-type")
if b.is_present(f"#vm-{name}-disks-vda-device"):
b.wait_in_text(f"#vm-{name}-disks-vda-device", "disk")
Expand All @@ -1863,7 +1868,8 @@ vnc_password= "{vnc_passwd}"
b.wait_in_text(f"#vm-{name}-disks-vda-type", "qcow2")
elif dialog.storage_pool == NEW_VOLUME_RAW:
b.wait_in_text(f"#vm-{name}-disks-vda-type", "raw")
elif (vm_state == "Running" and (((dialog.storage_pool == NO_STORAGE or dialog.storage_size == 0) and dialog.sourceType == 'file') or dialog.sourceType == 'url')):
elif (vm_state == "Running" and (((dialog.storage_pool == NO_STORAGE or dialog.storage_size == 0)
and dialog.sourceType == 'file') or dialog.sourceType == 'url')):
b.wait_visible(".disks-card table tbody:first-of-type")
if b.is_present(f"#vm-{name}-disks-sda-device"):
b.wait_in_text(f"#vm-{name}-disks-sda-device", "cdrom")
Expand Down Expand Up @@ -2075,7 +2081,8 @@ vnc_password= "{vnc_passwd}"

if dialog.sourceType != 'cloud':
self.browser.mouse(".pf-v5-c-tabs__list button[aria-disabled=true]:contains(Automation)", "mouseenter")
self.browser.wait_in_text("div.pf-v5-c-tooltip__content", "Automated installs are only available when downloading an image or using cloud-init.")
self.browser.wait_in_text("div.pf-v5-c-tooltip__content",
"Automated installs are only available when downloading an image or using cloud-init.")
self.browser.mouse(".pf-v5-c-tabs__list button[aria-disabled=true]:contains(Automation)", "mouseleave")
else:
self.browser.wait_visible(".pf-v5-c-tabs__list button[aria-disabled=false]:contains(Automation)")
Expand Down Expand Up @@ -2104,7 +2111,8 @@ vnc_password= "{vnc_passwd}"
b.click(".pf-v5-c-modal-box__footer button:contains(Create and edit)")
b.wait_not_present("#create-vm-dialog")

testlib.wait(lambda: "<cockpit_machines:os_variant>fedora28</cockpit_machines:os_variant>" in m.execute("virsh dumpxml VmNotInstalled"), delay=3)
testlib.wait(lambda: "<cockpit_machines:os_variant>fedora28</cockpit_machines:os_variant>" in m.execute("virsh dumpxml VmNotInstalled"),
delay=3)

self.waitVmPage("VmNotInstalled")

Expand Down Expand Up @@ -2196,7 +2204,8 @@ vnc_password= "{vnc_passwd}"
m.execute(f"> {logfile}") # clear logfile
self.performAction("VmNotInstalled", "forceOff", checkExpectedState=False)
b.wait_in_text("#vm-VmNotInstalled-system-state", "Shut off")
testlib.wait(lambda: "133120" in m.execute("virsh dominfo VmNotInstalled | grep 'Used memory'"), delay=1) # Wait until memory parameters get adjusted after shutting the VM
# Wait until memory parameters get adjusted after shutting the VM
testlib.wait(lambda: "133120" in m.execute("virsh dominfo VmNotInstalled | grep 'Used memory'"), delay=1)

# Check configuration changes survived installation
# Check memory settings have persisted
Expand Down
6 changes: 4 additions & 2 deletions test/check-machines-disks
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):

# Virtio bus type should not be shown for CDROM devices
m.execute("touch /var/lib/libvirt/novell.iso")
m.execute("virsh attach-disk --domain subVmTest1 --source /var/lib/libvirt/novell.iso --target hda --type cdrom --targetbus sata --mode readonly --persistent")
m.execute(
"virsh attach-disk --domain subVmTest1 --source /var/lib/libvirt/novell.iso --target hda --type cdrom --targetbus sata --mode readonly --persistent")
# virsh attach-disk want send an event for offline VM changes
b.reload()
b.enter_page('/machines')
Expand Down Expand Up @@ -722,7 +723,8 @@ class TestMachinesDisks(machineslib.VirtualMachinesCase):
self.test_obj.waitPoolRow(self.pool_name)
self.test_obj.togglePoolRow(self.pool_name)

b.click(f"tr[data-row-id=pool-{self.pool_name}-system] + tr li:contains('Storage volumes') button") # open the "Storage volumes" subtab
# open the "Storage volumes" subtab
b.click(f"tr[data-row-id=pool-{self.pool_name}-system] + tr li:contains('Storage volumes') button")
b.wait_visible(f"#pool-{self.pool_name}-system-volume-{self.volume_name}-name")

b.click(".machines-listing-breadcrumb li a:contains(Virtual machines)")
Expand Down
4 changes: 2 additions & 2 deletions test/check-machines-filesystems
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class TestMachinesFilesystems(machineslib.VirtualMachinesCase):
b.set_input_text("#vm-subVmTest1-filesystems-modal-mountTag", "")
b.set_input_text("#vm-subVmTest1-filesystems-modal-source-group input", "/tmp")
# In some hosts with the high latency, the path of the expand list needs some time to load, the check will fail if it is too quick.
# Thus, add a check that the folder input appears in the expand list(#vm-{name}-filesystems-modal-source) to ensure that the loading is finished
# #vm-{name}-filesystems-modal-source only contains the expand list, without the input line
# Thus, add a check that the folder input appears in the expand list(#vm-{name}-filesystems-modal-source)
# to ensure that the loading is finished #vm-{name}-filesystems-modal-source only contains the expand list, without the input line.
b.wait_in_text("#vm-subVmTest1-filesystems-modal-source", "/tmp")
b.click("#vm-subVmTest1-filesystems-modal-source button:nth-child(1)")
# Check the expand list disappears
Expand Down
3 changes: 2 additions & 1 deletion test/check-machines-migrate
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class TestMachinesMigration(machineslib.VirtualMachinesCase):

if fail != "port_closed":
# Plain migration: The source host VM opens a direct unencrypted TCP connection to the destination host for sending the migration data.
# Unless a port is manually specified, libvirt will choose a migration port in the range 49152-49215, which will need to be open in the firewall on the remote host.
# Unless a port is manually specified, libvirt will choose a migration port in the range 49152-49215,
# which will need to be open in the firewall on the remote host.
# https://wiki.libvirt.org/page/FAQ
machine2.execute("systemctl start firewalld")
machine2.execute("firewall-cmd --permanent --add-port 49152-49215/tcp")
Expand Down
Loading

0 comments on commit 7ecff4b

Please sign in to comment.