| 1 |
# Connection delay tests for valid user accounts |
| 2 |
|
| 3 |
# ---------------------------------------------------------------------- |
| 4 |
|
| 5 |
# Setup |
| 6 |
# Install connection_control plugin |
| 7 |
INSTALL PLUGIN connection_control SONAME 'CONNECTION_CONTROL_LIB'; |
| 8 |
INSTALL PLUGIN connection_control_failed_login_attempts SONAME 'CONNECTION_CONTROL_LIB'; |
| 9 |
# Create user account for testing |
| 10 |
CREATE USER u1 IDENTIFIED BY 'abcd'; |
| 11 |
# Save original values of connection_control variables |
| 12 |
SET @saved_connections_threshold = @@global.connection_control_failed_connections_threshold; |
| 13 |
SET @saved_max_delay = @@global.connection_control_max_connection_delay; |
| 14 |
SET @saved_min_delay = @@global.connection_control_min_connection_delay; |
| 15 |
# Set small values for connection_control variables |
| 16 |
SET @@global.connection_control_failed_connections_threshold = 3; |
| 17 |
SET @@global.connection_control_max_connection_delay = 4000; |
| 18 |
SET @@global.connection_control_min_connection_delay = 2000; |
| 19 |
|
| 20 |
# ---------------------------------------------------------------------- |
| 21 |
|
| 22 |
# Make enough failed attempts to trigger delays |
| 23 |
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET); |
| 24 |
connect(localhost,u1,haha,test,MASTER_PORT,MASTER_SOCKET); |
| 25 |
connect(localhost,u1,haha,test,MASTER_PORT,MASTER_SOCKET); |
| 26 |
|
| 27 |
# Following attempts will experience delay in server respose |
| 28 |
# Connection attempt should fail. |
| 29 |
Connection_control_delay_generated should be 1 |
| 30 |
Variable_name Value |
| 31 |
Connection_control_delay_generated 1 |
| 32 |
@server_response_time >= 2 |
| 33 |
1 |
| 34 |
# Connection attempt should fail. |
| 35 |
Connection_control_delay_generated should be 2 |
| 36 |
Variable_name Value |
| 37 |
Connection_control_delay_generated 2 |
| 38 |
@server_response_time >= 2 |
| 39 |
1 |
| 40 |
# Connection attempt should fail. |
| 41 |
Connection_control_delay_generated should be 3 |
| 42 |
Variable_name Value |
| 43 |
Connection_control_delay_generated 3 |
| 44 |
@server_response_time >= 3 |
| 45 |
1 |
| 46 |
# Connection attempt should fail. |
| 47 |
Connection_control_delay_generated should be 4 |
| 48 |
Variable_name Value |
| 49 |
Connection_control_delay_generated 4 |
| 50 |
@server_response_time >= 4 |
| 51 |
1 |
| 52 |
# Connection attempt should succeed. |
| 53 |
Connection_control_delay_generated should be 5 |
| 54 |
Variable_name Value |
| 55 |
Connection_control_delay_generated 5 |
| 56 |
@server_response_time >= 4 |
| 57 |
1 |
| 58 |
|
| 59 |
# Following attempts will not experience any delay in server respose |
| 60 |
# Connection attempt should fail. |
| 61 |
Connection_control_delay_generated should be 5 |
| 62 |
Variable_name Value |
| 63 |
Connection_control_delay_generated 5 |
| 64 |
# Connection attempt should succeed. |
| 65 |
Connection_control_delay_generated should be 5 |
| 66 |
Variable_name Value |
| 67 |
Connection_control_delay_generated 5 |
| 68 |
|
| 69 |
# ---------------------------------------------------------------------- |
| 70 |
|
| 71 |
# Cleanup |
| 72 |
# Restore original values of conenction_control variables |
| 73 |
SET @@global.connection_control_failed_connections_threshold = @saved_connections_threshold; |
| 74 |
SET @@global.connection_control_max_connection_delay = @saved_max_delay; |
| 75 |
SET @@global.connection_control_min_connection_delay = @saved_min_delay; |
| 76 |
# Remove user account created for the test |
| 77 |
DROP USER u1; |
| 78 |
# Uninstall connection_control plugin |
| 79 |
UNINSTALL PLUGIN connection_control; |
| 80 |
UNINSTALL PLUGIN connection_control_failed_login_attempts; |
| 81 |
|
| 82 |
# ---------------------------------------------------------------------- |