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): """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): """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 vmi_c = test.vmi_c vmi_g = test.vmi_g homedir_g = act.home_dir(vmi_g) success = False act.turn_accessibility(vmi_c) if utils.vm_is_rhel6(test.vm_c): # Activate accessibility for rhel6, BZ#1340160 for rhel7 act.reset_gui(vmi_c) act.x_active(vmi_c) act.x_active(vmi_g) ssn = act.new_ssn(vmi_c) act.rv_connect(vmi_c, ssn) # Nautilus cannot be docked to side when default resolution act.set_resolution(vmi_c, "1280x1024") if not utils.vm_is_rhel8(test.vm_c): act.install_rpm(vmi_c, vmi_c.cfg.dogtail_rpm) dst_script = act.chk_deps(vmi_c, cfg.helper_c) if cfg.locked: # enable screen lock cmd = utils.Cmd('rm', '-I', '/etc/dconf/db/local.d/screensaver') act.run(vmi_g, cmd, admin=True) cmd = utils.Cmd('dconf', 'update') act.run(vmi_g, cmd, admin=True) cmd = utils.Cmd('loginctl', 'lock-sessions') act.run(vmi_g, cmd, admin=True) logging.info('Locking gnome session on guest') if 'generate' in cfg.test_xfer_file: if cfg.copy_img: test_xfer_file = 'test.png' act.imggen(vmi_c, test_xfer_file, cfg.test_image_size) else: test_xfer_file = 'test.txt' act.gen_rnd_file(vmi_c, test_xfer_file, cfg.xfer_kbytes) elif 'http' in cfg.test_xfer_file: cmd = utils.Cmd('wget', cfg.test_xfer_file) act.run(vmi_c, cmd) test_xfer_file = os.path.basename(cfg.test_xfer_file) logger.info('Downloading %s', test_xfer_file) act.run(vmi_c, "nautilus 2>/dev/null &") if cfg.xfer_args: cmd = utils.Cmd(dst_script, cfg.xfer_args, test_xfer_file) else: cmd = utils.Cmd(dst_script, test_xfer_file) logger.info('Sending command to client: %s', cmd) try: act.run(vmi_c, cmd) except aexpect.exceptions.ShellCmdError: logger.info('Cannot transfer a file.') utils.SpiceTestFail(test, "Test failed.") md5src = act.md5sum(vmi_c, test_xfer_file) try: md5dst = act.md5sum( vmi_g, os.path.join(homedir_g, 'Downloads', test_xfer_file)) except aexpect.exceptions.ShellCmdError: logger.info('File is not transferred.') md5dst = None if md5src == md5dst: logger.info('%s transferred to guest VM', test_xfer_file) cmd1 = utils.Cmd('lsof') cmd2 = utils.Cmd('grep', '-q', '-s', test_xfer_file) cmd = utils.combine(cmd1, '|', cmd2) status, _ = act.rstatus(vmi_g, cmd) if status: logger.info('Transferred file %s is closed.', test_xfer_file) success = True elif cfg.xfer_args == '--negative': logger.info('File %s was not transferred.', test_xfer_file) success = True if not success: raise utils.SpiceTestFail(test, "Test failed.")