Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: client/tests/kvm/tests/netperf.py

Issue 6883035: Merge remote branch 'autotest-upstream/master' into autotest-merge (Closed) Base URL: ssh://gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/tests/kvm/tests/netperf.py
diff --git a/client/tests/kvm/tests/netperf.py b/client/tests/kvm/tests/netperf.py
index df2c839588704357a333d55180527b8fc6bf2ca7..5fdd4813c8be3db74466101131f0271a3b323920 100644
--- a/client/tests/kvm/tests/netperf.py
+++ b/client/tests/kvm/tests/netperf.py
@@ -1,16 +1,17 @@
import logging, os, signal
from autotest_lib.client.common_lib import error
from autotest_lib.client.bin import utils
-import kvm_subprocess
+import kvm_subprocess, kvm_utils
def run_netperf(test, params, env):
"""
Network stress test with netperf.
- 1) Boot up a VM.
+ 1) Boot up a VM with multiple nics.
2) Launch netserver on guest.
- 3) Execute netperf client on host with different protocols.
+ 3) Execute multiple netperf clients on host in parallel
+ with different protocols.
4) Output the test result.
@param test: KVM test object.
@@ -20,12 +21,12 @@ def run_netperf(test, params, env):
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)
+ session.close()
session_serial = vm.wait_for_serial_login(timeout=login_timeout)
netperf_dir = os.path.join(os.environ['AUTODIR'], "tests/netperf2")
setup_cmd = params.get("setup_cmd")
- guest_ip = vm.get_address()
- result_file = os.path.join(test.resultsdir, "output_%s" % test.iteration)
firewall_flush = "iptables -F"
session_serial.cmd_output(firewall_flush)
@@ -56,34 +57,54 @@ def run_netperf(test, params, env):
except:
pass
- try:
- logging.info("Setup and run netperf client on host")
- utils.run(setup_cmd % netperf_dir)
+ def netperf(i=0):
+ guest_ip = vm.get_address(i)
+ logging.info("Netperf_%s: netserver %s" % (i, guest_ip))
+ result_file = os.path.join(test.resultsdir, "output_%s_%s"
+ % (test.iteration, i ))
list_fail = []
result = open(result_file, "w")
result.write("Netperf test results\n")
- for i in params.get("protocols").split():
+ for p in params.get("protocols").split():
packet_size = params.get("packet_size", "1500")
for size in packet_size.split():
- cmd = params.get("netperf_cmd") % (netperf_dir, i,
+ cmd = params.get("netperf_cmd") % (netperf_dir, p,
guest_ip, size)
- logging.info("Netperf: protocol %s", i)
+ logging.info("Netperf_%s: protocol %s" % (i, p))
try:
netperf_output = utils.system_output(cmd,
retain_output=True)
result.write("%s\n" % netperf_output)
except:
- logging.error("Test of protocol %s failed", i)
- list_fail.append(i)
+ logging.error("Test of protocol %s failed", p)
+ list_fail.append(p)
result.close()
-
if list_fail:
raise error.TestFail("Some netperf tests failed: %s" %
", ".join(list_fail))
+ try:
+ logging.info("Setup and run netperf clients on host")
+ utils.run(setup_cmd % netperf_dir)
+
+ bg = []
+ nic_num = len(params.get("nics").split())
+ for i in range(nic_num):
+ bg.append(kvm_utils.Thread(netperf, (i,)))
+ bg[i].start()
+
+ completed = False
+ while not completed:
+ completed = True
+ for b in bg:
+ if b.is_alive():
+ completed = False
finally:
+ for b in bg:
+ if b:
+ b.join()
session_serial.cmd_output("killall netserver")
if tcpdump and pid:
logging.debug("Resuming the background tcpdump")

Powered by Google App Engine
This is Rietveld 408576698