Debian Codegraph @

mysql-test/suite/x/t/notice_admin_kill.test

raw
1 ################################################################################
2 #
3 # WL#14166 - xproto: notify on connection close
4 #
5 ## Verify that MySQL Server send notice on X Protocol connections
6 ## when it forces to close by admin command 'kill_client'
7
8 --source include/xplugin_preamble.inc
9 --source include/xplugin_create_user.inc
10
11 ## Test starts here
12 --let $xtest1_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_idle_connections.xpl
13 --let $xtest2_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_working.xpl
14 --let $xtest3_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_not_auth_connections.xpl
15
16 ## Test case description:
17 --echo ## I. Validate that X Plugin sends kill notice on IDLE connections
18 --echo #
19 --echo # Connect multiple clients, make the IDLE, and trigger kill, validate the notice
20 --echo #
21 --echo ## II. Validate that X Plugin sends kill notice on connections that process a query
22 --echo #
23 --echo # 1. A connection is waiting for lock
24 --echo # 2. A connection is sleeping "SELECT SLEEP(A);"
25 --echo #
26 --echo ## III. Validate that X Plugin not sends kill notice on not authorized connections
27 --echo #
28 --echo
29
30
31 --write_file $xtest1_file
32 import assert_notices.macro;
33
34 echo;
35 echo #;
36 echo # I;
37
38 echo;
39 echo #;
40 echo # Creating sessions;
41
42 repeat 10 %SESSION_ID%;
43 newsession session_%SESSION_ID% x_root;
44 quiet;
45 INSERT INTO test.client VALUES('session_%SESSION_ID%', %ACTIVE_CLIENT_ID%);
46 noquiet;
47 endrepeat;
48
49
50 echo;
51 echo #;
52 echo # Killing sessions;
53
54 setsession;
55 repeat 10 %SESSION_ID%;
56 echo kill session_%SESSION_ID%;
57 quiet;
58 stmtsql SELECT client_id AS Value FROM test.client WHERE session_id = 'session_%SESSION_ID%';
59 noquiet;
60 recvtovar %CLIENT_ID_TO_KILL% Value;
61 stmtadmin kill_client {"id": %CLIENT_ID_TO_KILL% };
62 recvresult;
63 endrepeat;
64
65
66 echo;
67 echo #;
68 echo # Reciving close notices;
69
70 varlet %ER_SESSION_WAS_KILLED% 3169;
71
72 repeat 10 %SESSION_ID%;
73 setsession session_%SESSION_ID%;
74 callmacro Assert_notice_warning ERROR %ER_SESSION_WAS_KILLED%;
75 recvuntildisc show-received;
76 endrepeat;
77
78 EOF
79
80
81
82 --write_file $xtest2_file
83 import assert_notices.macro;
84
85 echo;
86 echo #;
87 echo # II;
88
89 CREATE TABLE test.some_table(some_column INT);
90
91 -->sql
92 DELIMITER //
93 CREATE PROCEDURE test.loop_in_sp()
94 BEGIN
95 REPEAT
96 SET @A=1;
97 UNTIL FALSE END REPEAT;
98 END
99 //
100 DELIMITER ;
101 -->endsql
102
103
104 echo;
105 echo #;
106 echo # Creating sessions;
107
108 newsession session_WRITE_LOCK x_root;
109 varlet %client_id_WRITE_LOCK% %ACTIVE_CLIENT_ID%;
110 LOCK TABLE test.some_table WRITE;
111
112 newsession session_READ_LOCK x_root;
113 varlet %client_id_READ_LOCK% %ACTIVE_CLIENT_ID%;
114 stmtsql SELECT * FROM test.some_table;
115
116 newsession session_SLEEP x_root;
117 varlet %client_id_SLEEP% %ACTIVE_CLIENT_ID%;
118 stmtsql SELECT SLEEP(10000);
119
120 newsession session_SP x_root;
121 varlet %client_id_SP% %ACTIVE_CLIENT_ID%;
122 stmtsql CALL test.loop_in_sp();
123
124
125 setsession;
126 quiet;
127 wait_for 3 SELECT count(*) FROM information_schema.processlist WHERE (state like "Waiting%" or state like "User sleep%" or state like 'closing tables%') and user = "x_root";
128 noquiet;
129
130
131 echo;
132 echo #;
133 echo # Killing sessions;
134
135 setsession;
136
137 stmtadmin kill_client {"id": %client_id_READ_LOCK% };
138 recvresult;
139
140 stmtadmin kill_client {"id": %client_id_SLEEP% };
141 recvresult;
142
143 stmtadmin kill_client {"id": %client_id_SP% };
144 recvresult;
145
146 stmtadmin kill_client {"id": %client_id_WRITE_LOCK% };
147 recvresult;
148
149
150 echo;
151 echo #;
152 echo # Reciving close notices;
153
154 varlet %ER_SESSION_WAS_KILLED% 3169;
155 varlet %ER_QUERY_INTERRUPTED% 1317;
156
157 setsession session_WRITE_LOCK;
158 callmacro Assert_notice_warning ERROR %ER_SESSION_WAS_KILLED%;
159 recvuntildisc show-received;
160
161 setsession session_READ_LOCK;
162 recvtype Mysqlx.Error code %ER_QUERY_INTERRUPTED%;
163 recvuntildisc show-received;
164
165 setsession session_SLEEP;
166 recvresult;
167 callmacro Assert_notice_warning ERROR %ER_SESSION_WAS_KILLED%;
168 recvuntildisc show-received;
169
170 setsession session_SP;
171 recvtype Mysqlx.Error code %ER_QUERY_INTERRUPTED%;
172 recvuntildisc show-received;
173
174 EOF
175
176
177
178 --write_file $xtest3_file
179 echo;
180 echo #;
181 echo # III;
182
183 echo;
184 echo #;
185 echo # Creating sessions;
186
187 varlet %CLIENT_ID% %ACTIVE_CLIENT_ID%;
188
189 repeat 10 %SESSION_ID%;
190 newsession session_noauth_%SESSION_ID% -;
191 # reciving ServerHello notice
192 recvtype Mysqlx.Notice.Frame type 5;
193 varinc %CLIENT_ID% 1;
194 setsession;
195 quiet;
196 INSERT INTO test.client VALUES('session_noauth_%SESSION_ID%', %CLIENT_ID%);
197 noquiet;
198 endrepeat;
199
200 echo;
201 echo #;
202 echo # Killing sessions;
203
204 setsession;
205 repeat 10 %SESSION_ID%;
206 echo kill session_noauth_%SESSION_ID%;
207 quiet;
208 stmtsql SELECT client_id AS Value FROM test.client WHERE session_id = 'session_noauth_%SESSION_ID%';
209 noquiet;
210 recvtovar %CLIENT_ID_TO_KILL% Value;
211 stmtadmin kill_client {"id": %CLIENT_ID_TO_KILL% };
212 recvresult;
213 endrepeat;
214
215
216 echo;
217 echo #;
218 echo # Closing connection;
219
220 repeat 10 %SESSION_ID%;
221 setsession session_noauth_%SESSION_ID%;
222 echo # `recvunitldisc` command must report disconnection without any other messages;
223 recvuntildisc show-received;
224 endrepeat;
225
226 EOF
227
228
229
230 CREATE TABLE test.client(session_id VARCHAR(32), client_id INT);
231
232 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest1_file 2>&1
233 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest2_file 2>&1
234 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest3_file 2>&1
235
236
237 ## Cleanup
238 DROP TABLE test.client;
239 DROP TABLE test.some_table;
240 DROP PROCEDURE test.loop_in_sp;
241 --source ../include/xplugin_cleanup.inc