Example #1
0
def restart_cppaste(session_to_copy_from, session_to_paste_to, guest_session, params):
    """
    Sending the commands to copy from one session to another, and make
    sure it works correctly after Restarting vdagent

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # start vdagent daemon
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)
    # Command to copy text and put it in the keyboard, copy on the client
    place_text_in_clipboard(session_to_copy_from, interpreter, script_call, script_params, testing_text, test_timeout)
    # Now test to see if the copied text from the one session can be
    # pasted on the other
    verify_paste_successful(session_to_paste_to, testing_text, interpreter, script_call, test_timeout)
    # Restart vdagent, clear the clipboard, verify cp and paste still works
    utils_spice.restart_vdagent(guest_session, test_timeout)

    clear_cb(session_to_paste_to, params)
    clear_cb(session_to_copy_from, params)
    wait_timeout(5)

    # Command to copy text and put it in the keyboard, copy on the client
    place_text_in_clipboard(session_to_copy_from, interpreter, script_call, script_params, testing_text, test_timeout)

    wait_timeout(5)
    # Now test to see if the copied text from the one session can be
    # pasted on the other
    verify_paste_successful(session_to_paste_to, testing_text, interpreter, script_call, test_timeout)
Example #2
0
def run(test, params, env):
    """
    Tests spice vdagent (starting, stopping, restarting, and status)

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    vdagent_test = params.get("vdagent_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_root_session = guest_vm.wait_for_login(timeout=int(
        params.get("login_timeout", 360)),
                                                 username="******",
                                                 password="******")

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    vdagent_status = utils_spice.get_vdagent_status(guest_root_session,
                                                    test_timeout)

    # start test
    if vdagent_test == "start":
        if "running" in vdagent_status:
            # stop the service prior to starting
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
            utils_spice.start_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.start_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is running
        status = utils_spice.get_vdagent_status(guest_root_session,
                                                test_timeout)
        if "running" in status:
            pass
        else:
            raise error.TestFail(
                "Vdagent status is not running after a start attempt.")
    # stop test
    elif vdagent_test == "stop":
        if "stopped" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.start_vdagent(guest_root_session, test_timeout)
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is stopped
        status = utils_spice.get_vdagent_status(guest_root_session,
                                                test_timeout)
        if "stopped" in status:
            pass
        else:
            print "Status: " + status
            raise error.TestFail(
                "Vdagent status is not stopped after a stop attempt.")
    # restart test when vdagent service is running
    elif vdagent_test == "restart_start":
        if "stopped" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.start_vdagent(guest_root_session, test_timeout)
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is started
        status = utils_spice.get_vdagent_status(guest_root_session,
                                                test_timeout)
        if "running" in status:
            pass
        else:
            raise error.TestFail(
                "Vdagent status is not started after a restart attempt.")
    # restart test when vdagent service is stopped
    elif vdagent_test == "restart_stop":
        if "running" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is started
        status = utils_spice.get_vdagent_status(guest_root_session,
                                                test_timeout)
        if "running" in status:
            pass
        else:
            raise error.TestFail(
                "Vdagent status is not started after a restart attempt.")
    else:
        raise error.TestFail("No test to run, check value of vdagent_test")

    client_session.close()
    guest_root_session.close()
