Ejemplo n.º 1
0
def run(vt_test, test_params, env):
    """Inspects Xorg logs for QLX presence.

    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 some reason.

    """
    test = stest.GuestTest(vt_test, test_params, env)
    cfg = test.cfg
    act.x_active(test.vmi)
    cmd = utils.Cmd("grep", "-i", "qxl", cfg.qxl_log)
    exit_code, output = act.rstatus(test.vmi, cmd, admin=True)
    assert exit_code == 0
    act.info(test.vmi, "Mention about qxl: %s." % output)
Ejemplo n.º 2
0
def run(vt_test, test_params, env):
    """Inspects Xorg logs for QLX presence.

    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 some reason.

    """
    test = stest.GuestTest(vt_test, test_params, env)
    cfg = test.cfg
    act.x_active(test.vmi)
    cmd = utils.Cmd("grep", "-i", "qxl", cfg.qxl_log)
    exit_code, output = act.rstatus(test.vmi, cmd)
    assert exit_code == 0
    act.info(test.vmi, "Mention about qxl: %s." % output)
Ejemplo n.º 3
0
def run(vt_test, test_params, env):
    """Download SeleniumHQ server, and copy it to a client.

    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.ClientTest(vt_test, test_params, env)
    vmi = test.vmi
    cfg = vmi.cfg
    with act.new_ssn_context(vmi, name="Selenium session") as ssn:
        act.run_selenium(vmi, ssn)
        vm_addr = test.vm.get_address()
        logger.info("VM addr: %s", vm_addr)
        act.turn_firewall(vmi, "no")
        port = vmi.vm.get_port(int(cfg.selenium_port))
        act.info(vmi, "Use port to connect to selenium: %s.", port)
        drv = driver.DriverFactory(cfg.selenium_driver, vm_addr, port)
        drv.maximize_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"
        )
        assert cfg.ovirt_vm_name
        if not vm.is_up:
            tab_controller.run_vm_and_wait_until_up(cfg.ovirt_vm_name)
        home_page.sign_out()
Ejemplo n.º 4
0
def run(vt_test, test_params, env):
    """Download SeleniumHQ server, and copy it to a client.

    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.ClientTest(vt_test, test_params, env)
    vmi = test.vmi
    cfg = vmi.cfg
    with act.new_ssn_context(vmi, name='Selenium session') as ssn:
        act.run_selenium(vmi, ssn)
        vm_addr = test.vm.get_address()
        logger.info("VM addr: %s", vm_addr)
        act.turn_firewall(vmi, "no")
        port = vmi.vm.get_port(int(cfg.selenium_port))
        act.info(vmi, "Use port to connect to selenium: %s.", port)
        drv = driver.DriverFactory(cfg.selenium_driver, vm_addr, port)
        drv.maximize_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')
        assert cfg.ovirt_vm_name
        if not vmi.vm.is_up:
            #TODO: tab_controller undefined
            tab_controller.run_vm_and_wait_until_up(cfg.ovirt_vm_name)
        home_page.sign_out()
Ejemplo n.º 5
0
def rv_connect_menu(vmi, ssn, env):
    cmd = act.rv_basic_opts(vmi)
    utils.set_ticket(vmi.test)
    cmd = utils.combine(cmd, "2>&1")
    act.info(vmi, "Final RV command: %s", cmd)
    act.rv_run(vmi, cmd, ssn)
    url = act.rv_url(vmi)
    act.str_input(vmi, url)
    act.rv_auth(vmi)
Ejemplo n.º 6
0
def verify_virtio(vmi):
    """Verify Virtio-Serial linux driver is properly loaded.

    """
    cmd = [vmi.cfg.pnputil, '/e']
    output = act.run_cmd(vmi, cmd)
    installed = "System devices" in output
    act.info(vmi, "Virtio Serial driver is installed:", installed)
    return installed
Ejemplo n.º 7
0
def run_selenium(vmi, ssn):
    """Some general info.
    There are ways to define Firefox options globaly:

        * /usr/lib64/firefox/defaults/preferences/<anyname>.js
        * /etc/firefox/pref/<anyname>.js

    Format is:

        user_pref("some.key", "somevalue");
        pref("some.key", "somevalue");

    All values are defined at:

        about:config?filter=color

    Also user can define values for specific profile:

        http://kb.mozillazine.org/Profile_folder_-_Firefox#Linux

    For curent profile go to: about:support and press "Open Directory"

    Selenium understands next options:

        -Dwebdriver.firefox.profile=my-profile
        -Dwebdriver.firefox.bin=/path/to/firefox
        -trustAllSSLcertificates

    Also it is possible to specify Firefox profile in selenium python
    bindings:

        FirefoxProfile p = new FirefoxProfile(new File("D:\\profile2"));
        p.updateUserPrefs(new File("D:\\t.js"));

    To create a new profile call:

        firefox -CreateProfile <profile name>

    """
    selenium = utils.download_asset("selenium", section=vmi.cfg.selenium_ver)
    fname = os.path.basename(selenium)
    dst_fname = os.path.join(act.workdir(vmi), fname)
    vmi.vm.copy_files_to(selenium, dst_fname)
    defs = utils.Cmd()
    opts = utils.Cmd()
    opts.append("-port")
    opts.append(vmi.cfg.selenium_port)
    opts.append("-trustAllSSLcertificates")
    defs = " ".join(defs)
    opts = " ".join(opts)
    cmd = "java {} -jar {} {}".format(defs, dst_fname, opts)
    utils.info(vmi, "selenium cmd: %s", cmd)
    ssn.sendline(cmd)
    # There should be a pause to start and running selenium server.
    # So next log reading acts like a pause.
    out = ssn.read_nonblocking(internal_timeout=20)
    act.info(vmi, "Selenium start log:\n%s.", out)
