We want to use netperf to do the performance test so the impact of autotest framework should be minimized as less as possible, so this patch:
- stop iptables on host - stop tcpdump process before the netperf test by sending SIGSTOP and recover it after the test - use serial console Signed-off-by: Jason Wang <jasow...@redhat.com> --- client/tests/kvm/tests/netperf.py | 35 +++++++++++++++++++++++++++-------- 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/client/tests/kvm/tests/netperf.py b/client/tests/kvm/tests/netperf.py index e1153e1..8103fc0 100644 --- a/client/tests/kvm/tests/netperf.py +++ b/client/tests/kvm/tests/netperf.py @@ -1,4 +1,4 @@ -import logging, os +import logging, os, signal from autotest_lib.client.common_lib import error from autotest_lib.client.bin import utils import kvm_subprocess @@ -20,7 +20,8 @@ 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_serial = kvm_test_utils.wait_for_login(vm, timeout=login_timeout, + serial=True) netperf_dir = os.path.join(os.environ['AUTODIR'], "tests/netperf2") setup_cmd = params.get("setup_cmd") @@ -28,18 +29,33 @@ def run_netperf(test, params, env): result_file = os.path.join(test.resultsdir, "output_%s" % test.iteration) firewall_flush = "iptables -F" - session.cmd_output(firewall_flush) + session_serial.cmd_output(firewall_flush) + try: + utils.run("iptables -F") + except: + pass for i in params.get("netperf_files").split(): vm.copy_files_to(os.path.join(netperf_dir, i), "/tmp") try: - session.cmd(firewall_flush) + session_serial.cmd(firewall_flush) except kvm_subprocess.ShellError: logging.warning("Could not flush firewall rules on guest") - session.cmd(setup_cmd % "/tmp", timeout=200) - session.cmd(params.get("netserver_cmd") % "/tmp") + session_serial.cmd(setup_cmd % "/tmp", timeout=200) + session_serial.cmd(params.get("netserver_cmd") % "/tmp") + + tcpdump = env.get("tcpdump") + pid = None + if tcpdump: + # Stop the background tcpdump process + try: + pid = int(utils.system_output("pidof tcpdump")) + logging.debug("Stopping the background tcpdump") + os.kill(pid, signal.SIGSTOP) + except: + pass try: logging.info("Setup and run netperf client on host") @@ -69,5 +85,8 @@ def run_netperf(test, params, env): ", ".join(list_fail)) finally: - session.cmd_output("killall netserver") - session.close() + session_serial.cmd_output("killall netserver") + if tcpdump and pid: + logging.debug("Resuming the background tcpdump") + logging.info("pid is %s" % pid) + os.kill(pid, signal.SIGCONT) _______________________________________________ Autotest mailing list Autotest@test.kernel.org http://test.kernel.org/cgi-bin/mailman/listinfo/autotest