Beispiel #1
0
def run_boot(test, params, env):
    """
    Qemu reboot test:
    1) Log into a guest
    3) Send a reboot command or a system_reset monitor command (optional)
    4) Wait until the guest is up again
    5) Log into the guest to verify it's up again

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

    error.context("Try to log into guest.", logging.info)
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = float(params.get("login_timeout", 240))
    session = vm.wait_for_login(timeout=timeout)

    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)

    if params.get("reboot_method"):
        error.context("Reboot guest.", logging.info)
        if params["reboot_method"] == "system_reset":
            time.sleep(int(params.get("sleep_before_reset", 10)))
            # Reboot the VM
        for i in range(int(params.get("reboot_count", 1))):
            session = vm.reboot(session, params["reboot_method"], 0, timeout)

    session.close()
Beispiel #2
0
def run_boot(test, params, env):
    """
    Qemu reboot test:
    1) Log into a guest
    3) Send a reboot command or a system_reset monitor command (optional)
    4) Wait until the guest is up again
    5) Log into the guest to verify it's up again

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

    timeout = float(params.get("login_timeout", 240))
    #ting test
    #sys.stdout.restore()
    #print "\n\nparams :    ",params,"\n\n\n"
    #end test

    vms = env.get_all_vms()
    #ting test
    sys.stdout.restore()
    print "vms : ", vms, "\n\n\n"
    #end test
    for vm in vms:
        #ting test
        sys.stdout.restore()
        print "vm : ", vm, "\n"
        #end test
        error.context("Try to log into guest '%s'." % vm.name, logging.info)
        session = vm.wait_for_login(timeout=timeout)
        print "after wait\n\n"
        session.close()

    #ting test
    sys.stdout.restore()
    print "after for\n\n\n"
    #end test

    if params.get("rh_perf_envsetup_script"):
        for vm in vms:
            session = vm.wait_for_login(timeout=timeout)
            utils_test.service_setup(vm, session, test.virtdir)
            session.close()
    #ting test
    sys.stdout.restore()
    print "params.get reboot_method:  ", params.get("reboot_method"), "\n\n\n"
    #end test
    if params.get("reboot_method"):
        for vm in vms:
            error.context("Reboot guest '%s'." % vm.name, logging.info)
            if params["reboot_method"] == "system_reset":
                time.sleep(int(params.get("sleep_before_reset", 10)))
            # Reboot the VM
            session = vm.wait_for_login(timeout=timeout)
            for i in range(int(params.get("reboot_count", 1))):
                session = vm.reboot(session, params["reboot_method"], 0,
                                    timeout)
            session.close()
Beispiel #3
0
def run(test, params, env):
    """
    Qemu reboot test:
    1) Log into a guest
    3) Send a reboot command or a system_reset monitor command (optional)
    4) Wait until the guest is up again
    5) Log into the guest to verify it's up again

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

    timeout = float(params.get("login_timeout", 240))
    serial_login = params.get("serial_login", "no") == "yes"
    vms = env.get_all_vms()
    for vm in vms:
        error_context.context("Try to log into guest '%s'." % vm.name, logging.info)
        if serial_login:
            session = vm.wait_for_serial_login(timeout=timeout)
        else:
            session = vm.wait_for_login(timeout=timeout)
        session.close()

    if params.get("rh_perf_envsetup_script"):
        for vm in vms:
            if serial_login:
                session = vm.wait_for_serial_login(timeout=timeout)
            else:
                session = vm.wait_for_login(timeout=timeout)
            utils_test.service_setup(vm, session, test.virtdir)
            session.close()
    if params.get("reboot_method"):
        for vm in vms:
            error_context.context("Reboot guest '%s'." % vm.name, logging.info)
            if params["reboot_method"] == "system_reset":
                time.sleep(int(params.get("sleep_before_reset", 10)))
            # Reboot the VM
            if serial_login:
                session = vm.wait_for_serial_login(timeout=timeout)
            else:
                session = vm.wait_for_login(timeout=timeout)
            for i in range(int(params.get("reboot_count", 1))):
                session = vm.reboot(session,
                                    params["reboot_method"],
                                    0,
                                    timeout,
                                    serial_login)
            session.close()
Beispiel #4
0
def run(test, params, env):
    """
    Qemu reboot test:
    1) Log into a guest
    3) Send a reboot command or a system_reset monitor command (optional)
    4) Wait until the guest is up again
    5) Log into the guest to verify it's up again

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

    timeout = float(params.get("login_timeout", 240))
    serial_login = params.get("serial_login", "no") == "yes"
    vms = env.get_all_vms()
    for vm in vms:
        error_context.context("Try to log into guest '%s'." % vm.name,
                              test.log.info)
        if serial_login:
            session = vm.wait_for_serial_login(timeout=timeout)
        else:
            session = vm.wait_for_login(timeout=timeout)
        session.close()

    if params.get("rh_perf_envsetup_script"):
        for vm in vms:
            if serial_login:
                session = vm.wait_for_serial_login(timeout=timeout)
            else:
                session = vm.wait_for_login(timeout=timeout)
            utils_test.service_setup(vm, session, test.virtdir)
            session.close()
    if params.get("reboot_method"):
        for vm in vms:
            error_context.context("Reboot guest '%s'." % vm.name,
                                  test.log.info)
            if params["reboot_method"] == "system_reset":
                time.sleep(int(params.get("sleep_before_reset", 10)))
            # Reboot the VM
            if serial_login:
                session = vm.wait_for_serial_login(timeout=timeout)
            else:
                session = vm.wait_for_login(timeout=timeout)
            for i in range(int(params.get("reboot_count", 1))):
                session = vm.reboot(session, params["reboot_method"], 0,
                                    timeout, serial_login)
            session.close()
