OLD | NEW |
1 import logging, os, signal | 1 import logging, os, signal |
2 from autotest_lib.client.common_lib import error | 2 from autotest_lib.client.common_lib import error |
3 from autotest_lib.client.bin import utils | 3 from autotest_lib.client.bin import utils |
4 import kvm_subprocess, kvm_utils | 4 from autotest_lib.client.virt import aexpect, virt_utils |
5 | |
6 | 5 |
7 def run_netperf(test, params, env): | 6 def run_netperf(test, params, env): |
8 """ | 7 """ |
9 Network stress test with netperf. | 8 Network stress test with netperf. |
10 | 9 |
11 1) Boot up a VM with multiple nics. | 10 1) Boot up a VM with multiple nics. |
12 2) Launch netserver on guest. | 11 2) Launch netserver on guest. |
13 3) Execute multiple netperf clients on host in parallel | 12 3) Execute multiple netperf clients on host in parallel |
14 with different protocols. | 13 with different protocols. |
15 4) Output the test result. | 14 4) Output the test result. |
(...skipping 17 matching lines...) Expand all Loading... |
33 try: | 32 try: |
34 utils.run("iptables -F") | 33 utils.run("iptables -F") |
35 except: | 34 except: |
36 pass | 35 pass |
37 | 36 |
38 for i in params.get("netperf_files").split(): | 37 for i in params.get("netperf_files").split(): |
39 vm.copy_files_to(os.path.join(netperf_dir, i), "/tmp") | 38 vm.copy_files_to(os.path.join(netperf_dir, i), "/tmp") |
40 | 39 |
41 try: | 40 try: |
42 session_serial.cmd(firewall_flush) | 41 session_serial.cmd(firewall_flush) |
43 except kvm_subprocess.ShellError: | 42 except aexpect.ShellError: |
44 logging.warning("Could not flush firewall rules on guest") | 43 logging.warning("Could not flush firewall rules on guest") |
45 | 44 |
46 session_serial.cmd(setup_cmd % "/tmp", timeout=200) | 45 session_serial.cmd(setup_cmd % "/tmp", timeout=200) |
47 session_serial.cmd(params.get("netserver_cmd") % "/tmp") | 46 session_serial.cmd(params.get("netserver_cmd") % "/tmp") |
48 | 47 |
49 tcpdump = env.get("tcpdump") | 48 tcpdump = env.get("tcpdump") |
50 pid = None | 49 pid = None |
51 if tcpdump: | 50 if tcpdump: |
52 # Stop the background tcpdump process | 51 # Stop the background tcpdump process |
53 try: | 52 try: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 raise error.TestFail("Some netperf tests failed: %s" % | 84 raise error.TestFail("Some netperf tests failed: %s" % |
86 ", ".join(list_fail)) | 85 ", ".join(list_fail)) |
87 | 86 |
88 try: | 87 try: |
89 logging.info("Setup and run netperf clients on host") | 88 logging.info("Setup and run netperf clients on host") |
90 utils.run(setup_cmd % netperf_dir) | 89 utils.run(setup_cmd % netperf_dir) |
91 | 90 |
92 bg = [] | 91 bg = [] |
93 nic_num = len(params.get("nics").split()) | 92 nic_num = len(params.get("nics").split()) |
94 for i in range(nic_num): | 93 for i in range(nic_num): |
95 bg.append(kvm_utils.Thread(netperf, (i,))) | 94 bg.append(virt_utils.Thread(netperf, (i,))) |
96 bg[i].start() | 95 bg[i].start() |
97 | 96 |
98 completed = False | 97 completed = False |
99 while not completed: | 98 while not completed: |
100 completed = True | 99 completed = True |
101 for b in bg: | 100 for b in bg: |
102 if b.is_alive(): | 101 if b.is_alive(): |
103 completed = False | 102 completed = False |
104 finally: | 103 finally: |
105 for b in bg: | 104 for b in bg: |
106 if b: | 105 if b: |
107 b.join() | 106 b.join() |
108 session_serial.cmd_output("killall netserver") | 107 session_serial.cmd_output("killall netserver") |
109 if tcpdump and pid: | 108 if tcpdump and pid: |
110 logging.debug("Resuming the background tcpdump") | 109 logging.debug("Resuming the background tcpdump") |
111 logging.info("pid is %s" % pid) | 110 logging.info("pid is %s" % pid) |
112 os.kill(pid, signal.SIGCONT) | 111 os.kill(pid, signal.SIGCONT) |
OLD | NEW |