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