Debian Codegraph @

mysql-test/suite/ndb/t/ndbinfo_cpustat.test

raw
1 --source include/have_ndb.inc
2
3 use ndbinfo;
4
5 --echo Show view definitions
6
7 desc cpustat_50ms;
8 desc cpustat_1sec;
9 desc cpustat_20sec;
10 desc cpustat;
11
12 --echo Create temporary table for more diagnostics on failure
13 create temporary table cpustat_sum (
14 tstamp timestamp,
15 source char(20),
16 cnt int,
17 OS_user_time int,
18 OS_system_time int,
19 OS_idle_time int,
20 exec_time int,
21 sleep_time int,
22 spin_time int,
23 send_time int,
24 buffer_flule_time int,
25 elapsed_time int
26 );
27
28 --echo Check that the tables 'fill' over time if they are not
29 --echo already full
30 --disable_result_log
31 # Choose a thread
32 select @node_id:=node_id, @thr_no:=thr_no from cpustat_50ms limit 1;
33 --enable_result_log
34
35 --echo There should be no invalid lines.
36 --echo That is lines width longer duration than sampling period.
37 --echo Expect zero as result.
38
39 select count(1) as invalid_lines from cpustat_50ms
40 where node_id=@node_id and thr_no=@thr_no and
41 OS_user_time > (2 * 1 * 1000000);
42
43 select count(1) as invalid_lines from cpustat_1sec
44 where node_id=@node_id and thr_no=@thr_no and
45 OS_user_time > (2 * 20 * 1 * 1000000);
46
47 select count(1) as invalid_lines from cpustat_20sec
48 where node_id=@node_id and thr_no=@thr_no and
49 OS_user_time > (2 * 20 * 20 * 1000000);
50
51 --echo Save line counts before sleep.
52
53 select count(1) into @start_lines_50ms from cpustat_50ms
54 where node_id=@node_id and thr_no=@thr_no;
55
56 select count(1) into @start_lines_1sec from cpustat_1sec
57 where node_id=@node_id and thr_no=@thr_no;
58
59 select count(1) into @start_lines_20sec from cpustat_20sec
60 where node_id=@node_id and thr_no=@thr_no;
61
62 # Save aggregates of statistics for diagnostics on failure
63
64 insert into cpustat_sum
65 select now(), 'cpustat_50ms', count(*),
66 sum(OS_user_time), sum(OS_system_time), sum(OS_idle_time),
67 sum(exec_time), sum(sleep_time), sum(spin_time),
68 sum(send_time), sum(buffer_full_time), sum(elapsed_time)
69 from cpustat_50ms where node_id=@node_id and thr_no=@thr_no;
70
71 insert into cpustat_sum
72 select now(), 'cpustat_1sec', count(*),
73 sum(OS_user_time), sum(OS_system_time), sum(OS_idle_time),
74 sum(exec_time), sum(sleep_time), sum(spin_time),
75 sum(send_time), sum(buffer_full_time), sum(elapsed_time)
76 from cpustat_1sec where node_id=@node_id and thr_no=@thr_no;
77
78 insert into cpustat_sum
79 select now(), 'cpustat_20sec', count(*),
80 sum(OS_user_time), sum(OS_system_time), sum(OS_idle_time),
81 sum(exec_time), sum(sleep_time), sum(spin_time),
82 sum(send_time), sum(buffer_full_time), sum(elapsed_time)
83 from cpustat_20sec where node_id=@node_id and thr_no=@thr_no;
84
85 # Sleep as part of test, after sleep all cpustat should have full
86 # set of lines (20).
87
88 select now() into @sleep_start;
89
90 --sleep 40
91
92 select now() into @sleep_end;
93
94 # Save aggregates of statistics for diagnostics on failure.
95
96 insert into cpustat_sum
97 select now(), 'cpustat_50ms', count(*),
98 sum(OS_user_time), sum(OS_system_time), sum(OS_idle_time),
99 sum(exec_time), sum(sleep_time), sum(spin_time),
100 sum(send_time), sum(buffer_full_time), sum(elapsed_time)
101 from cpustat_50ms where node_id=@node_id and thr_no=@thr_no;
102
103 insert into cpustat_sum
104 select now(), 'cpustat_1sec', count(*),
105 sum(OS_user_time), sum(OS_system_time), sum(OS_idle_time),
106 sum(exec_time), sum(sleep_time), sum(spin_time),
107 sum(send_time), sum(buffer_full_time), sum(elapsed_time)
108 from cpustat_1sec where node_id=@node_id and thr_no=@thr_no;
109
110 insert into cpustat_sum
111 select now(), 'cpustat_20sec', count(*),
112 sum(OS_user_time), sum(OS_system_time), sum(OS_idle_time),
113 sum(exec_time), sum(sleep_time), sum(spin_time),
114 sum(send_time), sum(buffer_full_time), sum(elapsed_time)
115 from cpustat_20sec where node_id=@node_id and thr_no=@thr_no;
116
117 select count(1) as invalid_lines from cpustat_50ms
118 where node_id=@node_id and thr_no=@thr_no and
119 OS_user_time > (2 * 1 * 1000000);
120
121 select count(1) as invalid_lines from cpustat_1sec
122 where node_id=@node_id and thr_no=@thr_no and
123 OS_user_time > (2 * 20 * 1 * 1000000);
124
125 select count(1) as invalid_lines from cpustat_20sec
126 where node_id=@node_id and thr_no=@thr_no and
127 OS_user_time > (2 * 20 * 20 * 1000000);
128
129 --echo Save line counts after sleep.
130
131 select count(1) into @later_lines_50ms from cpustat_50ms
132 where node_id=@node_id and thr_no=@thr_no;
133
134 select count(1) into @later_lines_1sec from cpustat_1sec
135 where node_id=@node_id and thr_no=@thr_no;
136
137 select count(1) into @later_lines_20sec from cpustat_20sec
138 where node_id=@node_id and thr_no=@thr_no;
139
140 if (!`select @start_lines_50ms <= @later_lines_50ms AND
141 @start_lines_1sec <= @later_lines_1sec AND
142 @start_lines_20sec <= @later_lines_20sec AND
143 @later_lines_50ms = 20 AND
144 @later_lines_1sec = 20 AND
145 @later_lines_20sec > 1`)
146 {
147 select @start_invalid_20sec, @later_invalid_20sec,
148 TIMEDIFF(@sleep_end, @sleep_start) 'sleep 40s';
149 select * from cpustat_sum order by tstamp,source;
150 }
151
152 drop table cpustat_sum;