[Autotest PATCH v2 1/4] virt-test: add NTttcp subtests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 package can be downloaded from this link:
!   http://msdn.microsoft.com/en-us/windows/hardware/gg463264
! ntttcp.au3: This script will sign "End-user license agreement"
!   for you, please don't use this script if you don't agree EULA.
!
! Create a directory in winutils.iso and put msi and autoit script
! to it.
! winutils.iso:
!     NTttcp/
!     NTttcp/NT Testing TCP Tool.msi
!     NTttcp/ntttcp.au3

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

Signed-off-by: Qingtang Zhou <qzhou@xxxxxxxxxx>
Signed-off-by: Amos Kong <akong@xxxxxxxxxx>
---
 client/virt/scripts/ntttcp.au3  |   41 +++++++++
 client/virt/subtests.cfg.sample |   22 +++++
 client/virt/tests/ntttcp.py     |  183 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 246 insertions(+), 0 deletions(-)
 create mode 100755 client/virt/scripts/ntttcp.au3
 create mode 100644 client/virt/tests/ntttcp.py

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..5b41f67 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 -t 30"
+        ntttcp_receiver_cmd = "cmd /c C:\NTttcp\NTttcpr.exe -m %s,0,%s -a 6 -rb 256k -t 30"
+        session_num = 1
+        buffers = "2k 4k 8k 16k 32k 64k 128k 256k"
+        timeout = 300
+        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..188e0cf
--- /dev/null
+++ b/client/virt/tests/ntttcp.py
@@ -0,0 +1,183 @@
+import logging, os, glob, re, commands
+from autotest_lib.client.common_lib import error
+from autotest_lib.client.virt import virt_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)
+    if params.get("platform") == "64":
+        platform = "x64"
+    else:
+        platform = "x86"
+    buffers = params.get("buffers").split()
+    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(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 = int(params.get('numa_node', -1))
+    p = virt_utils.NumaNode(numa_node)
+    node_num = int(p.get_node_num())
+
+    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)
+            o = vm_receiver.monitor.info("cpus")
+            for i in re.findall("thread_id=(\d+)", o):
+                p.pin_cpu(i)
+        finally:
+            if sess:
+                sess.close()
+
+    vhost_threads = commands.getoutput("ps aux |grep '\[vhost-.*\]'|"
+                                       "grep -v grep|awk '{print $2}'")
+    for i in vhost_threads.split():
+        logging.debug("pin vhost_net thread(%s) to host cpu node" % i)
+        p.pin_cpu(i)
+    o = vm_sender.monitor.info("cpus")
+    for i in re.findall("thread_id=(\d+)", o):
+        p.pin_cpu(i)
+
+    def install_ntttcp(session):
+        """ Install ntttcp through a remote session """
+        logging.info("Installing NTttcp ...")
+        if session.cmd_status(params.get("check_ntttcp_cmd")) == 0:
+            # Don't install ntttcp if it's already installed
+            logging.info("NTttcp directory already exists")
+            return
+        ntttcp_install_cmd = params.get("ntttcp_install_cmd")
+        ret, output = session.cmd_status_output(ntttcp_install_cmd %
+                                  (platform, platform), timeout=200)
+        if ret != 0:
+            logging.error(output)
+            raise error.TestError("Can't install NTttcp on guest")
+
+    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
+            cmd = ntttcp_receiver_cmd % (session_num, receiver_addr)
+            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)
+                # 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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux