Home | History | Annotate | Download | only in profiler_sync
      1 # This "test" is used by autotest_lib.server.standalone_profilers to start
      2 # and stop profilers on a collection of hosts at approximately the same
      3 # time by synchronizing using barriers.
      4 
      5 from autotest_lib.client.bin import test
      6 from autotest_lib.client.common_lib import barrier
      7 
      8 class profiler_sync(test.test):
      9     version = 1
     10 
     11 
     12     def execute(self, timeout_sync, timeout_start, timeout_stop,
     13                 hostid, masterid, all_ids):
     14         """
     15         @param timeout_sync: Seconds to wait for the synchronization of all
     16                 hosts that will be launching profilers. (local_sync_profilers)
     17         @param timeout_start: Seconds to wait for each of the initial
     18                 sync_profilers and start_profilers barriers between this
     19                 host and the master to be reached.
     20         @param timeout_stop: Seconds to wait for this host and the master to
     21                 reach each of the stop_profilers and finish_profilers barriers.
     22         @param hostid: This host's id (typically the hostname).
     23         @param masterid: The master barrier host id where autoserv is running.
     24         @param all_ids: A list of all hosts to synchronize profilers on.
     25         """
     26         profilers = self.job.profilers
     27 
     28         barrier_server = barrier.listen_server(port=11920)
     29         b0 = self.job.barrier(hostid, "sync_profilers", timeout_start,
     30                               listen_server=barrier_server)
     31         b0.rendezvous_servers(masterid, hostid)
     32 
     33         b1 = self.job.barrier(hostid, "start_profilers", timeout_start,
     34                               listen_server=barrier_server)
     35         b1.rendezvous_servers(masterid, hostid)
     36 
     37         b2 = self.job.barrier(hostid, "local_sync_profilers", timeout_sync)
     38         b2.rendezvous(*all_ids)
     39 
     40         profilers.start(self)
     41 
     42         b3 = self.job.barrier(hostid, "stop_profilers", timeout_stop,
     43                               listen_server=barrier_server)
     44         b3.rendezvous_servers(masterid, hostid)
     45 
     46         profilers.stop(self)
     47         profilers.report(self)
     48 
     49         b4 = self.job.barrier(hostid, "finish_profilers", timeout_stop,
     50                               listen_server=barrier_server)
     51         b4.rendezvous_servers(masterid, hostid)
     52 
     53         barrier_server.close()
     54