mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 1 | from autotest_lib.server import autotest, hosts, subcommand, test |
| 2 | from autotest_lib.server import utils |
| 3 | |
| 4 | class 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 Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame] | 28 | # 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 | |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 35 | 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 Li | 861b2d5 | 2011-02-04 14:50:35 -0800 | [diff] [blame] | 43 | server_control_file = template % (server.ip, client.ip, 'server', test, |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame] | 44 | time, stream_list, 'server', cycles) |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 45 | client_control_file = template % (server.ip, client.ip, 'client', test, |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame] | 46 | time, stream_list, 'client', cycles) |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 47 | |
| 48 | server_command = subcommand.subcommand(server_at.run, |
Eric Li | 726afe8 | 2011-04-29 10:16:55 -0700 | [diff] [blame] | 49 | [server_control_file, server.hostname], |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame] | 50 | subdir='../') |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 51 | client_command = subcommand.subcommand(client_at.run, |
Eric Li | 726afe8 | 2011-04-29 10:16:55 -0700 | [diff] [blame] | 52 | [client_control_file, client.hostname], |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame] | 53 | subdir='../') |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 54 | |
| 55 | subcommand.parallel([server_command, client_command]) |
| 56 | |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame] | 57 | # 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 | |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 66 | for m in [client, server]: |
| 67 | status = m.run('/sbin/iptables -L') |
| 68 | if not status.exit_status: |
| 69 | m.enable_ipfilters() |