Debian Codegraph @

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

raw
1 #
2 # Check the handling of TCP/IP connections in the performance_schema socket
3 # instance tables
4 #
5 #==============================================================================
6
7 --source ../include/wait_for_pfs_thread_count.inc
8
9 # Since within the WL#7158 a transport used for initial(default) conneciton in mt
10 # has been changed from TCP/IP to Named Pipe we disconnect the default connection
11 # and establish new default one using TCP/IP. We do it in order to support
12 # original behaviour of the test.
13 --disconnect default
14 --source include/wait_until_disconnected.inc
15 --connect (default,localhost,root,,,,)
16
17 # Set this to enable debugging output
18 let $my_socket_debug=0;
19
20 --echo #==============================================================================
21 --echo # Establish the level of IPV6 support
22 --echo #==============================================================================
23 --source ../include/socket_ipv6.inc
24
25 --echo #==============================================================================
26 --echo # Get hostname, port number
27 --echo #==============================================================================
28 SELECT @@hostname INTO @MY_HOSTNAME;
29 SELECT @@port INTO @MY_MASTER_PORT;
30
31 if ($my_socket_debug)
32 {
33 SELECT @MY_HOSTNAME AS 'Hostname';
34 SELECT @MY_MASTER_PORT AS 'Master Port';
35 }
36 #==============================================================================
37 # Utility queries
38 #==============================================================================
39 let $count_client_connections=
40 SELECT COUNT(*) INTO @my_client_connections
41 FROM performance_schema.socket_instances
42 WHERE EVENT_NAME LIKE "%client_connection%";
43
44 let $get_thread_id=
45 SELECT THREAD_ID INTO @my_thread_id
46 FROM performance_schema.threads
47 WHERE PROCESSLIST_ID = CONNECTION_ID();
48
49 let $get_object_instance_begin=
50 SELECT OBJECT_INSTANCE_BEGIN INTO @my_object_instance_begin
51 FROM performance_schema.socket_instances
52 WHERE THREAD_ID = @my_thread_id;
53
54 let $get_port=
55 SELECT PORT INTO @my_port
56 FROM performance_schema.socket_instances
57 WHERE THREAD_ID = @my_thread_id;
58
59 let $ip_localhost=
60 (IP LIKE '%127.0.0.1' OR IP LIKE '%::1');
61
62 --echo #==============================================================================
63 --echo # 1.0 Get the default connection object_instance_begin, thread id and verify
64 --echo # the expected number of client connections.
65 --echo #==============================================================================
66 --echo
67 --echo # 1.1 Confirm only one client connection
68 --echo
69 eval $count_client_connections;
70
71 if (`SELECT @my_client_connections != 1`)
72 {
73 --echo # There should be one client connection
74 SELECT * FROM performance_schema.socket_instances;
75 --echo # abort
76 exit;
77 }
78
79 --echo
80 --echo # 1.2 Get the default THREAD_ID;
81 --echo
82 eval $get_thread_id;
83 let $default_thread_id= `SELECT @my_thread_id`;
84
85 --echo
86 --echo # 1.3 Get the default OBJECT_INSTANCE_BEGIN
87 --echo
88 eval $get_object_instance_begin;
89 let $default_object_instance_begin= `SELECT @my_object_instance_begin`;
90 --disable_query_log
91 SELECT @my_object_instance_begin INTO @default_object_instance_begin;
92 --enable_query_log
93
94 if ($my_socket_debug)
95 {
96 --echo # Default object instance begin = $default_object_instance_begin
97 --echo # Default thread id = $default_thread_id
98 }
99
100 --echo #==============================================================================
101 --echo # 2.0 ESTABLISH TCP/IP CONNECTION 1
102 --echo # Connect with IP = localhost (127.0.0.1 or ::1)
103 --echo #==============================================================================
104 --disable_query_log
105 --connect (con1,$my_localhost,root,,test,,$MASTER_MYPORT)
106 --enable_query_log
107
108 --echo
109 --echo # 2.1 Get the connection thread id
110 --echo
111 eval $get_thread_id;
112
113 --echo
114 --echo # 2.2 Get the connection object instance begin
115 --echo
116 eval $get_object_instance_begin;
117
118 --echo
119 --echo # 2.3 Get the connection port
120 --echo
121 eval $get_port;
122
123 --disable_query_log
124 SELECT @my_thread_id INTO @con1_thread_id;
125 SELECT @my_port INTO @con1_port;
126 SELECT @my_object_instance_begin INTO @con1_object_id;
127 let $con1_thread_id= `SELECT @con1_thread_id`;
128 let $con1_port= `SELECT @con1_port`;
129 let $con1_object_id= `SELECT @con1_object_id`;
130 let $con1_name1= "127.0.0.1:$con1_port";
131 let $con1_name2= "::1:$con1_port";
132 --enable_query_log
133
134 if ($my_socket_debug)
135 {
136 --echo # Con1 thread id = $con1_thread_id
137 --echo # Con1 object_id = $con1_object_id
138 --echo # Con1 port = $con1_port
139 --echo # Con1 name1 = $con1_name1
140 --echo # Con1 name2 = $con1_name2
141 }
142
143 --echo
144 --echo # 2.4 Verify that the connection is 127.0.0.1 or ::1
145 --echo
146 eval SELECT COUNT(*) = 1 AS 'Expect 1'
147 FROM performance_schema.socket_instances
148 WHERE EVENT_NAME LIKE '%client_connection%'
149 AND $ip_localhost
150 AND PORT= @con1_port
151 AND OBJECT_INSTANCE_BEGIN= @con1_object_id;
152
153 --echo
154 --echo # 2.5 Verify that the same connection is in the summary instance table
155 --echo
156 eval SELECT COUNT(*) = 1 AS 'Expect 1'
157 FROM performance_schema.socket_summary_by_instance
158 WHERE EVENT_NAME LIKE '%client_connection%'
159 AND OBJECT_INSTANCE_BEGIN= @con1_object_id;
160
161 --echo
162 --echo # Switch to connection default
163 --echo
164 --connection default
165
166 --echo #==============================================================================
167 --echo # 3.0 ESTABLISH TCP/IP CONNECTION 2
168 --echo # Connect with IP = localhost (127.0.0.1 or ::1)
169 --echo #==============================================================================
170 --disable_query_log
171 --connect (con2,$my_localhost,root,,test,,$MASTER_MYPORT)
172 --enable_query_log
173
174 --echo
175 --echo # 3.1 Get the connection thread id
176 --echo
177 eval $get_thread_id;
178
179 --echo
180 --echo # 3.2 Get the connection object instance begin
181 --echo
182 eval $get_object_instance_begin;
183
184 --echo
185 --echo # 3.3 Get the connection port
186 --echo
187 eval $get_port;
188
189 --disable_query_log
190 SELECT @my_thread_id INTO @con2_thread_id;
191 SELECT @my_port INTO @con2_port;
192 SELECT @my_object_instance_begin INTO @con2_object_id;
193 let $con2_thread_id= `SELECT @con2_thread_id`;
194 let $con2_port= `SELECT @con2_port`;
195 let $con2_object_id= `SELECT @con2_object_id`;
196 let $con2_name1= "127.0.0.1:$con2_port";
197 let $con2_name2= "::1:$con2_port";
198 --enable_query_log
199
200 if ($my_socket_debug)
201 {
202 --echo # con2 thread id = $con2_thread_id
203 --echo # con2 object_id = $con2_object_id
204 --echo # con2 port = $con2_port
205 --echo # con2 name1 = $con2_name1
206 --echo # con2 name2 = $con2_name2
207 }
208
209 --echo
210 --echo # 3.4 Verify that the connection is 127.0.0.1 or ::1
211 --echo
212
213 eval SELECT COUNT(*) = 1 AS 'Expect 1'
214 FROM performance_schema.socket_instances
215 WHERE EVENT_NAME LIKE '%client_connection%'
216 AND $ip_localhost
217 AND PORT= @con2_port
218 AND OBJECT_INSTANCE_BEGIN= @con2_object_id;
219
220 --echo
221 --echo # 3.5 Verify that the same connection is in the summary instance table
222 --echo
223 eval SELECT COUNT(*) = 1 AS 'Expect 1'
224 FROM performance_schema.socket_summary_by_instance
225 WHERE EVENT_NAME LIKE '%client_connection%'
226 AND OBJECT_INSTANCE_BEGIN= @con2_object_id;
227
228 --echo
229 --echo # 3.6 Verify that the connection is 127.0.0.1 or ::1
230 --echo
231 eval SELECT COUNT(*) = 1 AS 'Expect 1'
232 FROM performance_schema.socket_instances
233 WHERE EVENT_NAME LIKE '%client_connection%'
234 AND $ip_localhost
235 AND PORT= @con2_port
236 AND OBJECT_INSTANCE_BEGIN= @con2_object_id;
237
238 --echo #==============================================================================
239 --echo # 4.0 Verify both connections exist in the instance tables
240 --echo #==============================================================================
241 --connection default
242
243 --echo
244 --echo # 4.1 Verify that there are two TCP/IP connections in the socket instance table
245 --echo
246 eval SELECT COUNT(*) = 2 AS 'Expect 1'
247 FROM performance_schema.socket_instances
248 WHERE EVENT_NAME LIKE '%client_connection%'
249 AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
250 AND $ip_localhost;
251
252 --echo
253 --echo # 4.2 Verify that there are two TCP/IP connections in the summary instance table
254 --echo
255 eval SELECT COUNT(*) = 2 AS 'Expect 1'
256 FROM performance_schema.socket_summary_by_instance
257 WHERE EVENT_NAME LIKE '%client_connection%'
258 AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
259
260 --echo #==============================================================================
261 --echo # 5.0 Drop the client connections
262 --echo #==============================================================================
263
264 --echo # 5.1 Disconnect con1
265 --connection con1
266 --disconnect con1
267 --source include/wait_until_disconnected.inc
268
269 --echo # 5.2 Disconnect con2
270 --connection con2
271 --disconnect con2
272 --source include/wait_until_disconnected.inc
273 --connection default
274
275 --echo #==============================================================================
276 --echo # 6.0 Verify sockets were removed from the instance tables
277 --echo #==============================================================================
278
279 --echo
280 --echo # 6.1 Verify that there are no TCP/IP connections in the socket instance table
281 --echo
282 eval SELECT COUNT(*) = 0 AS 'Expect 1'
283 FROM performance_schema.socket_instances
284 WHERE EVENT_NAME LIKE '%client_connection%'
285 AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin
286 AND $ip_localhost;
287
288 --echo
289 --echo # 6.2 Verify that there are no TCP/IP connections in the summary instance table
290 --echo
291 eval SELECT COUNT(*) = 0 AS 'Expect 1'
292 FROM performance_schema.socket_summary_by_instance
293 WHERE EVENT_NAME LIKE '%client_connection%'
294 AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin;
295
296 exit;