Debian Codegraph @

mysql-test/suite/x/t/notice_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 sql query 'kill'
7
8 --source include/big_test.inc
9 --source include/xplugin_preamble.inc
10 --source include/xplugin_create_user.inc
11
12 ## Test case description:
13 --echo ## I. Validate that X Plugin sends kill notice on IDLE connections
14 --echo #
15 --echo # Connect multiple clients, make the IDLE, and trigger kill, validate the notice
16 --echo #
17 --echo ## II. Validate that X Plugin sends kill notice on connections that process a query
18 --echo #
19 --echo # 1. A connection is waiting for lock
20 --echo # 2. A connection is sleeping "SELECT SLEEP(A);"
21 --echo #
22 --echo ## III. Validate that X Plugin not sends kill notice on not authorized connections
23 --echo #
24 --echo
25
26 ## Test starts here
27 --let $xtest1_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_idle_connections.xpl
28 --let $xtest2_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_working.xpl
29 --let $xtest3_file= $MYSQL_TMP_DIR/kill_client_check_notices_on_not_auth_connections.xpl
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 endrepeat;
45
46
47 echo;
48 echo #;
49 echo # Killing sessions;
50
51 setsession;
52 repeat 10 %SESSION_ID%;
53 echo kill session_%SESSION_ID%;
54 quiet;
55 stmtsql SELECT id FROM information_schema.processlist WHERE command LIKE 'Sleep' AND user LIKE 'x_root' AND info LIKE "PLUGIN%" ORDER BY id;
56 recvtovar %CONNECTION_ID_TO_KILL% id;
57 KILL %CONNECTION_ID_TO_KILL%;
58 noquiet;
59 endrepeat;
60
61
62 echo;
63 echo #;
64 echo # Reciving close notices;
65
66 varlet %ER_SESSION_WAS_KILLED% 3169;
67 repeat 10 %SESSION_ID%;
68 setsession session_%SESSION_ID%;
69 callmacro Assert_notice_warning ERROR %ER_SESSION_WAS_KILLED%;
70 recvuntildisc show-received;
71 endrepeat;
72
73 EOF
74
75
76
77 --write_file $xtest2_file
78 import assert_notices.macro;
79
80 echo;
81 echo #;
82 echo # II;
83
84 CREATE TABLE test.some_table(some_column INT);
85
86 -->sql
87 DELIMITER //
88 CREATE PROCEDURE test.loop_in_sp()
89 BEGIN
90 REPEAT
91 SET @A=1;
92 UNTIL FALSE END REPEAT;
93 END
94 //
95 DELIMITER ;
96 -->endsql
97
98 echo;
99 echo #;
100 echo # Creating sessions;
101
102 newsession session_WRITE_LOCK x_root;
103 quiet;
104 stmtsql SELECT connection_id() AS Value;
105 noquiet;
106 recvtovar %connection_id_WRITE_LOCK% Value;
107 LOCK TABLE test.some_table WRITE;
108
109 newsession session_READ_LOCK x_root;
110 quiet;
111 stmtsql SELECT connection_id() AS Value;
112 noquiet;
113 recvtovar %connection_id_READ_LOCK% Value;
114 stmtsql SELECT * FROM test.some_table;
115
116 newsession session_SLEEP x_root;
117 quiet;
118 stmtsql SELECT connection_id() AS Value;
119 noquiet;
120 recvtovar %connection_id_SLEEP% Value;
121 stmtsql SELECT SLEEP(10000);
122
123 newsession session_SP x_root;
124 quiet;
125 stmtsql SELECT connection_id() AS Value;
126 noquiet;
127 recvtovar %connection_id_SP% Value;
128 stmtsql CALL test.loop_in_sp();
129
130
131 setsession;
132 quiet;
133 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";
134 noquiet;
135
136
137 echo;
138 echo #;
139 echo # Killing sessions;
140
141 setsession;
142
143 quiet;
144 KILL %connection_id_READ_LOCK%;
145 KILL %connection_id_SLEEP%;
146 KILL %connection_id_SP%;
147 KILL %connection_id_WRITE_LOCK%;
148 noquiet;
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 --write_file $xtest3_file
178 echo;
179 echo #;
180 echo # III;
181
182 echo;
183 echo #;
184 echo # Creating sessions;
185
186 repeat 10 %SESSION_ID%;
187 newsession session_noauth_%SESSION_ID% -;
188 # reciving ServerHello notice
189 recvtype Mysqlx.Notice.Frame type 5;
190 endrepeat;
191
192 echo;
193 echo #;
194 echo # Killing sessions;
195
196 setsession;
197 repeat 10 %SESSION_ID%;
198 echo kill session_noauth_%SESSION_ID%;
199 quiet;
200 stmtsql SELECT id FROM information_schema.processlist WHERE command NOT LIKE 'Killed' AND user LIKE 'unauthenticated user' AND info LIKE "PLUGIN%" ORDER BY id;
201 recvtovar %CONNECTION_ID_TO_KILL% id;
202 KILL %CONNECTION_ID_TO_KILL%;
203 noquiet;
204 endrepeat;
205
206
207 echo;
208 echo #;
209 echo # Closing connection;
210
211 repeat 10 %SESSION_ID%;
212 setsession session_noauth_%SESSION_ID%;
213 echo # `recvunitldisc` command must report disconnection without any other messages;
214 recvuntildisc show-received;
215 endrepeat;
216
217 EOF
218
219
220 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest1_file 2>&1
221 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest2_file 2>&1
222 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest3_file 2>&1
223
224
225 ## Cleanup
226 DROP TABLE test.some_table;
227 DROP PROCEDURE test.loop_in_sp;
228 --source ../include/xplugin_cleanup.inc