config root man

Current Path : /home/usr.opt/mysql57/mysql-test/suite/x/t/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //home/usr.opt/mysql57/mysql-test/suite/x/t/connection.test

## This is test file for connection authentication without ssl.
##
#--source include/have_mysql_no_login_plugin.inc

--source ../include/xplugin_preamble.inc

call mtr.add_suppression("Plugin mysqlx reported: '2.1: Unsuccessful login attempt: Invalid user or password'");
call mtr.add_suppression("Plugin mysqlx reported: '3.1: Unsuccessful login attempt: Invalid user or password'");
call mtr.add_suppression("Plugin mysqlx reported: '4.1: Unsuccessful login attempt: Your password has expired. To log in you must change it using a client that supports expired passwords.'");
call mtr.add_suppression("Plugin mysqlx reported: '5.1: Unsuccessful login attempt: Account is locked.'");
call mtr.add_suppression("Plugin mysqlx reported: '16.1: Unsuccessful login attempt: Account is locked.'");
call mtr.add_suppression("Plugin mysqlx reported: '6.1: Unsuccessful login attempt: Invalid user or password'");
call mtr.add_suppression("Plugin mysqlx reported: '1.1: Unsuccessful login attempt: Server works in offline mode.'");
call mtr.add_suppression("Plugin mysqlx reported: '2.1: Unsuccessful login attempt: Unable to switch context to user mysql.session'");
call mtr.add_suppression("Plugin mysqlx reported: 'Unable to switch context to user mysql.session'");
call mtr.add_suppression("Plugin mysqlx reported: 'Unable to accept connection, disconnecting client'");
call mtr.add_suppression("Plugin mysqlx reported: 'Could not open internal MySQL session'");
call mtr.add_suppression("Plugin mysqlx reported: '.*: Error initializing session for connection: Could not open session'");

call mtr.add_suppression("Plugin 'mysqlx' has ref_count=5 after shutdown");
call mtr.add_suppression("Plugin 'mysqlx' will be forced to shutdown");

## Test starts here
--write_file $MYSQL_TMP_DIR/mysqlx-connection.tmp
-->sql
SELECT PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where PLUGIN_NAME LIKE '%mysqlx%';
create user xplugin@localhost identified by 'xplugin';
alter user xplugin@localhost password expire;
create user nonblank@localhost identified by 'nonblank';
create user blank@localhost identified by '';
CREATE USER 'abc'@'localhost' IDENTIFIED BY 'abc' ACCOUNT LOCK;
#CREATE USER noauth@localhost IDENTIFIED WITH 'mysql_no_login';
create user ''@localhost identified by 'ramana';
create user special@localhost identified by '1aram@&Tpu';
create user session@localhost identified by 'session';
grant all on *.* to session@localhost;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';
-->endsql
EOF

--write_file $MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp
-->stmtsql select user(),current_user(),@@bind_address
-->expecterror %EXPECT_ERROR%
-->recvresult

-->stmtsql show status like 'Mysqlx_connections_closed'
-->expecterror %EXPECT_ERROR%
-->recvresult

-->stmtsql show status like 'Mysqlx_connections_accepted'
-->expecterror %EXPECT_ERROR%
-->recvresult

-->stmtsql show status like 'Mysqlx_connection_accept_errors'
-->expecterror %EXPECT_ERROR%
-->recvresult

### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
-->stmtsql show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error'
-->expecterror %EXPECT_ERROR%
-->recvresult

EOF

--write_file $MYSQL_TMP_DIR/mysqlx-connection_locked_user.tmp
-->expecterror ER_ACCESS_DENIED_ERROR
-->newsession bla	abc	abc
EOF


--write_file $MYSQL_TMP_DIR/mysqlx-connection_session_track.tmp
-->sql
SET @@session.session_track_system_variables='mysqlx_port,mysqlx_idle_worker_thread_timeout,mysqlx_max_allowed_packet,mysqlx_max_connections,mysqlx_min_worker_threads';
show variables like '%session_track%';
-->endsql

