| 1 |
## UNIX Socket connections |
| 2 |
|
| 3 |
## Preamble |
| 4 |
--source include/not_windows.inc |
| 5 |
--source ../include/have_performance_schema_threads.inc |
| 6 |
--source include/xplugin_preamble.inc |
| 7 |
--source include/xplugin_create_user.inc |
| 8 |
|
| 9 |
## Test starts here |
| 10 |
--write_file $MYSQL_TMP_DIR/check_unixsocket.xpl |
| 11 |
## Test data |
| 12 |
#Ensure that each of following uses UNIX Socket |
| 13 |
-->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query'; |
| 14 |
-->recvresult |
| 15 |
EOF |
| 16 |
|
| 17 |
--write_file $MYSQL_TMP_DIR/file.sock |
| 18 |
EOF |
| 19 |
|
| 20 |
--write_file $MYSQL_TMP_DIR/check_connection.xpl |
| 21 |
EOF |
| 22 |
|
| 23 |
--exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1 |
| 24 |
|
| 25 |
# Read only variable 'mysqlx_socket' |
| 26 |
--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 27 |
SET GLOBAL mysqlx_socket=null; |
| 28 |
--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 29 |
SET @@global.mysqlx_socket='invalid'; |
| 30 |
--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
| 31 |
SET GLOBAL mysqlx_socket=$MYSQL_TMP_DIR/socket_mysqlx.sock; |
| 32 |
|
| 33 |
--let UNIX_SOCKET_REGEX= /( |=)\/.*\.(sock|socket)/\1 SOCKET/ |
| 34 |
|
| 35 |
call mtr.add_suppression("Plugin mysqlx reported: .Setup of socket: '' failed, the socket file path is empty"); |
| 36 |
let $restart_parameters = restart: --loose-mysqlx-socket=; |
| 37 |
--let $wait_for_unixsocket_status = undefined_value |
| 38 |
--source include/restart_mysqld.inc |
| 39 |
|
| 40 |
--replace_regex $UNIX_SOCKET_REGEX |
| 41 |
exec $MYSQLXTEST |
| 42 |
--socket=$MASTER_X_MYSOCK |
| 43 |
-ux_root --password='' |
| 44 |
--expect-error 2002 |
| 45 |
--file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1; |
| 46 |
|
| 47 |
|
| 48 |
call mtr.add_suppression("Plugin mysqlx reported: .Setup of socket: '\(.+\)' failed, can't create lock file /dev/null/mysqlx\.sock\.lock"); |
| 49 |
let $restart_parameters = restart: --loose-mysqlx-socket="/dev/null/mysqlx.sock"; |
| 50 |
--let $wait_for_unixsocket_status = undefined_value |
| 51 |
--source include/restart_mysqld.inc |
| 52 |
|
| 53 |
--replace_regex $UNIX_SOCKET_REGEX |
| 54 |
exec $MYSQLXTEST |
| 55 |
--socket=$MASTER_X_MYSOCK |
| 56 |
-ux_root --password='' |
| 57 |
--expect-error 2002 |
| 58 |
--file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1; |
| 59 |
|
| 60 |
--replace_regex $UNIX_SOCKET_REGEX |
| 61 |
exec $MYSQLXTEST |
| 62 |
--socket="/dev/null/mysqlx.sock" |
| 63 |
-ux_root --password='' |
| 64 |
--expect-error 2002 |
| 65 |
--file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1; |
| 66 |
|
| 67 |
# Use the same socket as mysqld uses |
| 68 |
# X Plugin should fail with allocation |
| 69 |
call mtr.add_suppression("Plugin mysqlx reported: 'X Plugins UNIX socket must use different file than MySQL server. X Plugin won't be accessible through UNIX socket"); |
| 70 |
|
| 71 |
--replace_regex $UNIX_SOCKET_REGEX |
| 72 |
let $restart_parameters = restart: --loose-mysqlx-socket=$MASTER_MYSOCK; |
| 73 |
|
| 74 |
# There is no X Plugin installed, skip waiting |
| 75 |
--let $wait_for_tcpsocket_status = no_wait |
| 76 |
--let $wait_for_unixsocket_status = no_wait |
| 77 |
--source include/restart_mysqld.inc |
| 78 |
|
| 79 |
--let $wait_for_unixsocket_status = undefined_value |
| 80 |
--source include/xplugin_reset_and_wait.inc |
| 81 |
|
| 82 |
# The legacy UNIX socket should be still valid |
| 83 |
connect(socket_con,localhost,x_root,,,,$MASTER_MYSOCK); |
| 84 |
connection default; |
| 85 |
disconnect socket_con; |
| 86 |
|
| 87 |
|
| 88 |
# Try to use a file as UNIX socket |
| 89 |
--replace_regex $UNIX_SOCKET_REGEX |
| 90 |
let $restart_parameters = restart: --loose-mysqlx-socket=$MYSQL_TMP_DIR/file.sock; |
| 91 |
--let $wait_for_unixsocket_status = valid_value |
| 92 |
--source include/restart_mysqld.inc |
| 93 |
|
| 94 |
--exec $MYSQLXTEST --socket=$MYSQL_TMP_DIR/file.sock -ux_root --password='' --file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1 |
| 95 |
|
| 96 |
|
| 97 |
# Try to use directory as UNIX socket |
| 98 |
--let DIR_NAME= d.sock |
| 99 |
call mtr.add_suppression("Plugin mysqlx reported: .Setup of socket: '\(.+\)' failed, .bind... on UNIX socket failed with error"); |
| 100 |
--mkdir $MYSQL_TMP_DIR/$DIR_NAME |
| 101 |
--replace_regex $UNIX_SOCKET_REGEX |
| 102 |
let $restart_parameters = restart: --loose-mysqlx-socket=$MYSQL_TMP_DIR/$DIR_NAME; |
| 103 |
--let $wait_for_unixsocket_status = undefined_value |
| 104 |
--source include/restart_mysqld.inc |
| 105 |
|
| 106 |
--replace_regex /error: (Connection refused|Socket operation on non-socket), while connecting to \/.*\.(sock|socket)/error: Connection refused, while connecting to SOCKET/ |
| 107 |
exec $MYSQLXTEST |
| 108 |
--socket=$MYSQL_TMP_DIR/$DIR_NAME |
| 109 |
-ux_root --password='' |
| 110 |
--expect-error 2002 |
| 111 |
--file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1; |
| 112 |
|
| 113 |
|
| 114 |
# Try to create a UNIX socket inside directory without permissions to it |
| 115 |
call mtr.add_suppression("Plugin mysqlx reported: .Setup of socket: '\(.+\)' failed, can't create lock file .+\.lock"); |
| 116 |
--chmod 0000 $MYSQL_TMP_DIR/$DIR_NAME/ |
| 117 |
--replace_regex $UNIX_SOCKET_REGEX |
| 118 |
let $restart_parameters = restart: --loose-mysqlx-socket=$MYSQL_TMP_DIR/$DIR_NAME/x.sock; |
| 119 |
--let $wait_for_unixsocket_status = undefined_value |
| 120 |
--source include/restart_mysqld.inc |
| 121 |
|
| 122 |
--replace_regex $UNIX_SOCKET_REGEX |
| 123 |
exec $MYSQLXTEST |
| 124 |
--socket=$MYSQL_TMP_DIR/$DIR_NAME/x.sock |
| 125 |
-ux_root --password='' |
| 126 |
--expect-error 2002 |
| 127 |
--file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1; |
| 128 |
--chmod 0777 $MYSQL_TMP_DIR/$DIR_NAME/ |
| 129 |
|
| 130 |
|
| 131 |
call mtr.add_suppression("Plugin mysqlx reported: .Setup of socket: '\(.+\)' failed, can't create lock file .*ne/x.sock.lock"); |
| 132 |
--replace_regex $UNIX_SOCKET_REGEX |
| 133 |
# Following directory /no_existing/ was shorten to /ne/ |
| 134 |
let $restart_parameters = restart: --loose-mysqlx-socket=$MYSQL_TMP_DIR/$DIR_NAME/ne/x.sock; |
| 135 |
--let $wait_for_unixsocket_status = undefined_value |
| 136 |
--source include/restart_mysqld.inc |
| 137 |
|
| 138 |
--replace_regex $UNIX_SOCKET_REGEX |
| 139 |
exec $MYSQLXTEST |
| 140 |
--socket=$MYSQL_TMP_DIR/$DIR_NAME/ne/x.sock |
| 141 |
-ux_root --password='' |
| 142 |
--expect-error 2002 |
| 143 |
--file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1; |
| 144 |
|
| 145 |
|
| 146 |
--mkdir $MYSQL_TMP_DIR/long_dir012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 147 |
call mtr.add_suppression("Plugin mysqlx reported: .Setup of socket: '\(.+\)' failed, the socket file path is too long"); |
| 148 |
--replace_regex $UNIX_SOCKET_REGEX |
| 149 |
let $restart_parameters = restart: --loose-mysqlx-socket=$MYSQL_TMP_DIR/long_dir012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/x.sock; |
| 150 |
--let $wait_for_unixsocket_status = undefined_value |
| 151 |
--source include/restart_mysqld.inc |
| 152 |
|
| 153 |
--replace_regex /error: UNIX Socket file name too long, size should be less or equal [0-9]+/error: UNIX Socket file name too long, size should be less or equal LENGTH/ |
| 154 |
exec $MYSQLXTEST |
| 155 |
--socket=$MYSQL_TMP_DIR/long_dir012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789/x.sock |
| 156 |
-ux_root --password='' |
| 157 |
--expect-error 2005 |
| 158 |
--file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1; |
| 159 |
|
| 160 |
## Cleanup |
| 161 |
--let $restart_parameters = restart: |
| 162 |
--source include/restart_mysqld.inc |
| 163 |
|
| 164 |
--rmdir $MYSQL_TMP_DIR/$DIR_NAME |
| 165 |
--rmdir $MYSQL_TMP_DIR/long_dir012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 |
| 166 |
--remove_file $MYSQL_TMP_DIR/$DIR_NAME.lock |
| 167 |
--source ../include/xplugin_cleanup.inc |