Debian Codegraph @

mysql-test/suite/perfschema/t/show_coverage.test

raw
1 ################### suite/perfschema/t/show_coverage.test ######################
2 # #
3 # Testcases to increase DGCOV coverage of the status and system variable #
4 # implementation in the Performance Schema. #
5 # #
6 ################################################################################
7 # Test requires: sp-protocol/ps-protocol/view-protocol/cursor-protocol disabled
8 --source include/no_protocol.inc
9 --source include/count_sessions.inc
10
11 --echo
12 --echo # TEST 3
13 --echo # Select status and system variable tables using ORDER BY to exercise the
14 --echo # rnd_pos() method
15 --echo #
16 use performance_schema;
17 --disable_result_log
18 select * from global_variables order by variable_name;
19 select * from variables_by_thread order by variable_name;
20 select * from session_variables order by variable_name;
21 select * from global_status order by variable_name;
22 select * from session_status order by variable_name;
23 select * from status_by_thread order by variable_name;
24 select * from status_by_user order by variable_name;
25 select * from status_by_host order by variable_name;
26 select * from status_by_account order by variable_name;
27 --enable_result_log
28
29 --echo
30 --echo # TEST 4
31 --echo # Handling of SHOW STATUS/VARIABLES ... WHERE
32 --echo #
33 SHOW STATUS WHERE VARIABLE_NAME LIKE "foo";
34 --echo
35 SHOW GLOBAL STATUS WHERE VARIABLE_NAME LIKE "foo";
36 --echo
37 SHOW SESSION STATUS WHERE VARIABLE_NAME LIKE "foo";
38 --echo
39 SHOW VARIABLES WHERE VARIABLE_NAME LIKE "foo";
40 --echo
41 SHOW GLOBAL VARIABLES WHERE VARIABLE_NAME LIKE "foo";
42 --echo
43 SHOW SESSION VARIABLES WHERE VARIABLE_NAME LIKE "foo";
44
45 --echo
46 --echo # TEST 5
47 --echo # Confirm FLUSH STATUS resets counters for all threads.
48 --echo #
49 --echo
50 --echo # Create a new connection
51 --connect(con1, localhost, root,,)
52 --echo
53 --echo # Record thread id
54 let $thread_id= `SELECT THREAD_ID FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID()`;
55 --echo
56 --echo # Increase bytes_received for new connection
57 USE test;
58 SHOW TABLES;
59 --connection default
60 USE performance_schema;
61 --disable_query_log
62 eval SELECT $thread_id INTO @thread_id;
63 --enable_query_log
64
65 --echo
66 --echo # Record bytes_received for other connection
67 SELECT variable_value FROM status_by_thread
68 WHERE variable_name = "bytes_received" and thread_id = @thread_id INTO @bytes_before;
69 --echo
70 --echo # Reset status counters
71 FLUSH STATUS;
72 --echo
73 --echo # Record bytes_received after reset
74 SELECT variable_value FROM status_by_thread
75 WHERE variable_name = "bytes_received" and thread_id = @thread_id INTO @bytes_after;
76 --echo
77 --echo # Expect bytes_before > bytes_after
78 SELECT @bytes_before > @bytes_after AS 'Expect 1';
79 --echo
80 --echo # Expect bytes_after is zero
81 SELECT @bytes_after AS 'Expect 0';
82
83 disconnect con1;
84 --source include/wait_until_count_sessions.inc
85
86
87 --echo
88 --echo # TEST 6
89 --echo #
90 --echo # Bug#28291258 FLUSH STATUS ADDS TWICE TO GLOBAL VALUES
91 --echo #
92
93 --echo
94 --echo # Default connection
95 --let $initial_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
96
97 --source include/count_sessions.inc
98
99 --echo
100 --echo # First connection
101 --connect (con1, localhost, root,,)
102
103 ## Global value requested from the first session must not change
104 --let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
105 --let $assert_cond = $current_global_value - $initial_global_value = 0
106 --let $assert_text = Global value requested from the first session must not change
107 --source include/assert.inc
108
109 --echo
110 --echo # Generate a slow query
111 --echo
112 SET long_query_time = 2;
113 SELECT SLEEP(4);
114 SET long_query_time = @@global.long_query_time;
115 --echo
116
117 ## Global value requested from the first session after SLEEP() must increase by 1
118 --let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
119 --let $first_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1)
120 --let $assert_cond = $current_global_value - $initial_global_value = 1
121 --let $assert_text = Global value requested from the first session after SLEEP() must increase by 1
122 --source include/assert.inc
123 --let $assert_cond = $first_session_value = 1
124 --let $assert_text = First session value must increase by 1
125 --source include/assert.inc
126
127 --connection default
128 --disconnect con1
129 --source include/wait_until_count_sessions.inc
130
131 --echo
132 --echo # Default connection
133 --connection default
134
135 ## Global value requested from the default session after DISCONNECT must remain the same
136 --let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
137 --let $default_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1)
138 --let $assert_cond = $current_global_value - $initial_global_value = 1
139 --let $assert_text = Global value requested from the default session after DISCONNECT must remain the same
140 --source include/assert.inc
141
142 ## Default session value must remain zero
143 --let $assert_cond = $default_session_value = 0
144 --let $assert_text = Default session value must remain zero
145 --source include/assert.inc
146
147 --echo
148 FLUSH STATUS;
149 --echo
150
151 ## Global value requested from the default session after FLUSH must remain the same
152 --let $current_global_value = query_get_value(SHOW GLOBAL STATUS LIKE 'Slow_queries', Value, 1)
153 --let $default_session_value = query_get_value(SHOW SESSION STATUS LIKE 'Slow_queries', Value, 1)
154 --let $assert_cond = $current_global_value - $initial_global_value = 1
155 --let $assert_text = Global value requested from the default session after FLUSH must remain the same
156 --source include/assert.inc
157
158 ## Default session value after FLUSH must remain zero
159 --let $assert_cond = $default_session_value = 0
160 --let $assert_text = Default session value after FLUSH must remain zero
161 --source include/assert.inc
162
163