Beispiel #5
0
def run_boot(test, params, env):
    """
    KVM reboot test:
    1) Log into a guest
    2) Verify device(s) work well in guest (optional)
    3) Send a reboot command or a system_reset monitor command (optional)
    4) Wait until the guest is up again
    5) Log into the guest to verify it's up again
    6) Verify device(s) again after guest reboot (optional)

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

    def _check_device(check_func):
        func = _get_function(check_func)
        if not func:
            raise error.TestError("Could not find function %s" % check_func)
        func(test, params, env)


    error.context("Try to log into guest.")
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = float(params.get("login_timeout", 240))
    session = vm.wait_for_login(timeout=timeout)

    check_func = params.get("check_func")
    if check_func:
        error.context("Verify device(s) before rebooting.")
        _check_device(check_func)

    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)

    if params.get("reboot_method"):
        error.context("Reboot guest.")
        if params["reboot_method"] == "system_reset":
            time.sleep(int(params.get("sleep_before_reset", 10)))
        session = vm.reboot(session, params["reboot_method"], 0, timeout)

        if check_func:
            error.context("Verify device(s) after rebooting.")
            _check_device(check_func)

    session.close()
Beispiel #6
0
def run_netperf(test, params, env):
    """
    Network stress test with netperf.

    1) Boot up VM(s), setup SSH authorization between host
       and guest(s)/external host
    2) Prepare the test environment in server/client/host
    3) Execute netperf tests, collect and analyze the results

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    def env_setup(session, ip, user, port, password):
        error.context("Setup env for %s" % ip)
        ssh_cmd(session, "iptables -F; true")
        ssh_cmd(session, "service iptables stop; true")
        ssh_cmd(session, "echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore")

        download_link = params.get("netperf_download_link")
        download_dir = data_dir.get_download_dir()
        md5sum = params.get("pkg_md5sum")
        pkg = utils.unmap_url_cache(download_dir, download_link, md5sum)
        remote.scp_to_remote(ip, shell_port, username, password, pkg, "/tmp")
        ssh_cmd(session, params.get("setup_cmd"))

        agent_path = os.path.join(test.virtdir, "scripts/netperf_agent.py")
        remote.scp_to_remote(ip, shell_port, username, password,
                             agent_path, "/tmp")

    def _pin_vm_threads(vm, node):
        if node:
            if not isinstance(node, utils_misc.NumaNode):
                node = utils_misc.NumaNode(int(node))
            utils_test.qemu.pin_vm_threads(vm, node)

        return node

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    login_timeout = int(params.get("login_timeout", 360))

    session = vm.wait_for_login(timeout=login_timeout)
    config_cmds = params.get("config_cmds")
    if config_cmds:
        for config_cmd in config_cmds.split(","):
            cmd = params.get(config_cmd.strip())
            if cmd:
                s, o = session.cmd_status_output(cmd)
                if s:
                    msg = "Config command %s failed. Output: %s" % (cmd, o)
                    raise error.TestError(msg)
        if params.get("reboot_after_config", "yes") == "yes":
            session = vm.reboot(session=session, timeout=login_timeout)

    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)
    session.close()

    server_ip = vm.get_address()
    server_ctl = vm.wait_for_login(timeout=login_timeout)
    server_ctl_ip = server_ip
    if (params.get("os_type") == "windows"
            and params.get("use_cygwin") == "yes"):
        cygwin_prompt = params.get("cygwin_prompt", r"\$\s+$")
        cygwin_start = params.get("cygwin_start")
        server_cyg = vm.wait_for_login(timeout=login_timeout)
        server_cyg.set_prompt(cygwin_prompt)
        server_cyg.cmd_output(cygwin_start)
    else:
        server_cyg = None

    if len(params.get("nics", "").split()) > 1:
        vm.wait_for_login(nic_index=1, timeout=login_timeout)
        server_ip = vm.get_address(1)

    logging.debug(commands.getoutput("numactl --hardware"))
    logging.debug(commands.getoutput("numactl --show"))
    # pin guest vcpus/memory/vhost threads to last numa node of host by default
    numa_node = _pin_vm_threads(vm, params.get("numa_node"))

    host = params.get("host", "localhost")
    host_ip = host
    if host != "localhost":
        params_host = params.object_params("host")
        host = remote.wait_for_login(params_host.get("shell_client"),
                                     host_ip,
                                     params_host.get("shell_port"),
                                     params_host.get("username"),
                                     params_host.get("password"),
                                     params_host.get("shell_prompt"))

    client = params.get("client", "localhost")
    client_ip = client
    clients = []
    # client session 1 for control, session 2 for data communication
    for i in range(2):
        if client in params.get("vms"):
            vm_client = env.get_vm(client)
            tmp = vm_client.wait_for_login(timeout=login_timeout)
            client_ip = vm_client.get_address()
        elif client != "localhost":
            tmp = remote.wait_for_login(params.get("shell_client_client"),
                                        client_ip,
                                        params.get("shell_port_client"),
                                        params.get("username_client"),
                                        params.get("password_client"),
                                        params.get("shell_prompt_client"))
        else:
            tmp = "localhost"
        clients.append(tmp)
    client = clients[0]

    vms_list = params["vms"].split()
    if len(vms_list) > 1:
        vm2 = env.get_vm(vms_list[-1])
        vm2.verify_alive()
        session2 = vm2.wait_for_login(timeout=login_timeout)
        if params.get("rh_perf_envsetup_script"):
            utils_test.service_setup(vm2, session2, test.virtdir)
        client = vm2.wait_for_login(timeout=login_timeout)
        client_ip = vm2.get_address()
        session2.close()
        _pin_vm_threads(vm2, numa_node)

    error.context("Prepare env of server/client/host", logging.info)
    prepare_list = set([server_ctl, client, host])
    tag_dict = {server_ctl: "server", client: "client", host: "host"}
    ip_dict = {server_ctl: server_ctl_ip, client: client_ip, host: host_ip}
    for i in prepare_list:
        params_tmp = params.object_params(tag_dict[i])
        if params_tmp.get("os_type") == "linux":
            shell_port = int(params_tmp["shell_port"])
            password = params_tmp["password"]
            username = params_tmp["username"]
            env_setup(i, ip_dict[i], username, shell_port, password)

    env.stop_tcpdump()

    error.context("Start netperf testing", logging.info)
    start_test(server_ip, server_ctl, host, clients, test.resultsdir,
               l=int(params.get('l')),
               sessions_rr=params.get('sessions_rr'),
               sessions=params.get('sessions'),
               sizes_rr=params.get('sizes_rr'),
               sizes=params.get('sizes'),
               protocols=params.get('protocols'),
               ver_cmd=params.get('ver_cmd', "rpm -q qemu-kvm"),
               netserver_port=params.get('netserver_port', "12865"),
               params=params, server_cyg=server_cyg, test=test)
