def run(vt_test, test_params, env): """Run remote-viewer at client VM. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. """ test = stest.ClientGuestTest(vt_test, test_params, env) cfg = test.cfg act.x_active(test.vmi_c) act.x_active(test.vmi_g) res_target = "1600x1200" res_reset = "640x480" act.set_resolution(test.vmi_c, res_target) act.set_resolution(test.vmi_g, res_reset) with act.new_ssn_context(test.vmi_c, name="Remote Viewer") as ssn: act.rv_connect(test.vmi_c, ssn) act.rv_chk_con(test.vmi_c) res_g = act.get_display_resolution(test.vmi_g)[0] res_c = act.get_display_resolution(test.vmi_c)[0] logger.info("Target: %s, client: %s, guest: %s.", res_target, res_c, res_g) err_info = "Guest res should have adjusted to client, but it hasn't." assert res_target == res_c == res_g, err_info
def run(vt_test, test_params, env): """Run remote-viewer at client VM. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. """ test = stest.ClientGuestTest(vt_test, test_params, env) cfg = test.cfg act.reset_gui(test.vmi_c) act.reset_gui(test.vmi_g) with act.new_ssn_context(test.vmi_c, name="Remote Viewer") as ssn: act.rv_connect(test.vmi_c, ssn) try: act.rv_chk_con(test.vmi_c) except utils.SpiceUtilsError as e: logger.info("Test failed as expected. Reason: %s", e) else: raise exceptions.TestFail( "RV connection was established when it was supposed to fail.")
def run(vt_test, test_params, env): """Run remote-viewer at client VM. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. """ test = stest.ClientGuestTest(vt_test, test_params, env) cfg = test.cfg act.x_active(test.vmi_c) act.x_active(test.vmi_g) with act.new_ssn_context(test.vmi_c, dogtail_ssn=test.vmi_c.vm.is_rhel8(), name="Remote Viewer") as ssn: act.rv_connect(test.vmi_c, ssn) try: act.rv_chk_con(test.vmi_c) except utils.SpiceUtilsError as e: logger.info("Test failed as expected. Reason: %s", e) else: raise exceptions.TestFail( "RV connection was established when it was supposed to fail.")
def run(vt_test, test_params, env): """Run remote-viewer at client VM. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. """ test = stest.ClientGuestTest(vt_test, test_params, env) act.x_active(test.vmi_c) act.x_active(test.vmi_g) with act.new_ssn_context(test.vmi_c, dogtail_ssn=test.vmi_c.vm.is_rhel8(), name="Remote Viewer") as ssn: act.rv_connect(test.vmi_c, ssn) act.rv_chk_con(test.vmi_c)
def run(vt_test, test_params, env): """Test for testing keyboard inputs through spice. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. """ test = stest.ClientGuestTest(vt_test, test_params, env) cfg = test.cfg #test.cmd_g.install_rpm(cfg.xev) act.x_active(test.vmi_c) act.x_active(test.vmi_g) ssn = act.new_ssn(test.vmi_c) act.rv_connect(test.vmi_c, ssn) act.rv_chk_con(test.vmi_c) if cfg.ttype == 'type_and_func_keys': """Test typewriter and functional keys.""" keycodes = range(1, 69) # Skip Ctrl, RSH, LSH, PtScr, Alt, CpsLk skip = [29, 42, 54, 55, 56, 58] send_keys = filter(lambda k: k not in skip, keycodes) send_keys = map(lambda k: str(hex(k)), send_keys) expected_keysyms = [65307, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 45, 61, 65288, 65289, 113, 119, 101, 114, 116, 121, 117, 105, 111, 112, 91, 93, 65293, 97, 115, 100, 102, 103, 104, 106, 107, 108, 59, 39, 96, 92, 122, 120, 99, 118, 98, 110, 109, 44, 46, 47, 32, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479] test_seq(test, send_keys, expected_keysyms) if cfg.ttype == 'leds_and_esc_keys': escaped = ['insert', 'delete', 'home', 'end', 'pgup', 'pgdn', 'up', 'down', 'right', 'left'] expected_keysyms = [65379, 65535, 65360, 65367, 65365, 65366, 65362, 65364, 65363, 65361] test_seq(test, escaped, expected_keysyms) shortcuts = ['a', 'shift-a', 'shift_r-a', 'ctrl-a', 'ctrl-c', 'ctrl-v', 'alt-x'] expected_keysyms = [97, 65505, 65, 65506, 65, 65507, 97, 65507, 99, 65507, 118, 65513, 120] test_seq(test, shortcuts, expected_keysyms) leds = ['a', 'caps_lock', 'a', 'caps_lock', 'num_lock', 'kp_1', 'num_lock', 'kp_1'] expected_keysyms = [97, 65509, 65, 65509, 65407, 65457, 65407, 65436] test_seq(test, leds, expected_keysyms) if cfg.ttype == 'nonus_layout': cmd = utils.Cmd("setxkbmap", "cz") act.run(test.vmi_g, cmd) keys = ['7', '8', '9', '0', 'alt_r-x', 'alt_r-c', 'alt_r-v'] expected_keysyms = [253, 225, 237, 233, 65027, 35, 65027, 38, 65027, 64] test_seq(test, keys, expected_keysyms) cmd = utils.Cmd("setxkbmap", "de") act.run(test.vmi_g, cmd) keys = ['minus', '0x1a', 'alt_r-q', 'alt_r-m'] expected_keysyms = [223, 252, 65027, 64, 65027, 181] test_seq(test, keys, expected_keysyms) cmd = utils.Cmd("setxkbmap", "us") act.run(test.vmi_g, cmd) if cfg.ttype == "leds_migration": if test.vm_c.is_rhel6(): test.vm_c.send_key('num_lock') keys1 = ['a', 'kp_1', 'caps_lock', 'num_lock', 'a', 'kp_1'] keys2 = ['a', 'kp_1', 'caps_lock', 'num_lock'] expected_keysyms = ['97', '65457', '65509', '65407', '65', '65436', '65', '65436', '65509', '65407'] ssn = act.klogger_start(test.vmi_g) for i in keys1: test.vm_c.send_key(i) test.vm_g.migrate() for i in keys2: test.vm_c.send_key(i) logged_keys = act.klogger_stop(test.vmi_g, ssn) ssn.close keysyms = map(lambda (ignore, keysym): keysym, logged_keys) assert keysyms == expected_keysyms
def run(vt_test, test_params, env): """GUI tests for remote-viewer. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. Raises ------ TestFail Test fails for expected behaviour. """ test = stest.ClientGuestTest(vt_test, test_params, env) cfg = test.cfg vmi_c = test.vmi_c vmi_g = test.vmi_g vm_c = test.vm_c # Screen lock is now disabled in kickstart file for source QCOW images of # SPICE-QE team (https://gitlab.cee.redhat.com/spiceqe/install-compose/ks). # act.lock_scr_off(vmi_c) act.turn_accessibility(vmi_c) act.x_active(vmi_c) act.x_active(vmi_g) if utils.vm_is_rhel8(vm_c): act.set_alt_python(vmi_c, "/usr/bin/python3") else: act.install_rpm(vmi_c, test.cfg_c.epel_rpm) act.install_rpm(vmi_c, test.cfg_c.dogtail_rpm) act.install_rpm(vmi_c, "xdotool") if utils.vm_is_rhel6(vm_c): # Activate accessibility for rhel6 act.reset_gui(vmi_c) # Copy tests to client VM. # Some tests could require established RV session, some of them, don't. is_connected = False if cfg.make_rv_connect: ssn = act.new_ssn(vmi_c, dogtail_ssn=vmi_c.vm.is_rhel8()) act.rv_connect(vmi_c, ssn) if not cfg.negative: act.rv_chk_con(vmi_c) is_connected = True logging.getLogger().setLevel(logging.DEBUG) tdir = act.cp2vm(vmi_c, cfg.client_tests) tpath = os.path.join(tdir, cfg.script) cmd = utils.Cmd('python', *tpath.split()) try: status, _ = act.rstatus(vmi_c, cmd, dogtail_ssn=vmi_c.vm.is_rhel8()) except Exception as e: a = traceback.format_exc() logger.info("Exception: %s: %s.", repr(e), a) if cfg.make_rv_connect: out = ssn.read_nonblocking() logger.info("RV log: %s.", str(out)) if status: raise utils.SpiceTestFail(test, "Test failed.")
def run(vt_test, test_params, env): """Steps: - Download SeleniumHQ server, and copy it to a client. - Open ovirt portal. - Login as a user. - Switch to extended tab. - Connect with remote-viewer to selected VM. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. """ test = stest.ClientGuestOvirtTest(vt_test, test_params, env) vmi_c = test.vmi_c cfg = test.cfg with act.new_ssn_context(vmi_c, name='Selenium session') as ssn: act.run_selenium(vmi_c, ssn) vm_addr = test.vm_c.get_address() logger.info("VM addr: %s", vm_addr) act.turn_firewall(vmi_c, "no") port = test.vm_c.get_port(int(cfg.selenium_port)) act.info(vmi_c, "Use port to connect to selenium: %s.", port) drv = driver.DriverFactory(cfg.selenium_driver, # Browser name. vm_addr, port) drv.maximize_window() login_page = user_login.UserLoginPage(drv) home_page = login_page.login_user(username=cfg.ovirt_user, password=cfg.ovirt_password, domain=cfg.ovirt_profile, autoconnect=False) ext_tab = home_page.go_to_extended_tab() vms_tab = ext_tab.go_to_vms_tab() shutdown_vm = False if cfg.ovirt_vm_name: vm = vms_tab.get_vm(cfg.ovirt_vm_name) elif cfg.ovirt_pool_name: vm = vms_tab.start_vm_from_pool(cfg.ovirt_pool_name) shutdown_vm = True if vm.is_down: logger.info("Up VM: %s.", vm.name) vms_tab.run_vm(vm.name) vms_tab.wait_until_vm_starts_booting(vm.name) console_options_dialog = vm.console_edit() console_options_dialog.select_spice() console_options_dialog.set_open_in_fullscreen(cfg.full_screen) console_options_dialog.submit_and_wait_to_disappear(timeout=2) vms_tab.wait_until_vm_is_up(vm.name) vm.console() vms_base.GuestAgentIsNotResponsiveDlg.ok_ignore(drv) logging.info("remote-viewer is supposed now connected.") if shutdown_vm: vms_tab.power_off(vm.name) home_page.sign_out_user() drv.close() act.rv_chk_con(vmi_c) # Check connection on client.
def run(vt_test, test_params, env): """Steps: - Download SeleniumHQ server, and copy it to a client. - Open ovirt portal. - Login as an admin. - Connect with remote-viewer to selected VM. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. """ test = stest.ClientGuestOvirtTest(vt_test, test_params, env) vmi_c = test.vmi_c cfg = test.cfg with act.new_ssn_context(vmi_c, name='Selenium session') as ssn: act.run_selenium(vmi_c, ssn) vm_addr = test.vm_c.get_address() logger.info("VM addr: %s", vm_addr) act.turn_firewall(vmi_c, "no") # XXX port = test.vm_c.get_port(int(cfg.selenium_port)) act.info(vmi_c, "Use port to connect to selenium: %s.", port) drv = driver.DriverFactory(cfg.selenium_driver, # Browser name. vm_addr, port) drv.maximize_window() # Maximize web-browser window. login_page = admin_login.AdminLoginPage(drv) home_page = login_page.login_user(username=cfg.ovirt_admin_user, password=cfg.ovirt_admin_password, domain='internal') tab_controller = home_page.go_to_vms_tab() vm_name = cfg.ovirt_vm_name shutdown_vm = False if vm_name: vm = tab_controller.get_vm(vm_name) elif cfg.ovirt_pool_name: #TODO: vms_tab undefined vm = vms_tab.start_vm_from_pool(cfg.ovirt_pool_name) vm_name = vm.name test.cfg_g.ovirt_vm_name = vm_name shutdown_vm = True if vm.is_down: logger.info("Up VM: %s.", vm_name) vms_tab.run_vm(vm_name) tab_controller.wait_until_vm_starts_booting(vm_name) console_options_dialog = tab_controller.console_edit(vm_name) console_options_dialog.select_spice() console_options_dialog.set_open_in_fullscreen(cfg.full_screen) console_options_dialog.submit_and_wait_to_disappear(timeout=2) tab_controller.console(vm_name) vms_base.GuestAgentIsNotResponsiveDlg.ok_ignore(drv) if shutdown_vm: vms_tab.power_off(vm_name) home_page.sign_out() drv.close() act.rv_chk_con(vmi_c) # Check connection on client.
def run(vt_test, test_params, env): """Test for testing keyboard inputs through spice. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. """ test = stest.ClientGuestTest(vt_test, test_params, env) cfg = test.cfg #test.cmd_g.install_rpm(cfg.xev) act.x_active(test.vmi_c) act.x_active(test.vmi_g) ssn = act.new_ssn(test.vmi_c, dogtail_ssn=test.vmi_c.vm.is_rhel8()) act.rv_connect(test.vmi_c, ssn) act.rv_chk_con(test.vmi_c) if cfg.ttype == 'type_and_func_keys': """Test typewriter and functional keys.""" keycodes = range(1, 69) # Skip Ctrl, RSH, LSH, PtScr, Alt, CpsLk skip = [29, 42, 54, 55, 56, 58] send_keys = [hex(k) for k in keycodes if k not in skip] expected_keysyms = [ 65307, 49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 45, 61, 65288, 65289, 113, 119, 101, 114, 116, 121, 117, 105, 111, 112, 91, 93, 65293, 97, 115, 100, 102, 103, 104, 106, 107, 108, 59, 39, 96, 92, 122, 120, 99, 118, 98, 110, 109, 44, 46, 47, 32, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479 ] test_seq(test, send_keys, expected_keysyms) if cfg.ttype == 'leds_and_esc_keys': escaped = [ 'insert', 'delete', 'home', 'end', 'pgup', 'pgdn', 'up', 'down', 'right', 'left' ] expected_keysyms = [ 65379, 65535, 65360, 65367, 65365, 65366, 65362, 65364, 65363, 65361 ] test_seq(test, escaped, expected_keysyms) shortcuts = [ 'a', 'shift-a', 'shift_r-a', 'ctrl-a', 'ctrl-c', 'ctrl-v', 'alt-x' ] expected_keysyms = [ 97, 65505, 65, 65506, 65, 65507, 97, 65507, 99, 65507, 118, 65513, 120 ] test_seq(test, shortcuts, expected_keysyms) leds = [ 'a', 'caps_lock', 'a', 'caps_lock', 'num_lock', 'kp_1', 'num_lock', 'kp_1' ] expected_keysyms = [97, 65509, 65, 65509, 65407, 65457, 65407, 65436] test_seq(test, leds, expected_keysyms) if cfg.ttype == 'nonus_layout': cmd = utils.Cmd("setxkbmap", "cz") act.run(test.vmi_g, cmd) keys = ['7', '8', '9', '0', 'alt_r-x', 'alt_r-c', 'alt_r-v'] expected_keysyms = [ 253, 225, 237, 233, 65027, 35, 65027, 38, 65027, 64 ] test_seq(test, keys, expected_keysyms) cmd = utils.Cmd("setxkbmap", "de") act.run(test.vmi_g, cmd) keys = ['minus', '0x1a', 'alt_r-q', 'alt_r-m'] expected_keysyms = [223, 252, 65027, 64, 65027, 181] test_seq(test, keys, expected_keysyms) cmd = utils.Cmd("setxkbmap", "us") act.run(test.vmi_g, cmd) if cfg.ttype == "leds_migration": if test.vm_c.is_rhel6(): test.vm_c.send_key('num_lock') keys1 = ['a', 'kp_1', 'caps_lock', 'num_lock', 'a', 'kp_1'] keys2 = ['a', 'kp_1', 'caps_lock', 'num_lock'] expected_keysyms = [ '97', '65457', '65509', '65407', '65', '65436', '65', '65436', '65509', '65407' ] ssn = act.klogger_start(test.vmi_g) for i in keys1: test.vm_c.send_key(i) test.vm_g.migrate() for i in keys2: test.vm_c.send_key(i) logged_keys = act.klogger_stop(test.vmi_g, ssn) ssn.close() keysyms = [key[1] for key in logged_keys] assert keysyms == expected_keysyms
def run(vt_test, test_params, env): """Run remote-viewer at client VM. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. Notes ----- Tests clean exit after shutting down the VM. Covers two cases: * Shutdown from the command line of the guest. * Shutdown from the qemu monitor. Verify after the shutdown: * Verifying the guest is down. * Verify the spice connection to the guest is no longer established. * Verify the remote-viewer process is not running. """ test = stest.ClientGuestTest(vt_test, test_params, env) cfg = test.cfg act.x_active(test.vmi_c) act.x_active(test.vmi_g) ssn = act.new_ssn(test.vmi_c) act.rv_connect(test.vmi_c, ssn) act.rv_chk_con(test.vmi_c) if test.cfg.shutdown_cmdline: test.vm_g.info("Shutting down from command line.") try: cmd = test.cfg_g.shutdown_command act.run(test.vmi_g, cmd, admin=True) except aexpect.ShellProcessTerminatedError: pass elif test.cfg.shutdown_qemu: test.vm_g.info("Shutting down from qemu monitor.") cmd = test.cfg.cmd_qemu_shutdown test.vm_g.monitor.cmd(cmd) else: raise utils.SpiceTestFail(test, "Bad config.") # Test: guest VM is dead. @deco.retry(8, exceptions=(AssertionError,)) def is_dead(): assert test.vm_g.is_dead(), "VM is alive." is_dead() test.vm_g.info("VM is dead.") # Test: no network connection. try: act.rv_chk_con(test.vmi_c) except utils.SpiceUtilsError: pass else: raise utils.SpiceTestFail(test, "RV still connected.") # Test: no RV proccess on client. if act.proc_is_active(test.vmi_c, 'remote-viewer'): raise utils.SpiceTestFail(test, "RV is still running on the client.")
def run(vt_test, test_params, env): """Run remote-viewer at client VM. Parameters ---------- vt_test : avocado.core.plugins.vt.VirtTest QEMU test object. test_params : virttest.utils_params.Params Dictionary with the test parameters. env : virttest.utils_env.Env Dictionary with test environment. Notes ----- Tests clean exit after shutting down the VM. Covers two cases: * Shutdown from the command line of the guest. * Shutdown from the qemu monitor. Verify after the shutdown: * Verifying the guest is down. * Verify the spice connection to the guest is no longer established. * Verify the remote-viewer process is not running. """ test = stest.ClientGuestTest(vt_test, test_params, env) cfg = test.cfg act.x_active(test.vmi_c) act.x_active(test.vmi_g) ssn = act.new_ssn(test.vmi_c, dogtail_ssn=test.vmi_c.vm.is_rhel8()) act.rv_connect(test.vmi_c, ssn) act.rv_chk_con(test.vmi_c) if test.cfg.shutdown_cmdline: test.vm_g.info("Shutting down from command line.") try: cmd = test.cfg_g.shutdown_command act.run(test.vmi_g, cmd, admin=True) except aexpect.ShellProcessTerminatedError: pass elif test.cfg.shutdown_qemu: test.vm_g.info("Shutting down from qemu monitor.") test.vm_g.monitor.system_powerdown() else: raise utils.SpiceTestFail(test, "Bad config.") # Test: guest VM is dead. @deco.retry(8, exceptions=(AssertionError, )) def is_dead(): assert test.vm_g.is_dead(), "VM is alive." is_dead() test.vm_g.info("VM is dead.") # Test: no network connection. try: act.rv_chk_con(test.vmi_c) except utils.SpiceUtilsError: pass else: raise utils.SpiceTestFail(test, "RV still connected.") # Test: no RV proccess on client. if act.proc_is_active(test.vmi_c, 'remote-viewer'): raise utils.SpiceTestFail(test, "RV is still running on the client.")