blob: 81bf769852ff03dde55b2fb29871ab335353a386 [file] [log] [blame]
mblighfa29a2a2008-05-16 22:48:09 +00001#!/usr/bin/python
mbligh4a3e6972008-01-16 17:55:05 +00002#
3# Copyright 2007 Google Inc. All Rights Reserved.
4
5"""Runs profilers on a machine when no autotest job is running.
6
7This is used to profile a task when the task is running on a machine that is not
8running through autotest.
9"""
10
11__author__ = 'cranger@google.com (Colby Ranger)'
12
mblighfa29a2a2008-05-16 22:48:09 +000013import common
mblighccb9e182008-04-17 15:42:10 +000014from autotest_lib.client.common_lib import barrier
mbligh4a3e6972008-01-16 17:55:05 +000015
16
17def generate_test(machines, hostname, profilers, timeout_start, timeout_stop,
18 timeout_sync=180):
19 control_file = []
20 for profiler in profilers:
21 control_file.append("job.profilers.add(%s)"
22 % str(profiler)[1:-1]) # Remove parens
23
24 control_file.append("job.run_test('barriertest',%d,%d,%d,'%s','%s',%s)"
25 % (timeout_sync, timeout_start, timeout_stop,
26 hostname, "PROF_MASTER", str(machines)))
27
28 for profiler in profilers:
29 control_file.append("job.profilers.delete('%s')" % profiler[0])
30
31 return "\n".join(control_file)
32
33
34def wait_for_profilers(machines, timeout = 300):
35 sb = barrier.barrier("PROF_MASTER", "sync_profilers",
36 timeout, port=63100)
37 sb.rendevous_servers("PROF_MASTER", *machines)
38
39
40def start_profilers(machines, timeout = 120):
41 sb = barrier.barrier("PROF_MASTER", "start_profilers",
42 timeout, port=63100)
43 sb.rendevous_servers("PROF_MASTER", *machines)
44
45
46def stop_profilers(machines, timeout = 120):
47 sb = barrier.barrier("PROF_MASTER", "stop_profilers",
48 timeout, port=63100)
49 sb.rendevous_servers("PROF_MASTER", *machines)