2015-09-06 18:37:49 -04:00
import time
import tests
2015-09-14 12:53:02 -04:00
from tests . uitests import utils as uiutils
2015-09-06 18:37:49 -04:00
2018-01-09 10:01:56 -05:00
class NewVM ( uiutils . UITestCase ) :
2015-09-06 18:37:49 -04:00
"""
UI tests for virt - manager ' s NewVM wizard
"""
2015-09-09 09:49:45 -04:00
2015-09-06 18:37:49 -04:00
###################
# Private helpers #
###################
def _open_create_wizard ( self ) :
2018-01-19 10:51:33 -05:00
self . app . root . find ( " New " , " push button " ) . click ( )
return self . app . root . find ( " New VM " , " frame " )
2015-09-06 18:37:49 -04:00
2015-09-14 19:27:55 -04:00
def _do_simple_import ( self , newvm ) :
# Create default PXE VM
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Import " , " radio " ) . click ( )
newvm . find_fuzzy ( None ,
2016-06-17 19:30:45 -04:00
" text " , " existing storage " ) . text = " /dev/default-pool/testvol1.img "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Finish " , " button " ) . click ( )
2015-09-14 19:27:55 -04:00
2015-09-06 18:37:49 -04:00
##############
# Test cases #
##############
2015-09-09 09:49:45 -04:00
def testNewVMPXEDefault ( self ) :
2015-09-06 18:37:49 -04:00
"""
Click through the New VM wizard with default values + PXE , then
delete the VM
"""
newvm = self . _open_create_wizard ( )
2015-09-09 09:49:45 -04:00
# Create default PXE VM
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " PXE " , " radio " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Finish " , " button " ) . click ( )
2015-09-06 18:37:49 -04:00
# Delete it from the VM window
2018-01-10 18:57:40 -05:00
vmwindow = self . app . root . find_fuzzy ( " generic on " , " frame " )
2018-01-19 10:51:33 -05:00
vmwindow . find ( " Virtual Machine " , " menu " ) . click ( )
vmwindow . find ( " Delete " , " menu item " ) . click ( )
2015-09-14 12:53:02 -04:00
2018-01-10 18:57:40 -05:00
delete = self . app . root . find_fuzzy ( " Delete " , " frame " )
delete . find_fuzzy ( " Delete " , " button " ) . click ( )
2018-01-19 10:51:33 -05:00
alert = self . app . root . find ( " vmm dialog " , " alert " )
2018-01-10 18:57:40 -05:00
alert . find_fuzzy ( " Yes " , " push button " ) . click ( )
2015-09-06 18:37:49 -04:00
# Verify delete dialog and VM dialog are now gone
2018-01-09 10:45:46 -05:00
uiutils . check_in_loop ( lambda : vmwindow . showing is False )
2015-09-06 18:37:49 -04:00
2015-09-09 09:49:45 -04:00
def testNewVMCDROM ( self ) :
"""
Create a new CDROM VM , choosing distro win8 , and do some basic
' Customize before install ' before exiting
"""
newvm = self . _open_create_wizard ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Local install media " , " radio " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
# Select a fake iso
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Use ISO " , " radio " ) . click ( )
newvm . find_fuzzy ( " install-iso-browse " , " button " ) . click ( )
browser = self . app . root . find_fuzzy ( " Choose Storage " , " frame " )
browser . find_fuzzy ( " default-pool " , " table cell " ) . click ( )
browser . find_fuzzy ( " iso-vol " , " table cell " ) . click ( )
browser . find_fuzzy ( " Choose Volume " , " button " ) . click ( )
label = newvm . find_fuzzy ( " os-version-label " , " label " )
2018-01-09 10:45:46 -05:00
uiutils . check_in_loop ( lambda : browser . showing is False )
uiutils . check_in_loop ( lambda : label . text == " Unknown " )
2015-09-09 09:49:45 -04:00
# Change distro to win8
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Automatically detect " , " check " ) . click ( )
version = newvm . find_fuzzy ( " install-os-version-entry " , " text " )
2017-05-05 11:39:59 -04:00
self . assertEqual ( version . text , " Generic " )
2015-09-09 09:49:45 -04:00
2018-01-10 18:57:40 -05:00
ostype = newvm . find_fuzzy ( " install-os-type " , " combo " )
2015-09-10 18:19:49 -04:00
ostype . click ( )
2018-01-10 18:57:40 -05:00
ostype . find_fuzzy ( " Show all " , " menu item " ) . click ( )
newvm . find_fuzzy ( " install-os-type " , " combo " ) . click ( )
newvm . find_fuzzy ( " Windows " , " menu item " ) . click ( )
newvm . find_fuzzy ( " install-os-version-entry " ,
2015-09-09 09:49:45 -04:00
" text " ) . typeText ( " Microsoft Windows 8 " )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " install-os-version-entry " , " text " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
# Verify that CPU values are non-default
2018-01-19 10:51:33 -05:00
cpus = newvm . find ( " cpus " , " spin button " )
2015-09-14 18:37:56 -04:00
uiutils . check_in_loop ( lambda : int ( cpus . text ) > 1 , timeout = 5 )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
# Select customize wizard
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Customize " , " check " ) . click ( )
newvm . find_fuzzy ( " Finish " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
# Change to 'copy host CPU'
2018-01-10 18:57:40 -05:00
vmwindow = self . app . root . find_fuzzy ( " win8 on " , " frame " )
vmwindow . find_fuzzy ( " CPUs " , " table cell " ) . click ( )
vmwindow . find_fuzzy ( " Copy host " , " check " ) . click ( )
vmwindow . find_fuzzy ( " config-apply " ) . click ( )
2015-09-09 09:49:45 -04:00
2018-01-19 16:02:58 -05:00
# Add a default disk
vmwindow . find ( " add-hardware " , " push button " ) . click ( )
addhw = self . app . root . find ( " Add New Virtual Hardware " , " frame " )
addhw . find ( " Finish " , " push button " ) . click ( )
uiutils . check_in_loop ( lambda : vmwindow . active )
2015-09-09 09:49:45 -04:00
# Start the install, close via the VM window
2018-01-10 18:57:40 -05:00
vmwindow . find_fuzzy ( " Begin Installation " , " button " ) . click ( )
2018-01-09 10:45:46 -05:00
uiutils . check_in_loop ( lambda : newvm . showing is False )
2018-01-10 18:57:40 -05:00
vmwindow = self . app . root . find_fuzzy ( " win8 on " , " frame " )
vmwindow . find_fuzzy ( " File " , " menu " ) . click ( )
vmwindow . find_fuzzy ( " Quit " , " menu item " ) . click ( )
2018-01-09 10:45:46 -05:00
uiutils . check_in_loop ( lambda : self . app . is_running ( ) )
2015-09-09 09:49:45 -04:00
def testNewVMURL ( self ) :
"""
New VM with URL and distro detection , plus having fun with
the storage browser and network selection .
"""
self . app . uri = tests . utils . uri_kvm
newvm = self . _open_create_wizard ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Network Install " , " radio " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
2018-01-19 11:16:09 -05:00
newvm . find ( " URL " , " text " ) . text = (
2015-09-12 17:17:49 -04:00
" http://vault.centos.org/5.5/os/x86_64/ " )
2015-09-09 09:49:45 -04:00
2018-01-19 10:51:33 -05:00
version = newvm . find ( " install-os-version-label " )
2018-01-09 10:45:46 -05:00
uiutils . check_in_loop ( lambda : " Detecting " in version . text )
uiutils . check_in_loop (
lambda : version . text == " Red Hat Enterprise Linux 5.5 " ,
timeout = 10 )
2015-09-09 09:49:45 -04:00
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Finish " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
2018-01-10 18:57:40 -05:00
progress = self . app . root . find_fuzzy (
2015-09-09 09:49:45 -04:00
" Creating Virtual Machine " , " frame " )
2018-01-09 10:45:46 -05:00
uiutils . check_in_loop ( lambda : not progress . showing , timeout = 120 )
2015-09-09 09:49:45 -04:00
2018-01-10 18:57:40 -05:00
self . app . root . find_fuzzy ( " rhel5.5 on " , " frame " )
2015-09-09 09:49:45 -04:00
self . assertFalse ( newvm . showing )
2018-01-09 10:21:06 -05:00
2015-09-09 09:49:45 -04:00
2015-09-14 19:27:55 -04:00
def testNewPPC64 ( self ) :
2015-09-09 09:49:45 -04:00
"""
2015-09-14 19:27:55 -04:00
New PPC64 VM to test architecture selection
2015-09-09 09:49:45 -04:00
"""
2015-09-14 19:27:55 -04:00
self . app . uri = tests . utils . uri_kvm
2015-09-09 09:49:45 -04:00
newvm = self . _open_create_wizard ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Architecture options " , " toggle " ) . click ( )
2018-01-19 11:16:09 -05:00
newvm . find_fuzzy ( " Architecture " , " combo " ) . click ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " ppc64 " , " menu item " ) . click ( )
newvm . find_fuzzy ( " pseries " , " menu item " )
2015-09-14 19:27:55 -04:00
self . _do_simple_import ( newvm )
2015-09-09 09:49:45 -04:00
2018-01-10 18:57:40 -05:00
self . app . root . find_fuzzy ( " generic-ppc64 on " , " frame " )
2015-09-09 09:49:45 -04:00
self . assertFalse ( newvm . showing )
2015-09-14 19:27:55 -04:00
def testNewArmKernel ( self ) :
2015-09-09 09:49:45 -04:00
"""
New arm VM that requires kernel / initrd / dtb
"""
2015-09-14 19:27:55 -04:00
self . app . uri = tests . utils . uri_kvm_armv7l
2015-09-09 09:49:45 -04:00
newvm = self . _open_create_wizard ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Architecture options " , " toggle " ) . click ( )
2018-01-19 11:16:09 -05:00
newvm . find_fuzzy ( " Virt Type " , " combo " ) . click ( )
2018-01-10 18:57:40 -05:00
KVM = newvm . find_fuzzy ( " KVM " , " menu item " )
TCG = newvm . find_fuzzy ( " TCG " , " menu item " )
2015-09-14 19:27:55 -04:00
self . assertTrue ( KVM . focused )
self . assertTrue ( TCG . showing )
2018-01-19 11:16:09 -05:00
newvm . find_fuzzy ( " Virt Type " , " combo " ) . click ( )
2015-09-14 19:27:55 -04:00
# Validate some initial defaults
2015-09-09 09:49:45 -04:00
self . assertFalse (
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " PXE " , " radio " ) . sensitive )
newvm . find_fuzzy ( " vexpress-a15 " , " menu item " )
2018-01-19 10:51:33 -05:00
newvm . find ( " virt " , " menu item " )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
# Set the import media details
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( None ,
2015-09-09 09:49:45 -04:00
" text " , " existing storage " ) . text = " /dev/default-pool/default-vol "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( None ,
2015-09-09 09:49:45 -04:00
" text " , " Kernel path " ) . text = " /tmp/kernel "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( None ,
2015-09-09 09:49:45 -04:00
" text " , " Initrd " ) . text = " /tmp/initrd "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( None ,
2015-09-09 09:49:45 -04:00
" text " , " DTB " ) . text = " /tmp/dtb "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( None ,
2015-09-09 09:49:45 -04:00
" text " , " Kernel args " ) . text = " console=ttyS0 "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
# Disk collision box pops up, hit ok
2018-01-19 10:51:33 -05:00
alert = self . app . root . find ( " vmm dialog " , " alert " )
2018-01-10 18:57:40 -05:00
alert . find_fuzzy ( " Yes " , " push button " ) . click ( )
2015-09-09 09:49:45 -04:00
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Finish " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
time . sleep ( 1 )
2018-01-10 18:57:40 -05:00
self . app . root . find_fuzzy ( " generic on " , " frame " )
2015-09-09 09:49:45 -04:00
self . assertFalse ( newvm . showing )
def testNewVMContainerApp ( self ) :
"""
Simple LXC app install
"""
self . app . uri = tests . utils . uri_lxc
newvm = self . _open_create_wizard ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Application " , " radio " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
# Set custom init
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( None ,
2015-09-09 09:49:45 -04:00
" text " , " application path " ) . text = " /sbin/init "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Finish " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
time . sleep ( 1 )
2018-01-10 18:57:40 -05:00
self . app . root . find_fuzzy ( " container1 on " , " frame " )
2015-09-09 09:49:45 -04:00
self . assertFalse ( newvm . showing )
def testNewVMContainerTree ( self ) :
"""
Simple LXC tree install
"""
self . app . uri = tests . utils . uri_lxc
newvm = self . _open_create_wizard ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Operating system " , " radio " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
# Set directory path
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( None ,
2015-09-09 09:49:45 -04:00
" text " , " root directory " ) . text = " /tmp "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Finish " , " button " ) . click ( )
2015-09-09 09:49:45 -04:00
time . sleep ( 1 )
2018-01-10 18:57:40 -05:00
self . app . root . find_fuzzy ( " container1 on " , " frame " )
2015-09-09 09:49:45 -04:00
self . assertFalse ( newvm . showing )
2018-01-09 10:21:06 -05:00
2015-09-14 17:01:32 -04:00
2017-03-13 15:01:52 +03:00
def testNewVMContainerVZ ( self ) :
"""
Virtuozzo container install
"""
self . app . uri = tests . utils . uri_vz
newvm = self . _open_create_wizard ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Container " , " radio " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
2017-03-13 15:01:52 +03:00
# Set directory path
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( None ,
2017-03-13 15:01:52 +03:00
" text " , " container template " ) . text = " centos-6-x86_64 "
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Forward " , " button " ) . click ( )
newvm . find_fuzzy ( " Finish " , " button " ) . click ( )
2017-03-13 15:01:52 +03:00
2018-01-10 18:57:40 -05:00
self . app . root . find_fuzzy ( " container1 on " , " frame " )
2017-03-13 15:01:52 +03:00
self . assertFalse ( newvm . showing )
2018-01-09 10:21:06 -05:00
2017-03-13 15:01:52 +03:00
2015-09-14 17:01:32 -04:00
def testNewXenPV ( self ) :
"""
Test the create wizard with a fake xen PV install
"""
self . app . uri = tests . utils . uri_xen
newvm = self . _open_create_wizard ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " Architecture options " , " toggle " ) . click ( )
2018-01-19 11:16:09 -05:00
newvm . find_fuzzy ( " Xen Type " , " combo " ) . click ( )
2018-01-10 18:57:40 -05:00
newvm . find_fuzzy ( " paravirt " , " menu item " ) . click ( )
2015-09-14 17:01:32 -04:00
2015-09-14 19:27:55 -04:00
self . _do_simple_import ( newvm )