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.
2018-01-19 18:41:00 -05:00
from tests . uitests import utils as uiutils
class Manager ( uiutils . UITestCase ) :
"""
UI tests for manager window , and basic VM lifecycle stuff
"""
##############
# Test cases #
##############
def _testVMLifecycle ( self ) :
"""
2020-08-24 16:03:00 -04:00
Basic VM lifecycle test , shared between standard and no - events
2018-01-19 18:41:00 -05:00
testing
"""
manager = self . app . topwin
shutdown = manager . find ( " Shut Down " , " push button " )
pause = manager . find ( " Pause " , " toggle button " )
run = manager . find ( " Run " , " push button " )
force = manager . find ( " Force Off " , " menu item " )
smenu = manager . find ( " Menu " , " toggle button " )
save = manager . find ( " Save " , " menu item " )
c = manager . find ( " test-many-devices " , " table cell " )
c . click ( )
smenu . click ( )
force . click ( )
2020-08-21 12:55:10 -04:00
self . _click_alert_button ( " Are you sure you want " , " Yes " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : run . sensitive , timeout = 5 )
2018-01-19 18:41:00 -05:00
run . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not run . sensitive , timeout = 5 )
2018-01-19 18:41:00 -05:00
pause . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : pause . checked , timeout = 5 )
2018-01-19 18:41:00 -05:00
smenu . click ( )
save . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : run . sensitive , timeout = 5 )
uiutils . check ( lambda : " Saved " in c . text )
2018-01-19 18:41:00 -05:00
run . click ( )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : shutdown . sensitive , timeout = 5 )
2018-01-19 18:41:00 -05:00
def testVMLifecycle ( self ) :
self . _testVMLifecycle ( )
def testVMNoEventsLifecycle ( self ) :
2020-08-24 16:03:00 -04:00
self . app . open ( extra_opts = [ " --test-options=no-events " ] )
2018-01-19 18:41:00 -05:00
# Change preferences timeout to 1 second
self . app . root . find ( " Edit " , " menu " ) . click ( )
self . app . root . find ( " Preferences " , " menu item " ) . click ( )
win = self . app . root . find_fuzzy ( " Preferences " , " frame " )
win . find ( " Polling " , " page tab " ) . click ( )
win . find ( " cpu-poll " ) . text = " 1 "
win . find ( " Close " , " push button " ) . click ( )
self . _testVMLifecycle ( )
def testManagerColumns ( self ) :
# Enable all stat options
self . app . root . find ( " Edit " , " menu " ) . click ( )
self . app . root . find ( " Preferences " , " menu item " ) . click ( )
win = self . app . root . find_fuzzy ( " Preferences " , " frame " )
win . find ( " Polling " , " page tab " ) . click ( )
win . find_fuzzy ( " Poll Disk " , " check " ) . click ( )
win . find_fuzzy ( " Poll Network " , " check " ) . click ( )
win . find_fuzzy ( " Poll Memory " , " check " ) . click ( )
win . find ( " Close " , " push button " ) . click ( )
manager = self . app . topwin
manager . find ( " View " , " menu " ) . click ( )
manager . find ( " Graph " , " menu " ) . point ( )
manager . find ( " Host CPU " , " check menu item " ) . click ( )
manager . find ( " View " , " menu " ) . click ( )
manager . find ( " Graph " , " menu " ) . point ( )
manager . find ( " Memory Usage " , " check menu item " ) . click ( )
manager . find ( " View " , " menu " ) . click ( )
manager . find ( " Graph " , " menu " ) . point ( )
manager . find ( " Disk I/O " , " check menu item " ) . click ( )
manager . find ( " View " , " menu " ) . click ( )
manager . find ( " Graph " , " menu " ) . point ( )
manager . find ( " Network I/O " , " check menu item " ) . click ( )
# Verify columns showed up
manager . find ( " Name " , " table column header " )
manager . find ( " CPU usage " , " table column header " )
manager . find ( " Host CPU usage " , " table column header " )
manager . find ( " Memory usage " , " table column header " )
manager . find ( " Disk I/O " , " table column header " )
manager . find ( " Network I/O " , " table column header " )
2018-03-17 19:42:19 -04:00
def testManagerWindowCleanup ( self ) :
"""
Open migrate , clone , delete , newvm , details , host windows , close the
connection , make sure they all disappear
"""
def _drag ( win ) :
"""
Drag a window so it ' s not obscuring the manager window
"""
2019-06-13 13:50:13 -04:00
uiutils . drag ( win , 1000 , 1000 )
2018-03-17 19:42:19 -04:00
manager = self . app . topwin
# Open migrate dialog
c = manager . find ( " test-many-devices " , " table cell " )
c . click ( button = 3 )
self . app . root . find ( " Migrate... " , " menu item " ) . click ( )
migrate = self . app . root . find ( " Migrate the virtual machine " , " frame " )
_drag ( migrate )
# Open clone dialog
c = manager . find ( " test-clone " , " table cell " )
c . click ( button = 3 )
self . app . root . find ( " Clone... " , " menu item " ) . click ( )
clone = self . app . root . find ( " Clone Virtual Machine " , " frame " )
_drag ( clone )
# Open delete dialog
c . click ( )
manager . find ( " Edit " , " menu " ) . click ( )
manager . find ( " Delete " , " menu item " ) . click ( )
delete = self . app . root . find_fuzzy ( " Delete " , " frame " )
_drag ( delete )
# Open NewVM
self . app . root . find ( " New " , " push button " ) . click ( )
create = self . app . root . find ( " New VM " , " frame " )
_drag ( create )
# Open host
host = self . _open_host_window ( " Virtual Networks " )
_drag ( host )
# Open details
details = self . _open_details_window ( " test-many-devices " )
_drag ( details )
# Close the connection
2020-08-25 08:47:11 -04:00
self . sleep ( 1 )
manager . click ( )
2018-03-17 19:42:19 -04:00
c = manager . find_fuzzy ( " testdriver.xml " , " table cell " )
2020-08-25 08:47:11 -04:00
c . click ( )
2018-03-17 19:42:19 -04:00
c . click ( button = 3 )
self . app . root . find ( " conn-disconnect " , " menu item " ) . click ( )
# Ensure all those windows aren't showing
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not migrate . showing )
uiutils . check ( lambda : not clone . showing )
uiutils . check ( lambda : not create . showing )
uiutils . check ( lambda : not details . showing )
uiutils . check ( lambda : not delete . showing )
2018-03-17 19:42:19 -04:00
# Delete the connection, ensure the host dialog disappears
c = manager . find_fuzzy ( " testdriver.xml " , " table cell " )
c . click ( button = 3 )
self . app . root . find ( " conn-delete " , " menu item " ) . click ( )
2020-08-21 12:55:10 -04:00
self . _click_alert_button ( " will remove the connection " , " Yes " )
2020-08-25 09:48:56 -04:00
uiutils . check ( lambda : not host . showing )
2018-10-07 13:26:13 -04:00
def testManagerDefaultStartup ( self ) :
self . app . open ( use_uri = False )
manager = self . app . topwin
errlabel = manager . find ( " error-label " )
2020-08-25 09:48:56 -04:00
uiutils . check (
2018-10-07 13:26:13 -04:00
lambda : " Checking for virtualization " in errlabel . text )
2020-08-25 09:48:56 -04:00
uiutils . check (
2018-10-07 13:26:13 -04:00
lambda : " File->Add Connection " in errlabel . text )
2020-08-25 09:48:56 -04:00
uiutils . check (
2020-07-13 13:07:06 -04:00
lambda : " appropriate QEMU/KVM " in errlabel . text )