blob: 5cd7d893944edfbc2271434df303fc2f4a4f7127 [file] [log] [blame]
mblighe1417fa2007-12-10 16:55:13 +00001#!/usr/bin/python2.4
2# -*- mode: python; -*-
3
4import time
5
6ssh_hosts = [hosts.SSHHost(m, initialize=False) for m in machines]
7at_hosts = [autotest.Autotest(h) for h in ssh_hosts]
8
9
10def 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
28def wait_for_profilers(machines, timeout = 600):
29 # wait until the profilers have started
mbligh6b504ff2007-12-12 21:03:49 +000030 start_bar = barrier("PROF_MASTER", "start_profilers",
31 timeout, port=63100)
mblighe1417fa2007-12-10 16:55:13 +000032 start_bar.rendevous_servers("PROF_MASTER", *machines)
33
34
35def stop_profilers(machines, timeout = 120):
mbligh6b504ff2007-12-12 21:03:49 +000036 stop_bar = barrier("PROF_MASTER", "stop_profilers", timeout, port=63100)
mblighe1417fa2007-12-10 16:55:13 +000037 stop_bar.rendevous_servers("PROF_MASTER", *machines)
38
39
40def 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
48def 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
62main()