Debian Codegraph @

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

raw
1 #
2 # Some functional checks for the content of performance_schema.socket_instances.
3 #
4
5 --source include/windows.inc
6
7 # Set this to enable debugging output
8 let $my_socket_debug= 0;
9
10 #
11 # Set IP address defaults with respect to IPV6 support
12 #
13
14 # Determine if IPV6 supported
15 let $check_ipv6_just_check= 1;
16 --source include/check_ipv6.inc
17
18 # Determine if IPV4 mapped to IPV6 supported
19 let $check_ipv4_mapped_just_check= 1;
20 --source include/check_ipv4_mapped.inc
21
22 --source include/add_extra_root_users.inc
23
24 let $my_localhost= 127.0.0.1;
25
26 if($check_ipv6_supported)
27 {
28 let $my_localhost= ::1;
29 }
30
31 if($check_ipv4_mapped_supported)
32 {
33 let $my_localhost= ::ffff:127.0.0.1;
34 }
35
36 if($my_socket_debug)
37 {
38 --echo IPV6=$check_ipv6_supported, IPV4_MAPPED=$check_ipv4_mapped_supported, LOCALHOST=$my_localhost
39 }
40
41 #
42 # Preserve the current state of SOCKET_INSTANCES
43 #
44
45 --echo # Take a snapshot of SOCKET_INSTANCES
46 CREATE TEMPORARY TABLE my_socket_instances AS
47 SELECT * FROM performance_schema.socket_instances;
48
49 --echo # Get thread id of the default connection
50 SELECT THREAD_ID INTO @thread_id
51 FROM performance_schema.threads
52 WHERE PROCESSLIST_ID = CONNECTION_ID();
53
54 let $con0_thread_id= `SELECT @thread_id`;
55
56 #
57 # ESTABLISH TCP/IP CONNECTION 1
58 #
59 # Start connection with IP = localhost (127.0.0.1 or ::1)
60
61 --echo # Establish local TCP/IP connection (con1,localhost,root,,test,,)
62 --disable_query_log
63 --connect (con1,$my_localhost,root,,test,,$MASTER_MYPORT)
64 --enable_query_log
65
66 if($my_socket_debug)
67 {
68 # --replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
69 SELECT * FROM performance_schema.socket_instances;
70 }
71
72 --echo # Store the thread id of connection 1 (tcp/ip)
73 SELECT THREAD_ID INTO @thread_id
74 FROM performance_schema.threads
75 WHERE PROCESSLIST_ID = CONNECTION_ID();
76
77 --echo # Store the port of connection 1 (tcp/ip)
78 eval SELECT PORT INTO @port
79 FROM performance_schema.socket_instances
80 WHERE THREAD_ID = @thread_id;
81
82 let $con1_thread_id= `SELECT @thread_id`;
83 let $con1_port= `SELECT @port`;
84
85 --echo # Switch to connection default
86 --connection default
87
88 #
89 # ESTABLISH TCP/IP CONNECTION 2
90 #
91 # Start a second connection with IP = localhost (127.0.0.1 or ::1)
92
93 --echo # Establish second local TCP/IP connection (con1,localhost,root,,test,,)
94 --disable_query_log
95 --connect (con2,$my_localhost,root,,test,,$MASTER_MYPORT)
96 --enable_query_log
97
98 if($my_socket_debug)
99 {
100 # --replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
101 SELECT * FROM performance_schema.socket_instances;
102 }
103
104 --echo # Store the thread_id of connection 2 (tcp/ip)
105 SELECT THREAD_ID INTO @thread_id
106 FROM performance_schema.threads
107 WHERE PROCESSLIST_ID = CONNECTION_ID();
108
109 --echo # Store the port of connection 2 (tcp/ip)
110 eval SELECT PORT INTO @port
111 FROM performance_schema.socket_instances
112 WHERE THREAD_ID = @thread_id;
113
114 let $con2_thread_id= `SELECT @thread_id`;
115 let $con2_port = `SELECT @port`;
116
117 --echo # Switch to connection default
118 --connection default
119
120 #
121 # VERIFY EVENT NAMES
122 #
123
124 --echo # EVENT_NAME is the "wait/io/socket/*" instrument identifier.
125
126 SELECT COUNT(*) = 0 AS "Expect 1"
127 FROM performance_schema.socket_instances
128 WHERE EVENT_NAME NOT LIKE 'wait/io/socket/%';
129
130 #
131 # VERIFY UNIQUE EVENT IDs
132 #
133
134 --echo # OBJECT_INSTANCE_BEGIN is an arbitrary identifier, guaranteed to be unique.
135
136 SELECT COUNT(*) = COUNT(DISTINCT OBJECT_INSTANCE_BEGIN) AS "Expect 1"
137 FROM performance_schema.socket_instances;
138
139 #
140 # VERIFY UNIQUE SOCKET ID
141 #
142
143 --echo # SOCKET_ID is the internal file handle assigned to the socket.
144
145 SELECT COUNT(*) = COUNT(DISTINCT SOCKET_ID) AS "Expect 1"
146 FROM performance_schema.socket_instances;
147
148 #
149 # VERIFY UNIQUE THREAD IDs
150 #
151
152 --echo # Characteristics per our thread
153 --echo # There must be only one entry with our thread_id
154
155 --disable_query_log
156 eval SET @thread_id= $con1_thread_id;
157 --enable_query_log
158
159 eval SELECT COUNT(*) = 1 AS 'Expect 1'
160 FROM performance_schema.socket_instances
161 WHERE THREAD_ID = @thread_id;
162
163 #
164 # VERIFY UNIQUE PORT NUMBERS FOR TCP/IP CLIENTS
165 #
166
167 --echo # TCP/IP connections should have a unique port number
168 --disable_query_log
169 eval SET @port= $con1_port;
170 --enable_query_log
171
172 --echo # Connection 1 (tcp/ip)
173 eval SELECT COUNT(*) = 1 AS 'Expect 1'
174 FROM performance_schema.socket_instances
175 WHERE PORT = @port;
176
177 --disable_query_log
178 eval SET @port= $con2_port;
179 --enable_query_log
180
181 --echo # Connection 2 (tcp/ip)
182 eval SELECT COUNT(*) = 1 AS 'Expect 1'
183 FROM performance_schema.socket_instances
184 WHERE PORT = @port;
185
186 #
187 # VERIFY CONNECTION DETAILS FOR THE DEFAULT CONNECTION
188 #
189
190 --echo # Check the content for the default connection (tcpip)
191 # EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
192 # wait/io/socket/sql/client_connection 26139912 16 907296 127.0.0.1 2631 ACTIVE
193
194 --disable_query_log
195 eval SET @thread_id = $con1_thread_id;
196 --enable_query_log
197
198 SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
199 AND (IP LIKE '%127.0.0.1' OR IP = '::1') AS 'Expect 1'
200 FROM performance_schema.socket_instances
201 WHERE THREAD_ID = @thread_id;
202
203 #
204 # VERIFY SERVER LISTENING SOCKET, TCP/IP
205 #
206
207 --echo # Characteristics of 'server_tcpip_socket' entry
208 --echo # Server listening socket, TCP/IP
209 --echo # There is only one entry with 'wait/io/socket/sql/server_tcpip_socket'.
210 --echo # It shares the same thread id as 'wait/io/socket/sql/server_unix_socket'.
211
212 SELECT COUNT(*) = 1 AS 'Expect 1'
213 FROM performance_schema.socket_instances
214 WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
215
216 # Store the thread id of server_tcpip_socket
217 --echo # Get the 'server_tcpip_socket' thread id
218
219 SELECT THREAD_ID INTO @thread_id
220 FROM performance_schema.socket_instances
221 WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
222
223 let $server_tcpip_thread_id= `SELECT @thread_id`;
224
225 --echo # Check the content.
226 --disable_query_log
227 eval SET @port = $MASTER_MYPORT;
228 --enable_query_log
229
230 eval SELECT THREAD_ID = @thread_id
231 AND (IP = '0.0.0.0' OR IP = '::')
232 AND PORT = @port
233 AND STATE = 'ACTIVE' AS 'Expect 1'
234 FROM performance_schema.socket_instances
235 WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket';
236
237 #
238 # VERIFY TCP/IP CLIENT CONNECTION 1
239 #
240
241 # EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
242 # wait/io/socket/sql/client_connection 140707865187120 18 59 127.0.0.1 59298 IDLE or ACTIVE
243
244 --echo # Check content for client connection 1 (tcpip)
245
246 --disable_query_log
247 eval SET @port = $con1_port;
248 eval SET @thread_id = $con1_thread_id;
249 eval SET @addr = '$my_localhost';
250 --enable_query_log
251
252 eval SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
253 AND (IP LIKE '%127.0.0.1' OR IP = '::1')
254 AND PORT = @port
255 AS 'Expect 1'
256 FROM performance_schema.socket_instances
257 WHERE THREAD_ID = @thread_id;
258
259 --echo # Characteristics of entries with THREAD_ID of con1
260 --echo # There is only one entry with this id.
261
262 eval SELECT COUNT(*) = 1 AS 'Expect 1'
263 FROM performance_schema.socket_instances
264 WHERE THREAD_ID = @thread_id;
265
266 #
267 # VERIFY TCP/IP CLIENT CONNECTION 2
268 #
269
270 # EVENT_NAME OBJECT_INSTANCE_BEGIN THREAD_ID SOCKET_ID IP PORT STATE
271 # wait/io/socket/sql/client_connection 140707865187120 18 59 127.0.0.1 59298 IDLE or ACTIVE
272
273 --echo # Check content for client connection 2 (tcpip)
274
275 --disable_query_log
276 eval SET @port = $con2_port;
277 eval SET @thread_id = $con2_thread_id;
278 eval SET @addr = '$my_localhost';
279 --enable_query_log
280
281 eval SELECT EVENT_NAME = 'wait/io/socket/sql/client_connection'
282 AND (IP LIKE '%127.0.0.1' OR IP = '::1')
283 AND PORT = @port
284 AS 'Expect 1'
285 FROM performance_schema.socket_instances
286 WHERE THREAD_ID = @thread_id;
287
288 --echo # Characteristics of entries with THREAD_ID of con2
289 --echo # There is only one entry with this id.
290
291 eval SELECT COUNT(*) = 1 AS 'Expect 1'
292 FROM performance_schema.socket_instances
293 WHERE THREAD_ID = @thread_id;
294
295 #
296 # LIST CLIENT CONNECTIONS
297 #
298
299 --echo # Show differences to socket_instances before con1, con2 and con3 connecting
300 let $part=
301 FROM performance_schema.socket_instances
302 WHERE (EVENT_NAME,OBJECT_INSTANCE_BEGIN,THREAD_ID,SOCKET_ID,IP,PORT,STATE)
303 NOT IN (SELECT EVENT_NAME,OBJECT_INSTANCE_BEGIN,THREAD_ID,SOCKET_ID,IP,PORT,STATE
304 FROM my_socket_instances)
305 ORDER BY THREAD_ID;
306 --replace_result '::ffff:127.0.0.1' <LOCALHOST> '127.0.0.1' <LOCALHOST> '::1' <LOCALHOST> '::' <BINDADDR> '0.0.0.0' <BINDADDR>
307 eval
308 SELECT EVENT_NAME, IP
309 $part;
310
311 --connection default
312
313 #
314 # DROP CLIENT CONNECTIONS
315 #
316
317 --echo # Disconnect con1 and con2
318 --connection con1
319 --disconnect con1
320 --source include/wait_until_disconnected.inc
321 --connection con2
322 --disconnect con2
323 --source include/wait_until_disconnected.inc
324 --connection default
325
326 #
327 # VERIFY CONNECTIONS DROPPED
328 #
329
330 --echo # After waiting a bit we should have no differences to socket_instances
331 --echo # before con1, con2 connecting.
332 let $wait_timeout= 10;
333 let $wait_condition= SELECT COUNT(*) = 0 $part;
334 --source include/wait_condition.inc
335 #
336 eval
337 SELECT *
338 $part;
339
340 --source include/remove_extra_root_users.inc