Ejemplo n.º 8
0
def verify_virtio(vmi):
    """Verify Virtio-Serial linux driver is properly loaded.

    """
    cmd = [vmi.cfg.pnputil, "/e"]
    output = act.run_cmd(vmi, cmd)
    installed = "System devices" in output
    act.info(vmi, "Virtio Serial driver is installed:", installed)
    return installed
Ejemplo n.º 9
0
def rv_connect_menu(vmi, ssn, env):
    cmd = act.rv_basic_opts(vmi)
    utils.set_ticket(vmi.test)
    cmd = utils.combine(cmd, "2>&1")
    act.info(vmi, "Final RV command: %s", cmd)
    act.rv_run(vmi, cmd, ssn, env)
    url = act.rv_url(vmi)
    act.str_input(vmi, url)
    act.rv_auth(vmi)
Ejemplo n.º 10
0
def rv_connect_cmd(vmi, ssn, env):
    cmd = act.rv_basic_opts(vmi)
    url = act.rv_url(vmi)
    cmd.append(url)
    cmd = utils.combine(cmd, "2>&1")
    act.info(vmi, "Final RV command: %s", cmd)
    utils.set_ticket(vmi.test)
    act.rv_run(vmi, cmd, ssn, env)
    act.rv_auth(vmi)
Ejemplo n.º 11
0
def rv_connect_cmd(vmi, ssn, env):
    cmd = act.rv_basic_opts(vmi)
    url = act.rv_url(vmi)
    cmd.append(url)
    cmd = utils.combine(cmd, "2>&1")
    act.info(vmi, "Final RV command: %s", cmd)
    utils.set_ticket(vmi.test)
    act.rv_run(vmi, cmd, ssn)
    act.rv_auth(vmi)
Ejemplo n.º 12
0
def klogger_stop(vmi, ssn):
    # Send ctrl+c (SIGINT) through ssh session.
    time.sleep(1)
    ssn.send("\003")
    output = ssn.read_up_to_prompt()
    a = re.findall("KeyPress.*\n.*\n.* keycode (\d*) \(keysym ([0-9A-Fa-fx]*)", output)
    act.info(vmi, "Keyboard logger out: %r", a)
    keys = map(lambda (keycode, keysym): (int(keycode), int(keysym, base=16)), a)
    utils.info(vmi, "Read keys: %s" % keys)
    # Return list of pressed: (keycode, keysym)
    return keys
Ejemplo n.º 13
0
def rv_connect_file(vmi, ssn, env):
    cmd = utils.Cmd(vmi.cfg.rv_binary)
    vv_file_host = act.gen_vv_file(vmi)
    with open(vv_file_host, 'r') as rvfile:
        file_contents = rvfile.read()
        act.info(vmi, "RV file contents:\n%s", file_contents)
    vv_file_client = act.cp_file(vmi, vv_file_host)
    cmd.append(vv_file_client)
    utils.set_ticket(vmi.test)
    cmd = utils.combine(cmd, "2>&1")
    act.info(vmi, "Final RV command: %s", cmd)
    act.rv_run(vmi, cmd, ssn)
Ejemplo n.º 14
0
def rv_connect_file(vmi, ssn, env):
    cmd = utils.Cmd(vmi.cfg.rv_binary)
    vv_file_host = act.gen_vv_file(vmi)
    with open(vv_file_host, 'r') as rvfile:
        file_contents = rvfile.read()
        act.info(vmi, "RV file contents:\n%s", file_contents)
    vv_file_client = act.cp_file(vmi, vv_file_host)
    cmd.append(vv_file_client)
    utils.set_ticket(vmi.test)
    cmd = utils.combine(cmd, "2>&1")
    act.info(vmi, "Final RV command: %s", cmd)
    act.rv_run(vmi, cmd, ssn, env)
