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 netpipe(test.test): |
| 5 | version = 2 |
| 6 | |
| 7 | def run_once(self, pair, buffer, upper_bound, variance): |
| 8 | print "running on %s and %s\n" % (pair[0], pair[1]) |
| 9 | |
| 10 | # Designate a platform label for the server side of 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 | # Disable IP Filters if they are enabled. |
| 22 | for m in [client, server]: |
| 23 | status = m.run('iptables -L') |
| 24 | if not status.exit_status: |
| 25 | m.disable_ipfilters() |
| 26 | |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame^] | 27 | # Starting a test indents the status.log entries. This test starts 2 |
| 28 | # additional tests causing their log entries to be indented twice. This |
| 29 | # double indent confuses the parser, so reset the indent level on the |
| 30 | # job, let the forked tests record their entries, then restore the |
| 31 | # previous indent level. |
| 32 | self.job._indenter.decrement() |
| 33 | |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 34 | server_at = autotest.Autotest(server) |
| 35 | client_at = autotest.Autotest(client) |
| 36 | |
| 37 | template = ''.join(["job.run_test('netpipe', server_ip='%s', ", |
| 38 | "client_ip='%s', role='%s', bidirectional=True, ", |
| 39 | "buffer_size=%d, upper_bound=%d," |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame^] | 40 | "perturbation_size=%d, tag='%s')"]) |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 41 | |
| 42 | server_control_file = template % (server.ip, client.ip, 'server', |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame^] | 43 | buffer, upper_bound, variance, |
| 44 | 'server') |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 45 | client_control_file = template % (server.ip, client.ip, 'client', |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame^] | 46 | buffer, upper_bound, variance, |
| 47 | 'client') |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 48 | |
| 49 | server_command = subcommand.subcommand(server_at.run, |
Eric Li | 726afe8 | 2011-04-29 10:16:55 -0700 | [diff] [blame] | 50 | [server_control_file, server.hostname], |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame^] | 51 | subdir='../') |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 52 | client_command = subcommand.subcommand(client_at.run, |
Eric Li | 726afe8 | 2011-04-29 10:16:55 -0700 | [diff] [blame] | 53 | [client_control_file, client.hostname], |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame^] | 54 | subdir='../') |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 55 | |
| 56 | subcommand.parallel([server_command, client_command]) |
| 57 | |
Paul Pendlebury | 07eb487 | 2011-05-03 15:21:33 -0700 | [diff] [blame^] | 58 | # The parser needs a keyval file to know what host ran the test. |
| 59 | utils.write_keyval('../' + server.hostname, |
| 60 | {"hostname": server.hostname}) |
| 61 | utils.write_keyval('../' + client.hostname, |
| 62 | {"hostname": client.hostname}) |
| 63 | |
| 64 | # Restore indent level of main job. |
| 65 | self.job._indenter.increment() |
| 66 | |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 67 | for m in [client, server]: |
| 68 | status = m.run('iptables -L') |
| 69 | if not status.exit_status: |
| 70 | m.enable_ipfilters() |