mbligh | fa29a2a | 2008-05-16 22:48:09 +0000 | [diff] [blame^] | 1 | #!/usr/bin/python |
mbligh | 4a3e697 | 2008-01-16 17:55:05 +0000 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2007 Google Inc. All Rights Reserved. |
| 4 | |
| 5 | """Runs profilers on a machine when no autotest job is running. |
| 6 | |
| 7 | This is used to profile a task when the task is running on a machine that is not |
| 8 | running through autotest. |
| 9 | """ |
| 10 | |
| 11 | __author__ = 'cranger@google.com (Colby Ranger)' |
| 12 | |
mbligh | fa29a2a | 2008-05-16 22:48:09 +0000 | [diff] [blame^] | 13 | import common |
mbligh | ccb9e18 | 2008-04-17 15:42:10 +0000 | [diff] [blame] | 14 | from autotest_lib.client.common_lib import barrier |
mbligh | 4a3e697 | 2008-01-16 17:55:05 +0000 | [diff] [blame] | 15 | |
| 16 | |
| 17 | def 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 | |
| 34 | def 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 | |
| 40 | def 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 | |
| 46 | def stop_profilers(machines, timeout = 120): |
| 47 | sb = barrier.barrier("PROF_MASTER", "stop_profilers", |
| 48 | timeout, port=63100) |
| 49 | sb.rendevous_servers("PROF_MASTER", *machines) |