1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-05 08:04:25 +03:00
Files
mariadb/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test
Monty 9cba6c5aa3 Updated mtr files to support different compiled in options
This allows one to run the test suite even if any of the following
options are changed:
- character-set-server
- collation-server
- join-cache-level
- log-basename
- max-allowed-packet
- optimizer-switch
- query-cache-size and query-cache-type
- skip-name-resolve
- table-definition-cache
- table-open-cache
- Some innodb options
etc

Changes:
- Don't print out the value of system variables as one can't depend on
  them to being constants.
- Don't set global variables to 'default' as the default may not
  be the same as the test was started with if there was an additional
  option file. Instead save original value and reset it at end of test.
- Test that depends on the latin1 character set should include
  default_charset.inc or set the character set to latin1
- Test that depends on the original optimizer switch, should include
  default_optimizer_switch.inc
- Test that depends on the value of a specific system variable should
  set it in the test (like optimizer_use_condition_selectivity)
- Split subselect3.test into subselect3.test and subselect3.inc to
  make it easier to set and reset system variables.
- Added .opt files for test that required specfic options that could
  be changed by external configuration files.
- Fixed result files in rockdsb & tokudb that had not been updated for
  a while.
2019-09-01 19:17:35 +03:00

264 lines
7.1 KiB
Plaintext

#
# Tests for the performance_schema host_cache.
#
# Simulate failures from per user quotas:
# - reported in COUNT_MAX_USER_CONNECTION_ERRORS
# - reported in COUNT_MAX_USER_CONNECTION_PER_HOUR_ERRORS
# Simulate failures from server quotas:
# - reported in COUNT_MAX_CONNECTION_ERRORS
--source include/not_embedded.inc
--source include/have_debug.inc
--source include/have_perfschema.inc
--source include/have_hostname_cache.inc
# Enforce a clean state
--source ../include/wait_for_pfs_thread_count.inc
--source ../include/hostcache_set_state.inc
select @@global.max_connections into @saved_max_connections;
select @@global.max_user_connections into @saved_max_user_connections;
create user 'quota'@'santa.claus.ipv4.example.com';
grant select on test.* to 'quota'@'santa.claus.ipv4.example.com';
grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
with max_connections_per_hour 3;
connect (con1,"127.0.0.1",root,,test,$MASTER_MYPORT,);
select "Con1 is alive";
select current_user();
disconnect con1;
--connection default
set global debug_dbug= "+d,vio_peer_addr_fake_ipv4,getnameinfo_fake_ipv4,getaddrinfo_fake_good_ipv4";
connect (con2a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con2a is alive";
select current_user();
disconnect con2a;
--connection default
--source ../include/hostcache_dump.inc
connect (con2b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con2b is alive";
select current_user();
disconnect con2b;
--connection default
--source ../include/hostcache_dump.inc
connect (con2c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con2c is alive";
select current_user();
disconnect con2c;
--connection default
--source ../include/hostcache_dump.inc
--disable_query_log
--error ER_USER_LIMIT_REACHED
connect (con2d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
--enable_query_log
--connection default
--source ../include/hostcache_dump.inc
--disable_query_log
--error ER_USER_LIMIT_REACHED
connect (con2e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
--enable_query_log
--connection default
--source ../include/hostcache_dump.inc
# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc
grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
with max_connections_per_hour 0;
grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
with max_user_connections 3;
flush user_resources;
connect (con3a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con7 is alive";
select current_user();
--connection default
--source ../include/hostcache_dump.inc
connect (con3b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con3b is alive";
select current_user();
--connection default
--source ../include/hostcache_dump.inc
connect (con3c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con3c is alive";
select current_user();
--connection default
--source ../include/hostcache_dump.inc
--disable_query_log
--error ER_USER_LIMIT_REACHED
connect (con3d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
--enable_query_log
--connection default
--source ../include/hostcache_dump.inc
--disable_query_log
--error ER_USER_LIMIT_REACHED
connect (con3e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
--enable_query_log
--connection default
--source ../include/hostcache_dump.inc
disconnect con3a;
disconnect con3b;
disconnect con3c;
# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc
grant usage on *.* to 'quota'@'santa.claus.ipv4.example.com'
with max_user_connections 0;
flush user_resources;
set global max_user_connections = 3;
connect (con4a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con4a is alive";
select current_user();
--connection default
--source ../include/hostcache_dump.inc
connect (con4b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con4b is alive";
select current_user();
--connection default
--source ../include/hostcache_dump.inc
connect (con4c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con4c is alive";
select current_user();
--connection default
--source ../include/hostcache_dump.inc
--disable_query_log
--error ER_TOO_MANY_USER_CONNECTIONS
connect (con4d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
--enable_query_log
--connection default
--source ../include/hostcache_dump.inc
--disable_query_log
--error ER_TOO_MANY_USER_CONNECTIONS
connect (con4e,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
--enable_query_log
--connection default
--source ../include/hostcache_dump.inc
disconnect con4a;
disconnect con4b;
disconnect con4c;
# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc
set global max_user_connections = 0;
set global max_connections = 10;
flush user_resources;
connect (tmp_con1,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con2,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con3,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con4,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con5,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con6,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
connect (tmp_con7,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
connect (con5a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con4a is alive";
select current_user();
--connection default
--source ../include/hostcache_dump.inc
connect (con5b,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con5b is alive";
select current_user();
--connection default
--source ../include/hostcache_dump.inc
# About error ER_CON_COUNT_ERROR:
# - this error is associated with SQLSTATE 08004,
# and returned from 2 places in the server code.
# - which path returns the error is not predictable,
# as it depends on the server load and thread scheduling
# - one path returns a SQLSTATE of 08004
# - another path returns no SQLSTATE at all,
# and then the client sets a default value of HY000 for SQLSTATE
#
# Testing for error ER_CON_COUNT_ERROR alone causes this to
# be printed in the result file:
# - ERROR 08004: Too many connections
# which in turn causes spurious test failures.
#
# To work around this, this scripts expect to see either
# the error number ER_CON_COUNT_ERROR (it always does)
# or the error number 9999 (it never does, this error does not exist).
# The exact error number and SQLSTATE is not printed in the result file,
# makig this test robust for both cases:
# - ERROR 08004: Too many connections
# - ERROR HY000: Too many connections
--disable_query_log
--error ER_CON_COUNT_ERROR, 9999
connect (con5c,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
--enable_query_log
--connection default
--source ../include/hostcache_dump.inc
--disable_query_log
--error ER_CON_COUNT_ERROR, 9999
connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
--enable_query_log
--connection default
--source ../include/hostcache_dump.inc
disconnect con5a;
disconnect con5b;
--disconnect tmp_con1
--disconnect tmp_con2
--disconnect tmp_con3
--disconnect tmp_con4
--disconnect tmp_con5
--disconnect tmp_con6
--disconnect tmp_con7
# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc
set global max_connections = @saved_max_connections;
set global max_user_connections = @saved_max_user_connections;
# revoke all privileges on test.* from 'quota'@'santa.claus.ipv4.example.com';
drop user 'quota'@'santa.claus.ipv4.example.com';
set global debug_dbug= default;