Looks good, applied to next! On Thu, Feb 28, 2013 at 3:19 AM, Amos Kong <[email protected]> wrote: > Currently we use many threads/heavy control sessions to launch many > clients, Autotest takes too much host resouse. > > This patch introduced an agent script, we execute it insider client > system to launch multiple sessions, and Autotest only need to use one > background thread to control clients. > > We can consider to process the raw results in this agent script in > future, if it can help to simplify the case. > > Signed-off-by: Amos Kong <[email protected]> > --- > shared/scripts/netperf_agent.py | 24 +++++++++++++++++++++++ > tests/netperf.py | 40 ++++++++++++++------------------------ > 2 files changed, 39 insertions(+), 25 deletions(-) > create mode 100755 shared/scripts/netperf_agent.py > > diff --git a/shared/scripts/netperf_agent.py b/shared/scripts/netperf_agent.py > new file mode 100755 > index 0000000..294f447 > --- /dev/null > +++ b/shared/scripts/netperf_agent.py > @@ -0,0 +1,24 @@ > +#!/usr/bin/python > +""" > +@author Amos Kong <[email protected]> > + > +""" > +import os, sys, time > + > +if len(sys.argv) < 4: > + print """ netperf agent usage: > + %s [session_number] [netperf_path] [netperf_parameters_str] > + > + $session_number: number of client sessions > + $netperf_path: client path > + $netperf_parameter_str: netperf parameters string""" % sys.argv[0] > + sys.exit() > + > +n = int(sys.argv[1]) > +path = sys.argv[2] > +params = " ".join(sys.argv[3:]) > + > +for i in range(n - 1): > + os.system("%s %s &" % (path, params)) > +os.system("%s %s" % (path, params)) > + > diff --git a/tests/netperf.py b/tests/netperf.py > index 999b523..aad0f91 100644 > --- a/tests/netperf.py > +++ b/tests/netperf.py > @@ -90,6 +90,9 @@ def run_netperf(test, params, env): > "%s/%s" % (netperf_dir, i), "/tmp/") > ssh_cmd(session, params.get("setup_cmd")) > > + agent_path = os.path.join(test.virtdir, "scripts/netperf_agent.py") > + remote.scp_to_remote(ip, shell_port, username, password, > + agent_path, "/tmp/") > > def _pin_vm_threads(vm, node): > if node: > @@ -159,14 +162,8 @@ def run_netperf(test, params, env): > client = params.get("client", "localhost") > client_ip = client > clients = [] > - clients_n = 1 > - # Get the sessions that needed when run netperf parallel > - # The default client connect is the first one. > - if params.get("sessions") or params.get("sessions_rr"): > - sessions_str = params.get('sessions') + " " + > params.get("sessions_rr") > - for i in sessions_str.split(): > - clients_n = max(clients_n, int(i.strip())) > - for i in range(clients_n + 1): > + # client session 1 for control, session 2 for data communication > + for i in range(2): > if client in params.get("vms"): > vm_client = utils_test.get_living_vm(env, client) > tmp = vm_client.wait_for_login(timeout=login_timeout) > @@ -472,15 +469,10 @@ def launch_client(sessions, server, server_ctl, host, > clients, l, nf_args, > output = ssh_cmd(client_s, "numactl --hardware") > n = int(re.findall("available: (\d+) nodes", output)[0]) - 1 > cmd += "numactl --cpunodebind=%s --membind=%s " % (n, n) > - cmd += "%s -D 1 -H %s -l %s %s" % (client_path, server, int(l)*1.5, > nf_args) > + cmd += "/tmp/netperf_agent.py %d %s -D 1 -H %s -l %s %s" % (i, > + client_path, server, int(l)*1.5, nf_args) > cmd += " >> %s" % fname > - > ssh_cmd(client_s, cmd) > - output = ssh_cmd(client_s, "cat %s" % fname) > - if not os.path.exists(fname): > - f = file(fname, "w") > - f.write(output) > - f.close() > > > def parse_demo_result(fname, sessions): > @@ -516,14 +508,13 @@ def launch_client(sessions, server, server_ctl, host, > clients, l, nf_args, > pid = str(os.getpid()) > fname = "/tmp/netperf.%s.nf" % pid > ssh_cmd(clients[-1], "rm -f %s" % fname) > - threads = [] > numa_enable = params.get("netperf_with_numa", "yes") == "yes" > - for i in range(int(sessions)): > - t = threading.Thread(target=netperf_thread, > - kwargs={"i": i, "numa_enable": numa_enable, > - "client_s":clients[i]}) > - threads.append(t) > - t.start() > + client_thread = threading.Thread(target=netperf_thread, > + kwargs={"i": int(sessions), > + "numa_enable": numa_enable, > + "client_s":clients[0]}) > + client_thread.start() > + > ret = {} > ret['pid'] = pid > > @@ -554,9 +545,8 @@ def launch_client(sessions, server, server_ctl, host, > clients, l, nf_args, > for i in range(len(end_state) / 2): > ret[end_state[i * 2]] = (end_state[i * 2 + 1] > - start_state[i * 2 + 1]) > - # wait all the threads stop > - for t in threads: > - t.join() > + > + client_thread.join() > > # recover result file to remove the noise from end > f = open(fname, "w") > -- > 1.7.1 > > _______________________________________________ > Virt-test-devel mailing list > [email protected] > https://www.redhat.com/mailman/listinfo/virt-test-devel
-- Lucas _______________________________________________ Virt-test-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/virt-test-devel
