blob: 6317c6c864096cffcb397064034b7b4578b21b4a [file] [log] [blame]
mbligh97590302010-03-11 17:42:46 +00001from autotest_lib.server import autotest, hosts, subcommand, test
2from autotest_lib.server import utils
3
4class netperf2(test.test):
5 version = 2
6
7 def run_once(self, pair, test, time, stream_list, cycles):
8 print "running on %s and %s\n" % (pair[0], pair[1])
9
10 # Designate a label for the server side tests.
11 server_label = 'net_server'
12
13 server = hosts.create_host(pair[0])
14 client = hosts.create_host(pair[1])
15
16 # If client has the server_label, then swap server and client.
17 platform_label = client.get_platform_label()
18 if platform_label == server_label:
19 (server, client) = (client, server)
20
21
22 # Disable IPFilters if they are enabled.
23 for m in [client, server]:
24 status = m.run('/sbin/iptables -L')
25 if not status.exit_status:
26 m.disable_ipfilters()
27
28 server_at = autotest.Autotest(server)
29 client_at = autotest.Autotest(client)
30
31 template = ''.join(["job.run_test('netperf2', server_ip='%s', ",
32 "client_ip='%s', role='%s', test='%s', ",
33 "test_time=%d, stream_list=%s, tag='%s', ",
34 "iterations=%d)"])
35
Eric Li861b2d52011-02-04 14:50:35 -080036 server_control_file = template % (server.ip, client.ip, 'server', test,
mbligh97590302010-03-11 17:42:46 +000037 time, stream_list, test, cycles)
38 client_control_file = template % (server.ip, client.ip, 'client', test,
39 time, stream_list, test, cycles)
40
41 server_command = subcommand.subcommand(server_at.run,
Eric Li726afe82011-04-29 10:16:55 -070042 [server_control_file, server.hostname],
43 subdir='server')
mbligh97590302010-03-11 17:42:46 +000044 client_command = subcommand.subcommand(client_at.run,
Eric Li726afe82011-04-29 10:16:55 -070045 [client_control_file, client.hostname],
46 subdir='client')
mbligh97590302010-03-11 17:42:46 +000047
48 subcommand.parallel([server_command, client_command])
49
50 for m in [client, server]:
51 status = m.run('/sbin/iptables -L')
52 if not status.exit_status:
53 m.enable_ipfilters()