Debian Codegraph @

mysql-test/suite/x/t/macros/kill_and_restart.macro

raw
1 ################################################################
2 #
3 # This file contains following restart-oriented macros:
4 #
5 # * Kill_and_restart_mysqld - SESSION_NAME MTR_EXPECT_FILE
6 # * Expect_restart_mysqld_file - MTR_EXPECT_FILE
7 # * Expect_restart_mysqld_instance - ID
8 # * Wait_for_others_are_idle - NONE
9 # * kill_client - %CLIENT_ID_TO_KILL%
10 # * kill_client_expect_error - %CLIENT_ID_TO_KILL% %ERROR_CODE%
11 #
12
13
14 ## Restart server macros
15 #
16 -->macro Kill_and_restart_mysqld %SESSION_NAME% %EXPECT_FILE%
17 echo [Killing and restarting server associated with %SESSION_NAME%];
18 quiet;
19 setsession %SESSION_NAME%;
20 callmacro Expect_restart_mysqld_file %EXPECT_FILE%;
21 quiet;
22
23 #Kill Mysqld server
24 shutdown_server 0;
25
26 #Wait for the server restart
27 reconnect;
28 -->endmacro
29
30
31 ## Make MTR to expect MySQL Server to shutdown
32 #
33 -->macro Expect_restart_mysqld_file %EXPECT_FILE%
34 system echo restart > %EXPECT_FILE%;
35 -->endmacro
36
37
38 ## Make MTR to expect MySQL Server to shutdown
39 #
40 -->macro Expect_restart_mysqld_instance %ID%
41 env %MYSQLXTEST_VARDIR% MYSQLTEST_VARDIR;
42 system echo restart > %MYSQLXTEST_VARDIR%/tmp/mysqld.%ID%.expect;
43 -->endmacro
44
45
46 # Wait for all other sql-session to be idle
47 # only the current session (that check the state) can be active
48 #
49 # This macro can be used before killing other mysqlx session
50 # to get stable status variable output.
51 #
52 -->macro Wait_for_others_are_idle
53 -->echo WAIT [count(*) information_schema.PROCESSLIST == 1 - only current process can be active]
54 wait_for 1
55 select count(*) from information_schema.PROCESSLIST where COMMAND!='Daemon' and COMMAND!='Sleep';
56 -->endmacro
57
58
59 -->macro kill_client %CLIENT_ID_TO_KILL%
60 quiet;
61 callmacro Wait_for_others_are_idle;
62
63 echo RUN [stmtadmin kill_client %CLIENT_ID_TO_KILL%];
64 -->stmtadmin kill_client {"id": %CLIENT_ID_TO_KILL% }
65 -->recvresult
66 noquiet;
67 -->endmacro
68
69
70 -->macro kill_client_expect_error %CLIENT_ID_TO_KILL% %ERROR_CODE%
71 quiet;
72 echo RUN [stmtadmin kill_client %CLIENT_ID_TO_KILL%];
73 -->stmtadmin kill_client {"id": %CLIENT_ID_TO_KILL% }
74 -->expecterror %ERROR_CODE%
75 -->recvresult
76 noquiet;
77 -->endmacro