示例#1
0
def group_test(test, params, env, vm, session):
    """
    :param test:
    :param params:
    :param env:
    :param vm:
    :param session:
    :return:
    """
    logging.info(test, params, env, vm, session)
    tgm = ThrottleGroupManager(vm)
    tgm.get_throttle_group_props("group2")
    logging.info(vm.devices.str_bus_short())
    images = ["stg2", "stg4"]
    tester1 = ThrottleTester(test, params, vm, session, "group2", images)
    tester1.build_default_option()
    images_info = tester1.build_images_fio_option()
    print(images_info)

    fio = generate_instance(params, vm, 'fio')
    tester1.set_fio(fio)
    # tester1.start()

    groups_tester = ThrottleGroupsTester([tester1])
    groups_tester.start()
 def fio_on_vm(vm_t, session_t):
     error_context.context("Deploy fio", logging.info)
     fio = generate_instance(params, vm_t, 'fio')
     logging.info("fio: %s", fio)
     tgm = ThrottleGroupManager(vm_t)
     logging.info("tgm: %s", tgm)
     groups = params["throttle_groups"].split()
     testers = []
     for group in groups:
         tgm.get_throttle_group_props(group)
         images = params["throttle_group_member_%s" % group].split()
         tester = ThrottleTester(test, params, vm_t, session_t, group,
                                 images)
         error_context.context(
             "Build test stuff for %s:%s" % (group, images), logging.info)
         tester.build_default_option()
         tester.build_images_fio_option()
         tester.set_fio(fio)
         testers.append(tester)
     error_context.context("Start groups testing:%s" % groups, logging.info)
     groups_tester = ThrottleGroupsTester(testers)
     groups_tester.start()
