2018-04-04 16:35:41 +03:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 22:00:02 +03:00
# See the COPYING file in the top-level directory.
2018-01-11 23:32:18 +03:00
from tests . uitests import utils as uiutils
class CreatePool ( uiutils . UITestCase ) :
"""
UI tests for the createpool wizard
"""
2019-05-23 23:14:39 +03:00
def _open_create_win ( self , hostwin ) :
hostwin . find ( " pool-add " , " push button " ) . click ( )
win = self . app . root . find (
" Add a New Storage Pool " , " frame " )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : win . active )
2019-05-23 23:14:39 +03:00
return win
2018-01-11 23:32:18 +03:00
##############
# Test cases #
##############
2019-06-17 03:10:37 +03:00
def testCreatePools ( self ) :
2018-01-11 23:32:18 +03:00
hostwin = self . _open_host_window ( " Storage " )
2019-05-23 23:14:39 +03:00
win = self . _open_create_win ( hostwin )
2018-01-19 18:51:33 +03:00
finish = win . find ( " Finish " , " push button " )
2018-01-19 19:16:09 +03:00
name = win . find ( " Name: " , " text " )
2019-07-04 01:26:57 +03:00
def _browse_local_path ( winlabel , usepath ) :
chooser = self . app . root . find ( winlabel , " file chooser " )
# Enter the filename and select it
chooser . find ( usepath , " table cell " ) . click ( )
obutton = chooser . find ( " Open " , " push button " )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : obutton . sensitive )
2019-07-04 01:26:57 +03:00
obutton . click ( )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : not chooser . showing )
uiutils . check ( lambda : win . active )
2019-07-04 01:26:57 +03:00
# Create a simple default dir pool
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : name . text == " pool " )
2019-05-23 23:14:39 +03:00
newname = " a-test-new-pool "
2020-08-27 19:23:14 +03:00
name . set_text ( newname )
2018-01-11 23:32:18 +03:00
finish . click ( )
# Select the new object in the host window, then do
# stop->start->stop->delete, for lifecycle testing
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : hostwin . active )
2018-01-19 18:51:33 +03:00
cell = hostwin . find ( newname , " table cell " )
delete = hostwin . find ( " pool-delete " , " push button " )
start = hostwin . find ( " pool-start " , " push button " )
stop = hostwin . find ( " pool-stop " , " push button " )
2018-01-11 23:32:18 +03:00
cell . click ( )
stop . click ( )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : start . sensitive )
2018-01-11 23:32:18 +03:00
start . click ( )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : stop . sensitive )
2018-01-11 23:32:18 +03:00
stop . click ( )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : delete . sensitive )
2018-01-11 23:32:18 +03:00
2020-08-21 21:39:24 +03:00
# Delete it, clicking 'No' first
delete . click ( )
self . _click_alert_button ( " permanently delete the pool " , " No " )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : not cell . dead )
2018-01-11 23:32:18 +03:00
delete . click ( )
2020-08-21 19:55:10 +03:00
self . _click_alert_button ( " permanently delete the pool " , " Yes " )
2018-01-11 23:32:18 +03:00
# Ensure it's gone
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : cell . dead )
2018-01-11 23:32:18 +03:00
2019-07-04 01:26:57 +03:00
# Test a disk pool
win = self . _open_create_win ( hostwin )
2020-08-25 19:46:59 +03:00
win . combo_select ( " Type: " , " disk: " )
2019-07-04 01:26:57 +03:00
newname = " a-disk-pool "
2020-08-27 19:23:14 +03:00
name . set_text ( " a-disk-pool " )
2019-07-04 01:26:57 +03:00
win . find ( " source-browse " ) . click ( )
_browse_local_path ( " Choose source path " , " console " )
finish . click ( )
hostwin . find ( newname , " table cell " )
# Test a iscsi pool
win = self . _open_create_win ( hostwin )
2020-08-25 19:46:59 +03:00
win . combo_select ( " Type: " , " iscsi: " )
2019-07-04 01:26:57 +03:00
newname = " a-iscsi-pool "
2020-08-27 19:23:14 +03:00
name . set_text ( " a-iscsi-pool " )
2019-07-04 01:26:57 +03:00
win . find ( " target-browse " ) . click ( )
_browse_local_path ( " Choose target directory " , " by-path " )
finish . click ( )
# Catch example error
2020-08-21 19:55:10 +03:00
self . _click_alert_button ( " source host name " , " Close " )
2020-08-27 19:23:14 +03:00
win . find ( " Host Name: " , " text " ) . set_text ( " example.com " )
win . find ( " pool-source-path-text " ) . set_text ( " foo-iqn " )
2019-07-04 01:26:57 +03:00
win . find_fuzzy ( " Initiator IQN: " , " check " ) . click ( )
2020-08-27 19:23:14 +03:00
win . find ( " iqn-text " , " text " ) . set_text ( " initiator-foo " )
2019-07-04 01:26:57 +03:00
finish . click ( )
hostwin . find ( newname , " table cell " )
2019-06-17 03:10:37 +03:00
# Test a logical pool
win = self . _open_create_win ( hostwin )
2020-08-25 19:46:59 +03:00
win . combo_select ( " Type: " , " logical: " )
2019-06-17 03:10:37 +03:00
newname = " a-lvm-pool "
2020-08-27 19:23:14 +03:00
name . set_text ( " a-lvm-pool " )
2020-08-25 19:46:59 +03:00
win . combo_check_default ( " Volgroup " , " testvg1 " )
win . combo_select ( " Volgroup " , " testvg2 " )
2019-06-17 03:10:37 +03:00
finish . click ( )
hostwin . find ( newname , " table cell " )
2018-01-11 23:32:18 +03:00
# Test a scsi pool
2019-05-23 23:14:39 +03:00
win = self . _open_create_win ( hostwin )
2020-08-25 19:46:59 +03:00
win . combo_select ( " Type: " , " scsi: " )
2018-01-11 23:32:18 +03:00
newname = " a-scsi-pool "
2020-08-27 19:23:14 +03:00
name . set_text ( " a-scsi-pool " )
2020-08-25 19:46:59 +03:00
win . combo_select ( " Source Adapter: " , " host2 " )
2018-01-11 23:32:18 +03:00
finish . click ( )
2018-01-19 18:51:33 +03:00
hostwin . find ( newname , " table cell " )
2018-01-11 23:32:18 +03:00
# Test a ceph pool
2019-05-23 23:14:39 +03:00
win = self . _open_create_win ( hostwin )
2018-01-11 23:32:18 +03:00
newname = " a-ceph-pool "
2020-08-27 19:23:14 +03:00
name . set_text ( " a-ceph-pool " )
2020-08-25 19:46:59 +03:00
win . combo_select ( " Type: " , " rbd: " )
2020-08-27 19:23:14 +03:00
win . find_fuzzy ( " Host Name: " , " text " ) . set_text ( " example.com:1234 " )
2019-06-17 03:10:37 +03:00
win . find_fuzzy ( " pool-source-name-text " , " text " ) . typeText ( " frob " )
2018-01-11 23:32:18 +03:00
finish . click ( )
2020-08-25 23:15:43 +03:00
uiutils . check ( lambda : not win . showing )
uiutils . check ( lambda : hostwin . active )
2018-01-19 18:51:33 +03:00
hostwin . find ( newname , " table cell " )
2018-01-11 23:32:18 +03:00
# Ensure host window closes fine
hostwin . click ( )
hostwin . keyCombo ( " <ctrl>w " )
2020-08-25 23:15:43 +03:00
uiutils . check ( lambda : not hostwin . showing )
2019-05-23 23:14:39 +03:00
def testCreatePoolXMLEditor ( self ) :
2019-06-06 00:40:54 +03:00
self . app . open ( xmleditor_enabled = True )
2019-05-23 23:14:39 +03:00
hostwin = self . _open_host_window ( " Storage " )
win = self . _open_create_win ( hostwin )
finish = win . find ( " Finish " , " push button " )
name = win . find ( " Name: " , " text " )
# Create a new obj with XML edited name, verify it worked
tmpname = " objtmpname "
newname = " froofroo "
2020-08-27 19:23:14 +03:00
name . set_text ( tmpname )
2019-05-23 23:14:39 +03:00
win . find ( " XML " , " page tab " ) . click ( )
xmleditor = win . find ( " XML editor " )
2020-08-27 19:23:14 +03:00
newtext = xmleditor . text . replace ( " > %s < " % tmpname , " > %s < " % newname )
xmleditor . set_text ( newtext )
2019-05-23 23:14:39 +03:00
finish . click ( )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : hostwin . active )
2019-05-23 23:14:39 +03:00
cell = hostwin . find ( newname , " table cell " )
cell . click ( )
# Do standard xmleditor tests
win = self . _open_create_win ( hostwin )
self . _test_xmleditor_interactions ( win , finish )
win . find ( " Cancel " , " push button " ) . click ( )
2020-08-25 16:48:56 +03:00
uiutils . check ( lambda : not win . visible )