-->stmtsql uninstall plugin mysqlx;
-->expecterror ER_PLUGGABLE_PROTOCOL_COMMAND_NOT_SUPPORTED
-->recvresult

-->sql
show warnings;
show variables like '%mysqlx_max_connections%';
set @@global.mysqlx_max_connections=100;
show variables like '%mysqlx_max_connections%';
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';
-->endsql
EOF

--write_file $MYSQL_TMP_DIR/mysqlx-connection_uninstallplugin.tmp
-->sql
uninstall plugin mysqlx;
-->endsql
EOF

##change result file once Bug#21782329 is fixed
--exec $MYSQLXTEST -uroot --password='' --file=$MYSQL_TMP_DIR/mysqlx-connection.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###try to login with bogus accounts that could match a valid account by collation
--let $expected_error_msg= Invalid user or password \(code 1045\)
--source ../include/mysqlxtest_expected_error.inc
--exec $MYSQLXTEST -uRoot --password='' --file=$MYSQL_TMP_DIR/mysqlx-connection.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

--let $expected_error_msg= Invalid user or password \(code 1045\)
--source ../include/mysqlxtest_expected_error.inc
--exec $MYSQLXTEST -u"root  " --password='' --file=$MYSQL_TMP_DIR/mysqlx-connection.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###try login with user having special characters in password when mysqlxplugin installed
--exec $MYSQLXTEST -uspecial --password="1aram@&Tpu" -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

### Not a Bug, anon user doesn't exist in xplugin
###try login with annonymous user when mysqx plugin is installed
###Test for Bug#21372364
###--exec $MYSQLXTEST -ut --password='ramana' -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1

###try login with invalid host when mysqx plugin is installed
###this is expected to crash until Bug#21372364 is fixed
--replace_regex /No such host is known.+$/Host not found/ /Host not found .+$/Host not found/
--error 1
--exec $MYSQLXTEST -uroot --password='' -hinvalid -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1

# replace_regex did consume last character in line, lets put it back
--echo

show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

## uninstalling mysqlx
uninstall plugin mysqlx;

##trying with valid user when mysqlx is not installed

--replace_regex /ERROR.*(No connection could be made because the target machine actively refused it connecting to*| *Connection refused connecting to*) .*:[0-9]*/ERROR: Connection refused connecting to HOST:PORT/
--error 1
--exec $MYSQLXTEST -uroot --password='' --file=$MYSQL_TMP_DIR/mysqlx-connection.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';
--replace_regex /\.dll/.so/

##try login using mysqlx protocol when server and mysqlx loaded with super user
let $restart_parameters = restart: --plugin-load=$MYSQLXPLUGIN;
--source ../include/restart_mysqld_and_wait_for_xplugin.inc
--exec $MYSQLXTEST -u root --password='' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###try login with valid user but incorrect password
--let $expected_error_msg= Invalid user or password \(code 1045\)
--source ../include/mysqlxtest_expected_error.inc
--exec $MYSQLXTEST -uroot --password='root' --file=$MYSQL_TMP_DIR/mysqlx-connection.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###try login with user doesn't exists when mysqlx installed
--let $expected_error_msg= Invalid user or password \(code 1045\)
--source ../include/mysqlxtest_expected_error.inc
--exec $MYSQLXTEST -u rt --password='root' --file=$MYSQL_TMP_DIR/mysqlx-connection.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###try login with user whose password expired when mysqlx installed
--let $expected_error_msg= Your password has expired. To log in you must change it using a client that supports expired passwords. \(code 1045\)
--source ../include/mysqlxtest_expected_error.inc
--exec $MYSQLXTEST -u xplugin --password='xplugin' -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###try login with user whose account is locked when mysqlx installed
--let $expected_error_msg= Account is locked. \(code 1045\)
--source ../include/mysqlxtest_expected_error.inc
--exec $MYSQLXTEST -u abc --password='abc' -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###try login with internal user account and expect account is locked error
--let $expected_error_msg= Invalid user or password \(code 1045\)
--source ../include/mysqlxtest_expected_error.inc
--exec $MYSQLXTEST -u'mysql.session' --password='' --sql "SELECT CURRENT_USER()"
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