Example #3
0
def run(test, params, env):
    """
    Tests the logging of remote-viewer

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    # Get the necessary parameters to run the tests
    log_test = params.get("logtest")
    qxl_logfile = params.get("qxl_log")
    spicevdagent_logfile = params.get("spice_log")
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(timeout=int(
        params.get("login_timeout", 360)),
                                                 username="******",
                                                 password="******")

    scriptdir = os.path.join("scripts", script)
    script_path = utils_misc.get_path(test.virtdir, scriptdir)

    # Copying the clipboard script to the guest to test spice vdagent
    logging.info(
        "Transferring the clipboard script to the guest,"
        "destination directory: %s, source script location: %s", dst_path,
        script_path)
    guest_vm.copy_files_to(script_path, dst_path, timeout=60)

    # Some logging tests need the full desktop environment
    guest_session.cmd("export DISPLAY=:0.0")

    # Logging test for the qxl driver
    if (log_test == 'qxl'):
        logging.info("Running the logging test for the qxl driver")
        guest_root_session.cmd("grep -i qxl " + qxl_logfile)
    # Logging test for spice-vdagent
    elif (log_test == 'spice-vdagent'):
        logging.info("Running the logging test for spice-vdagent daemon")
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)

        # Testing the log after stopping spice-vdagentd
        utils_spice.stop_vdagent(guest_root_session, test_timeout=15)
        output = guest_root_session.cmd("tail -n 3 " + spicevdagent_logfile +
                                        " | grep 'vdagentd quiting'")

        # Testing the log after starting spice-vdagentd
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)
        output = guest_root_session.cmd(
            "tail -n 2 " + spicevdagent_logfile +
            " | grep 'opening vdagent virtio channel'")

        # Testing the log after restart spice-vdagentd
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)
        output = guest_root_session.cmd(
            "tail -n 2 " + spicevdagent_logfile +
            " | grep 'opening vdagent virtio channel'")

        cmd = ("echo \"SPICE_VDAGENTD_EXTRA_ARGS=-dd\">"
               "/etc/sysconfig/spice-vdagentd")
        guest_root_session.cmd(cmd)
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)

        # Finally test copying text within the guest
        cmd = "%s %s %s %s" % (interpreter, script_call, script_params,
                               testing_text)

        logging.info("This command here: " + cmd)

        try:
            logging.debug("------------ Script output ------------")
            output = guest_session.cmd(cmd)

            if "The text has been placed into the clipboard." in output:
                logging.info("Copying of text was successful")
            else:
                raise error.TestFail("Copying to the clipboard failed ELSE",
                                     output)
        except:
            raise error.TestFail("Copying to the clipboard failed try" +
                                 " block failed")

        logging.debug("------------ End of script output of the Copying"
                      " Session ------------")

        output = guest_root_session.cmd("tail -n 3 " + spicevdagent_logfile +
                                        " | grep 'clipboard grab'")

    else:
        # Couldn't find the right test to run
        guest_session.close()
        guest_root_session.close()
        raise error.TestFail("Couldn't find the right test to run," +
                             " check cfg files.")
    guest_session.close()
Example #4
0
def run(test, params, env):
    """
    Tests the logging of remote-viewer

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    # Get the necessary parameters to run the tests
    log_test = params.get("logtest")
    qxl_logfile = params.get("qxl_log")
    spicevdagent_logfile = params.get("spice_log")
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)),
        username="******", password="******")

    scriptdir = os.path.join("scripts", script)
    script_path = utils_misc.get_path(test.virtdir, scriptdir)

    # Copying the clipboard script to the guest to test spice vdagent
    logging.info("Transferring the clipboard script to the guest,"
                 "destination directory: %s, source script location: %s",
                 dst_path, script_path)
    guest_vm.copy_files_to(script_path, dst_path, timeout=60)

    # Some logging tests need the full desktop environment
    guest_session.cmd("export DISPLAY=:0.0")

    # Logging test for the qxl driver
    if(log_test == 'qxl'):
        logging.info("Running the logging test for the qxl driver")
        guest_root_session.cmd("grep -i qxl " + qxl_logfile)
    # Logging test for spice-vdagent
    elif(log_test == 'spice-vdagent'):

        # Check for RHEL6 or RHEL7
        # RHEL7 uses gsettings and RHEL6 uses gconftool-2
        try:
            release = guest_session.cmd("cat /etc/redhat-release")
            logging.info("Redhat Release: %s" % release)
        except:
            test.cancel("Test is only currently supported on "
                        "RHEL and Fedora operating systems")

        if "release 7." in release:
            spice_vdagent_loginfo_cmd = "journalctl" \
                                        " SYSLOG_IDENTIFIER=spice-vdagent" \
                                        " SYSLOG_IDENTIFIER=spice-vdagentd"
        else:
            spice_vdagent_loginfo_cmd = "tail -n 10 " + spicevdagent_logfile

        cmd = ("echo \"SPICE_VDAGENTD_EXTRA_ARGS=-dd\">"
               "/etc/sysconfig/spice-vdagentd")
        guest_root_session.cmd(cmd)

        logging.info("Running the logging test for spice-vdagent daemon")
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)

        # Testing the log after stopping spice-vdagentd
        utils_spice.stop_vdagent(guest_root_session, test_timeout=15)
        cmd = spice_vdagent_loginfo_cmd + " | tail -n 3 | grep \"vdagentd quitting\""
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Testing the log after starting spice-vdagentd
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)
        cmd = spice_vdagent_loginfo_cmd + "| tail -n 7 | grep \"opening vdagent virtio channel\""
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Testing the log after restart spice-vdagentd
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)
        cmd = spice_vdagent_loginfo_cmd + "| tail -n 7 | grep 'opening vdagent virtio channel'"
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Finally test copying text within the guest
        cmd = "%s %s %s %s" % (interpreter, script_call,
                               script_params, testing_text)
        logging.info("This command here: " + cmd)

        try:
            logging.debug("------------ Script output ------------")
            output = guest_session.cmd(cmd)

            if "The text has been placed into the clipboard." in output:
                logging.info("Copying of text was successful")
            else:
                test.fail("Copying to the clipboard failed. %s" % output)
        except:
            test.fail("Copying to the clipboard failed try block failed")

        logging.debug("------------ End of script output of the Copying"
                      " Session ------------")

        output = guest_root_session.cmd(spice_vdagent_loginfo_cmd + "| tail -n 2" +
                                        " | grep 'clipboard grab'")

    else:
        # Couldn't find the right test to run
        guest_session.close()
        guest_root_session.close()
        test.fail("Couldn't find the right test to run, check cfg files.")
    guest_session.close()
