This case will test tcp throughput between 2 windows guests, or between 1 guest and 1 external Windows host. When test between guest and external Windows host, 'receiver_address' should be set to external Windows' ip address. NTttcp is not a freely redistributable binary, so you *must* download it from microsoft and be in agreement with its EULA. See @see tag for a complete download link and also documentation on how to integrate it to your autotest setup. @see: http://msdn.microsoft.com/en-us/windows/hardware/gg463264 @see: http://download.microsoft.com/download/f/1/e/f1e1ac7f-e632-48ea-83ac-56b016318735/NT%20Testing%20TCP%20Tool.msi @see: https://github.com/autotest/autotest/wiki/KVMAutotest-Networking ! ntttcp.au3: This script will sign "End-user license agreement" ! for you, please don't use this script if you don't agree EULA. This test will generate result files with 'standard' format, split different items by '|', use one line as the title. We can analyze them by a general modules. raw_output_1.RHS: buf(k)| throughput(Mbit/s) ... 64| 2407.548 128| 2102.254 256| 4930.362 512| 4723.035 1024| 4725.334 Changes from v1: - pin vcpus/vhost_net threads to numa node - add autoio script for ntttcp test - user should put msi and autoit script to iso - fix threads sync issue - set test time to 30 seconds - support to use fixed receiver buf or use same buf as sender - 30 seconds is not enough, assign buf number to 2000000 Signed-off-by: Qingtang Zhou <qzhou@xxxxxxxxxx> Signed-off-by: Amos Kong <akong@xxxxxxxxxx> --- 0 files changed, 0 insertions(+), 0 deletions(-) diff --git a/client/virt/scripts/ntttcp.au3 b/client/virt/scripts/ntttcp.au3 new file mode 100755 index 0000000..00489e8 --- /dev/null +++ b/client/virt/scripts/ntttcp.au3 @@ -0,0 +1,41 @@ +#cs --------------------------------------------- +AutoIt Version: 3.1.1.0 +Author: Qingtang Zhou <qzhou@xxxxxxxxxx> + +Script Function: +Install NT Testing TCP tool + +Note: This script will sign "End-user license agreement" for user +#ce --------------------------------------------- + +Func WaitWind($title) + WinWait($title, "") + + If Not WinActive($title, "") Then + WinActivate($title, "") + EndIf +EndFunc + +$FILE="msiexec /i ""D:\NTttcp\\NT Testing TCP Tool.msi""" +Run($FILE) + +WaitWind("NT Testing TCP Tool") +WinWaitActive("NT Testing TCP Tool", "Welcome to the NT Testing TCP Tool Setup Wizard") +Send("!n") + +WaitWind("NT Testing TCP Tool") +WinWaitActive("NT Testing TCP Tool", "License Agreement") +send("!a") +send("{ENTER}") + +WaitWind("NT Testing TCP Tool") +WinWaitActive("NT Testing TCP Tool", "Select Installation Folder") +Send("{ENTER}") + +WaitWind("NT Testing TCP Tool") +WinWaitActive("NT Testing TCP Tool", "Confirm Installation") +send("{ENTER}") + +WinWaitActive("NT Testing TCP Tool", "Installation Complete") +send("!c") + diff --git a/client/virt/subtests.cfg.sample b/client/virt/subtests.cfg.sample index 89dda8c..cc0986a 100644 --- a/client/virt/subtests.cfg.sample +++ b/client/virt/subtests.cfg.sample @@ -1007,6 +1007,28 @@ variants: netperf_cmd = %s/netperf-2.4.5/src/netperf -t %s -H %s -l 60 -- -r %s protocols = "TCP_RR TCP_CRR UDP_RR" + - ntttcp: + type = ntttcp + image_snapshot = yes + check_ntttcp_cmd = "cmd /c dir C:\NTttcp" + ntttcp_sender_cmd = "cmd /c C:\NTttcp\NTttcps.exe -m %s,0,%s -a 2 -l %s -n %s" + ntttcp_receiver_cmd = "cmd /c C:\NTttcp\NTttcpr.exe -m %s,0,%s -a 6 -rb %s -n %s" + session_num = 1 + buffers = "2k 4k 8k 16k 32k 64k 128k 256k 512k 1024k 2048k" + timeout = 1200 + kill_vm = yes + numa_node = -1 + variants: + - guest_guest: + vms += " vm2" + - guest_host: + # external Windows system IP, NTttcp need to be installed firstly. + receiver_address = "192.168.1.1" + 32: + ntttcp_install_cmd = 'cmd /c "D:\autoit3.exe D:\NTttcp\NTttcp.au3 && mkdir C:\NTttcp && copy "C:\Program Files\Microsoft Corporation\NT Testing TCP Tool\*" C:\NTttcp && cd C:\NTttcp\ && copy NTttcp_%s.exe NTttcps.exe && copy NTttcp_%s.exe NTttcpr.exe"' + 64: + ntttcp_install_cmd = 'cmd /c "D:\autoit3.exe D:\NTttcp\NTttcp.au3 && mkdir C:\NTttcp && copy "C:\Program Files (x86)\Microsoft Corporation\NT Testing TCP Tool\*" C:\NTttcp && cd C:\NTttcp\ && copy NTttcp_%s.exe NTttcps.exe && copy NTttcp_%s.exe NTttcpr.exe"' + - ethtool: install setup image_copy unattended_install.cdrom only Linux type = ethtool diff --git a/client/virt/tests/ntttcp.py b/client/virt/tests/ntttcp.py new file mode 100644 index 0000000..66cdbfe --- /dev/null +++ b/client/virt/tests/ntttcp.py @@ -0,0 +1,175 @@ +import logging, os, glob, re, commands +from autotest_lib.client.common_lib import error +from autotest_lib.client.common_lib import utils +from autotest_lib.client.virt import virt_utils, aexpect, virt_test_utils + +_receiver_ready = False + +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) + + def receiver(): + """ Receive side """ + logging.info("Starting receiver process on %s", receiver_addr) + if vm_receiver: + session = vm_receiver.wait_for_login(timeout=login_timeout) + else: + username = params.get("username", "") + password = params.get("password", "") + prompt = params.get("shell_prompt", "[\#\$]") + linesep = eval("'%s'" % params.get("shell_linesep", r"\n")) + client = params.get("shell_client") + port = int(params.get("shell_port")) + log_filename = ("session-%s-%s.log" % (receiver_addr, + virt_utils.generate_random_string(4))) + session = virt_utils.remote_login(client, receiver_addr, port, + username, password, prompt, + linesep, log_filename, timeout) + session.set_status_test_command("echo %errorlevel%") + install_ntttcp(session) + ntttcp_receiver_cmd = params.get("ntttcp_receiver_cmd") + global _receiver_ready + f = open(results_path + ".receiver", 'a') + for b in buffers: + virt_utils.wait_for(lambda: not _wait(), timeout) + _receiver_ready = True + rbuf = params.get("fixed_rbuf", b) + cmd = ntttcp_receiver_cmd % (session_num, receiver_addr, rbuf, buf_num) + r = session.cmd_output(cmd, timeout=timeout, + print_func=logging.debug) + f.write("Send buffer size: %s\n%s\n%s" % (b, cmd, r)) + f.close() + session.close() + + def _wait(): + """ Check if receiver is ready """ + global _receiver_ready + if _receiver_ready: + return _receiver_ready + return False + + def sender(): + """ Send side """ + logging.info("Sarting sender process ...") + session = vm_sender.wait_for_login(timeout=login_timeout) + install_ntttcp(session) + ntttcp_sender_cmd = params.get("ntttcp_sender_cmd") + f = open(results_path + ".sender", 'a') + try: + global _receiver_ready + for b in buffers: + cmd = ntttcp_sender_cmd % (session_num, receiver_addr, b, buf_num) + # Wait until receiver ready + virt_utils.wait_for(_wait, timeout) + r = session.cmd_output(cmd, timeout=timeout, + print_func=logging.debug) + _receiver_ready = False + f.write("Send buffer size: %s\n%s\n%s" % (b, cmd, r)) + finally: + f.close() + session.close() + + def parse_file(resultfile): + """ Parse raw result files and generate files with standard format """ + file = open(resultfile, "r") + list= [] + found = False + for line in file.readlines(): + o = re.findall("Send buffer size: (\d+)", line) + if o: + buffer = o[0] + if "Total Throughput(Mbit/s)" in line: + found = True + if found: + fields = line.split() + if len(fields) == 0: + continue + try: + [float(i) for i in fields] + list.append([buffer, fields[-1]]) + except ValueError: + continue + found = False + return list + + try: + bg = virt_utils.Thread(receiver, ()) + bg.start() + if bg.is_alive(): + sender() + bg.join(suppress_exception=True) + else: + raise error.TestError("Can't start backgroud receiver thread") + finally: + for i in glob.glob("%s.receiver" % results_path): + f = open("%s.RHS" % results_path, "w") + raw = " buf(k)| throughput(Mbit/s)" + logging.info(raw) + f.write(raw + "\n") + for j in parse_file(i): + raw = "%8s| %8s" % (j[0], j[1]) + logging.info(raw) + f.write(raw + "\n") + f.close() -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html