blob: 42f32f22bb19dbac1064b52c151ac47b9588e3f7 [file] [log] [blame]
mblighe1417fa2007-12-10 16:55:13 +00001import time
2
3ssh_hosts = [hosts.SSHHost(m, initialize=False) for m in machines]
4at_hosts = [autotest.Autotest(h) for h in ssh_hosts]
5
6
7def add_profilers(at, profilers, timeout_sync, timeout_start, timeout_stop,
jadmanski0afbb632008-06-06 21:10:57 +00008 machines, name):
9 control_file = []
10 for profiler in profilers:
11 control_file.append("job.profilers.add(%s)"
12 % str(profiler)[1:-1])
mblighe1417fa2007-12-10 16:55:13 +000013
jadmanski0afbb632008-06-06 21:10:57 +000014 control_file.append("job.run_test('barriertest',%d,%d,%d,'%s','%s',%s)"
15 % (timeout_sync, timeout_start, timeout_stop,
16 at.host.hostname, "PROF_MASTER", str(machines)))
mblighe1417fa2007-12-10 16:55:13 +000017
jadmanski0afbb632008-06-06 21:10:57 +000018 for profiler in profilers:
19 control_file.append("job.profilers.delete('%s')" % profiler[0])
mblighe1417fa2007-12-10 16:55:13 +000020
jadmanski0afbb632008-06-06 21:10:57 +000021 params = ["\n".join(control_file), "profile-" + profiler[0], at.host]
22 return subcommand(at.run, params, name)
mblighe1417fa2007-12-10 16:55:13 +000023
24
mblighe74782b2008-01-03 01:58:17 +000025def wait_for_profilers(machines, timeout = 180):
jadmanski0afbb632008-06-06 21:10:57 +000026 # wait until the profilers have started
27 sync_bar = barrier("PROF_MASTER", "sync_profilers",
28 timeout, port=63100)
29 sync_bar.rendevous_servers("PROF_MASTER", *machines)
mblighe74782b2008-01-03 01:58:17 +000030
31
32def start_profilers(machines, timeout = 180):
jadmanski0afbb632008-06-06 21:10:57 +000033 # wait until the profilers have started
34 start_bar = barrier("PROF_MASTER", "start_profilers",
35 timeout, port=63100)
36 start_bar.rendevous_servers("PROF_MASTER", *machines)
mblighe1417fa2007-12-10 16:55:13 +000037
38
39def stop_profilers(machines, timeout = 120):
jadmanski0afbb632008-06-06 21:10:57 +000040 stop_bar = barrier("PROF_MASTER", "stop_profilers", timeout, port=63100)
41 stop_bar.rendevous_servers("PROF_MASTER", *machines)
mblighe1417fa2007-12-10 16:55:13 +000042
43
44def server_sleep_test(seconds):
jadmanski0afbb632008-06-06 21:10:57 +000045 wait_for_profilers(machines)
46 start_profilers(machines)
47 for i in range(seconds):
48 print "%d of %d" % (i, seconds)
49 time.sleep(1)
50 stop_profilers(machines)
mblighe1417fa2007-12-10 16:55:13 +000051
52
53def main():
jadmanski0afbb632008-06-06 21:10:57 +000054 timeout_sync = 180
55 timeout_start = 60
56 timeout_stop = 60
57 profilers = [["vmstat"], ["iostat"]]
mblighe1417fa2007-12-10 16:55:13 +000058
jadmanski0afbb632008-06-06 21:10:57 +000059 tests = [subcommand(server_sleep_test, [20], "server_sleep_test")]
60 for at in at_hosts:
61 name = "profiled-%s" % at.host.hostname
62 tests.append(add_profilers(at, profilers, timeout_sync,
63 timeout_start, timeout_stop, machines, name))
64 parallel(tests)
mblighe1417fa2007-12-10 16:55:13 +000065
66
67main()