Example #5
0
def restart_cppaste_image(session_to_copy_from, session_to_paste_to, guest_session, params):
    """
    Sending the commands to copy an image from one session to another.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    image_type = params.get("image_type")
    script_set_params = params.get("script_params_img_set")
    script_save_params = params.get("script_params_img_save")
    dst_path = params.get("dst_dir", "guest_script")
    dst_image_path = os.path.join(params.get("dst_dir"), params.get("image_tocopy_name"))
    dst_image_path_bmp = os.path.join(params.get("dst_dir"), params.get("image_tocopy_name_bmp"))
    final_image_path = os.path.join(params.get("dst_dir"), params.get("final_image"))
    final_image_path_bmp = os.path.join(params.get("dst_dir"), params.get("final_image_bmp"))
    script_call = os.path.join(dst_path, script)

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Start vdagent
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)

    if "png" in image_type:
        # Command to copy text and put it in the keyboard, copy on the client
        place_img_in_clipboard(
            session_to_copy_from, interpreter, script_call, script_set_params, dst_image_path, test_timeout
        )
        # Now test to see if the copied text from the one session can be
        # pasted on the other
        image_size = verify_img_paste(
            session_to_copy_from, interpreter, script_call, script_save_params, final_image_path, test_timeout
        )
        wait_timeout(30)

        # Verify the paste on the session to paste to
        verify_img_paste_success(
            session_to_paste_to,
            interpreter,
            script_call,
            script_save_params,
            final_image_path,
            image_size,
            test_timeout,
        )
    else:
        # Testing bmp
        place_img_in_clipboard(
            session_to_copy_from, interpreter, script_call, script_set_params, dst_image_path_bmp, test_timeout
        )

        # Now test to see if the copied text from the one session can be
        # pasted on the other
        image_size = verify_img_paste(
            session_to_copy_from, interpreter, script_call, script_save_params, final_image_path_bmp, test_timeout
        )
        wait_timeout(30)

        # Verify the paste on the session to paste to
        verify_img_paste_success(
            session_to_paste_to,
            interpreter,
            script_call,
            script_save_params,
            final_image_path_bmp,
            image_size,
            test_timeout,
        )
    # Restart vdagent & clear the clipboards.
    utils_spice.restart_vdagent(guest_session, test_timeout)
    clear_cb(session_to_paste_to, params)
    clear_cb(session_to_copy_from, params)
    wait_timeout(5)

    if "png" in image_type:
        # Command to copy text and put it in the keyboard, copy on the client
        place_img_in_clipboard(
            session_to_copy_from, interpreter, script_call, script_set_params, dst_image_path, test_timeout
        )
        # Now test to see if the copied text from the one session can be
        # pasted on the other
        image_size = verify_img_paste(
            session_to_copy_from, interpreter, script_call, script_save_params, final_image_path, test_timeout
        )
        wait_timeout(30)

        # Verify the paste on the session to paste to
        verify_img_paste_success(
            session_to_paste_to,
            interpreter,
            script_call,
            script_save_params,
            final_image_path,
            image_size,
            test_timeout,
        )
    else:
        # Testing bmp
        place_img_in_clipboard(
            session_to_copy_from, interpreter, script_call, script_set_params, dst_image_path_bmp, test_timeout
        )

        # Now test to see if the copied text from the one session can be
        # pasted on the other
        image_size = verify_img_paste(
            session_to_copy_from, interpreter, script_call, script_save_params, final_image_path_bmp, test_timeout
        )
        wait_timeout(30)

        # Verify the paste on the session to paste to
        verify_img_paste_success(
            session_to_paste_to,
            interpreter,
            script_call,
            script_save_params,
            final_image_path_bmp,
            image_size,
            test_timeout,
        )
Example #6
0
def restart_cppaste_lrgtext(session_to_copy_from, session_to_paste_to, guest_session, params):
    """
    Sending the commands to copy large text from one session to another, and
    make sure the data is still correct after restarting vdagent.

    @param session_to_copy_from: ssh session of the vm to copy from
    @param session_to_paste_to: ssh session of the vm to paste to
    @param guest_session: guest ssh session
    @param params: Dictionary with the test parameters.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_write_params = params.get("script_params_writef")
    script_create_params = params.get("script_params_createf")
    dst_path = params.get("dst_dir", "guest_script")
    final_text_path = os.path.join(params.get("dst_dir"), params.get("final_textfile"))
    script_call = os.path.join(dst_path, script)
    string_length = params.get("text_to_test")

    # Before doing the copy and paste, verify vdagent is
    # installed and the daemon is running on the guest
    utils_spice.verify_vdagent(guest_session, test_timeout)
    # Start vdagent
    utils_spice.start_vdagent(guest_session, test_timeout)
    # Make sure virtio driver is running
    utils_spice.verify_virtio(guest_session, test_timeout)

    # Command to copy text and put it in the clipboard
    textfile_checksum = verify_text_copy(
        session_to_copy_from,
        interpreter,
        script_call,
        script_create_params,
        string_length,
        final_text_path,
        test_timeout,
    )
    wait_timeout(30)

    # Verify the paste on the session to paste to
    verify_txt_paste_success(
        session_to_paste_to,
        interpreter,
        script_call,
        script_write_params,
        final_text_path,
        textfile_checksum,
        test_timeout,
    )
    # Restart vdagent & clear the clipboards.
    utils_spice.restart_vdagent(guest_session, test_timeout)
    clear_cb(session_to_paste_to, params)
    clear_cb(session_to_copy_from, params)
    wait_timeout(5)

    # Command to copy text and put it in the clipboard
    textfile_checksum = verify_text_copy(
        session_to_copy_from,
        interpreter,
        script_call,
        script_create_params,
        string_length,
        final_text_path,
        test_timeout,
    )
    wait_timeout(30)

    # Verify the paste on the session to paste to
    verify_txt_paste_success(
        session_to_paste_to,
        interpreter,
        script_call,
        script_write_params,
        final_text_path,
        textfile_checksum,
        test_timeout,
    )