##commenting this scenario since multiple plugins can't be loaded in dev environment now
###try login with mysql_no_login user when mysqlx installed
#--error 1
#--exec $MYSQLXTEST -u noauth --password='' -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1

###login with valid user and valid password when mysqlx installed
--exec $MYSQLXTEST -u nonblank --password='nonblank' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###login with valid user and blank password when mysqlx installed
--exec $MYSQLXTEST -u blank --password='' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

--remove_file $MYSQL_TMP_DIR/mysqlx-connection.tmp

--write_file $MYSQL_TMP_DIR/mysqlx-connection.tmp
-->sql
SELECT PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_STATUS,PLUGIN_TYPE,PLUGIN_TYPE_VERSION,PLUGIN_LIBRARY,PLUGIN_LIBRARY_VERSION,PLUGIN_AUTHOR,PLUGIN_DESCRIPTION,PLUGIN_LICENSE,LOAD_OPTION from information_schema.plugins where PLUGIN_NAME LIKE '%xplugin%';
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';
-->endsql
EOF

##try login with valid user when server started with localhost as bind-address and mysqlx loaded
let $restart_parameters = restart: --bind-address=localhost --plugin-load=$MYSQLXPLUGIN;
--replace_regex /\.dll/.so/
--source ../include/restart_mysqld_and_wait_for_xplugin.inc
--exec $MYSQLXTEST -u nonblank --password='nonblank' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
--exec $MYSQLXTEST -u nonblank --password='nonblank' -hlocalhost -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

##try login with valid user when server started with 127.0.0.1 as bind-address and mysqlx loaded
let $restart_parameters = restart: --bind-address=127.0.0.1 --plugin-load=$MYSQLXPLUGIN;
--replace_regex /\.dll/.so/
--source ../include/restart_mysqld_and_wait_for_xplugin.inc
--exec $MYSQLXTEST -u nonblank --password='nonblank' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';
--exec $MYSQLXTEST -u nonblank --password='nonblank' -h127.0.0.1 -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

##try login with valid non-super and super user when server is in offline mode and mysqlx loaded
let $restart_parameters = restart: --offline_mode=ON --plugin-load=$MYSQLXPLUGIN;
--replace_regex /\.dll/.so/
--source ../include/restart_mysqld_and_wait_for_xplugin.inc
--let $expected_error_msg= Server works in offline mode. \(code 1045\)
--source ../include/mysqlxtest_expected_error.inc
--exec $MYSQLXTEST -u nonblank --password='nonblank' --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';
--exec $MYSQLXTEST -u root --password='' -v%EXPECT_ERROR%=ER_SUCCESS --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

##start server with session tracking variables and monitor them using xprotocol
let $restart_parameters = restart: --plugin-load=$MYSQLXPLUGIN;
--replace_regex /\.dll/.so/
--source ../include/restart_mysqld_and_wait_for_xplugin.inc
--exec $MYSQLXTEST -u session --password='session' --file=$MYSQL_TMP_DIR/mysqlx-connection_session_track.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

###try login with user whose password expired when mysqlx installed and when server started with skip-disconnect-on-expired-password option
let $restart_parameters = restart:  --skip-disconnect-on-expired-password --plugin-load=$MYSQLXPLUGIN;
--replace_regex /\.dll/.so/
--source ../include/restart_mysqld_and_wait_for_xplugin.inc

--exec $MYSQLXTEST -u xplugin --password='xplugin' -v%EXPECT_ERROR%=ER_MUST_CHANGE_PASSWORD --file=$MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
###  Bug #21782329
show status where `Variable_name` like  'Mysqlx_sessions%' and not `Variable_name` like  'Mysqlx_sessions_fatal_error';