Beispiel #7
0
def run(test, params, env):
    """
    Network stress test with netperf.

    1) Boot up VM(s), setup SSH authorization between host
       and guest(s)/external host
    2) Prepare the test environment in server/client/host
    3) Execute netperf tests, collect and analyze the results

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    def mtu_set(mtu):
        """
        Set server/client/host's mtu

        :param mtu: mtu value to be set
        """

        server_mtu_cmd = params.get("server_mtu_cmd")
        client_mtu_cmd = params.get("client_mtu_cmd")
        host_mtu_cmd = params.get("host_mtu_cmd")
        error_context.context("Changing the MTU of guest", logging.info)
        if params.get("os_type") == "linux":
            ethname = utils_net.get_linux_ifname(server_ctl, mac)
            netperf_base.ssh_cmd(server_ctl, server_mtu_cmd % (ethname, mtu))
        elif params.get("os_type") == "windows":
            connection_id = utils_net.get_windows_nic_attribute(
                server_ctl, "macaddress", mac, "netconnectionid")
            netperf_base.ssh_cmd(server_ctl,
                                 server_mtu_cmd % (connection_id, mtu))

        error_context.context("Changing the MTU of client", logging.info)
        netperf_base.ssh_cmd(
            client, client_mtu_cmd % (params.get("client_physical_nic"), mtu))

        netdst = params.get("netdst", "switch")
        host_bridges = utils_net.Bridge()
        br_in_use = host_bridges.list_br()
        if netdst in br_in_use:
            ifaces_in_use = host_bridges.list_iface()
            target_ifaces = list(ifaces_in_use + br_in_use)
        if params.get("netdst_nic1") in process.system_output(
                "ovs-vsctl list-br", ignore_status=True, shell=True).decode():
            ovs_list = "ovs-vsctl list-ports %s" % params["netdst_nic1"]
            ovs_port = process.system_output(ovs_list,
                                             shell=True).decode().splitlines()
            target_ifaces = target_ifaces + \
                params.objects("netdst_nic1") + ovs_port
        if vm.virtnet[0].nettype == "macvtap":
            target_ifaces.extend([vm.virtnet[0].netdst, vm.get_ifname(0)])
        error_context.context("Change all Bridge NICs MTU to %s" % mtu,
                              logging.info)
        for iface in target_ifaces:
            try:
                process.run(host_mtu_cmd % (iface, mtu),
                            ignore_status=False,
                            shell=True)
            except process.CmdError as err:
                if "SIOCSIFMTU" in err.result.stderr.decode():
                    test.cancel("The ethenet device does not support jumbo,"
                                "cancel test")

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    login_timeout = int(params.get("login_timeout", 360))

    try:
        vm.wait_for_serial_login(timeout=login_timeout,
                                 restart_network=True).close()
    except virt_vm.VMIPAddressMissingError:
        pass

    if len(params.get("nics", "").split()) > 1:
        session = vm.wait_for_login(nic_index=1, timeout=login_timeout)
    else:
        session = vm.wait_for_login(timeout=login_timeout)

    config_cmds = params.get("config_cmds")
    if config_cmds:
        for config_cmd in config_cmds.split(","):
            cmd = params.get(config_cmd.strip())
            if cmd:
                s, o = session.cmd_status_output(cmd)
                if s:
                    msg = "Config command %s failed. Output: %s" % (cmd, o)
                    test.error(msg)
        if params.get("reboot_after_config", "yes") == "yes":
            session = vm.reboot(session=session, timeout=login_timeout)
            vm.wait_for_serial_login(timeout=login_timeout,
                                     restart_network=True).close()

    mac = vm.get_mac_address(0)
    if params.get("os_type") == "linux":
        ethname = utils_net.get_linux_ifname(session, mac)
    queues = int(params.get("queues", 1))
    if queues > 1:
        if params.get("os_type") == "linux":
            session.cmd_status_output("ethtool -L %s combined %s" %
                                      (ethname, queues))
        else:
            logging.info("FIXME: support to enable MQ for Windows guest!")

    if params.get("server_private_ip") and params.get("os_type") == "linux":
        server_ip = params.get("server_private_ip")
        cmd = "systemctl stop NetworkManager.service"
        cmd += " && ifconfig %s %s up" % (ethname, server_ip)
        session.cmd_output(cmd)
    else:
        server_ip = vm.wait_for_get_address(0, timeout=90)

    if len(params.get("nics", "").split()) > 1:
        server_ctl = vm.wait_for_login(nic_index=1, timeout=login_timeout)
        server_ctl_ip = vm.wait_for_get_address(1, timeout=90)
    else:
        server_ctl = vm.wait_for_login(timeout=login_timeout)
        server_ctl_ip = server_ip

    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)
    session.close()

    if (params.get("os_type") == "windows"
            and params.get("use_cygwin") == "yes"):
        cygwin_prompt = params.get("cygwin_prompt", r"\$\s+$")
        cygwin_start = params.get("cygwin_start")
        server_cyg = vm.wait_for_login(timeout=login_timeout)
        server_cyg.set_prompt(cygwin_prompt)
        server_cyg.cmd_output(cygwin_start)
    else:
        server_cyg = None

    logging.debug(
        process.system_output("numactl --hardware",
                              verbose=False,
                              ignore_status=True,
                              shell=True).decode())
    logging.debug(
        process.system_output("numactl --show",
                              verbose=False,
                              ignore_status=True,
                              shell=True).decode())
    # pin guest vcpus/memory/vhost threads to last numa node of host by default
    numa_node = netperf_base.pin_vm_threads(vm, params.get("numa_node"))

    host = params.get("host", "localhost")
    host_ip = host
    if host != "localhost":
        params_host = params.object_params("host")
        host = remote.wait_for_login(params_host.get("shell_client"), host_ip,
                                     params_host.get("shell_port"),
                                     params_host.get("username"),
                                     params_host.get("password"),
                                     params_host.get("shell_prompt"))

    client = params.get("client", "localhost")
    client_ip = client
    clients = []
    # client session 1 for control, session 2 for data communication
    for i in range(2):
        if client in params.get("vms"):
            vm_client = env.get_vm(client)
            tmp = vm_client.wait_for_login(timeout=login_timeout)
            client_ip = vm_client.wait_for_get_address(0, timeout=5)
        elif client != "localhost" and params.get("os_type_client") == "linux":
            client_pub_ip = params.get("client_public_ip")
            tmp = remote.wait_for_login(params.get("shell_client_client"),
                                        client_pub_ip,
                                        params.get("shell_port_client"),
                                        params.get("username_client"),
                                        params.get("password_client"),
                                        params.get("shell_prompt_client"))
            cmd = "ifconfig %s %s up" % (params.get("client_physical_nic"),
                                         client_ip)
            netperf_base.ssh_cmd(tmp, cmd)
        else:
            tmp = "localhost"
        clients.append(tmp)
    client = clients[0]

    vms_list = params["vms"].split()
    if len(vms_list) > 1:
        vm2 = env.get_vm(vms_list[-1])
        vm2.verify_alive()
        session2 = vm2.wait_for_login(timeout=login_timeout)
        if params.get("rh_perf_envsetup_script"):
            utils_test.service_setup(vm2, session2, test.virtdir)
        client = vm2.wait_for_login(timeout=login_timeout)
        client_ip = vm2.get_address()
        session2.close()
        netperf_base.pin_vm_threads(vm2, numa_node)

    error_context.context("Prepare env of server/client/host", logging.info)
    prepare_list = set([server_ctl, client, host])
    tag_dict = {server_ctl: "server", client: "client", host: "host"}
    if client_pub_ip:
        ip_dict = {
            server_ctl: server_ctl_ip,
            client: client_pub_ip,
            host: host_ip
        }
    else:
        ip_dict = {server_ctl: server_ctl_ip, client: client_ip, host: host_ip}
    for i in prepare_list:
        params_tmp = params.object_params(tag_dict[i])
        if params_tmp.get("os_type") == "linux":
            shell_port = int(params_tmp["shell_port"])
            password = params_tmp["password"]
            username = params_tmp["username"]
            netperf_base.env_setup(test, params, i, ip_dict[i], username,
                                   shell_port, password)
        elif params_tmp.get("os_type") == "windows":
            windows_disable_firewall = params.get("windows_disable_firewall")
            netperf_base.ssh_cmd(i, windows_disable_firewall)
    netperf_base.tweak_tuned_profile(params, server_ctl, client, host)
    mtu = int(params.get("mtu", "1500"))
    mtu_set(mtu)

    env.stop_ip_sniffing()

    try:
        error_context.context("Start netperf testing", logging.info)
        start_test(server_ip,
                   server_ctl,
                   host,
                   clients,
                   test.resultsdir,
                   test_duration=int(params.get('l')),
                   sessions_rr=params.get('sessions_rr'),
                   sessions=params.get('sessions'),
                   sizes_rr=params.get('sizes_rr'),
                   sizes=params.get('sizes'),
                   protocols=params.get('protocols'),
                   netserver_port=params.get('netserver_port', "12865"),
                   params=params,
                   server_cyg=server_cyg,
                   test=test)

        if params.get("log_hostinfo_script"):
            src = os.path.join(test.virtdir, params.get("log_hostinfo_script"))
            path = os.path.join(test.resultsdir, "systeminfo")
            process.system_output("bash %s %s &> %s" %
                                  (src, test.resultsdir, path),
                                  shell=True)

        if params.get("log_guestinfo_script") and params.get(
                "log_guestinfo_exec"):
            src = os.path.join(test.virtdir,
                               params.get("log_guestinfo_script"))
            path = os.path.join(test.resultsdir, "systeminfo")
            destpath = params.get("log_guestinfo_path",
                                  "/tmp/log_guestinfo.sh")
            vm.copy_files_to(src, destpath, nic_index=1)
            logexec = params.get("log_guestinfo_exec", "bash")
            output = server_ctl.cmd_output("%s %s" % (logexec, destpath))
            logfile = open(path, "a+")
            logfile.write(output)
            logfile.close()
    finally:
        if mtu != 1500:
            mtu_default = 1500
            error_context.context(
                "Change back server, client and host's mtu to %s" %
                mtu_default)
            mtu_set(mtu_default)
        if params.get("client_physical_nic") and params.get(
                "os_type_client") == "linux":
            cmd = 'ifconfig %s 0.0.0.0 down' % params.get(
                "client_physical_nic")
            netperf_base.ssh_cmd(client, cmd)
Beispiel #8
0
def run_netperf(test, params, env):
    """
    Network stress test with netperf.

    1) Boot up VM(s), setup SSH authorization between host
       and guest(s)/external host
    2) Prepare the test environment in server/client/host
    3) Execute netperf tests, collect and analyze the results

    @param test: KVM test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    login_timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=login_timeout)
    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)
    server = vm.get_address()
    server_ctl = vm.get_address(1)
    session.close()

    logging.debug(commands.getoutput("numactl --hardware"))
    logging.debug(commands.getoutput("numactl --show"))
    # pin guest vcpus/memory/vhost threads to last numa node of host by default
    if params.get('numa_node'):
        numa_node = int(params.get('numa_node'))
        node = utils_misc.NumaNode(numa_node)
        utils_test.pin_vm_threads(vm, node)

    if "vm2" in params["vms"]:
        vm2 = env.get_vm("vm2")
        vm2.verify_alive()
        session2 = vm2.wait_for_login(timeout=login_timeout)
        if params.get("rh_perf_envsetup_script"):
            utils_test.service_setup(vm2, session2, test.virtdir)
        client = vm2.get_address()
        session2.close()
        if params.get('numa_node'):
            utils_test.pin_vm_threads(vm2, node)

    if params.get("client"):
        client = params["client"]
    if params.get("host"):
        host = params["host"]
    else:
        cmd = "ifconfig %s|awk 'NR==2 {print $2}'|awk -F: '{print $2}'"
        host = commands.getoutput(cmd % params["netdst"])

    shell_port = int(params["shell_port"])
    password = params["password"]
    username = params["username"]

    def env_setup(ip):
        logging.debug("Setup env for %s" % ip)
        ssh_key.setup_ssh_key(hostname=ip, user=username, port=shell_port,
                              password=password)
        ssh_cmd(ip, "service iptables stop")
        ssh_cmd(ip, "echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore")

        netperf_dir = os.path.join(os.environ['AUTODIR'], "tests/netperf2")
        for i in params.get("netperf_files").split():
            remote.scp_to_remote(ip, shell_port, username, password,
                                      "%s/%s" % (netperf_dir, i), "/tmp/")
        ssh_cmd(ip, params.get("setup_cmd"))

    logging.info("Prepare env of server/client/host")

    env_setup(server_ctl)
    env_setup(client)
    env_setup(host)
    logging.info("Start netperf testing ...")
    start_test(server, server_ctl, host, client, test.resultsdir,
               l=int(params.get('l')),
               sessions_rr=params.get('sessions_rr'),
               sessions=params.get('sessions'),
               sizes_rr=params.get('sizes_rr'),
               sizes=params.get('sizes'),
               protocols=params.get('protocols'),
               ver_cmd=params.get('ver_cmd', "rpm -q qemu-kvm"),
               netserver_port=params.get('netserver_port', "12865"), test=test)