Example #7
0
def run(test, params, env):
    """
    Tests the logging of remote-viewer

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    # Get the necessary parameters to run the tests
    log_test = params.get("logtest")
    qxl_logfile = params.get("qxl_log")
    spicevdagent_logfile = params.get("spice_log")
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)),
        username="******", password="******")

    scriptdir = os.path.join("scripts", script)
    script_path = utils_misc.get_path(test.virtdir, scriptdir)

    # Copying the clipboard script to the guest to test spice vdagent
    logging.info("Transferring the clipboard script to the guest,"
                 "destination directory: %s, source script location: %s",
                 dst_path, script_path)
    guest_vm.copy_files_to(script_path, dst_path, timeout=60)

    # Some logging tests need the full desktop environment
    guest_session.cmd("export DISPLAY=:0.0")

    # Logging test for the qxl driver
    if(log_test == 'qxl'):
        logging.info("Running the logging test for the qxl driver")
        guest_root_session.cmd("grep -i qxl " + qxl_logfile)
    # Logging test for spice-vdagent
    elif(log_test == 'spice-vdagent'):
        logging.info("Running the logging test for spice-vdagent daemon")
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)

        # Testing the log after stopping spice-vdagentd
        utils_spice.stop_vdagent(guest_root_session, test_timeout=15)
        output = guest_root_session.cmd("tail -n 3 " + spicevdagent_logfile +
                                        " | grep 'vdagentd quiting'")

        # Testing the log after starting spice-vdagentd
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)
        output = guest_root_session.cmd("tail -n 2 " + spicevdagent_logfile +
                                        " | grep 'opening vdagent virtio channel'")

        # Testing the log after restart spice-vdagentd
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)
        output = guest_root_session.cmd("tail -n 2 " + spicevdagent_logfile +
                                        " | grep 'opening vdagent virtio channel'")

        cmd = ("echo \"SPICE_VDAGENTD_EXTRA_ARGS=-dd\">"
               "/etc/sysconfig/spice-vdagentd")
        guest_root_session.cmd(cmd)
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)

        # Finally test copying text within the guest
        cmd = "%s %s %s %s" % (interpreter, script_call,
                               script_params, testing_text)

        logging.info("This command here: " + cmd)

        try:
            logging.debug("------------ Script output ------------")
            output = guest_session.cmd(cmd)

            if "The text has been placed into the clipboard." in output:
                logging.info("Copying of text was successful")
            else:
                raise error.TestFail("Copying to the clipboard failed ELSE",
                                     output)
        except:
            raise error.TestFail("Copying to the clipboard failed try" +
                                 " block failed")

        logging.debug("------------ End of script output of the Copying"
                      " Session ------------")

        output = guest_root_session.cmd("tail -n 3 " + spicevdagent_logfile +
                                        " | grep 'clipboard grab'")

    else:
        # Couldn't find the right test to run
        guest_session.close()
        guest_root_session.close()
        raise error.TestFail("Couldn't find the right test to run,"
                             + " check cfg files.")
    guest_session.close()
Example #8
0
def run(test, params, env):
    """
    Tests spice vdagent (starting, stopping, restarting, and status)

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    # Get necessary params
    test_timeout = float(params.get("test_timeout", 600))
    vdagent_test = params.get("vdagent_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_root_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)),
        username="******", password="******")

    client_vm = env.get_vm(params["client_vm"])
    client_vm.verify_alive()
    client_session = client_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))

    vdagent_status = utils_spice.get_vdagent_status(
        guest_root_session, test_timeout)

    # start test
    if vdagent_test == "start":
        if "running" in vdagent_status:
            # stop the service prior to starting
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
            utils_spice.start_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.start_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is running
        status = utils_spice.get_vdagent_status(
            guest_root_session, test_timeout)
        if "running" in status:
            pass
        else:
            test.fail("Vdagent status is not running after a start attempt.")
    # stop test
    elif vdagent_test == "stop":
        if "stopped" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.start_vdagent(guest_root_session, test_timeout)
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is stopped
        status = utils_spice.get_vdagent_status(
            guest_root_session, test_timeout)
        if "stopped" in status:
            pass
        else:
            logging.error("Status: " + status)
            test.fail("Vdagent status is not stopped after a stop attempt.")
    # restart test when vdagent service is running
    elif vdagent_test == "restart_start":
        if "stopped" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.start_vdagent(guest_root_session, test_timeout)
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is started
        status = utils_spice.get_vdagent_status(
            guest_root_session, test_timeout)
        if "running" in status:
            pass
        else:
            test.fail("Vdagent status is not started after a restart attempt.")
    # restart test when vdagent service is stopped
    elif vdagent_test == "restart_stop":
        if "running" in vdagent_status:
            # start the service prior to stopping the service
            utils_spice.stop_vdagent(guest_root_session, test_timeout)
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        else:
            utils_spice.restart_vdagent(guest_root_session, test_timeout)
        # Verify the status of vdagent is started
        status = utils_spice.get_vdagent_status(
            guest_root_session, test_timeout)
        if "running" in status:
            pass
        else:
            test.fail("Vdagent status is not started after a restart attempt.")
    else:
        test.fail("No test to run, check value of vdagent_test")

    client_session.close()
    guest_root_session.close()