def run(test, params, env):
    """
        Test throttle relevant properties feature.

        1) Boot up guest with throttle groups.
        There are two throttle groups and each have two disk
        2) Build fio operation options and expected result
         according to throttle properties.
        3) Execute one disk or all disks testing on groups parallel.
    """

    error_context.context("Get the main VM", test.log.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    session = vm.wait_for_login(timeout=360)

    error_context.context("Deploy fio", test.log.info)
    fio = generate_instance(params, vm, 'fio')

    tgm = ThrottleGroupManager(vm)
    groups = params["throttle_groups"].split()
    testers = []
    for group in groups:
        tgm.get_throttle_group_props(group)
        images = params["throttle_group_member_%s" % group].split()
        tester = ThrottleTester(test, params, vm, session, group, images)
        error_context.context("Build test stuff for %s:%s" % (group, images),
                              test.log.info)
        tester.build_default_option()
        tester.build_images_fio_option()
        tester.set_fio(fio)
        testers.append(tester)

    error_context.context("Start groups testing:%s" % groups, test.log.info)
    groups_tester = ThrottleGroupsTester(testers)

    groups_tester.start()
示例#4
0
def utils_test(test, params, env, vm, session):
    """
    :param test:
    :param params:
    :param env:
    :param vm:
    :param session:
    :return:
    """
    logging.info(test, params, env, vm, session)
    tgm = ThrottleGroupManager(vm)

    logging.info("query_throttle_group group1")
    tgm.get_throttle_group_props("group1")

    logging.info("query_throttle_group group4")
    tgm.get_throttle_group_props("group4")
    # stg2 nonexist
    tgm.get_throttle_group_props("stg2")
    # group5 nonexist
    logging.info("delete_throttle_group group5")
    tgm.delete_throttle_group("group5")

    logging.info("query_throttle_group group3")
    tgm.get_throttle_group_props("group3")

    # add group3 failed
    logging.info("add_throttle_group group3")
    try:
        tgm.add_throttle_group("group3", {"iopsx-total": 50})
    except Exception as err:
        logging.error(err)

    # add group3 succeed
    tgm.add_throttle_group("group3", {"iops-total": 50})
    out = tgm.get_throttle_group_props("group3")
    logging.info(out)

    logging.info("get_throttle_group group3")
    dev = tgm.get_throttle_group("group3")

    plug = BlockDevicesPlug(vm)

    # hotplug stg7
    logging.info("stg7 hot-plug")
    plug.hotplug_devs_serial("stg7")
    logging.info(vm.devices.str_bus_short())

    # hotplug stg6
    logging.info("stg6 hot-plug")
    plug.hotplug_devs_serial("stg6")
    logging.info(vm.devices.str_bus_short())

    logging.info("change stg6 from group3 to group1")
    tgm.change_throttle_group("stg6", "group1")
    logging.info("change stg3 from group1 to group2")
    tgm.change_throttle_group("stg3", "group2")
    logging.info(vm.devices.str_bus_short())
    logging.info("change stg3 from group2 to group1")
    tgm.change_throttle_group("stg3", "group1")
    logging.info(vm.devices.str_bus_short())
    vm.monitor.info("block")

    logging.info("stg6 hot-unplug")
    plug.unplug_devs_serial("stg6")
    logging.info(vm.devices.str_bus_short())

    logging.info("update throttle group")
    tgm.update_throttle_group("group3", {"bps-total": 150})
    out = tgm.get_throttle_group_props("group3")
    logging.info(out)
    logging.info(dev.raw_limits)

    logging.info("throttle group hot-unplug")
    tgm.delete_throttle_group("group3")
    logging.info(vm.devices.str_bus_short())
    tgm.get_throttle_group("group3")
    logging.info("==================")

    # image hotplug-unplug
    logging.info("unplug stg1 ")
    plug.unplug_devs_serial("stg1")
    logging.info(vm.devices.str_bus_short())

    logging.info("plug stg1")
    plug.hotplug_devs_serial("stg1")
    logging.info(vm.devices.str_bus_short())

    logging.info("unplug stg1")
    plug.unplug_devs_serial("stg1")
    logging.info(vm.devices.str_bus_short())

    logging.info("==================")
    logging.info("plug stg5 belong to no group")
    plug.hotplug_devs_serial("stg5")
    logging.info(vm.devices.str_bus_short())

    logging.info("unplug stg5")
    plug.unplug_devs_serial("stg5")
    logging.info(vm.devices.str_bus_short())
    logging.info("sleep 3...")
    time.sleep(3)

    logging.info("test simple_hotplug ...")
    image_name = "stg1"
    image_params = params.object_params(image_name)
    # include blockdevs and devices
    stg_a_devs = vm.devices.images_define_by_params(image_name, image_params,
                                                    'disk')
    for dev in stg_a_devs:
        vm.devices.simple_hotplug(dev, vm.monitor)

    image_name = "stg5"
    image_params = params.object_params(image_name)
    stg_b_devs = vm.devices.images_define_by_params(image_name, image_params,
                                                    'disk')
    for dev in stg_b_devs:
        vm.devices.simple_hotplug(dev, vm.monitor)
    logging.info(vm.devices.str_bus_short())
    time.sleep(3)

    logging.info("test simple_unplug ...")
    vm.devices.simple_unplug(stg_a_devs[-1], vm.monitor)
    vm.devices.simple_unplug(stg_b_devs[-1], vm.monitor)
    logging.info(vm.devices.str_bus_short())
    time.sleep(3)
def run(test, params, env):
    """
        Test throttle relevant properties feature.

        1) Boot up guest with throttle groups.
        There are two throttle groups. One have two disks,other is empty.
        2) Build fio operation options and expected result
         according to throttle properties.
        3) Execute single disk throttle testing on  first group.
        4) Execute group relevant testing for example:
        Change throttle group attribute or move disk to other group
        5) Or Execute other operation testing for example:
        Reboot guest or stop-resume guest
        6) Execute throttle testing on all groups.
    """
    def negative_test():
        """negative test for the group option"""
        all_groups = params.get("groups", "group2")
        for name in all_groups.split():
            props = json.loads(params.get(name, "{}"))
            err_msg = params.object_params(name)["err_msg"]
            try:
                tgm.update_throttle_group("group1", props)
            except QMPCmdError as err:
                qmp_desc = err.data["desc"]
                if qmp_desc.find(err_msg) >= 0:
                    logging.info("Find expected result for %s", name)
                    continue
                logging.error(
                    "Cannot got expected wrong result on %s: %s in %s", name,
                    err_msg, qmp_desc)
                raise err
            else:
                test.fail("Can not got expected wrong result")

    def group_change():
        """change group attributes testing"""
        props = json.loads(params["throttle_group_parameters_group2"])

        tgm.update_throttle_group("group1", props)

    def group_move():
        """Move disk to other group"""
        tgm.change_throttle_group("stg2", "group2")

    def operation_reboot():
        """Guest reboot test"""
        vm.reboot(session)

    def operation_stop_resume():
        """Guest stop resume test"""
        vm.pause()
        vm.resume()

    def operation_hotplug():
        """
        relevant operation:
        unplug throttle group
        plug throttle group
        add disk into exist throttle group
        add disk into plugged throttle group
        """
        opts = json.loads(params.get("throttle_group_parameters_group2", "{}"))
        tgm.delete_throttle_group("group2")
        tgm.add_throttle_group("group2", opts)
        plug = BlockDevicesPlug(vm)
        plug.hotplug_devs_serial("stg3")
        plug.hotplug_devs_serial("stg4")

    error_context.context("Get the main VM", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()

    session = vm.wait_for_login(timeout=360)

    error_context.context("Deploy fio", logging.info)
    fio = generate_instance(params, vm, 'fio')

    tgm = ThrottleGroupManager(vm)
    groups = params["throttle_groups"].split()
    operation = params["operation"]

    # simple test on group1
    error_context.context("Execute simple test on group1", logging.info)
    tester = ThrottleTester(test, params, vm, session, "group1", ["stg1"])
    tester.build_default_option()
    tester.build_images_fio_option()
    tester.set_fio(fio)
    tester.start()

    # execute relevant operation
    error_context.context("Execute operation %s" % operation, logging.info)
    locals_var = locals()
    locals_var[operation]()
    # test after operation
    testers = []
    tgm = ThrottleGroupManager(vm)
    session = vm.wait_for_login(timeout=360)
    for group in groups:
        tgm.get_throttle_group_props(group)
        images = params.get("throttle_group_member_%s" % group, "").split()
        if len(images) == 0:
            logging.warning("No images in group %s", group)
            continue
        tester = ThrottleTester(test, params, vm, session, group, images)
        error_context.context("Build test stuff for %s:%s" % (group, images),
                              logging.info)
        tester.build_default_option()
        tester.build_images_fio_option()
        tester.set_fio(fio)
        testers.append(tester)

    error_context.context("Start groups testing:%s" % groups, logging.info)
    groups_tester = ThrottleGroupsTester(testers)

    groups_tester.start()