| 1 |
## This is test file for connection authentication using mysqlx. |
| 2 |
## |
| 3 |
--source include/restart_mysqld.inc |
| 4 |
|
| 5 |
--source include/xplugin_preamble.inc |
| 6 |
--source include/xplugin_create_user.inc |
| 7 |
call mtr.add_suppression("Plugin mysqlx reported: '3.1: Unhandled message of type 12'"); |
| 8 |
call mtr.add_suppression("Plugin mysqlx reported: '4.1: Unhandled message of type 12'"); |
| 9 |
call mtr.add_suppression("Plugin mysqlx reported: '5.1: Unhandled message of type 12'"); |
| 10 |
|
| 11 |
|
| 12 |
## Test starts here |
| 13 |
--write_file $MYSQL_TMP_DIR/mysqlx-connection.xpl |
| 14 |
-->sql |
| 15 |
create user killsession@localhost identified by 'killsession'; |
| 16 |
select USER,COMMAND,STATE from information_schema.processlist order by ID desc; |
| 17 |
-->endsql |
| 18 |
EOF |
| 19 |
|
| 20 |
--write_file $MYSQL_TMP_DIR/mysqlx-connection_current_user.xpl |
| 21 |
-->sql |
| 22 |
select user(),current_user(),@@bind_address; |
| 23 |
-->endsql |
| 24 |
EOF |
| 25 |
|
| 26 |
--write_file $MYSQL_TMP_DIR/mysqlx-connection.processlist.xpl |
| 27 |
-->fatalerrors |
| 28 |
-->sql |
| 29 |
set @current := connection_id(); |
| 30 |
select USER,COMMAND,STATE from information_schema.processlist order by ID desc; |
| 31 |
kill %MYSQLTEST_CONNECTION_ID%; |
| 32 |
-->endsql |
| 33 |
-->expecterror ER_QUERY_INTERRUPTED |
| 34 |
-->sql |
| 35 |
kill @current; |
| 36 |
-->endsql |
| 37 |
EOF |
| 38 |
|
| 39 |
--write_file $MYSQL_TMP_DIR/mysqlx-connection_killiunprivileged.xpl |
| 40 |
-->sql |
| 41 |
select USER,COMMAND,STATE from information_schema.processlist order by ID desc; |
| 42 |
-->endsql |
| 43 |
-->expecterror ER_KILL_DENIED_ERROR |
| 44 |
-->sql |
| 45 |
kill %MYSQLTEST_CONNECTION_ID%; |
| 46 |
select USER,COMMAND,STATE from information_schema.processlist order by ID desc; |
| 47 |
-->endsql |
| 48 |
EOF |
| 49 |
|
| 50 |
--write_file $MYSQL_TMP_DIR/mysqlx-connection_killmysqlxsession.xpl |
| 51 |
-->fatalerrors |
| 52 |
-->sql |
| 53 |
set @current := connection_id(); |
| 54 |
select USER,COMMAND,STATE from information_schema.processlist order by ID desc; |
| 55 |
-->endsql |
| 56 |
-->expecterror ER_QUERY_INTERRUPTED |
| 57 |
-->sql |
| 58 |
kill @current; |
| 59 |
-->endsql |
| 60 |
EOF |
| 61 |
|
| 62 |
--write_file $MYSQL_TMP_DIR/mysqlx-connection_killinvalid.xpl |
| 63 |
-->fatalerrors |
| 64 |
-->sql |
| 65 |
select USER,COMMAND,STATE from information_schema.processlist order by ID desc; |
| 66 |
-->endsql |
| 67 |
-->expecterror ER_NO_SUCH_THREAD |
| 68 |
-->sql |
| 69 |
kill 5126; |
| 70 |
-->endsql |
| 71 |
EOF |
| 72 |
|
| 73 |
|
| 74 |
--replace_regex /localhost:[0-9]*/localhost/ /Execute/Query/ |
| 75 |
--exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-connection.xpl 2>&1 |
| 76 |
|
| 77 |
###try killing with unprivileged user both mysqlx and mysql session ids using mysqlx protocol |
| 78 |
###processlist should show the current session info even privileges are minimal |
| 79 |
let $MYSQLTEST_CONNID_1=`select connection_id()`; |
| 80 |
--replace_regex /localhost:[0-9]*/localhost/ /kill [0-9]+/kill $CONNECTION_ID/ /thread [0-9]+/thread $CONNECTION_ID/ |
| 81 |
--exec $MYSQLXTEST -u killsession --password='killsession' --file=$MYSQL_TMP_DIR/mysqlx-connection_killiunprivileged.xpl -v%MYSQLTEST_CONNECTION_ID%=$MYSQLTEST_CONNID_1 2>&1 |
| 82 |
|
| 83 |
--connection default |
| 84 |
let $wait_for_status_variable = |
| 85 |
'Mysqlx_sessions_closed', |
| 86 |
'Mysqlx_sessions'; |
| 87 |
let $wait_for_status_value = 2, 0; |
| 88 |
source ../include/wait_for_status_variables.inc; |
| 89 |
###try killing sessionid which doesn't exists when mysqlxplugin installed using mysqlx protocol |
| 90 |
###show processlist returns 0 rows effected even more rows are returned Bug#21392187 |
| 91 |
--replace_regex /localhost:[0-9]*/localhost/ /Execute/Query/ |
| 92 |
--exec $MYSQLXTEST -u x_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-connection_killinvalid.xpl 2>&1 |
| 93 |
|
| 94 |
--connection default |
| 95 |
let $wait_for_status_variable = |
| 96 |
'Mysqlx_sessions_closed', |
| 97 |
'Mysqlx_sessions'; |
| 98 |
let $wait_for_status_value = 3, 0; |
| 99 |
source ../include/wait_for_status_variables.inc; |
| 100 |
--connect(con1,localhost,x_root,,) |
| 101 |
let $MYSQLTEST_CONNID_2=`select connection_id()`; |
| 102 |
###try killing both mysqlx and mysql session ids using mysqlx protocol (expect error from getting killed) |
| 103 |
--replace_regex /localhost:[0-9]*/localhost/ /kill [0-9]+/kill CONNECTION_ID/ /Execute/Query/ |
| 104 |
--exec $MYSQLXTEST --expect-error CR_SERVER_GONE_ERROR -u x_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-connection.processlist.xpl -v%MYSQLTEST_CONNECTION_ID%=$MYSQLTEST_CONNID_2 2>&1 |
| 105 |
|
| 106 |
--connection default |
| 107 |
let $wait_for_status_variable = |
| 108 |
'Mysqlx_sessions_fatal_error', |
| 109 |
'Mysqlx_sessions'; |
| 110 |
let $wait_for_status_value = 1, 0; |
| 111 |
source ../include/wait_for_status_variables.inc; |
| 112 |
--replace_regex /Execute/Query/ |
| 113 |
select USER,COMMAND,STATE from information_schema.processlist order by ID desc; |
| 114 |
|
| 115 |
###kill mysqlx protocol session using mysqlx protocol when mysqlxplugin installed (expect error again) |
| 116 |
--replace_regex /localhost:[0-9]*/localhost/ /Execute/Query/ |
| 117 |
--exec $MYSQLXTEST --expect-error CR_SERVER_GONE_ERROR -u x_root --password='' --file=$MYSQL_TMP_DIR/mysqlx-connection_killmysqlxsession.xpl 2>&1 |
| 118 |
|
| 119 |
--connection default |
| 120 |
let $wait_for_status_variable = |
| 121 |
'Mysqlx_sessions_fatal_error', |
| 122 |
'Mysqlx_sessions'; |
| 123 |
let $wait_for_status_value = 2, 0; |
| 124 |
source ../include/wait_for_status_variables.inc; |
| 125 |
--replace_regex /Execute/Query/ |
| 126 |
select USER,COMMAND,STATE from information_schema.processlist order by ID desc; |
| 127 |
##expect Mysqlx_sessions_fatal_error incremented when killing its own session |
| 128 |
show status like 'Mysqlx_sessions%'; |
| 129 |
|
| 130 |
## Cleanup |
| 131 |
drop user killsession@localhost; |
| 132 |
--source ../include/xplugin_cleanup.inc |