Example #9
0
def run(test, params, env):
    """
    Tests the logging of remote-viewer

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """

    # Get the necessary parameters to run the tests
    log_test = params.get("logtest")
    qxl_logfile = params.get("qxl_log")
    spicevdagent_logfile = params.get("spice_log")
    interpreter = params.get("interpreter")
    script = params.get("guest_script")
    script_params = params.get("script_params", "")
    dst_path = params.get("dst_dir", "guest_script")
    script_call = os.path.join(dst_path, script)
    testing_text = params.get("text_to_test")

    guest_vm = env.get_vm(params["guest_vm"])
    guest_vm.verify_alive()
    guest_session = guest_vm.wait_for_login(
        timeout=int(params.get("login_timeout", 360)))
    guest_root_session = guest_vm.wait_for_login(timeout=int(
        params.get("login_timeout", 360)),
                                                 username="******",
                                                 password="******")

    scriptdir = os.path.join("scripts", script)
    script_path = utils_misc.get_path(test.virtdir, scriptdir)

    # Copying the clipboard script to the guest to test spice vdagent
    logging.info(
        "Transferring the clipboard script to the guest,"
        "destination directory: %s, source script location: %s", dst_path,
        script_path)
    guest_vm.copy_files_to(script_path, dst_path, timeout=60)

    # Some logging tests need the full desktop environment
    guest_session.cmd("export DISPLAY=:0.0")

    # Logging test for the qxl driver
    if (log_test == 'qxl'):
        logging.info("Running the logging test for the qxl driver")
        guest_root_session.cmd("grep -i qxl " + qxl_logfile)
    # Logging test for spice-vdagent
    elif (log_test == 'spice-vdagent'):

        # Check for RHEL6 or RHEL7
        # RHEL7 uses gsettings and RHEL6 uses gconftool-2
        try:
            release = guest_session.cmd("cat /etc/redhat-release")
            logging.info("Redhat Release: %s", release)
        except:
            test.cancel("Test is only currently supported on "
                        "RHEL and Fedora operating systems")

        if "release 7." in release:
            spice_vdagent_loginfo_cmd = "journalctl" \
                                        " SYSLOG_IDENTIFIER=spice-vdagent" \
                                        " SYSLOG_IDENTIFIER=spice-vdagentd"
        else:
            spice_vdagent_loginfo_cmd = "tail -n 10 " + spicevdagent_logfile

        cmd = ("echo \"SPICE_VDAGENTD_EXTRA_ARGS=-dd\">"
               "/etc/sysconfig/spice-vdagentd")
        guest_root_session.cmd(cmd)

        logging.info("Running the logging test for spice-vdagent daemon")
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)

        # Testing the log after stopping spice-vdagentd
        utils_spice.stop_vdagent(guest_root_session, test_timeout=15)
        cmd = spice_vdagent_loginfo_cmd + " | tail -n 3 | grep \"vdagentd quitting\""
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Testing the log after starting spice-vdagentd
        utils_spice.start_vdagent(guest_root_session, test_timeout=15)
        cmd = spice_vdagent_loginfo_cmd + "| tail -n 7 | grep \"opening vdagent virtio channel\""
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Testing the log after restart spice-vdagentd
        utils_spice.restart_vdagent(guest_root_session, test_timeout=10)
        cmd = spice_vdagent_loginfo_cmd + "| tail -n 7 | grep 'opening vdagent virtio channel'"
        output = guest_root_session.cmd(cmd)
        logging.debug(output)

        # Finally test copying text within the guest
        cmd = "%s %s %s %s" % (interpreter, script_call, script_params,
                               testing_text)
        logging.info("This command here: %s", cmd)

        try:
            logging.debug("------------ Script output ------------")
            output = guest_session.cmd(cmd)

            if "The text has been placed into the clipboard." in output:
                logging.info("Copying of text was successful")
            else:
                test.fail("Copying to the clipboard failed. %s" % output)
        except:
            test.fail("Copying to the clipboard failed try block failed")

        logging.debug("------------ End of script output of the Copying"
                      " Session ------------")

        output = guest_root_session.cmd(spice_vdagent_loginfo_cmd +
                                        "| tail -n 2" +
                                        " | grep 'clipboard grab'")

    else:
        # Couldn't find the right test to run
        guest_session.close()
        guest_root_session.close()
        test.fail("Couldn't find the right test to run, check cfg files.")
    guest_session.close()