Ejemplo n.º 15
0
def rstatus(vmi, cmd, ssn=None, admin=False, dogtail_ssn=False, timeout=None):
    """
    Raises
    ------
        See: /usr/lib/python2.7/site-packages/aexpect/client.py

    Returns
    -------
    str
        Command output + exit status.
    """
    if not ssn:
        ssn = act.new_ssn(vmi, admin, dogtail_ssn)
    cmdline = str(cmd)
    kwargs = {}
    if timeout:
        kwargs['timeout'] = timeout
    status, out = ssn.cmd_status_output(cmdline, **kwargs)
    act.info(vmi, "cmd: %s, status: %s, output: %s", cmdline, status, out)
    return (status, out)
Ejemplo n.º 16
0
def rstatus(vmi, cmd, ssn=None, admin=False, timeout=None):
    """
    Raises
    ------
        See: /usr/lib/python2.7/site-packages/aexpect/client.py

    Returns
    -------
    str
        Command output + exit status.
    """
    if not ssn:
        ssn = act.new_ssn(vmi, admin)
    cmdline = str(cmd)
    kwargs = {}
    if timeout:
        kwargs['timeout'] = timeout
    status, out = ssn.cmd_status_output(cmdline)
    act.info(vmi, "cmd: %s, status: %s, output: %s", cmdline, status, out)
    return (status, out)
Ejemplo n.º 17
0
def run(vmi, cmd, ssn=None, admin=False, timeout=None):
    """
    Raises
    ------
        If the command's exit status is nonzero, raise an exception.
        See: /usr/lib/python2.7/site-packages/aexpect/client.py

    Returns
    -------
    str
        Command output.
    """
    if not ssn:
        ssn = act.new_ssn(vmi, admin)
    cmdline = str(cmd)
    kwargs = {}
    if timeout:
        kwargs['timeout'] = timeout
    out = ssn.cmd(cmdline, **kwargs)
    act.info(vmi, "cmd: %s, out: %s", cmdline, out)
    return out
Ejemplo n.º 18
0
def run(vmi, cmd, ssn=None, dogtail_ssn=False, admin=False, timeout=None):
    """
    Raises
    ------
        If the command's exit status is nonzero, raise an exception.
        See: /usr/lib/python2.7/site-packages/aexpect/client.py

    Returns
    -------
    str
        Command output.
    """
    if not ssn:
        ssn = act.new_ssn(vmi, admin, dogtail_ssn=dogtail_ssn)
    cmdline = str(cmd)
    kwargs = {}
    if timeout:
        kwargs['timeout'] = timeout
    out = ssn.cmd(cmdline, **kwargs)
    act.info(vmi, "cmd: %s, out: %s", cmdline, out)
    return out
Ejemplo n.º 19
0
def rv_connect(vmi, ssn, env=None):
    """Establish connection between client and guest based on test parameters
    supplied at cartesian config.

    Notes
    -----
    There are three possible methods to connect from client to guest:

        * Cmdline + parameters
        * Cmdline + rv file
        * remote-viewer menu URL

    Parameters
    ----------
    vmi : VmInfo
        VM that runs RV.
    ssn : xxx
        Session object, as a exec-layer to VM.
    env : dict
        Dictionary of env variables to be passed  before remote-viewer starts.

    Returns
    -------
    None

    """
    env = env or {}
    method = vmi.cfg.rv_parameters_from
    if method == 'cmd':
        act.info(vmi, "Connect to VM using command line.")
        rv_connect_cmd(vmi, ssn, env)
    elif method == 'menu':
        act.info(vmi, "Connect to VM using menu.")
        rv_connect_menu(vmi, ssn, env)
    elif method == 'file':
        act.info(vmi, "Connect to VM using .vv file.")
        rv_connect_file(vmi, ssn, env)
    else:
        raise RVSessionConnect(vmi.test, "Wrong connect method.")
Ejemplo n.º 20
0
def rv_connect(vmi, ssn, env={}):
    """Establish connection between client and guest based on test parameters
    supplied at cartesian config.

    Notes
    -----
    There are three possible methods to connect from client to guest:

        * Cmdline + parameters
        * Cmdline + rv file
        * remote-viewer menu URL

    Parameters
    ----------
    test : VmInfo
        VM that runs RV.
    ssn : xxx
        Session object, as a exec-layer to VM.
    env : dict
        Dictionary of env variables to passed before remote-viewer start.

    Returns
    -------
    None

    """
    method = vmi.cfg.rv_parameters_from
    if method == 'cmd':
        act.info(vmi, "Connect to VM using command line.")
        rv_connect_cmd(vmi, ssn, env)
    elif method == 'menu':
        act.info(vmi, "Connect to VM using menu.")
        rv_connect_menu(vmi, ssn, env)
    elif method == 'file':
        act.info(vmi, "Connect to VM using .vv file.")
        rv_connect_file(vmi, ssn, env)
    else:
        raise RVSessionConnect(vmi.test, "Wrong connect method.")
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.
Ejemplo n.º 22
0
def export_vars(vmi, ssn):
    """Export essentials variables per SSH session."""
    act.info(vmi, "Export vars for session.")
    cmd = utils.Cmd("export", "DISPLAY=:0.0")
    act.run(vmi, cmd, ssn=ssn)
Ejemplo n.º 23
0
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.