blob: 2c7969ad1b8a65d64aab414c637cc2c90f1a4712 [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
mblighe74782b2008-01-03 01:58:17 +000028def wait_for_profilers(machines, timeout = 180):
29 # wait until the profilers have started
30 sync_bar = barrier("PROF_MASTER", "sync_profilers",
31 timeout, port=63100)
32 sync_bar.rendevous_servers("PROF_MASTER", *machines)
33
34
35def start_profilers(machines, timeout = 180):
mblighe1417fa2007-12-10 16:55:13 +000036 # wait until the profilers have started
mbligh6b504ff2007-12-12 21:03:49 +000037 start_bar = barrier("PROF_MASTER", "start_profilers",
38 timeout, port=63100)
mblighe1417fa2007-12-10 16:55:13 +000039 start_bar.rendevous_servers("PROF_MASTER", *machines)
40
41
42def stop_profilers(machines, timeout = 120):
mbligh6b504ff2007-12-12 21:03:49 +000043 stop_bar = barrier("PROF_MASTER", "stop_profilers", timeout, port=63100)
mblighe1417fa2007-12-10 16:55:13 +000044 stop_bar.rendevous_servers("PROF_MASTER", *machines)
45
46
47def server_sleep_test(seconds):
48 wait_for_profilers(machines)
mblighe74782b2008-01-03 01:58:17 +000049 start_profilers(machines)
mblighe1417fa2007-12-10 16:55:13 +000050 for i in range(seconds):
51 print "%d of %d" % (i, seconds)
52 time.sleep(1)
53 stop_profilers(machines)
54
55
56def main():
mblighe74782b2008-01-03 01:58:17 +000057 timeout_sync = 180
mblighe1417fa2007-12-10 16:55:13 +000058 timeout_start = 60
59 timeout_stop = 60
60 profilers = [["vmstat"], ["iostat"]]
61
62 tests = [subcommand(server_sleep_test, [20], "server_sleep_test")]
63 for at in at_hosts:
64 name = "profiled-%s" % at.host.hostname
65 tests.append(add_profilers(at, profilers, timeout_sync,
66 timeout_start, timeout_stop, machines, name))
67 parallel(tests)
68
69
70main()