Home | History | Annotate | Download | only in netperf2
      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 
     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 
     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 
     43         server_control_file = template % (server.ip, client.ip, 'server', test,
     44                                           time, stream_list, 'server', cycles)
     45         client_control_file = template % (server.ip, client.ip, 'client', test,
     46                                           time, stream_list, 'client', cycles)
     47 
     48         server_command = subcommand.subcommand(server_at.run,
     49                                     [server_control_file, server.hostname],
     50                                     subdir='../')
     51         client_command = subcommand.subcommand(client_at.run,
     52                                     [client_control_file, client.hostname],
     53                                     subdir='../')
     54 
     55         subcommand.parallel([server_command, client_command])
     56 
     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 
     66         for m in [client, server]:
     67             status = m.run('/sbin/iptables -L')
     68             if not status.exit_status:
     69                 m.enable_ipfilters()
     70