Beispiel #9
0
def run(test, params, env):
    """
    Network stress test with netperf.

    1) Boot up VM(s), setup SSH authorization between host
       and guest(s)/external host
    2) Prepare the test environment in server/client/host
    3) Execute netperf tests, collect and analyze the results

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    def env_setup(session, ip, user, port, password):
        error_context.context("Setup env for %s" % ip)
        if params.get("env_setup_cmd"):
            ssh_cmd(session, params.get("env_setup_cmd"), ignore_status=True)

        pkg = params["netperf_pkg"]
        pkg = os.path.join(data_dir.get_deps_dir(), pkg)
        remote.scp_to_remote(ip, shell_port, username, password, pkg, "/tmp")
        ssh_cmd(session, params.get("setup_cmd"))

        agent_path = os.path.join(test.virtdir, "scripts/netperf_agent.py")
        remote.scp_to_remote(ip, shell_port, username, password,
                             agent_path, "/tmp")

    def mtu_set(mtu):
        """
        Set server/client/host's mtu

        :param mtu: mtu value to be set
        """

        server_mtu_cmd = params.get("server_mtu_cmd")
        client_mtu_cmd = params.get("client_mtu_cmd")
        host_mtu_cmd = params.get("host_mtu_cmd")
        error_context.context("Changing the MTU of guest", logging.info)
        if params.get("os_type") == "linux":
            ethname = utils_net.get_linux_ifname(server_ctl, mac)
            ssh_cmd(server_ctl, server_mtu_cmd % (ethname, mtu))
        elif params.get("os_type") == "windows":
            connection_id = utils_net.get_windows_nic_attribute(
                server_ctl, "macaddress", mac, "netconnectionid")
            ssh_cmd(server_ctl, server_mtu_cmd % (connection_id, mtu))

        error_context.context("Changing the MTU of client", logging.info)
        ssh_cmd(client, client_mtu_cmd
                % (params.get("client_physical_nic"), mtu))

        netdst = params.get("netdst", "switch")
        host_bridges = utils_net.Bridge()
        br_in_use = host_bridges.list_br()
        if netdst in br_in_use:
            ifaces_in_use = host_bridges.list_iface()
            target_ifaces = list(ifaces_in_use + br_in_use)
        if params.get("netdst_nic1") in process.system_output(
                "ovs-vsctl list-br", ignore_status=True, shell=True).decode():
            ovs_list = "ovs-vsctl list-ports %s" % params["netdst_nic1"]
            ovs_port = process.system_output(ovs_list,
                                             shell=True).decode().splitlines()
            target_ifaces = target_ifaces + \
                params.objects("netdst_nic1") + ovs_port
        if vm.virtnet[0].nettype == "macvtap":
            target_ifaces.extend([vm.virtnet[0].netdst, vm.get_ifname(0)])
        error_context.context("Change all Bridge NICs MTU to %s"
                              % mtu, logging.info)
        for iface in target_ifaces:
            try:
                process.run(host_mtu_cmd % (iface, mtu), ignore_status=False,
                            shell=True)
            except process.CmdError as err:
                if "SIOCSIFMTU" in err.result.stderr.decode():
                    test.cancel("The ethenet device does not support jumbo,"
                                "cancel test")

    def tweak_tuned_profile():
        """

        Tweak configuration with truned profile

        """

        client_tuned_profile = params.get("client_tuned_profile")
        server_tuned_profile = params.get("server_tuned_profile")
        host_tuned_profile = params.get("host_tuned_profile")
        error_context.context("Changing tune profile of guest", logging.info)
        if params.get("os_type") == "linux" and server_tuned_profile:
            ssh_cmd(server_ctl, server_tuned_profile)

        error_context.context("Changing tune profile of client/host",
                              logging.info)
        if client_tuned_profile:
            ssh_cmd(client, client_tuned_profile)
        if host_tuned_profile:
            ssh_cmd(host, host_tuned_profile)

    def _pin_vm_threads(vm, node):
        if node:
            if not isinstance(node, utils_misc.NumaNode):
                node = utils_misc.NumaNode(int(node))
            utils_test.qemu.pin_vm_threads(vm, node)

        return node

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    login_timeout = int(params.get("login_timeout", 360))

    vm.wait_for_serial_login(timeout=login_timeout, restart_network=True).close()
    if len(params.get("nics", "").split()) > 1:
        session = vm.wait_for_login(nic_index=1, timeout=login_timeout)
    else:
        session = vm.wait_for_login(timeout=login_timeout)

    config_cmds = params.get("config_cmds")
    if config_cmds:
        for config_cmd in config_cmds.split(","):
            cmd = params.get(config_cmd.strip())
            if cmd:
                s, o = session.cmd_status_output(cmd)
                if s:
                    msg = "Config command %s failed. Output: %s" % (cmd, o)
                    test.error(msg)
        if params.get("reboot_after_config", "yes") == "yes":
            session = vm.reboot(session=session, timeout=login_timeout)
            vm.wait_for_serial_login(timeout=login_timeout, restart_network=True).close()

    server_ip = vm.wait_for_get_address(0, timeout=90)
    if len(params.get("nics", "").split()) > 1:
        server_ctl = vm.wait_for_login(nic_index=1, timeout=login_timeout)
        server_ctl_ip = vm.wait_for_get_address(1, timeout=90)
    else:
        server_ctl = vm.wait_for_login(timeout=login_timeout)
        server_ctl_ip = server_ip

    mac = vm.get_mac_address(0)
    queues = int(params.get("queues", 1))
    if queues > 1:
        if params.get("os_type") == "linux":
            ethname = utils_net.get_linux_ifname(session, mac)
            session.cmd_status_output("ethtool -L %s combined %s" %
                                      (ethname, queues))
        else:
            logging.info("FIXME: support to enable MQ for Windows guest!")

    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)
    session.close()

    if (params.get("os_type") == "windows" and
            params.get("use_cygwin") == "yes"):
        cygwin_prompt = params.get("cygwin_prompt", r"\$\s+$")
        cygwin_start = params.get("cygwin_start")
        server_cyg = vm.wait_for_login(timeout=login_timeout)
        server_cyg.set_prompt(cygwin_prompt)
        server_cyg.cmd_output(cygwin_start)
    else:
        server_cyg = None

    logging.debug(process.system_output("numactl --hardware",
                                        verbose=False, ignore_status=True,
                                        shell=True).decode())
    logging.debug(process.system_output("numactl --show",
                                        verbose=False, ignore_status=True,
                                        shell=True).decode())
    # pin guest vcpus/memory/vhost threads to last numa node of host by default
    numa_node = _pin_vm_threads(vm, params.get("numa_node"))

    host = params.get("host", "localhost")
    host_ip = host
    if host != "localhost":
        params_host = params.object_params("host")
        host = remote.wait_for_login(params_host.get("shell_client"),
                                     host_ip,
                                     params_host.get("shell_port"),
                                     params_host.get("username"),
                                     params_host.get("password"),
                                     params_host.get("shell_prompt"))

    client = params.get("client", "localhost")
    client_ip = client
    clients = []
    # client session 1 for control, session 2 for data communication
    for i in range(2):
        if client in params.get("vms"):
            vm_client = env.get_vm(client)
            tmp = vm_client.wait_for_login(timeout=login_timeout)
            client_ip = vm_client.wait_for_get_address(0, timeout=5)
        elif client != "localhost":
            tmp = remote.wait_for_login(params.get("shell_client_client"),
                                        client_ip,
                                        params.get("shell_port_client"),
                                        params.get("username_client"),
                                        params.get("password_client"),
                                        params.get("shell_prompt_client"))
        else:
            tmp = "localhost"
        clients.append(tmp)
    client = clients[0]

    vms_list = params["vms"].split()
    if len(vms_list) > 1:
        vm2 = env.get_vm(vms_list[-1])
        vm2.verify_alive()
        session2 = vm2.wait_for_login(timeout=login_timeout)
        if params.get("rh_perf_envsetup_script"):
            utils_test.service_setup(vm2, session2, test.virtdir)
        client = vm2.wait_for_login(timeout=login_timeout)
        client_ip = vm2.get_address()
        session2.close()
        _pin_vm_threads(vm2, numa_node)

    error_context.context("Prepare env of server/client/host", logging.info)
    prepare_list = set([server_ctl, client, host])
    tag_dict = {server_ctl: "server", client: "client", host: "host"}
    ip_dict = {server_ctl: server_ctl_ip, client: client_ip, host: host_ip}
    for i in prepare_list:
        params_tmp = params.object_params(tag_dict[i])
        if params_tmp.get("os_type") == "linux":
            shell_port = int(params_tmp["shell_port"])
            password = params_tmp["password"]
            username = params_tmp["username"]
            env_setup(i, ip_dict[i], username, shell_port, password)
        elif params_tmp.get("os_type") == "windows":
            windows_disable_firewall = params.get("windows_disable_firewall")
            ssh_cmd(i, windows_disable_firewall)
    tweak_tuned_profile()
    mtu = int(params.get("mtu", "1500"))
    mtu_set(mtu)

    env.stop_ip_sniffing()

    try:
        error_context.context("Start netperf testing", logging.info)
        start_test(server_ip, server_ctl, host, clients, test.resultsdir,
                   test_duration=int(params.get('l')),
                   sessions_rr=params.get('sessions_rr'),
                   sessions=params.get('sessions'),
                   sizes_rr=params.get('sizes_rr'),
                   sizes=params.get('sizes'),
                   protocols=params.get('protocols'),
                   ver_cmd=params.get('ver_cmd', "rpm -q qemu-kvm"),
                   netserver_port=params.get('netserver_port', "12865"),
                   params=params, server_cyg=server_cyg, test=test)

        if params.get("log_hostinfo_script"):
            src = os.path.join(test.virtdir, params.get("log_hostinfo_script"))
            path = os.path.join(test.resultsdir, "systeminfo")
            process.system_output("bash %s %s &> %s" % (
                                  src, test.resultsdir, path), shell=True)

        if params.get("log_guestinfo_script") and params.get("log_guestinfo_exec"):
            src = os.path.join(test.virtdir, params.get("log_guestinfo_script"))
            path = os.path.join(test.resultsdir, "systeminfo")
            destpath = params.get("log_guestinfo_path", "/tmp/log_guestinfo.sh")
            vm.copy_files_to(src, destpath, nic_index=1)
            logexec = params.get("log_guestinfo_exec", "bash")
            output = server_ctl.cmd_output("%s %s" % (logexec, destpath))
            logfile = open(path, "a+")
            logfile.write(output)
            logfile.close()
    finally:
        if mtu != 1500:
            mtu_default = 1500
            error_context.context("Change back server, client and host's mtu to %s"
                                  % mtu_default)
            mtu_set(mtu_default)
Beispiel #10
0
def run_boot(test, params, env):
    """
    Qemu reboot test:
    1) Log into a guest
    3) Send a reboot command or a system_reset monitor command (optional)
    4) Wait until the guest is up again
    5) Log into the guest to verify it's up again

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

    timeout = float(params.get("login_timeout", 240))
    #ting test
    #sys.stdout.restore()
    #print "\n\nparams :    ",params,"\n\n\n"
    #end test

    vms = env.get_all_vms()
    #ting test
    sys.stdout.restore()
    print "vms : ",vms,"\n\n\n"
    #end test
    for vm in vms:
        #ting test
        sys.stdout.restore()
        print "vm : ",vm,"\n"
        #end test
        error.context("Try to log into guest '%s'." % vm.name, logging.info)
        session = vm.wait_for_login(timeout=timeout)
        print "after wait\n\n"
        session.close()

    #ting test
    sys.stdout.restore()
    print "after for\n\n\n"
    #end test

    
    if params.get("rh_perf_envsetup_script"):
        for vm in vms:
            session = vm.wait_for_login(timeout=timeout)
            utils_test.service_setup(vm, session, test.virtdir)
            session.close()
    #ting test
    sys.stdout.restore()
    print "params.get reboot_method:  ",params.get("reboot_method"),"\n\n\n"
    #end test
    if params.get("reboot_method"):
        for vm in vms:
            error.context("Reboot guest '%s'." % vm.name, logging.info)
            if params["reboot_method"] == "system_reset":
                time.sleep(int(params.get("sleep_before_reset", 10)))
            # Reboot the VM
            session = vm.wait_for_login(timeout=timeout)
            for i in range(int(params.get("reboot_count", 1))):
                session = vm.reboot(session,
                                    params["reboot_method"],
                                    0,
                                    timeout)
            session.close()
