blob: 4d0b5fb352073735bfad4e305a9e835e43757c2b [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
Paul Pendlebury07eb4872011-05-03 15:21:33 -070028 # Starting a test indents the status.log entries. This test starts 2
29 # additional tests causing their log entries to be indented twice. This
30 # double indent confuses the parser, so reset the indent level on the
31 # job, let the forked tests record their entries, then restore the
32 # previous indent level.
33 self.job._indenter.decrement()
34
mbligh97590302010-03-11 17:42:46 +000035 server_at = autotest.Autotest(server)
36 client_at = autotest.Autotest(client)
37
38 template = ''.join(["job.run_test('netperf2', server_ip='%s', ",
39 "client_ip='%s', role='%s', test='%s', ",
40 "test_time=%d, stream_list=%s, tag='%s', ",
41 "iterations=%d)"])
42
Eric Li861b2d52011-02-04 14:50:35 -080043 server_control_file = template % (server.ip, client.ip, 'server', test,
Paul Pendlebury07eb4872011-05-03 15:21:33 -070044 time, stream_list, 'server', cycles)
mbligh97590302010-03-11 17:42:46 +000045 client_control_file = template % (server.ip, client.ip, 'client', test,
Paul Pendlebury07eb4872011-05-03 15:21:33 -070046 time, stream_list, 'client', cycles)
mbligh97590302010-03-11 17:42:46 +000047
48 server_command = subcommand.subcommand(server_at.run,
Eric Li726afe82011-04-29 10:16:55 -070049 [server_control_file, server.hostname],
Paul Pendlebury07eb4872011-05-03 15:21:33 -070050 subdir='../')
mbligh97590302010-03-11 17:42:46 +000051 client_command = subcommand.subcommand(client_at.run,
Eric Li726afe82011-04-29 10:16:55 -070052 [client_control_file, client.hostname],
Paul Pendlebury07eb4872011-05-03 15:21:33 -070053 subdir='../')
mbligh97590302010-03-11 17:42:46 +000054
55 subcommand.parallel([server_command, client_command])
56
Paul Pendlebury07eb4872011-05-03 15:21:33 -070057 # The parser needs a keyval file to know what host ran the test.
58 utils.write_keyval('../' + server.hostname,
59 {"hostname": server.hostname})
60 utils.write_keyval('../' + client.hostname,
61 {"hostname": client.hostname})
62
63 # Restore indent level of main job.
64 self.job._indenter.increment()
65
mbligh97590302010-03-11 17:42:46 +000066 for m in [client, server]:
67 status = m.run('/sbin/iptables -L')
68 if not status.exit_status:
69 m.enable_ipfilters()