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 | |
| 27 | server_at = autotest.Autotest(server) |
| 28 | client_at = autotest.Autotest(client) |
| 29 | |
| 30 | template = ''.join(["job.run_test('netpipe', server_ip='%s', ", |
| 31 | "client_ip='%s', role='%s', bidirectional=True, ", |
| 32 | "buffer_size=%d, upper_bound=%d," |
| 33 | "perturbation_size=%d)"]) |
| 34 | |
| 35 | server_control_file = template % (server.ip, client.ip, 'server', |
| 36 | buffer, upper_bound, variance) |
| 37 | client_control_file = template % (server.ip, client.ip, 'client', |
| 38 | buffer, upper_bound, variance) |
| 39 | |
| 40 | server_command = subcommand.subcommand(server_at.run, |
Eric Li | 726afe8 | 2011-04-29 10:16:55 -0700 | [diff] [blame^] | 41 | [server_control_file, server.hostname], |
| 42 | subdir='server') |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 43 | client_command = subcommand.subcommand(client_at.run, |
Eric Li | 726afe8 | 2011-04-29 10:16:55 -0700 | [diff] [blame^] | 44 | [client_control_file, client.hostname], |
| 45 | subdir='client') |
mbligh | 9759030 | 2010-03-11 17:42:46 +0000 | [diff] [blame] | 46 | |
| 47 | subcommand.parallel([server_command, client_command]) |
| 48 | |
| 49 | for m in [client, server]: |
| 50 | status = m.run('iptables -L') |
| 51 | if not status.exit_status: |
| 52 | m.enable_ipfilters() |