mbligh | e1417fa | 2007-12-10 16:55:13 +0000 | [diff] [blame] | 1 | #!/usr/bin/python2.4 |
| 2 | # -*- mode: python; -*- |
| 3 | |
| 4 | import time |
| 5 | |
| 6 | ssh_hosts = [hosts.SSHHost(m, initialize=False) for m in machines] |
| 7 | at_hosts = [autotest.Autotest(h) for h in ssh_hosts] |
| 8 | |
| 9 | |
| 10 | def add_profilers(at, profilers, timeout_sync, timeout_start, timeout_stop, |
| 11 | machines, name): |
| 12 | control_file = [] |
| 13 | for profiler in profilers: |
| 14 | control_file.append("job.profilers.add(%s)" |
| 15 | % str(profiler)[1:-1]) |
| 16 | |
| 17 | control_file.append("job.run_test('barriertest',%d,%d,%d,'%s','%s',%s)" |
| 18 | % (timeout_sync, timeout_start, timeout_stop, |
| 19 | at.host.hostname, "PROF_MASTER", str(machines))) |
| 20 | |
| 21 | for profiler in profilers: |
| 22 | control_file.append("job.profilers.delete('%s')" % profiler[0]) |
| 23 | |
| 24 | params = ["\n".join(control_file), "profile-" + profiler[0], at.host] |
| 25 | return subcommand(at.run, params, name) |
| 26 | |
| 27 | |
| 28 | def wait_for_profilers(machines, timeout = 600): |
| 29 | # wait until the profilers have started |
mbligh | 6b504ff | 2007-12-12 21:03:49 +0000 | [diff] [blame] | 30 | start_bar = barrier("PROF_MASTER", "start_profilers", |
| 31 | timeout, port=63100) |
mbligh | e1417fa | 2007-12-10 16:55:13 +0000 | [diff] [blame] | 32 | start_bar.rendevous_servers("PROF_MASTER", *machines) |
| 33 | |
| 34 | |
| 35 | def stop_profilers(machines, timeout = 120): |
mbligh | 6b504ff | 2007-12-12 21:03:49 +0000 | [diff] [blame] | 36 | stop_bar = barrier("PROF_MASTER", "stop_profilers", timeout, port=63100) |
mbligh | e1417fa | 2007-12-10 16:55:13 +0000 | [diff] [blame] | 37 | stop_bar.rendevous_servers("PROF_MASTER", *machines) |
| 38 | |
| 39 | |
| 40 | def server_sleep_test(seconds): |
| 41 | wait_for_profilers(machines) |
| 42 | for i in range(seconds): |
| 43 | print "%d of %d" % (i, seconds) |
| 44 | time.sleep(1) |
| 45 | stop_profilers(machines) |
| 46 | |
| 47 | |
| 48 | def main(): |
| 49 | timeout_sync = 600 |
| 50 | timeout_start = 60 |
| 51 | timeout_stop = 60 |
| 52 | profilers = [["vmstat"], ["iostat"]] |
| 53 | |
| 54 | tests = [subcommand(server_sleep_test, [20], "server_sleep_test")] |
| 55 | for at in at_hosts: |
| 56 | name = "profiled-%s" % at.host.hostname |
| 57 | tests.append(add_profilers(at, profilers, timeout_sync, |
| 58 | timeout_start, timeout_stop, machines, name)) |
| 59 | parallel(tests) |
| 60 | |
| 61 | |
| 62 | main() |