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.
2017-07-20 16:14:19 -04:00
from tests . uitests import utils as uiutils
2018-01-09 10:01:56 -05:00
class Host ( uiutils . UITestCase ) :
2017-07-20 16:14:19 -04:00
"""
UI tests for virt - manager ' s VM details window
"""
##############
# Test cases #
##############
def testHostNetworkSmokeTest ( self ) :
"""
Verify that each virtual network displays , without error .
"""
win = self . _open_host_window ( " Virtual Networks " )
2018-01-19 10:51:33 -05:00
lst = win . find ( " net-list " , " table " )
errlabel = win . find ( " net-error-label " , " label " )
2018-01-11 09:46:41 -05:00
self . _walkUIList ( win , lst , lambda : errlabel . showing )
2017-07-20 16:14:19 -04:00
2019-05-23 16:14:39 -04:00
# Select XML editor, and reverse walk the list
win . find ( " network-grid " ) . find ( " XML " , " page tab " ) . click ( )
self . _walkUIList ( win , lst , lambda : errlabel . showing , reverse = True )
def testHostNetworkEdit ( self ) :
"""
Test edits to net config
"""
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_host_window ( " Virtual Networks " ) . find ( " network-grid " )
finish = win . find ( " Apply " , " push button " )
2020-08-21 14:39:24 -04:00
# Shut it off, do an XML edit, verify it
2019-05-23 16:14:39 -04:00
win . find ( " default " , " table cell " ) . click ( )
delete = win . find ( " net-delete " , " push button " )
stop = win . find ( " net-stop " , " push button " )
stop . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : delete . sensitive )
2019-05-23 16:14:39 -04:00
win . find ( " XML " , " page tab " ) . click ( )
xmleditor = win . find ( " XML editor " )
origdev = " virbr0 "
newdev = " virbr77 "
2020-08-27 12:23:14 -04:00
xmleditor . set_text ( xmleditor . text . replace ( origdev , newdev ) )
2019-05-23 16:14:39 -04:00
finish . click ( )
win . find ( " Details " , " page tab " ) . click ( )
2020-08-25 09:48:56 -04:00
netdev = win . find ( " net-device " )
uiutils . check ( lambda : netdev . text == newdev )
2019-05-23 16:14:39 -04:00
2020-08-21 14:39:24 -04:00
# Rename it
win . find ( " default " , " table cell " ) . click ( )
2020-08-27 12:23:14 -04:00
win . find ( " net-name " ) . set_text ( " newsort-default " )
2020-08-21 14:39:24 -04:00
finish . click ( )
# Change autostart, trigger it by clicking away
win . find ( " newsort-default " , " table cell " ) . click ( )
win . find ( " net-autostart " ) . click ( )
win . find ( " netboot " , " table cell " ) . click ( )
self . _click_alert_button ( " There are unapplied changes " , " Yes " )
2019-05-23 16:14:39 -04:00
# Do standard xmleditor tests
self . _test_xmleditor_interactions ( win , finish )
2017-07-20 16:14:19 -04:00
def testHostStorageSmokeTest ( self ) :
"""
Verify that each storage pool displays , without error .
"""
win = self . _open_host_window ( " Storage " )
2018-01-19 10:51:33 -05:00
lst = win . find ( " pool-list " , " table " )
errlabel = win . find ( " pool-error-label " , " label " )
2018-01-11 09:46:41 -05:00
self . _walkUIList ( win , lst , lambda : errlabel . showing )
2019-05-23 16:14:39 -04:00
# Select XML editor, and reverse walk the list
win . find ( " storage-grid " ) . find ( " XML " , " page tab " ) . click ( )
self . _walkUIList ( win , lst , lambda : errlabel . showing , reverse = True )
def testHostStorageEdit ( self ) :
"""
Test edits to pool config
"""
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_host_window ( " Storage " ) . find ( " storage-grid " )
finish = win . find ( " Apply " , " push button " )
# Shut off a pool, do an XML edit, verify it
win . find ( " default-pool " , " table cell " ) . click ( )
delete = win . find ( " pool-delete " , " push button " )
stop = win . find ( " pool-stop " , " push button " )
stop . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : delete . sensitive )
2019-05-23 16:14:39 -04:00
win . find ( " XML " , " page tab " ) . click ( )
xmleditor = win . find ( " XML editor " )
origpath = " /dev/default-pool "
newpath = " /dev/foo/bar/baz "
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
poolloc = win . find ( " pool-location " )
uiutils . check ( lambda : poolloc . text == newpath )
2019-05-23 16:14:39 -04:00
2020-08-21 14:39:24 -04:00
# Rename it
win . find ( " default " , " table cell " ) . click ( )
2020-08-27 12:23:14 -04:00
win . find ( " pool-name " ) . set_text ( " newsort-default " )
2020-08-21 14:39:24 -04:00
finish . click ( )
# Change autostart. Trigger it by clicking on new cell
win . find ( " newsort-default " , " table cell " ) . click ( )
win . find ( " pool-autostart " ) . click ( )
win . find ( " disk-pool " , " table cell " ) . click ( )
self . _click_alert_button ( " There are unapplied changes " , " Yes " )
2019-05-23 16:14:39 -04:00
# Do standard xmleditor tests
self . _test_xmleditor_interactions ( win , finish )
2020-08-21 14:39:24 -04:00
def testHostStorageVolMisc ( self ) :
"""
Misc actions involving volumes
"""
win = self . _open_host_window ( " Storage " ) . find ( " storage-grid " )
win . find_fuzzy ( " default-pool " , " table cell " ) . click ( )
vollist = win . find ( " vol-list " , " table " )
vol1 = vollist . find ( " backingl1.img " , " table cell " )
vol2 = vollist . find ( " UPPER " , " table cell " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : vol1 . onscreen )
uiutils . check ( lambda : not vol2 . onscreen )
2020-08-21 14:39:24 -04:00
win . find ( " Size " , " table column header " ) . click ( )
win . find ( " Size " , " table column header " ) . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not vol1 . onscreen )
uiutils . check ( lambda : vol2 . onscreen )
2020-08-21 14:39:24 -04:00
vol2 . click ( button = 3 )
self . app . root . find ( " Copy Volume Path " , " menu item " ) . click ( )
from gi . repository import Gdk , Gtk
clipboard = Gtk . Clipboard . get_default ( Gdk . Display . get_default ( ) )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : clipboard . wait_for_text ( ) == " /dev/default-pool/UPPER " )
2020-08-21 14:39:24 -04:00
def testHostConn ( self ) :
"""
Change some connection parameters
"""
manager = self . app . topwin
# Disconnect the connection
c = manager . find_fuzzy ( " testdriver.xml " , " table cell " )
c . click ( button = 3 )
self . app . root . find ( " conn-disconnect " , " menu item " ) . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : " Not Connected " in c . text )
2020-08-21 14:39:24 -04:00
# Open Host Details from right click menu
c . click ( button = 3 )
self . app . root . find ( " conn-details " , " menu item " ) . click ( )
win = self . app . root . find_fuzzy ( " Connection Details " , " frame " )
# Click the tabs and then back
win . find_fuzzy ( " Storage " , " tab " ) . click ( )
win . find_fuzzy ( " Network " , " tab " ) . click ( )
win . find_fuzzy ( " Overview " , " tab " ) . click ( )
# Unset autoconnect
win . find ( " Autoconnect: " , " check box " ) . click ( )
# Change the name, verify that title bar changed
2020-08-27 12:23:14 -04:00
win . find ( " Name: " , " text " ) . set_text ( " FOOBAR " )
2020-08-21 14:39:24 -04:00
self . app . root . find ( " FOOBAR Connection Details " , " frame " )
# Open the manager window
win . find ( " File " , " menu " ) . click ( )
win . find ( " View Manager " , " menu item " ) . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : manager . active )
2020-08-21 14:39:24 -04:00
# Confirm connection row is named differently in manager
manager . find ( " FOOBAR " , " table cell " )
# Close the manager
manager . keyCombo ( " <alt>F4 " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : win . active )
2020-08-21 14:39:24 -04:00
# Quit app from the file menu
win . find ( " File " , " menu " ) . click ( )
win . find ( " Quit " , " menu item " ) . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not self . app . is_running ( ) )