Debian Codegraph @

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

raw
1 ################################################################################
2 #
3 # WL#14166 - xproto: notify on connection close
4 #
5 # Verify that MySQL Server send notice trough X Protocol connections
6 # when it forces the closure at server shutdown.
7
8 --source include/xplugin_preamble.inc
9 --source include/xplugin_create_user.inc
10
11 ## Test case description:
12 --echo ## I. Validate that X Plugin sends shutdown notice on IDLE connections
13 --echo #
14 --echo # 1. Connect multiple clients, make the IDLE, and trigger restart, validate the notice
15 --echo # 2. Assert status variables after server restart (they should be set at 0)
16 --echo # 3. Assert MYSQLXTEST message counters that it saw the warning notice
17 --echo #
18 --echo ## II. Validate that X Plugin sends shutdown notice on connections that process a query
19 --echo #
20 --echo # 1. A connection is waiting for lock
21 --echo # 2. A connection is sleeping "SELECT SLEEP(A);"
22 --echo #
23 --echo ## III. Validate that X Plugin not sends shutdown notice on not authotized connections
24 --echo #
25 --echo
26
27 ## Test starts here
28 --let $xtest1_file= $MYSQL_TMP_DIR/restart_server_and_check_notices_on_idle_connections.xpl
29 --let $xtest2_file= $MYSQL_TMP_DIR/restart_server_and_check_notices_on_working.xpl
30 --let $xtest3_file= $MYSQL_TMP_DIR/restart_server_and_check_notices_on_not_auth_connections.xpl
31
32 --write_file $xtest1_file
33 import kill_and_restart.macro;
34 import assert_notices.macro;
35 import assert_status_variable.macro;
36
37 env %MYSQLADMIN% MYSQLADMIN;
38 env %MASTER_MYPORT% MASTER_MYPORT;
39
40 echo;
41 echo #;
42 echo # I.1;
43 callmacro Expect_restart_mysqld_instance 1;
44
45 repeat 10 %SESSION_ID%;
46 newsession session_%SESSION_ID% x_root;
47 endrepeat;
48
49
50 echo;
51 echo #;
52 echo # Shutting down MySQL Server;
53 system %MYSQLADMIN% -P %MASTER_MYPORT% --protocol tcp -u x_root -h localhost shutdown;
54
55 varlet %ER_SERVER_SHUTDOWN% 1053;
56
57 repeat 10 %SESSION_ID%;
58 echo session_%SESSION_ID%;
59 setsession session_%SESSION_ID%;
60 callmacro Assert_notice_warning ERROR %ER_SERVER_SHUTDOWN%;
61 recvuntildisc show-received keep-session;
62 reconnect;
63 -->endrepeat
64
65 setsession;
66 callmacro Assert_notice_warning ERROR %ER_SERVER_SHUTDOWN%;
67 recvuntildisc show-received keep-session;
68 echo # Reconnecting default session;
69 reconnect;
70
71
72 echo;
73 echo #;
74 echo # I.2;
75 # Server has restarted thus status variables on server side should be set to "0"
76 callmacro Assert_status_variable Mysqlx_notice_warning_sent 0;
77 callmacro Assert_global_status_variable Mysqlx_notice_warning_sent 0;
78
79 echo;
80 echo #;
81 echo # I.3;
82 # It can be only checked on mysqlxtest side
83 callmacro Assert_client_message_count Mysqlx.Notice.Warning == 1;
84
85 EOF
86
87 --write_file $xtest2_file
88 import kill_and_restart.macro;
89 import assert_notices.macro;
90 import assert_status_variable.macro;
91
92 env %MYSQLADMIN% MYSQLADMIN;
93 env %MASTER_MYPORT% MASTER_MYPORT;
94
95 echo;
96 echo #;
97 echo # II. Prepare;
98 CREATE TABLE test.some_table(some_column int);
99
100 -->sql
101 DELIMITER //
102 CREATE PROCEDURE test.loop_in_sp()
103 BEGIN
104 REPEAT
105 SET @A=1;
106 UNTIL FALSE END REPEAT;
107 END
108 //
109 DELIMITER ;
110 -->endsql
111
112 newsession session_WRITE_LOCK x_root;
113 LOCK TABLE test.some_table WRITE;
114
115 newsession session_READ_LOCK x_root;
116 stmtsql SELECT * FROM test.some_table;
117
118 newsession session_SLEEP x_root;
119 stmtsql SELECT SLEEP(10000);
120
121 newsession session_SP x_root;
122 stmtsql CALL test.loop_in_sp();
123
124 setsession;
125 quiet;
126 wait_for 2 SELECT count(*) FROM information_schema.processlist WHERE (state like "Waiting%" or state like "User sleep%") and user = "x_root";
127 noquiet;
128
129 echo;
130 echo #;
131 echo # Shutting down MySQL Server;
132 setsession;
133 callmacro Expect_restart_mysqld_instance 1;
134 system %MYSQLADMIN% -P %MASTER_MYPORT% --protocol tcp -u x_root -h localhost shutdown;
135
136
137 echo;
138 echo #;
139 echo # II.1;
140 varlet %ER_SERVER_SHUTDOWN% 1053;
141
142 setsession session_WRITE_LOCK;
143 callmacro Assert_notice_warning ERROR %ER_SERVER_SHUTDOWN%;
144 recvuntildisc show-received keep-session;
145 reconnect;
146
147
148 echo;
149 echo #;
150 echo # II.1;
151
152 setsession session_READ_LOCK;
153 expecterror ER_QUERY_INTERRUPTED,ER_SUCCESS;
154 recvresult be-quiet;
155 recvuntildisc show-received keep-session;
156 reconnect;
157
158
159 echo;
160 echo #;
161 echo # II.2;
162
163 setsession session_SLEEP;
164 recvresult;
165 callmacro Assert_notice_warning ERROR %ER_SERVER_SHUTDOWN%;
166 recvuntildisc show-received keep-session;
167 reconnect;
168
169
170 echo;
171 echo #;
172 echo # II.3;
173
174 setsession session_SP;
175 recvtype Mysqlx.Error code %ER_SERVER_SHUTDOWN%;
176 callmacro Assert_notice_warning ERROR %ER_SERVER_SHUTDOWN%;
177 recvuntildisc show-received keep-session;
178 reconnect;
179
180 EOF
181
182
183 --write_file $xtest3_file
184 import kill_and_restart.macro;
185 import assert_notices.macro;
186
187 env %MYSQLADMIN% MYSQLADMIN;
188 env %MASTER_MYPORT% MASTER_MYPORT;
189
190 echo;
191 echo #;
192 echo # III;
193
194 echo;
195 echo #;
196 echo # Creating sessions;
197
198 repeat 10 %SESSION_ID%;
199 newsession session_%SESSION_ID% -;
200 # reciving ServerHello notice
201 recvtype Mysqlx.Notice.Frame type 5;
202 endrepeat;
203
204
205 echo;
206 echo #
207 echo # Shutting down MySQL Server;
208 setsession;
209 callmacro Expect_restart_mysqld_instance 1;
210 system %MYSQLADMIN% -P %MASTER_MYPORT% --protocol tcp -u x_root -h localhost shutdown;
211
212
213 echo;
214 echo #;
215 echo # Closing connection and reconect;
216
217 repeat 10 %SESSION_ID%;
218 setsession session_%SESSION_ID%;
219 echo # `recvunitldisc` command must report disconnection without any other messages;
220 recvuntildisc show-received keep-session;
221 reconnect;
222 endrepeat;
223
224 setsession;
225 varlet %ER_SERVER_SHUTDOWN% 1053;
226 callmacro Assert_notice_warning ERROR %ER_SERVER_SHUTDOWN%;
227 recvuntildisc show-received keep-session;
228 echo # Reconnecting default session;
229 reconnect;
230
231 EOF
232
233
234
235 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest1_file 2>&1
236 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest2_file 2>&1
237 --exec $MYSQLXTEST -ux_root --password='' --file=$xtest3_file 2>&1
238
239 --enable_reconnect
240 --source include/wait_until_connected_again.inc
241 --disable_reconnect
242
243 ## Cleanup
244 DROP TABLE test.some_table;
245 DROP PROCEDURE test.loop_in_sp;
246 --source ../include/xplugin_cleanup.inc