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 # 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 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," 40 "perturbation_size=%d, tag='%s')"]) 41 42 server_control_file = template % (server.ip, client.ip, 'server', 43 buffer, upper_bound, variance, 44 'server') 45 client_control_file = template % (server.ip, client.ip, 'client', 46 buffer, upper_bound, variance, 47 'client') 48 49 server_command = subcommand.subcommand(server_at.run, 50 [server_control_file, server.hostname], 51 subdir='../') 52 client_command = subcommand.subcommand(client_at.run, 53 [client_control_file, client.hostname], 54 subdir='../') 55 56 subcommand.parallel([server_command, client_command]) 57 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 67 for m in [client, server]: 68 status = m.run('iptables -L') 69 if not status.exit_status: 70 m.enable_ipfilters() 71