--write_file $MYSQL_TMP_DIR/open_max_mysqlx_connection.tmp
-->sql
create user con1@localhost identified by 'con1';
create user con2@localhost identified by 'con2';
grant all on *.* to con2@localhost;
-->endsql
-->echo Test data
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->echo create and activate new session con1
-->newsession con1	con1	con1

Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->echo open 3rd xprotocol connection where 2 sessions already opened (may fail)
-->newsession con2	-
-->peerdisc 1000 1000

-->sleep 2
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF

##try to open xprotocol sessions more than mysqlx_max_connections,expect error for last connection
let $restart_parameters = restart: --plugin-load=$MYSQLXPLUGIN --mysqlx_max_connections=2;
--replace_regex /\.dll/.so/
--source ../include/restart_mysqld_and_wait_for_xplugin.inc
--exec $MYSQLXTEST -u root --password='' --file=$MYSQL_TMP_DIR/open_max_mysqlx_connection.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329

--write_file $MYSQL_TMP_DIR/open_max_mysqlx_connection2.tmp
-->sql
create user con1@localhost identified by 'con1';
create user con2@localhost identified by 'con2';
grant all on *.* to con2@localhost;
-->endsql
-->echo Test data
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->echo create and activate new session con1
-->newsession con1	con1	con1

Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->echo open 3rd xprotocol connection where 2 sessions already opened
-->newsession con2	con2	con2

Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF


## try to open xprotocol sessions as that of mysqlx_max_connections set
drop user con1@localhost;
drop user con2@localhost;
let $restart_parameters = restart: --plugin-load=$MYSQLXPLUGIN --mysqlx_max_connections=3;
--replace_regex /\.dll/.so/
--source ../include/restart_mysqld_and_wait_for_xplugin.inc
--exec $MYSQLXTEST -u root --password='' --file=$MYSQL_TMP_DIR/open_max_mysqlx_connection2.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329

--write_file $MYSQL_TMP_DIR/allconn_root.tmp
-->sql
create user xcon1@localhost identified by 'xcon1';
create user xcon2@localhost identified by 'xcon2';
grant all on *.* to xcon2@localhost;
set @@global.mysqlx_max_connections=2;
-->endsql
-->echo Test data
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql

-->echo create and activate new session con1
-->newsession xcon1	xcon1	xcon1

Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql

-->echo open 3rd xprotocol connection where 2 sessions already opened
-->echo this scenario is related to Bug#21374656
-->newsession xcon2	-
-->peerdisc 1500 1500

## switch back to default session
-->setsession
-->sleep 2
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->recvresult client_id user host

-->sql
set @@global.mysqlx_max_connections=3;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql

-->newsession xcon2	xcon2	xcon2

Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->recvresult client_id user host

-->sql
drop user xcon1@localhost;
drop user xcon2@localhost;
set @@global.mysqlx_max_connections=100;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF

##open max allowed connections and expect error for new connections and changes value and connect again,expect success
--exec $MYSQLXTEST -u root --password='' --file=$MYSQL_TMP_DIR/allconn_root.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329

--write_file $MYSQL_TMP_DIR/admin_xkill_parallel.tmp
-->echo kill xprotocol session when some operations are going on there using mysqx protocol
-->sql
create user xcon1@localhost identified by 'xcon1';
create user xcon2@localhost identified by 'xcon2';
grant all on *.* to xcon2@localhost;
SET GLOBAL mysqlx_connect_timeout = 300;
-->endsql
-->echo Test data
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql

-->echo create and activate new session con1
-->newsession xcon1	xcon1	xcon1

-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql

Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

Mysqlx.Sql.StmtExecute {
  stmt: "select sleep(100);"
}

-->echo open 3rd xprotocol connection where 2 sessions already opened
-->newsession xcon2	xcon2	xcon2
-->sql
#select ID,USER,COMMAND,STATE from information_schema.processlist order by ID desc;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql

