Ejemplo n.º 1
0
def run(test, params, env):
    """
    Balloon service should be in running status after sc interrogate it.
    1) boot a guest with balloon device.
    2) check balloon driver installation status.
    3) enable and check driver verifier in guest.
    4) install and start balloon service in guest.
    5) send INTERROGATE signal to balloon service.
    6) check balloon service status again.
    """
    def interrogate_balloon_service(session):
        """
        Sending INTERROGATE to balloon service.
        :param session: VM session.
        """
        logging.info("Send INTERROGATE to balloon service")
        sc_interrogate_cmd = params["sc_interrogate_cmd"]
        status, output = session.cmd_status_output(sc_interrogate_cmd)
        if status:
            test.error(output)

    error_context.context("Boot guest with balloon device", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session = vm.wait_for_login()
    driver_name = params.get("driver_name", "balloon")

    session = utils_test.qemu.windrv_check_running_verifier(
        session, vm, test, driver_name)
    balloon_test = BallooningTestWin(test, params, env)
    err = None
    try:
        # Install and start balloon service in guest
        balloon_test.configure_balloon_service(session)

        # Send INTERROGATE signal to balloon service
        interrogate_balloon_service(session)

        # Check ballloon serivce status again
        output = balloon_test.operate_balloon_service(session, "status")
        if not re.search("running", output.lower(), re.M):
            test.fail("Balloon service is not running after sc interrogate!"
                      "Output is: \n %s" % output)
    except Exception as err:
        pass

    finally:
        try:
            error_context.context("Clear balloon service in guest",
                                  logging.info)
            balloon_test.operate_balloon_service(session, "uninstall")
        except Exception as uninst_err:
            if not err:
                err = uninst_err
            else:
                logging.error(uninst_err)
        session.close()
        if err:
            raise err  # pylint: disable=E0702
Ejemplo n.º 2
0
def run(test, params, env):
    """
    Balloon service should be in running status after sc interrogate it.
    1) boot a guest with balloon device.
    2) check balloon driver installation status.
    3) enable and check driver verifier in guest.
    4) install and start balloon service in guest.
    5) send INTERROGATE signal to balloon service.
    6) check balloon service status again.
    """

    def interrogate_balloon_service(session):
        """
        Sending INTERROGATE to balloon service.
        :param session: VM session.
        """
        logging.info("Send INTERROGATE to balloon service")
        sc_interrogate_cmd = params["sc_interrogate_cmd"]
        status, output = session.cmd_status_output(sc_interrogate_cmd)
        if status:
            test.error(output)

    error_context.context("Boot guest with balloon device", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    session = vm.wait_for_login()
    driver_name = params.get("driver_name", "balloon")

    session = utils_test.qemu.windrv_check_running_verifier(session, vm,
                                                            test, driver_name)
    balloon_test = BallooningTestWin(test, params, env)
    err = None
    try:
        # Install and start balloon service in guest
        balloon_test.configure_balloon_service(session)

        # Send INTERROGATE signal to balloon service
        interrogate_balloon_service(session)

        # Check ballloon serivce status again
        output = balloon_test.operate_balloon_service(session, "status")
        if not re.search("running", output.lower(), re.M):
            test.fail("Balloon service is not running after sc interrogate!"
                      "Output is: \n %s" % output)
    except Exception as err:
        pass

    finally:
        try:
            error_context.context("Clear balloon service in guest", logging.info)
            balloon_test.operate_balloon_service(session, "uninstall")
        except Exception as uninst_err:
            if not err:
                err = uninst_err
            else:
                logging.error(uninst_err)
        session.close()
        if err:
            raise err   # pylint: disable=E0702
Ejemplo n.º 3
0
    def enable_balloon_service():
        """
        Install balloon service and check its status in windows guests
        """
        if params['os_type'] != 'windows':
            return
        error_context.context("Install and check balloon service in windows "
                              "guest", logging.info)
        session = vm.wait_for_login()
        driver_name = params.get("driver_name", "balloon")
        session = utils_test.qemu.windrv_check_running_verifier(session,
                                                                vm, test,
                                                                driver_name)
        balloon_test = BallooningTestWin(test, params, env)
        balloon_test.configure_balloon_service(session)

        output = balloon_test.operate_balloon_service(session, "status")
        if not re.search(r"running", output.lower(), re.M):
            test.error("Ballooon service status is not running")
        session.close()
Ejemplo n.º 4
0
def run(test, params, env):
    """
    Balloon service test, i.e. guest-stats-polling-interval test.
    1) boot a guest with balloon device.
    2) enable and check driver verifier in guest(only for windows guest).
    3) install balloon service in guest(only for windows guest).
    4) evict / enlarge balloon.
    5) get polling value in qmp, then do memory check if necessary.
    6) uninstall or stop balloon service(optional)
    7) check memory status(optional)
    8) install or run balloon service(optional)
    9) check memory status(optional)
    10) uninstall balloon service and clear driver verifier(only for
       windows guest).
    """
    def balloon_memory(vm, mem_check, min_sz, max_sz):
        """
        Doing memory balloon in a loop and check memory statistics during balloon.

        :param vm: VM object.
        :param mem_check: need to do memory check if param mem_check is 'yes'
        :param min_sz: guest minimal memory size
        :param max_sz: guest maximal memory size
        """
        repeat_times = int(params.get("repeat_times", 5))
        logging.info("repeat times: %d", repeat_times)

        while repeat_times:
            for tag in params.objects('test_tags'):
                error_context.context("Running %s test" % tag, logging.info)
                params_tag = params.object_params(tag)
                balloon_type = params_tag['balloon_type']
                if balloon_type == 'evict':
                    expect_mem = int(
                        random.uniform(min_sz,
                                       balloon_test.get_ballooned_memory()))
                else:
                    expect_mem = int(
                        random.uniform(balloon_test.get_ballooned_memory(),
                                       max_sz))

                quit_after_test = balloon_test.run_ballooning_test(
                    expect_mem, tag)
                time.sleep(20)
                if mem_check == "yes":
                    check_list = params["mem_stat_check_list"].split()
                    for mem_check_name in check_list:
                        balloon_test.memory_stats_check(
                            mem_check_name, mem_stat_working)
                if quit_after_test:
                    return

            repeat_times -= 1

    mem_check = params.get("mem_check", "yes")
    mem_stat_working = True

    error_context.context("Boot guest with balloon device", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    session = vm.wait_for_login()
    if params['os_type'] == 'windows':
        driver_name = params.get("driver_name", "balloon")
        session = utils_test.qemu.windrv_check_running_verifier(
            session, vm, test, driver_name)
        balloon_test = BallooningTestWin(test, params, env)
        error_context.context("Config balloon service in guest", logging.info)
        balloon_test.configure_balloon_service(session)
    else:
        balloon_test = BallooningTestLinux(test, params, env)

    try:
        min_sz, max_sz = balloon_test.get_memory_boundary()
        balloon_memory(vm, mem_check, min_sz, max_sz)
        blnsrv_operation = params.objects("blnsrv_operation")
        mem_stat_working = False
        for bln_oper in blnsrv_operation:
            error_context.context("%s balloon service" % bln_oper,
                                  logging.info)
            balloon_test.operate_balloon_service(session, bln_oper)

            error_context.context(
                "Balloon vm memory after %s balloon service" % bln_oper,
                logging.info)
            balloon_memory(vm, mem_check, min_sz, max_sz)
            mem_stat_working = True

    finally:
        if params['os_type'] == 'windows':
            error_context.context("Clear balloon service in guest",
                                  logging.info)
            balloon_test.operate_balloon_service(session, "uninstall")
        session.close()
Ejemplo n.º 5
0
def run(test, params, env):
    """
    Balloon service test, i.e. guest-stats-polling-interval test.
    1) boot a guest with balloon device.
    2) enable and check driver verifier in guest(only for windows guest).
    3) install balloon service in guest(only for windows guest).
    4) evict / enlarge balloon.
    5) get polling value in qmp, then do memory check if necessary.
    6) uninstall or stop balloon service(optional)
    7) check memory status(optional)
    8) install or run balloon service(optional)
    9) check memory status(optional)
    10) uninstall balloon service and clear driver verifier(only for
       windows guest).
    """

    def balloon_memory(vm, mem_check, min_sz, max_sz):
        """
        Doing memory balloon in a loop and check memory statistics during balloon.

        :param vm: VM object.
        :param mem_check: need to do memory check if param mem_check is 'yes'
        :param min_sz: guest minimal memory size
        :param max_sz: guest maximal memory size
        """
        repeat_times = int(params.get("repeat_times", 5))
        logging.info("repeat times: %d" % repeat_times)

        while repeat_times:
            for tag in params.objects('test_tags'):
                error_context.context("Running %s test" % tag, logging.info)
                params_tag = params.object_params(tag)
                balloon_type = params_tag['balloon_type']
                if balloon_type == 'evict':
                    expect_mem = int(random.uniform(
                        min_sz, balloon_test.get_ballooned_memory()))
                else:
                    expect_mem = int(random.uniform(
                        balloon_test.get_ballooned_memory(), max_sz))

                quit_after_test = balloon_test.run_ballooning_test(expect_mem,
                                                                   tag)
                time.sleep(20)
                if mem_check == "yes":
                    balloon_test.memory_stats_check('stat-free-memory', mem_stat_working)
                if quit_after_test:
                    return

            repeat_times -= 1

    mem_check = params.get("mem_check", "yes")
    mem_stat_working = True

    error_context.context("Boot guest with balloon device", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    session = vm.wait_for_login()
    if params['os_type'] == 'windows':
        driver_name = params.get("driver_name", "balloon")
        session = utils_test.qemu.windrv_check_running_verifier(session, vm,
                                                                test, driver_name)
        balloon_test = BallooningTestWin(test, params, env)
        error_context.context("Config balloon service in guest",
                              logging.info)
        balloon_test.configure_balloon_service(session)
    else:
        balloon_test = BallooningTestLinux(test, params, env)

    try:
        min_sz, max_sz = balloon_test.get_memory_boundary()
        balloon_memory(vm, mem_check, min_sz, max_sz)
        blnsrv_operation = params.objects("blnsrv_operation")
        mem_stat_working = False
        for bln_oper in blnsrv_operation:
            error_context.context("%s balloon service" % bln_oper, logging.info)
            balloon_test.operate_balloon_service(session, bln_oper)

            error_context.context("Balloon vm memory after %s balloon service"
                                  % bln_oper, logging.info)
            balloon_memory(vm, mem_check, min_sz, max_sz)
            mem_stat_working = True

    finally:
        if params['os_type'] == 'windows':
            error_context.context("Clear balloon service in guest",
                                  logging.info)
            balloon_test.operate_balloon_service(session, "uninstall")
        session.close()