Beispiel #1
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)
    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 = virt_utils.NumaNode(numa_node)
        virt_test_utils.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)
        client = vm2.get_address()
        session2.close()
        if params.get('numa_node'):
            virt_test_utils.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["bridge"])

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

    def env_setup(ip):
        logging.debug("Setup env for %s" % ip)
        SSHHost(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():
            virt_utils.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'))
Beispiel #2
0
def run_ntttcp(test, params, env):
    """
    Run NTttcp on Windows guest

    1) Install NTttcp in server/client side by Autoit
    2) Start NTttcp in server/client side
    3) Get test results

    @param test: kvm test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment.
    """
    login_timeout = int(params.get("login_timeout", 360))
    timeout = int(params.get("timeout"))
    results_path = os.path.join(test.resultsdir, "raw_output_%s" % test.iteration)
    platform = "x86"
    if params.get("platform") == "64":
        platform = "x64"
    buffers = params.get("buffers").split()
    buf_num = params.get("buf_num", 200000)
    session_num = params.get("session_num")

    vm_sender = env.get_vm(params["main_vm"])
    vm_sender.verify_alive()
    vm_receiver = None
    receiver_addr = params.get("receiver_address")

    logging.debug(utils.system("numactl --hardware", ignore_status=True))
    logging.debug(utils.system("numactl --show", ignore_status=True))
    # 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 = virt_utils.NumaNode(numa_node)
        virt_test_utils.pin_vm_threads(vm_sender, node)

    if not receiver_addr:
        vm_receiver = env.get_vm("vm2")
        vm_receiver.verify_alive()
        try:
            sess = None
            sess = vm_receiver.wait_for_login(timeout=login_timeout)
            receiver_addr = vm_receiver.get_address()
            if not receiver_addr:
                raise error.TestError("Can't get receiver(%s) ip address" % vm_sender.name)
            if params.get("numa_node"):
                virt_test_utils.pin_vm_threads(vm_receiver, node)
        finally:
            if sess:
                sess.close()

    @error.context_aware
    def install_ntttcp(session):
        """ Install ntttcp through a remote session """
        logging.info("Installing NTttcp ...")
        try:
            # Don't install ntttcp if it's already installed
            error.context("NTttcp directory already exists")
            session.cmd(params.get("check_ntttcp_cmd"))
        except aexpect.ShellCmdError, e:
            ntttcp_install_cmd = params.get("ntttcp_install_cmd")
            error.context("Installing NTttcp on guest")
            session.cmd(ntttcp_install_cmd % (platform, platform), timeout=200)