## switch back to default session
-->setsession

Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql

-->newsession xcon3	xcon2	xcon2

Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->recvresult client_id user host

Mysqlx.Sql.StmtExecute {
  stmt: "kill_client"
  namespace: "xplugin"
  args {
    type: SCALAR
    scalar {
      type: V_UINT
      v_unsigned_int: 9
    }
  }
}
-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult

-->setsession xcon1
-->recvuntildisc xcon3
-->sleep 1
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->recvresult client_id user host

-->sql
drop user xcon1@localhost;
drop user xcon2@localhost;
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF


--write_file $MYSQL_TMP_DIR/open_max_mysql_connection.tmp
-->echo open more xconnections than specified max_connections,expect error
-->sql
create user mysqlcon1@localhost identified by 'mysqlcon1';
create user mysqlcon2@localhost identified by 'mysqlcon2';
set @@global.max_connections=2;
-->endsql
-->echo Test data
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->echo create and activate new session con1
-->newsession con1	mysqlcon1	mysqlcon1

-->sleep 2
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->echo expect Mysqlx.Sql.StmtExecuteOk
-->recvresult client_id user host

-->echo open 3rd xprotocol connection where 2 sessions already opened
-->newsession con2	-
-->recvtype Mysqlx.Error
-->peerdisc 1000 1000

-->sleep 2
Mysqlx.Sql.StmtExecute {
  stmt: "list_clients"
  namespace: "xplugin"
}

-->recvresult client_id user host
-->sql
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
set @@global.max_connections=150;
### show status like 'Mysqlx_connection_errors'; Bug #21782329
-->endsql
EOF

##kill xprotocol session when some operations are going on there using mysqx protocol
--exec $MYSQLXTEST -u root --password='' --file=$MYSQL_TMP_DIR/admin_xkill_parallel.tmp 2>&1
--sleep 1
show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329

##try open more xconnections than specified max_connections,expect error
--exec $MYSQLXTEST -u root --password='' --file=$MYSQL_TMP_DIR/open_max_mysql_connection.tmp 2>&1
--sleep 1

##ensure proper error for locked account
--exec $MYSQLXTEST -uabc --no-auth --file=$MYSQL_TMP_DIR/mysqlx-connection_locked_user.tmp 2>&1
--sleep 2

--remove_file $MYSQL_TMP_DIR/mysqlx-connection_session_track.tmp
--remove_file $MYSQL_TMP_DIR/mysqlx-connection_uninstallplugin.tmp
--remove_file $MYSQL_TMP_DIR/mysqlx-connection_current_user.tmp
--remove_file $MYSQL_TMP_DIR/mysqlx-connection.tmp
--remove_file $MYSQL_TMP_DIR/open_max_mysqlx_connection.tmp
--remove_file $MYSQL_TMP_DIR/open_max_mysqlx_connection2.tmp
--remove_file $MYSQL_TMP_DIR/open_max_mysql_connection.tmp
--remove_file $MYSQL_TMP_DIR/allconn_root.tmp
--remove_file $MYSQL_TMP_DIR/admin_xkill_parallel.tmp
--remove_file $MYSQL_TMP_DIR/mysqlx-connection_locked_user.tmp

##cleanup
drop user xplugin@localhost;
drop user nonblank@localhost;
drop user blank@localhost;
drop user abc@localhost;
drop user con1@localhost;
drop user con2@localhost;
drop user mysqlcon1@localhost;
drop user mysqlcon2@localhost;
drop user ''@localhost;
drop user special@localhost;
drop user session@localhost;

show status like 'Mysqlx_connections_closed';
show status like 'Mysqlx_connections_accepted';
show status like 'Mysqlx_connection_accept_errors';
### show status like 'Mysqlx_connection_errors'; Bug #21782329
#drop user noauth@localhost;

Man Man