Beispiel #11
0
def run(test, params, env):
    """
    Network stress test with netperf.

    1) Boot up VM(s), setup SSH authorization between host
       and guest(s)/external host
    2) Prepare the test environment in server/client/host
    3) Execute netperf tests, collect and analyze the results

    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
    """
    def env_setup(session, ip, user, port, password):
        error_context.context("Setup env for %s" % ip)
        ssh_cmd(session, "iptables -F", ignore_status=True)
        ssh_cmd(session, "service iptables stop", ignore_status=True)
        ssh_cmd(session, "systemctl stop firewalld.service",
                ignore_status=True)
        ssh_cmd(session, "echo 2 > /proc/sys/net/ipv4/conf/all/arp_ignore")
        ssh_cmd(session, "echo 0 > /sys/kernel/mm/ksm/run", ignore_status=True)

        pkg = params["netperf_pkg"]
        pkg = os.path.join(data_dir.get_deps_dir(), pkg)
        remote.scp_to_remote(ip, shell_port, username, password, pkg, "/tmp")
        ssh_cmd(session, params.get("setup_cmd"))

        agent_path = os.path.join(test.virtdir, "scripts/netperf_agent.py")
        remote.scp_to_remote(ip, shell_port, username, password,
                             agent_path, "/tmp")

    def mtu_set(mtu):
        """
        Set server/client/host's mtu

        :param mtu: mtu value to be set
        """

        server_mtu_cmd = params.get("server_mtu_cmd")
        client_mtu_cmd = params.get("client_mtu_cmd")
        host_mtu_cmd = params.get("host_mtu_cmd")
        error_context.context("Changing the MTU of guest", logging.info)
        if params.get("os_type") == "linux":
            ethname = utils_net.get_linux_ifname(server_ctl, mac)
            ssh_cmd(server_ctl, server_mtu_cmd % (ethname, mtu))
        elif params.get("os_type") == "windows":
            connection_id = utils_net.get_windows_nic_attribute(
                server_ctl, "macaddress", mac, "netconnectionid")
            ssh_cmd(server_ctl, server_mtu_cmd % (connection_id, mtu))

        error_context.context("Changing the MTU of client", logging.info)
        ssh_cmd(client, client_mtu_cmd
                % (params.get("client_physical_nic"), mtu))

        netdst = params.get("netdst", "switch")
        host_bridges = utils_net.Bridge()
        br_in_use = host_bridges.list_br()
        if netdst in br_in_use:
            ifaces_in_use = host_bridges.list_iface()
            target_ifaces = list(ifaces_in_use + br_in_use)
        if vm.virtnet[0].nettype == "macvtap":
            target_ifaces.extend([vm.virtnet[0].netdst, vm.get_ifname(0)])
        error_context.context("Change all Bridge NICs MTU to %s"
                              % mtu, logging.info)
        for iface in target_ifaces:
            process.run(host_mtu_cmd % (iface, mtu), ignore_status=False,
                        shell=True)

    def _pin_vm_threads(vm, node):
        if node:
            if not isinstance(node, utils_misc.NumaNode):
                node = utils_misc.NumaNode(int(node))
            utils_test.qemu.pin_vm_threads(vm, node)

        return node

    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    login_timeout = int(params.get("login_timeout", 360))

    server_ip = vm.wait_for_get_address(0, timeout=5)
    if len(params.get("nics", "").split()) > 1:
        vm.wait_for_serial_login(timeout=30, restart_network=True).close()
        server_ctl = vm.wait_for_login(nic_index=1, timeout=login_timeout)
        server_ctl_ip = vm.wait_for_get_address(1, timeout=5)
        session = vm.wait_for_login(nic_index=1, timeout=30)
    else:
        server_ctl = vm.wait_for_login(timeout=login_timeout)
        server_ctl_ip = server_ip
        session = vm.wait_for_login(timeout=login_timeout)

    mac = vm.get_mac_address(0)
    queues = int(params.get("queues", 1))
    if queues > 1:
        if params.get("os_type") == "linux":
            ethname = utils_net.get_linux_ifname(session, mac)
            session.cmd_status_output("ethtool -L %s combined %s" %
                                      (ethname, queues))
        else:
            logging.info("FIXME: support to enable MQ for Windows guest!")

    config_cmds = params.get("config_cmds")
    if config_cmds:
        for config_cmd in config_cmds.split(","):
            cmd = params.get(config_cmd.strip())
            if cmd:
                s, o = session.cmd_status_output(cmd)
                if s:
                    msg = "Config command %s failed. Output: %s" % (cmd, o)
                    test.error(msg)
        if params.get("reboot_after_config", "yes") == "yes":
            session = vm.reboot(session=session, timeout=login_timeout)

    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)
    session.close()

    if (params.get("os_type") == "windows" and
            params.get("use_cygwin") == "yes"):
        cygwin_prompt = params.get("cygwin_prompt", r"\$\s+$")
        cygwin_start = params.get("cygwin_start")
        server_cyg = vm.wait_for_login(timeout=login_timeout)
        server_cyg.set_prompt(cygwin_prompt)
        server_cyg.cmd_output(cygwin_start)
    else:
        server_cyg = None

    if len(params.get("nics", "").split()) > 1:
        vm.wait_for_login(nic_index=1, timeout=login_timeout,
                          restart_network=True)
        server_ctl_ip = vm.wait_for_get_address(1, timeout=5)

    logging.debug(process.system_output("numactl --hardware",
                                        verbose=False, ignore_status=True,
                                        shell=True))
    logging.debug(process.system_output("numactl --show",
                                        verbose=False, ignore_status=True,
                                        shell=True))
    # pin guest vcpus/memory/vhost threads to last numa node of host by default
    numa_node = _pin_vm_threads(vm, params.get("numa_node"))

    host = params.get("host", "localhost")
    host_ip = host
    if host != "localhost":
        params_host = params.object_params("host")
        host = remote.wait_for_login(params_host.get("shell_client"),
                                     host_ip,
                                     params_host.get("shell_port"),
                                     params_host.get("username"),
                                     params_host.get("password"),
                                     params_host.get("shell_prompt"))

    client = params.get("client", "localhost")
    client_ip = client
    clients = []
    # client session 1 for control, session 2 for data communication
    for i in range(2):
        if client in params.get("vms"):
            vm_client = env.get_vm(client)
            tmp = vm_client.wait_for_login(timeout=login_timeout)
            client_ip = vm_client.wait_for_get_address(0, timeout=5)
        elif client != "localhost":
            tmp = remote.wait_for_login(params.get("shell_client_client"),
                                        client_ip,
                                        params.get("shell_port_client"),
                                        params.get("username_client"),
                                        params.get("password_client"),
                                        params.get("shell_prompt_client"))
        else:
            tmp = "localhost"
        clients.append(tmp)
    client = clients[0]

    vms_list = params["vms"].split()
    if len(vms_list) > 1:
        vm2 = env.get_vm(vms_list[-1])
        vm2.verify_alive()
        session2 = vm2.wait_for_login(timeout=login_timeout)
        if params.get("rh_perf_envsetup_script"):
            utils_test.service_setup(vm2, session2, test.virtdir)
        client = vm2.wait_for_login(timeout=login_timeout)
        client_ip = vm2.get_address()
        session2.close()
        _pin_vm_threads(vm2, numa_node)

    error_context.context("Prepare env of server/client/host", logging.info)
    prepare_list = set([server_ctl, client, host])
    tag_dict = {server_ctl: "server", client: "client", host: "host"}
    ip_dict = {server_ctl: server_ctl_ip, client: client_ip, host: host_ip}
    for i in prepare_list:
        params_tmp = params.object_params(tag_dict[i])
        if params_tmp.get("os_type") == "linux":
            shell_port = int(params_tmp["shell_port"])
            password = params_tmp["password"]
            username = params_tmp["username"]
            env_setup(i, ip_dict[i], username, shell_port, password)
    mtu = int(params.get("mtu", "1500"))
    mtu_set(mtu)

    env.stop_ip_sniffing()

    error_context.context("Start netperf testing", logging.info)
    start_test(server_ip, server_ctl, host, clients, test.resultsdir,
               test_duration=int(params.get('l')),
               sessions_rr=params.get('sessions_rr'),
               sessions=params.get('sessions'),
               sizes_rr=params.get('sizes_rr'),
               sizes=params.get('sizes'),
               protocols=params.get('protocols'),
               ver_cmd=params.get('ver_cmd', "rpm -q qemu-kvm"),
               netserver_port=params.get('netserver_port', "12865"),
               params=params, server_cyg=server_cyg, test=test)

    if params.get("log_hostinfo_script"):
        src = os.path.join(test.virtdir, params.get("log_hostinfo_script"))
        path = os.path.join(test.resultsdir, "systeminfo")
        process.system_output(
            "bash %s %s &> %s" % (src, test.resultsdir, path), shell=True)

    if params.get("log_guestinfo_script") and params.get("log_guestinfo_exec"):
        src = os.path.join(test.virtdir, params.get("log_guestinfo_script"))
        path = os.path.join(test.resultsdir, "systeminfo")
        destpath = params.get("log_guestinfo_path", "/tmp/log_guestinfo.sh")
        vm.copy_files_to(src, destpath, nic_index=1)
        logexec = params.get("log_guestinfo_exec", "bash")
        output = server_ctl.cmd_output("%s %s" % (logexec, destpath))
        logfile = open(path, "a+")
        logfile.write(output)
        logfile.close()

    if mtu != 1500:
        mtu_default = 1500
        error_context.context("Change back server, client and host's mtu to %s"
                              % mtu_default)
        mtu_set(mtu_default)
