2018-04-04 14:35:41 +01:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 15:00:02 -04:00
# See the COPYING file in the top-level directory.
2016-04-18 16:42:12 -04:00
from tests . uitests import utils as uiutils
2019-03-26 11:43:12 -04:00
import tests . utils
2016-04-18 16:42:12 -04:00
2015-09-14 14:11:04 -04:00
2018-01-09 10:01:56 -05:00
class Details ( uiutils . UITestCase ) :
2015-09-14 14:11:04 -04:00
"""
UI tests for virt - manager ' s VM details window
"""
2018-01-20 17:25:16 -05:00
def _select_hw ( self , win , hwname , tabname ) :
c = win . find ( hwname , " table cell " )
if not c . onscreen :
hwlist = win . find ( " hw-list " )
hwlist . click ( )
while not c . onscreen :
self . pressKey ( " Down " )
c . click ( )
tab = win . find ( tabname , None )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : tab . showing )
2018-01-20 17:25:16 -05:00
return tab
def _stop_vm ( self , win ) :
run = win . find ( " Run " , " push button " )
win . find ( " Shut Down " , " push button " ) . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : run . sensitive )
2018-01-20 17:25:16 -05:00
def _start_vm ( self , win ) :
run = win . find ( " Run " , " push button " )
run . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not run . sensitive )
2018-01-20 17:25:16 -05:00
2015-09-14 14:11:04 -04:00
##############
# Test cases #
##############
2020-08-22 14:21:49 -04:00
def _testSmokeTest ( self , vmname ) :
2015-09-14 14:11:04 -04:00
"""
Open the VM with all the crazy hardware and just verify that each
HW panel shows itself without raising any error .
"""
2020-08-22 14:21:49 -04:00
win = self . _open_details_window ( vmname = vmname , double = True )
2018-01-19 10:51:33 -05:00
lst = win . find ( " hw-list " , " table " )
2018-01-11 09:46:41 -05:00
self . _walkUIList ( win , lst , lambda : False )
2017-03-08 13:08:22 -05:00
2019-05-23 16:14:39 -04:00
# Select XML editor, and reverse walk the list
win . find ( " XML " , " page tab " ) . click ( )
self . _walkUIList ( win , lst , lambda : False , reverse = True )
2020-08-27 16:37:15 -04:00
return win
2019-05-23 16:14:39 -04:00
2020-08-22 14:21:49 -04:00
def testDetailsHardwareSmokeTest ( self ) :
self . _testSmokeTest ( None )
def testDetailsHardwareSmokeTestAlternate ( self ) :
2020-08-23 13:48:59 -04:00
self . app . open ( keyfile = " allstats.ini " )
2020-08-27 16:37:15 -04:00
win = self . _testSmokeTest ( " test alternate devs title " )
win . find ( " Details " , " page tab " ) . click ( )
self . _select_hw ( win , " Performance " , " performance-tab " )
# Wait for perf signals to trigger, to cover more code
self . sleep ( 2 )
2020-08-22 14:21:49 -04:00
2017-03-08 13:08:22 -05:00
def _testRename ( self , origname , newname ) :
2020-08-23 13:48:59 -04:00
# Enable all stats prefs to hit some extra code
2017-03-08 13:08:22 -05:00
win = self . _open_details_window ( origname )
# Ensure the Overview page is the first selected
2018-01-19 10:51:33 -05:00
win . find ( " Hypervisor Details " , " label " )
win . find ( " Overview " , " table cell " ) . click ( )
2017-03-08 13:08:22 -05:00
2018-01-10 18:57:40 -05:00
oldcell = self . app . root . find_fuzzy ( origname , " table cell " )
2020-08-27 16:37:15 -04:00
badname = " foo/bar "
win . find ( " Name: " , " text " ) . set_text ( badname )
appl = win . find ( " config-apply " )
appl . click ( )
self . _click_alert_button ( badname , " Close " )
# Actual name change
2020-08-27 12:23:14 -04:00
win . find ( " Name: " , " text " ) . set_text ( newname )
2020-08-27 16:37:15 -04:00
appl . click ( )
uiutils . check ( lambda : not appl . sensitive )
2017-03-08 13:08:22 -05:00
# Confirm lists were updated
2018-01-19 10:51:33 -05:00
self . app . root . find ( " %s on " % newname , " frame " )
2018-01-10 18:57:40 -05:00
self . app . root . find_fuzzy ( newname , " table cell " )
2017-03-08 13:08:22 -05:00
2018-01-10 16:42:53 -05:00
# Make sure the old entry is gone
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : origname not in oldcell . name )
2017-03-08 13:08:22 -05:00
def testDetailsRenameSimple ( self ) :
"""
Rename a simple VM
"""
self . _testRename ( " test-clone-simple " , " test-new-name " )
def testDetailsRenameNVRAM ( self ) :
"""
Rename a VM that will trigger the nvram behavior
"""
origname = " test-many-devices "
# Shutdown the VM
2018-01-10 18:57:40 -05:00
self . app . root . find_fuzzy ( origname , " table cell " ) . click ( )
2018-01-19 10:51:33 -05:00
b = self . app . root . find ( " Shut Down " , " push button " )
2018-01-09 10:45:46 -05:00
b . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : b . sensitive is False )
2017-03-08 13:08:22 -05:00
self . _testRename ( origname , " test-new-name " )
2018-01-20 17:25:16 -05:00
2020-08-26 18:01:02 -04:00
def testDetailsStateMisc ( self ) :
"""
Test state changes and unapplied changes warnings
"""
self . app . uri = tests . utils . URIs . kvm
win = self . _open_details_window ( vmname = " test " , shutdown = True )
2020-08-27 16:37:15 -04:00
fmenu = win . find ( " File " , " menu " )
fmenu . click ( )
fmenu . find ( " View Manager " ) . click ( )
2020-08-26 18:01:02 -04:00
# Double run to hit a show() codepath
win = self . _open_details_window ( vmname = " test " )
uiutils . check ( lambda : win . active )
appl = win . find ( " config-apply " , " push button " )
# View Manager option
win . find ( " File " , " menu " ) . click ( )
win . find ( " View Manager " , " menu item " ) . click ( )
uiutils . check ( lambda : self . app . topwin . active )
self . app . topwin . keyCombo ( " <alt>F4 " )
uiutils . check ( lambda : win . active )
# Make a change and then trigger unapplied change warning
tab = self . _select_hw ( win , " Overview " , " overview-tab " )
2020-08-27 12:23:14 -04:00
tab . find ( " Name: " , " text " ) . set_text ( " " )
2020-08-26 18:01:02 -04:00
uiutils . check ( lambda : appl . sensitive )
run = win . find ( " Run " , " push button " )
run . click ( )
# Trigger apply error to hit some code paths
self . _click_alert_button ( " unapplied changes " , " Yes " )
self . _click_alert_button ( " name must be specified " , " Close " )
uiutils . check ( lambda : run . sensitive )
consolebtn = win . find ( " Console " , " radio button " )
consolebtn . click ( )
self . _click_alert_button ( " unapplied changes " , " Yes " )
self . _click_alert_button ( " name must be specified " , " Close " )
uiutils . check ( lambda : not consolebtn . checked )
# Test the pause toggle
win . find ( " config-cancel " ) . click ( )
run . click ( )
uiutils . check ( lambda : not run . sensitive )
pause = win . find ( " Pause " , " toggle button " )
pause . click ( )
uiutils . check ( lambda : pause . checked )
pause . click ( )
uiutils . check ( lambda : not pause . checked )
uiutils . check ( lambda : win . active )
2018-09-29 16:04:05 -04:00
def testDetailsEditDomain1 ( self ) :
"""
Test overview , memory , cpu pages
"""
2020-08-26 18:01:02 -04:00
self . app . uri = tests . utils . URIs . kvm_cpu_insecure
2020-01-25 15:11:02 -05:00
win = self . _open_details_window ( vmname = " test " )
2018-01-20 17:25:16 -05:00
appl = win . find ( " config-apply " , " push button " )
# Overview description
tab = self . _select_hw ( win , " Overview " , " overview-tab " )
2020-08-27 12:23:14 -04:00
tab . find ( " Description: " , " text " ) . set_text ( " hey new description " )
tab . find ( " Title: " , " text " ) . set_text ( " hey new title " )
2018-01-20 17:25:16 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 17:25:16 -05:00
2020-01-25 15:25:16 -05:00
# There's no hotplug operations after this point
self . _stop_vm ( win )
2018-01-20 17:25:16 -05:00
2020-01-25 15:25:16 -05:00
# Memory
2018-01-20 17:25:16 -05:00
tab = self . _select_hw ( win , " Memory " , " memory-tab " )
2020-08-27 12:23:14 -04:00
tab . find ( " Memory allocation: " , " spin button " ) . set_text ( " 300 " )
2018-01-20 17:25:16 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
# Static CPU config
# more cpu config: host-passthrough, copy, clear CPU, manual
2020-08-26 18:01:02 -04:00
tab = self . _select_hw ( win , " CPUs " , " cpu-tab " )
2018-01-20 18:21:54 -05:00
tab . find ( " cpu-model " ) . click_combo_entry ( )
tab . find_fuzzy ( " Clear CPU " , " menu item " ) . click ( )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
tab . find ( " cpu-model " ) . click_combo_entry ( )
tab . find ( " coreduo " , " menu item " ) . click ( )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2020-08-26 18:01:02 -04:00
tab . find_fuzzy ( " CPU security " , " check box " ) . click ( )
appl . click ( )
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
tab . find ( " cpu-model " ) . click_combo_entry ( )
tab . find ( " Application Default " , " menu item " ) . click ( )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2020-08-26 18:01:02 -04:00
copyhost = tab . find ( " Copy host " , " check box " )
2020-08-27 12:23:14 -04:00
uiutils . check ( lambda : copyhost . checked )
2020-08-26 18:01:02 -04:00
copyhost . click ( )
2018-01-20 18:21:54 -05:00
tab . find ( " cpu-model " ) . click_combo_entry ( )
tab . find ( " Hypervisor Default " , " menu item " ) . click ( )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2020-08-27 12:23:14 -04:00
tab . find ( " cpu-model " ) . find ( None , " text " ) . text = " host-passthrough "
2020-08-26 18:01:02 -04:00
appl . click ( )
uiutils . check ( lambda : not appl . sensitive )
# vCPUs
2020-08-27 12:23:14 -04:00
tab . find ( " vCPU allocation: " , " spin button " ) . set_text ( " 50 " )
2020-08-26 18:01:02 -04:00
appl . click ( )
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
# CPU topology
2020-01-25 15:11:02 -05:00
tab . find_fuzzy ( " Topology " , " toggle button " ) . click_expander ( )
2018-01-20 18:21:54 -05:00
tab . find_fuzzy ( " Manually set " , " check " ) . click ( )
2020-08-26 18:01:02 -04:00
sockets = tab . find ( " Sockets: " , " spin button " )
sockets . typeText ( " 8 " )
2018-01-20 18:21:54 -05:00
tab . find ( " Cores: " , " spin button " ) . typeText ( " 2 " )
tab . find ( " Threads: " , " spin button " ) . typeText ( " 2 " )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2020-08-26 18:01:02 -04:00
# Confirm VCPUs were adjusted
2020-08-25 09:48:56 -04:00
vcpualloc = tab . find_fuzzy ( " vCPU allocation " , " spin " )
uiutils . check ( lambda : vcpualloc . text == " 32 " )
2018-01-20 18:21:54 -05:00
2020-08-26 18:01:02 -04:00
# Unset topology
tab . find_fuzzy ( " Manually set " , " check " ) . click ( )
uiutils . check ( lambda : not sockets . sensitive )
appl . click ( )
2020-08-27 18:05:48 -04:00
uiutils . check ( lambda : not appl . sensitive )
2020-08-26 18:01:02 -04:00
2018-01-20 17:25:16 -05:00
2018-09-29 16:04:05 -04:00
def testDetailsEditDomain2 ( self ) :
"""
Test boot and OS pages
"""
win = self . _open_details_window ( vmname = " test-many-devices " )
appl = win . find ( " config-apply " , " push button " )
self . _stop_vm ( win )
# OS edits
tab = self . _select_hw ( win , " OS information " , " os-tab " )
entry = tab . find ( " oslist-entry " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : entry . text == " Fedora " )
2018-09-29 16:04:05 -04:00
entry . click ( )
self . pressKey ( " Down " )
popover = win . find ( " oslist-popover " )
popover . find ( " include-eol " ) . click ( )
2020-08-27 12:23:14 -04:00
entry . set_text ( " fedora12 " )
2018-09-29 16:04:05 -04:00
popover . find_fuzzy ( " fedora12 " ) . bring_on_screen ( ) . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not popover . visible )
uiutils . check ( lambda : entry . text == " Fedora 12 " )
2018-09-29 16:04:05 -04:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
uiutils . check ( lambda : entry . text == " Fedora 12 " )
2018-09-29 16:04:05 -04:00
# Boot tweaks
2018-01-20 17:25:16 -05:00
def check_bootorder ( c ) :
# Click the bootlist checkbox, which is hard to find in the tree
import dogtail . rawinput
x = c . position [ 0 ] - 30
y = c . position [ 1 ] + c . size [ 1 ] / 2
button = 1
dogtail . rawinput . click ( x , y , button )
tab = self . _select_hw ( win , " Boot Options " , " boot-tab " )
tab . find_fuzzy ( " Start virtual machine on host " , " check box " ) . click ( )
tab . find ( " Enable boot menu " , " check box " ) . click ( )
2020-08-27 12:23:14 -04:00
tab . find ( " SCSI Disk 1 " , " table cell " ) . click ( )
2018-01-20 17:25:16 -05:00
tab . find ( " boot-movedown " , " push button " ) . click ( )
tab . find ( " Floppy 1 " , " table cell " ) . click ( )
tab . find ( " boot-moveup " , " push button " ) . click ( )
2020-08-27 12:23:14 -04:00
check_bootorder ( tab . find ( " NIC :33:44 " , " table cell " ) )
check_bootorder ( tab . find ( " PCI 0003: " , " table cell " ) )
2018-01-20 17:25:16 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 17:25:16 -05:00
# Kernel boot
tab . find_fuzzy ( " Direct kernel boot " , " toggle button " ) . click_expander ( )
tab . find_fuzzy ( " Enable direct kernel " , " check box " ) . click ( )
2020-08-26 18:01:02 -04:00
2020-08-27 12:23:14 -04:00
tab . find ( " Kernel args: " , " text " ) . set_text ( " console=ttyS0 " )
2020-08-26 18:01:02 -04:00
appl . click ( )
self . _click_alert_button ( " arguments without specifying " , " OK " )
uiutils . check ( lambda : win . active )
initrd = tab . find ( " Initrd path: " , " text " )
tab . find ( " initrd-browse " , " push button " ) . click ( )
self . _select_storagebrowser_volume ( " default-pool " , " backingl1.img " )
uiutils . check ( lambda : win . active )
uiutils . check ( lambda : " backing " in initrd . text )
appl . click ( )
self . _click_alert_button ( " initrd without specifying " , " OK " )
uiutils . check ( lambda : win . active )
2018-01-20 17:25:16 -05:00
tab . find ( " kernel-browse " , " push button " ) . click ( )
2020-08-25 10:33:20 -04:00
self . _select_storagebrowser_volume ( " default-pool " , " bochs-vol " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : win . active )
kernelpath = tab . find ( " Kernel path: " , " text " )
uiutils . check ( lambda : " bochs " in kernelpath . text )
2020-08-26 18:01:02 -04:00
dtb = tab . find ( " DTB path: " , " text " )
tab . find ( " dtb-browse " , " push button " ) . click ( )
self . _select_storagebrowser_volume ( " default-pool " , " iso-vol " )
uiutils . check ( lambda : win . active )
uiutils . check ( lambda : " iso-vol " in dtb . text )
2018-01-20 17:25:16 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 17:25:16 -05:00
2020-08-26 18:01:02 -04:00
# Now disable kernel, but verify that we keep the values in the UI
tab . find_fuzzy ( " Enable direct kernel " , " check box " ) . click ( )
appl . click ( )
uiutils . check ( lambda : not appl . sensitive )
tab = self . _select_hw ( win , " OS information " , " os-tab " )
tab = self . _select_hw ( win , " Boot Options " , " boot-tab " )
uiutils . check ( lambda : " backing " in initrd . text )
2018-01-20 18:21:54 -05:00
2020-08-27 16:37:15 -04:00
def testDetailsAlternateEdits ( self ) :
"""
Some specific handling via test - alternate - devs
"""
win = self . _open_details_window ( vmname = " test alternate devs title " )
# tests the console dup removal
self . _select_hw ( win , " Serial 1 " , " char-tab " )
win . find ( " config-remove " ) . click ( )
self . _click_alert_button ( " Are you sure " , " Yes " )
self . _click_alert_button ( " take effect after " , " OK " )
self . _stop_vm ( win )
def testDetailsEmptyBoot ( self ) :
"""
Check boot handling when VM has no devices
"""
win = self . _open_details_window ( vmname = " test-state-crashed " )
self . _select_hw ( win , " Boot Options " , " boot-tab " )
win . find ( " No bootable devices " )
# Add in switching back to the console view to hit a vmwindow path
win . find ( " Console " , " radio button " ) . click ( )
2018-09-29 16:04:05 -04:00
def testDetailsEditDiskNet ( self ) :
"""
Test disk and network devices
"""
win = self . _open_details_window ( vmname = " test-many-devices " )
appl = win . find ( " config-apply " , " push button " )
2020-08-28 10:25:38 -04:00
# Quick test to hit some serialcon.py paths
viewmenu = win . find ( " ^View$ " , " menu " )
viewmenu . click ( )
textmenu = viewmenu . find ( " Text Consoles " , " menu " )
textmenu . point ( )
conitem = textmenu . find ( " Serial 1 " )
uiutils . check ( lambda : not conitem . sensitive )
viewmenu . click ( )
self . _stop_vm ( win )
2018-09-29 16:04:05 -04:00
2018-01-20 17:25:16 -05:00
# Disk options
tab = self . _select_hw ( win , " IDE Disk 1 " , " disk-tab " )
2020-09-07 18:29:20 -04:00
tab . find ( " Advanced options " , " toggle button " ) . click_expander ( )
2018-01-20 17:25:16 -05:00
tab . find ( " Shareable: " , " check box " ) . click ( )
tab . find ( " Readonly: " , " check box " ) . click ( )
2020-09-08 12:16:19 -04:00
tab . find ( " Serial: " , " text " ) . set_text ( " 1234-ABCD " )
2020-09-07 18:29:20 -04:00
tab . combo_select ( " Cache mode: " , " unsafe " )
tab . combo_select ( " Discard mode: " , " unmap " )
tab . combo_select ( " Detect zeroes: " , " unmap " )
2018-01-20 17:25:16 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 17:25:16 -05:00
2020-01-25 19:47:35 -05:00
# Network values w/ macvtap manual
2018-01-20 17:25:16 -05:00
tab = self . _select_hw ( win , " NIC :54:32:10 " , " network-tab " )
2020-08-26 18:01:02 -04:00
tab . find ( " IP address " , " push button " ) . click ( )
2020-08-25 12:46:59 -04:00
src = tab . find ( " net-source " )
2018-01-20 17:25:16 -05:00
src . click ( )
2020-01-25 19:47:35 -05:00
self . pressKey ( " Home " )
tab . find_fuzzy ( " Macvtap device... " ,
" menu item " ) . bring_on_screen ( ) . click ( )
2020-08-27 12:23:14 -04:00
tab . find ( " Device name: " , " text " ) . set_text ( " fakedev12 " )
2020-08-25 12:46:59 -04:00
tab . combo_select ( " Device model: " , " rtl8139 " )
2020-08-26 18:01:02 -04:00
tab . find ( " Link state: " , " check box " ) . click ( )
2018-01-20 17:25:16 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 17:25:16 -05:00
# Manual bridge
src . click ( )
2020-01-25 16:48:44 -05:00
tab . find_fuzzy ( " Bridge device... " ,
2018-09-02 01:25:22 +03:00
" menu item " ) . bring_on_screen ( ) . click ( )
2020-08-27 12:23:14 -04:00
tab . find ( " Device name: " , " text " ) . set_text ( " " )
2018-01-20 17:25:16 -05:00
appl . click ( )
# Check validation error
2020-08-21 12:55:10 -04:00
self . _click_alert_button ( " Error changing VM configuration " , " Close " )
2020-08-27 12:23:14 -04:00
tab . find ( " Device name: " , " text " ) . set_text ( " zbr0 " )
2018-01-20 17:25:16 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 17:25:16 -05:00
2020-08-27 16:29:10 -04:00
def testDetailsNetIPAddress ( self ) :
"""
Test all the IP code paths with a few mock cases
"""
win = self . _open_details_window ( vmname = " test-many-devices " )
def check_ip ( * args ) :
for ip in args :
tab . find_fuzzy ( ip , " label " )
# First case has a virtual network, so hits the leases path
tab = self . _select_hw ( win , " NIC :54:32:10 " , " network-tab " )
check_ip ( " 10.0.0.2 " , " fd00:beef::2 " )
tab . find ( " IP address: " , " push button " ) . click ( )
check_ip ( " 10.0.0.2 " , " fd00:beef::2 " )
# Next case has a missing virtual network, so hits the arp path
tab = self . _select_hw ( win , " NIC :11:11:11 " , " network-tab " )
check_ip ( " Unknown " )
tab . find ( " IP address: " , " push button " ) . click ( )
check_ip ( " 10.0.0.3 " )
win . keyCombo ( " <alt>F4 " )
uiutils . check ( lambda : not win . showing )
self . app . topwin . click_title ( )
# Tests the fake qemu guest agent path
win = self . _open_details_window ( vmname = " test alternate devs title " )
tab = self . _select_hw ( win , " NIC :11:72:72 " , " network-tab " )
check_ip ( " 10.0.0.1 " , " fd00:beef::1/128 " )
2018-01-20 17:25:16 -05:00
2020-08-26 18:01:02 -04:00
def testDetailsEditDevices1 ( self ) :
2018-09-29 16:04:05 -04:00
"""
Test all other devices
"""
2020-08-27 16:37:15 -04:00
win = self . _open_details_window ( vmname = " test-many-devices " )
2018-09-29 16:04:05 -04:00
appl = win . find ( " config-apply " , " push button " )
2020-08-27 16:29:10 -04:00
# Fail to hotremove
tab = self . _select_hw ( win , " Floppy 1 " , " disk-tab " )
2020-09-07 18:29:20 -04:00
tab . find ( " Advanced options " , " toggle button " ) . click_expander ( )
2020-08-27 16:29:10 -04:00
share = tab . find ( " Shareable " , " check box " )
share . click ( )
uiutils . check ( lambda : appl . sensitive )
win . find ( " config-remove " ) . click ( )
delete = self . app . root . find_fuzzy ( " Remove Disk " , " frame " )
delete . find_fuzzy ( " Delete " , " button " ) . click ( )
self . _click_alert_button ( " change will take effect " , " OK " )
uiutils . check ( lambda : not delete . showing )
uiutils . check ( lambda : appl . sensitive )
uiutils . check ( lambda : share . checked )
win . find ( " config-cancel " ) . click ( )
self . _stop_vm ( win )
2020-08-26 18:01:02 -04:00
# Graphics simple VNC -> SPICE
2018-01-20 18:21:54 -05:00
tab = self . _select_hw ( win , " Display VNC " , " graphics-tab " )
2020-08-25 12:46:59 -04:00
tab . combo_select ( " Type: " , " Spice " )
2018-01-20 18:21:54 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
2020-08-26 18:01:02 -04:00
# Spice GL example
tab . combo_select ( " Listen type: " , " None " )
tab . find ( " OpenGL: " , " check box " ) . click ( )
tab . combo_check_default ( " graphics-rendernode " , " 0000 " )
2018-01-20 18:21:54 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
2020-08-26 18:01:02 -04:00
# Switch to VNC with options
tab . combo_select ( " Type: " , " VNC " )
tab . combo_select ( " Listen type: " , " Address " )
tab . find ( " graphics-port-auto " , " check " ) . click ( )
2020-09-01 18:04:38 -04:00
tab . find ( " graphics-port-auto " , " check " ) . click ( )
2020-08-27 12:23:14 -04:00
tab . find ( " graphics-port " , " spin button " ) . set_text ( " 6001 " )
2020-08-26 18:01:02 -04:00
tab . find ( " Password: " , " check " ) . click ( )
passwd = tab . find_fuzzy ( " graphics-password " , " text " )
newpass = " foobar "
passwd . typeText ( newpass )
appl . click ( )
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
# Sound device
tab = self . _select_hw ( win , " Sound sb16 " , " sound-tab " )
2020-08-27 12:23:14 -04:00
tab . find ( " Model: " , " text " ) . set_text ( " ac97 " )
2018-01-20 18:21:54 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2020-08-26 18:01:02 -04:00
# Test non-disk removal
win . find ( " config-remove " ) . click ( )
cell = win . find ( " Sound ac97 " , " table cell " )
oldtext = cell . text
self . _click_alert_button ( " Are you sure " , " No " )
uiutils . check ( lambda : cell . state_selected )
cell . click ( button = 3 )
self . app . root . find ( " Remove Hardware " , " menu item " ) . click ( )
self . _click_alert_button ( " Are you sure " , " Yes " )
uiutils . check ( lambda : cell . text != oldtext )
2018-01-20 18:21:54 -05:00
# Host device
tab = self . _select_hw ( win , " PCI 0000:00:19.0 " , " host-tab " )
tab . find ( " ROM BAR: " , " check box " ) . click ( )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
# Video device
tab = self . _select_hw ( win , " Video VMVGA " , " video-tab " )
2020-08-27 12:23:14 -04:00
tab . find ( " Model: " , " text " ) . set_text ( " virtio " )
2018-01-20 18:21:54 -05:00
tab . find ( " 3D acceleration: " , " check box " ) . click ( )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
# Watchdog
tab = self . _select_hw ( win , " Watchdog " , " watchdog-tab " )
2020-08-27 12:23:14 -04:00
tab . find ( " Model: " , " text " ) . set_text ( " diag288 " )
2018-01-20 18:21:54 -05:00
tab . find ( " Action: " , " text " ) . click ( )
self . pressKey ( " Down " )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
2020-08-26 18:01:02 -04:00
def testDetailsEditDevices2 ( self ) :
win = self . _open_details_window ( vmname = " test-many-devices " ,
shutdown = True )
appl = win . find ( " config-apply " , " push button " )
2018-01-20 18:21:54 -05:00
# Controller SCSI
tab = self . _select_hw (
2020-07-13 13:07:06 -04:00
win , " Controller VirtIO SCSI 9 " , " controller-tab " )
2020-08-25 12:46:59 -04:00
tab . combo_select ( " controller-model " , " Hypervisor " )
2018-01-20 18:21:54 -05:00
tab . find ( " SCSI Disk 1 on 9:0:0:0 " , " table cell " )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
# Controller USB
tab = self . _select_hw ( win , " Controller USB 0 " , " controller-tab " )
2020-08-25 12:46:59 -04:00
tab . combo_select ( " controller-model " , " USB 2 " )
2018-01-20 18:21:54 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
tab = self . _select_hw ( win , " Controller USB 0 " , " controller-tab " )
2020-08-25 12:46:59 -04:00
tab . combo_select ( " controller-model " , " USB 3 " )
2018-01-20 18:21:54 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2020-08-27 16:37:15 -04:00
tab = self . _select_hw ( win , " Controller USB 0 " , " controller-tab " )
tab . find ( " controller-model " ) . find ( None , " text " ) . text = " piix3-uhci "
appl . click ( )
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
# Filesystem tweaks
tab = self . _select_hw ( win , " Filesystem /target/ " , " filesystem-tab " )
2020-08-25 12:46:59 -04:00
tab . combo_select ( " Driver: " , " Path " )
tab . combo_select ( " Write Policy: " , " Immediate " )
2020-08-27 12:23:14 -04:00
tab . find ( " Source path: " , " text " ) . set_text ( " /frib1 " )
tab . find ( " Target path: " , " text " ) . set_text ( " newtarget " )
2018-01-20 18:21:54 -05:00
tab . find_fuzzy ( " Export filesystem " , " check box " ) . click ( )
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
# Smartcard tweaks
tab = self . _select_hw ( win , " Smartcard " , " smartcard-tab " )
2020-08-25 12:46:59 -04:00
tab . combo_select ( " smartcard-mode " , " Passthrough " )
2018-01-20 18:21:54 -05:00
appl . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
2020-08-26 18:01:02 -04:00
# TPM tweaks
tab = self . _select_hw ( win , " TPM " , " tpm-tab " )
tab . combo_select ( " tpm-model " , " CRB " )
appl . click ( )
uiutils . check ( lambda : not appl . sensitive )
2018-01-20 18:21:54 -05:00
2019-01-08 12:06:02 -05:00
# vsock tweaks
2020-07-13 13:07:06 -04:00
tab = self . _select_hw ( win , " VirtIO VSOCK " , " vsock-tab " )
2019-01-08 12:06:02 -05:00
addr = tab . find ( " vsock-cid " )
auto = tab . find ( " vsock-auto " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : addr . text == " 5 " )
2020-08-27 12:23:14 -04:00
addr . set_text ( " 7 " )
2020-08-26 18:01:02 -04:00
appl . click ( )
uiutils . check ( lambda : addr . text == " 7 " )
uiutils . check ( lambda : not appl . sensitive )
2019-01-08 12:06:02 -05:00
auto . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not addr . visible )
2019-01-08 12:06:02 -05:00
appl . click ( )
2020-08-26 18:01:02 -04:00
uiutils . check ( lambda : not appl . sensitive )
2019-01-08 12:06:02 -05:00
2018-01-20 18:21:54 -05:00
def testDetailsMiscEdits ( self ) :
2018-01-20 17:25:16 -05:00
"""
2018-05-21 20:42:50 +01:00
Test misc editing behavior , like checking for unapplied
2018-01-20 18:21:54 -05:00
changes
"""
2018-03-17 18:41:12 -04:00
win = self . _open_details_window ( vmname = " test-many-devices " ,
double = True )
2018-01-20 18:21:54 -05:00
hwlist = win . find ( " hw-list " )
2018-01-20 17:25:16 -05:00
2018-01-20 18:21:54 -05:00
# Live device removal, see results after shutdown
disklabel = " SCSI Disk 1 "
tab = self . _select_hw ( win , disklabel , " disk-tab " )
win . find ( " config-remove " , " push button " ) . click ( )
2020-01-28 11:34:23 -05:00
delete = self . app . root . find_fuzzy ( " Remove Disk " , " frame " )
2020-01-24 14:59:44 -05:00
delete . find_fuzzy ( " Delete " , " button " ) . click ( )
2018-01-20 17:25:16 -05:00
2020-01-24 14:59:44 -05:00
# Will be fixed eventually
2020-08-21 12:55:10 -04:00
self . _click_alert_button ( " Device could not be removed " , " OK " )
2018-01-20 18:21:54 -05:00
c = hwlist . find ( disklabel , " table cell " )
self . _stop_vm ( win )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : c . text != disklabel )
2018-01-20 18:21:54 -05:00
# Remove a device for offline VM
tab = self . _select_hw ( win , " SCSI CDROM 1 " , " disk-tab " )
win . find ( " config-remove " , " push button " ) . click ( )
2020-01-28 11:34:23 -05:00
delete = self . app . root . find_fuzzy ( " Remove Disk " , " frame " )
2020-01-24 14:59:44 -05:00
delete . find_fuzzy ( " Delete " , " button " ) . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : win . active )
2018-01-20 18:21:54 -05:00
2020-08-26 18:01:02 -04:00
# Attempt to apply changes when skipping away, but they fail
tab . find ( " Advanced options " , " toggle button " ) . click_expander ( )
2020-09-07 18:29:20 -04:00
tab . find ( " Cache mode: " , " combo " ) . find ( None , " text " ) . set_text ( " badcachemode " )
2020-08-26 18:01:02 -04:00
hwlist . find ( " CPUs " , " table cell " ) . click ( )
self . _click_alert_button ( " There are unapplied changes " , " Yes " )
self . _click_alert_button ( " badcachemode " , " Close " )
2018-01-20 18:21:54 -05:00
# Cancelling changes
tab = self . _select_hw ( win , " IDE Disk 1 " , " disk-tab " )
share = tab . find ( " Shareable: " , " check box " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not share . checked )
2018-01-20 18:21:54 -05:00
share . click ( )
win . find ( " config-cancel " ) . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not share . checked )
2018-01-20 18:21:54 -05:00
# Unapplied, clicking no
share = tab . find ( " Shareable: " , " check box " )
share . click ( )
hwlist . find ( " CPUs " , " table cell " ) . click ( )
2020-08-21 12:55:10 -04:00
self . _click_alert_button ( " There are unapplied changes " , " No " )
2018-01-20 18:21:54 -05:00
tab = self . _select_hw ( win , " IDE Disk 1 " , " disk-tab " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not share . checked )
2018-01-20 18:21:54 -05:00
# Unapplied changes but clicking yes
share . click ( )
hwlist . find ( " CPUs " , " table cell " ) . click ( )
alert = self . app . root . find ( " vmm dialog " , " alert " )
alert . find_fuzzy ( " There are unapplied changes " , " label " )
alert . find_fuzzy ( " Don ' t warn " , " check box " ) . click ( )
alert . find ( " Yes " , " push button " ) . click ( )
tab = self . _select_hw ( win , " IDE Disk 1 " , " disk-tab " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : share . checked )
2018-01-20 18:21:54 -05:00
# Make sure no unapplied changes option sticks
share . click ( )
self . _select_hw ( win , " CPUs " , " cpu-tab " )
tab = self . _select_hw ( win , " IDE Disk 1 " , " disk-tab " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : share . checked )
2018-01-20 18:21:54 -05:00
# VM State change doesn't refresh UI
share . click ( )
2018-01-20 17:25:16 -05:00
self . _start_vm ( win )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not share . checked )
2018-01-20 18:21:54 -05:00
# Now apply changes to running VM, ensure they show up on shutdown
win . find ( " config-apply " ) . click ( )
2020-08-21 12:55:10 -04:00
self . _click_alert_button ( " changes will take effect " , " OK " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : share . checked )
2018-01-20 18:21:54 -05:00
self . _stop_vm ( win )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not share . checked )
2019-05-23 16:14:39 -04:00
2019-06-15 11:58:43 +02:00
# Unapplied changes should warn when switching to XML tab
tab = self . _select_hw ( win , " Overview " , " overview-tab " )
2020-08-27 12:23:14 -04:00
tab . find ( " Description: " , " text " ) . set_text ( " hey new description " )
2019-06-15 11:58:43 +02:00
win . find ( " XML " , " page tab " ) . click ( )
# Select 'No', meaning don't abandon changes
2020-08-21 12:55:10 -04:00
self . _click_alert_button ( " changes will be lost " , " No " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : tab . showing )
2019-06-15 11:58:43 +02:00
# Try unapplied changes again, this time abandon our changes
win . find ( " XML " , " page tab " ) . click ( )
2020-08-21 12:55:10 -04:00
self . _click_alert_button ( " changes will be lost " , " Yes " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not tab . showing )
2019-06-15 11:58:43 +02:00
2020-08-26 18:01:02 -04:00
# Verify addhardware right click works
2020-08-27 12:23:14 -04:00
win . find ( " Overview " , " table cell " ) . click ( button = 3 )
2020-08-26 18:01:02 -04:00
self . app . root . find ( " Add Hardware " , " menu item " ) . click ( )
self . app . root . find ( " Add New Virtual Hardware " , " frame " )
2019-05-23 16:14:39 -04:00
def testDetailsXMLEdit ( self ) :
"""
Test XML editing interaction
"""
2019-06-05 17:40:54 -04:00
self . app . open ( xmleditor_enabled = True )
2019-05-23 16:14:39 -04:00
win = self . _open_details_window ( vmname = " test-clone-simple " )
finish = win . find ( " config-apply " )
xmleditor = win . find ( " XML editor " )
# Edit vcpu count and verify it's reflected in CPU page
tab = self . _select_hw ( win , " CPUs " , " cpu-tab " )
win . find ( " XML " , " page tab " ) . click ( )
2020-08-27 12:23:14 -04:00
xmleditor . set_text ( xmleditor . text . replace ( " >5</vcpu " , " >8</vcpu " ) )
2019-05-23 16:14:39 -04:00
finish . click ( )
win . find ( " Details " , " page tab " ) . click ( )
2020-08-25 09:48:56 -04:00
vcpualloc = tab . find ( " vCPU allocation: " , " spin button " )
uiutils . check ( lambda : vcpualloc . text == " 8 " )
2019-05-23 16:14:39 -04:00
# Make some disk edits
tab = self . _select_hw ( win , " IDE Disk 1 " , " disk-tab " )
win . find ( " XML " , " page tab " ) . click ( )
origpath = " /dev/default-pool/test-clone-simple.img "
newpath = " /path/FOOBAR "
2020-08-27 12:23:14 -04:00
xmleditor . set_text ( xmleditor . text . replace ( origpath , newpath ) )
2019-05-23 16:14:39 -04:00
finish . click ( )
win . find ( " Details " , " page tab " ) . click ( )
2020-08-25 09:48:56 -04:00
disksrc = win . find ( " disk-source-path " )
uiutils . check ( lambda : disksrc . text == newpath )
2019-05-23 16:14:39 -04:00
# Do standard xmleditor tests
self . _test_xmleditor_interactions ( win , finish )
2020-08-29 13:32:37 -04:00
def testDetailsConsoleChecksSSH ( self ) :
"""
Trigger a bunch of console connection failures to hit
various details / * code paths
"""
fakeuri = " qemu+ssh://foouser@256.256.256.256:1234/system "
uri = tests . utils . URIs . test_full + " ,fakeuri= %s " % fakeuri
self . app . uri = uri
self . app . open ( xmleditor_enabled = True )
self . app . topwin . find ( " test \n " , " table cell " ) . doubleClick ( )
win = self . app . root . find ( " test on " , " frame " )
conpages = win . find ( " console-pages " )
run = win . find ( " Run " , " push button " )
shutdown = win . find ( " Shut Down " , " push button " )
conbtn = win . find ( " Console " , " radio button " )
detailsbtn = win . find ( " Details " , " radio button " )
def _run ( ) :
win . click_title ( )
run . click ( )
uiutils . check ( lambda : not run . sensitive )
def _stop ( ) :
shutdown . click ( )
uiutils . check ( lambda : not shutdown . sensitive )
def _checkcon ( msg ) :
conbtn . click ( )
uiutils . check ( lambda : conpages . showing )
conpages . find ( msg )
def _check_textconsole_menu ( msg ) :
vmenu = win . find ( " ^View$ " , " menu " )
vmenu . click ( )
tmenu = win . find ( " Text Consoles " , " menu " )
tmenu . point ( )
tmenu . find ( msg , " menu item " )
vmenu . click ( )
# Check initial state
_checkcon ( " Graphical console not configured " )
_stop ( )
_check_textconsole_menu ( " No graphical console available " )
# Add a SDL graphics device which can't be displayed
detailsbtn . click ( )
win . find ( " add-hardware " , " push button " ) . click ( )
addhw = self . app . root . find ( " Add New Virtual Hardware " , " frame " )
addhw . find ( " Graphics " , " table cell " ) . click ( )
addhw . find ( " XML " , " page tab " ) . click ( )
dev = ' <graphics type= " sdl " display= " :3.4 " xauth= " /tmp/.Xauthority " /> '
addhw . find ( " XML editor " ) . text = dev
addhw . find ( " Finish " , " push button " ) . click ( )
uiutils . check ( lambda : not addhw . active )
uiutils . check ( lambda : win . active )
_run ( )
_checkcon ( " Cannot display graphical console type " )
def _change_gfx_xml ( _xml ) :
detailsbtn . click ( )
win . find ( " Display " , " table cell " ) . click ( )
win . find ( " XML " , " page tab " ) . click ( )
win . find ( " XML editor " ) . set_text ( _xml )
win . find ( " config-apply " ) . click ( )
# Listening from some other address
_stop ( )
xml = ' <graphics type= " spice " listen= " 0.0.0.0 " port= " 6000 " tlsPort= " 6001 " /> '
_change_gfx_xml ( xml )
_run ( )
_checkcon ( " .*resolving.*256.256.256.256.* " )
# Listening from some other address
_stop ( )
xml = ' <graphics type= " spice " listen= " 257.0.0.1 " port= " 6000 " /> '
_change_gfx_xml ( xml )
_run ( )
_checkcon ( " .*resolving.*257.0.0.1.* " )
# Hit a specific error about tls only and ssh
_stop ( )
xml = ' <graphics type= " spice " tlsPort= " 60001 " autoport= " no " /> '
_change_gfx_xml ( xml )
_run ( )
_checkcon ( " .*configured for TLS only.* " )
# Fake a socket connection
_stop ( )
xml = ' <graphics type= " vnc " socket= " /tmp/foobar.sock " /> '
_change_gfx_xml ( xml )
_run ( )
_checkcon ( " .*SSH tunnel error output.* " )
# Add a listen type='none' check
_stop ( )
xml = ' <graphics type= " spice " ><listen type= " none " /></graphics> '
_change_gfx_xml ( xml )
_run ( )
_checkcon ( " .*local file descriptor.* " )
# Add a local list + port check
_stop ( )
xml = ' <graphics type= " spice " listen= " 127.0.0.1 " port= " 6000 " tlsPort= " 60001 " /> '
_change_gfx_xml ( xml )
_run ( )
_checkcon ( " .*SSH tunnel error output.* " )
def testDetailsConsoleChecksTCP ( self ) :
"""
Hit a specific warning when the connection has
non - SSH transport but the guest config is only listening locally
"""
fakeuri = " qemu+tcp://foouser@256.256.256.256:1234/system "
uri = tests . utils . URIs . test_full + " ,fakeuri= %s " % fakeuri
self . app . uri = uri
self . app . open ( xmleditor_enabled = True )
self . app . topwin . find ( " test \n " , " table cell " ) . doubleClick ( )
win = self . app . root . find ( " test on " , " frame " )
conpages = win . find ( " console-pages " )
run = win . find ( " Run " , " push button " )
shutdown = win . find ( " Shut Down " , " push button " )
conbtn = win . find ( " Console " , " radio button " )
detailsbtn = win . find ( " Details " , " radio button " )
def _run ( ) :
win . click_title ( )
run . click ( )
uiutils . check ( lambda : not run . sensitive )
def _stop ( ) :
shutdown . click ( )
uiutils . check ( lambda : not shutdown . sensitive )
def _checkcon ( msg ) :
conbtn . click ( )
uiutils . check ( lambda : conpages . showing )
conpages . find ( msg )
# Check initial state
_checkcon ( " Graphical console not configured " )
_stop ( )
# Add a SDL graphics device which can't be displayed
detailsbtn . click ( )
win . find ( " add-hardware " , " push button " ) . click ( )
addhw = self . app . root . find ( " Add New Virtual Hardware " , " frame " )
addhw . find ( " Graphics " , " table cell " ) . click ( )
addhw . find ( " XML " , " page tab " ) . click ( )
dev = ' <graphics type= " vnc " port= " 6000 " address= " 127.0.0.1 " /> '
addhw . find ( " XML editor " ) . text = dev
addhw . find ( " Finish " , " push button " ) . click ( )
uiutils . check ( lambda : not addhw . active )
uiutils . check ( lambda : win . active )
_run ( )
_checkcon ( " .*configured to listen locally.* " )