Beispiel #12
0
def run_netperf(test, params, env):
    """
    Network stress test with netperf.

    1) Boot up VM(s), setup SSH authorization between host
       and guest(s)/external host
    2) Prepare the test environment in server/client/host
    3) Execute netperf tests, collect and analyze the results

    @param test: KVM test object.
    @param params: Dictionary with the test parameters.
    @param env: Dictionary with test environment.
    """
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    login_timeout = int(params.get("login_timeout", 360))
    session = vm.wait_for_login(timeout=login_timeout)
    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)
    server = vm.get_address()
    server_ctl = vm.get_address(1)
    session.close()

    logging.debug(commands.getoutput("numactl --hardware"))
    logging.debug(commands.getoutput("numactl --show"))
    # pin guest vcpus/memory/vhost threads to last numa node of host by default
    if params.get('numa_node'):
        numa_node = int(params.get('numa_node'))
        node = utils_misc.NumaNode(numa_node)
        utils_test.pin_vm_threads(vm, node)

    if "vm2" in params["vms"]:
        vm2 = env.get_vm("vm2")
        vm2.verify_alive()
        session2 = vm2.wait_for_login(timeout=login_timeout)
        if params.get("rh_perf_envsetup_script"):
            utils_test.service_setup(vm2, session2, test.virtdir)
        client = vm2.get_address()
        session2.close()
        if params.get('numa_node'):
            utils_test.pin_vm_threads(vm2, node)

    if params.get("client"):
        client = params["client"]
    if params.get("host"):
        host = params["host"]
    else:
        cmd = "ifconfig %s|awk 'NR==2 {print $2}'|awk -F: '{print $2}'"
        host = commands.getoutput(cmd % params["netdst"])

    shell_port = int(params["shell_port"])
    password = params["password"]
    username = params["username"]

    def env_setup(ip):
        logging.debug("Setup env for %s" % ip)
        ssh_key.setup_ssh_key(hostname=ip, user=username, port=shell_port,
                              password=password)
        ssh_cmd(ip, "service iptables stop")
        ssh_cmd(ip, "echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore")

        netperf_dir = os.path.join(os.environ['AUTODIR'], "tests/netperf2")
        for i in params.get("netperf_files").split():
            remote.scp_to_remote(ip, shell_port, username, password,
                                      "%s/%s" % (netperf_dir, i), "/tmp/")
        ssh_cmd(ip, params.get("setup_cmd"))

    logging.info("Prepare env of server/client/host")

    env_setup(server_ctl)
    env_setup(client)
    env_setup(host)
    logging.info("Start netperf testing ...")
    start_test(server, server_ctl, host, client, test.resultsdir,
               l=int(params.get('l')),
               sessions_rr=params.get('sessions_rr'),
               sessions=params.get('sessions'),
               sizes_rr=params.get('sizes_rr'),
               sizes=params.get('sizes'),
               protocols=params.get('protocols'),
               ver_cmd=params.get('ver_cmd', "rpm -q qemu-kvm"),
               netserver_port=params.get('netserver_port', "12865"), test=test)