| 1 |
## Tests detecting presence of xplugin objects in PERFORMANCE_SCHEMA. |
| 2 |
|
| 3 |
## Preamble |
| 4 |
--source ../include/have_performance_schema_threads.inc |
| 5 |
--source include/xplugin_preamble.inc |
| 6 |
--source include/xplugin_create_user.inc |
| 7 |
|
| 8 |
# Tests |
| 9 |
--write_file $MYSQL_TMP_DIR/performance_schema_socket_num.xpl |
| 10 |
-->quiet |
| 11 |
-->macro check_xconnection_count %EXPECTED_NUM_OF_CONNECTIONS% |
| 12 |
-->echo Verify [Checking if X Plugin reports %EXPECTED_NUM_OF_CONNECTIONS% connections] |
| 13 |
-->wait_for %EXPECTED_NUM_OF_CONNECTIONS% SELECT count(*) as Num FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/client_connection' |
| 14 |
-->endmacro |
| 15 |
|
| 16 |
|
| 17 |
-->varlet %CON_COUNTER% 1 |
| 18 |
-->callmacro check_xconnection_count %CON_COUNTER% |
| 19 |
|
| 20 |
-->repeat 10 |
| 21 |
-->varinc %CON_COUNTER% 1 |
| 22 |
-->newsession NAME_%CON_COUNTER% x_root |
| 23 |
-->callmacro check_xconnection_count %CON_COUNTER% |
| 24 |
-->endrepeat |
| 25 |
|
| 26 |
-->echo Verify [Peer addresses of all sockets should be set to ::ffff:127.0.0.1] |
| 27 |
-->stmtsql SELECT count(*) as Num FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/client_connection' AND IP='::ffff:127.0.0.1' |
| 28 |
-->recvtovar %NUM% |
| 29 |
-->assert_eq %CON_COUNTER% %NUM% |
| 30 |
|
| 31 |
-->echo Verify [Peer ports should be unique] |
| 32 |
-->stmtsql SELECT COUNT(*) FROM (SELECT `PORT` FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/client_connection' AND IP='::ffff:127.0.0.1' GROUP BY `PORT`) as `temp_table` |
| 33 |
-->recvtovar %NUM% |
| 34 |
-->assert_eq %CON_COUNTER% %NUM% |
| 35 |
|
| 36 |
# Synchronize with X Plugin |
| 37 |
-->wait_for 1 SELECT 1 FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/client_connection' AND `STATE` = 'IDLE' |
| 38 |
|
| 39 |
-->echo Check if we have connection ACTIVE and IDLE state |
| 40 |
-->stmtsql SELECT `STATE` FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/client_connection' GROUP BY `STATE` ORDER BY `STATE` |
| 41 |
-->recvresult |
| 42 |
|
| 43 |
-->repeat 10 |
| 44 |
-->echo switched to session NAME_%CON_COUNTER% |
| 45 |
-->setsession NAME_%CON_COUNTER% |
| 46 |
-->closesession |
| 47 |
-->varinc %CON_COUNTER% -1 |
| 48 |
-->endrepeat |
| 49 |
|
| 50 |
-->echo switched to session default |
| 51 |
-->setsession |
| 52 |
-->callmacro check_xconnection_count %CON_COUNTER% |
| 53 |
-->query_result |
| 54 |
-->noquiet |
| 55 |
EOF |
| 56 |
|
| 57 |
--write_file $MYSQL_TMP_DIR/performance_schema_socket_io_stats.xpl |
| 58 |
|
| 59 |
-->macro socket_current_xconnection %VAR% |
| 60 |
stmtsql select OBJECT_INSTANCE_BEGIN FROM `performance_schema`.socket_instances WHERE |
| 61 |
THREAD_ID in (select THREAD_ID from `performance_schema`.threads WHERE PROCESSLIST_ID = connection_id()); |
| 62 |
recvtovar %VAR%; |
| 63 |
-->endmacro |
| 64 |
|
| 65 |
-->macro socket_tcp_xlisten %VAR% |
| 66 |
stmtsql select OBJECT_INSTANCE_BEGIN from `performance_schema`.socket_instances where |
| 67 |
EVENT_NAME like 'wait/io/socket/mysqlx/tcpip_socket'; |
| 68 |
recvtovar %VAR%; |
| 69 |
-->endmacro |
| 70 |
|
| 71 |
-->macro Verify_increase %VARI% %COLUMN% %EVENT_NAME% |
| 72 |
# Kick client socket counters |
| 73 |
quiet; |
| 74 |
stmtsql SELECT 1; |
| 75 |
recvresult be-quiet; |
| 76 |
callmacro %EVENT_NAME% %OBJ_ID%; |
| 77 |
stmtsql SELECT %COLUMN% FROM `performance_schema`.`socket_summary_by_instance` |
| 78 |
WHERE |
| 79 |
OBJECT_INSTANCE_BEGIN = %OBJ_ID%; |
| 80 |
recvtovar %TMP%; |
| 81 |
echo Verify [Checking if data in column %COLUMN% had increased]; |
| 82 |
assert_gt %TMP% %VARI%; |
| 83 |
varlet %VARI% %TMP%; |
| 84 |
noquiet; |
| 85 |
-->endmacro |
| 86 |
|
| 87 |
# This function doesn't get latest entry ! |
| 88 |
-->macro Verify_greater_or_equal %VARI% %COLUMN% %TABLE% %EVENT_NAME% |
| 89 |
#Kick client socket counters |
| 90 |
-->quiet |
| 91 |
-->stmtsql SELECT 1 |
| 92 |
-->recvresult be-quiet |
| 93 |
#MAKE THE CHECK |
| 94 |
-->stmtsql SELECT %COLUMN% FROM `performance_schema`.%TABLE% WHERE `EVENT_NAME` LIKE %EVENT_NAME% |
| 95 |
-->recvtovar %TMP% |
| 96 |
-->echo Verify [Checking if data in column %COLUMN% had increased] |
| 97 |
-->assert_ge %TMP% %VARI% |
| 98 |
-->varlet %VARI% %TMP% |
| 99 |
-->noquiet |
| 100 |
-->endmacro |
| 101 |
|
| 102 |
-->varlet %READ_CNT% 0 |
| 103 |
-->callmacro Verify_increase %READ_CNT% `COUNT_READ` socket_current_xconnection |
| 104 |
-->callmacro Verify_increase %READ_CNT% `COUNT_READ` socket_current_xconnection |
| 105 |
-->callmacro Verify_increase %READ_CNT% `COUNT_READ` socket_current_xconnection |
| 106 |
-->callmacro Verify_increase %READ_CNT% `COUNT_READ` socket_current_xconnection |
| 107 |
|
| 108 |
-->varlet %WRITE_CNT% 0 |
| 109 |
-->callmacro Verify_increase %WRITE_CNT% `COUNT_WRITE` socket_current_xconnection |
| 110 |
-->callmacro Verify_increase %WRITE_CNT% `COUNT_WRITE` socket_current_xconnection |
| 111 |
-->callmacro Verify_increase %WRITE_CNT% `COUNT_WRITE` socket_current_xconnection |
| 112 |
-->callmacro Verify_increase %WRITE_CNT% `COUNT_WRITE` socket_current_xconnection |
| 113 |
|
| 114 |
|
| 115 |
-->varlet %READ_BYTES1% 0 |
| 116 |
-->callmacro Verify_increase %READ_BYTES1% `SUM_NUMBER_OF_BYTES_READ` socket_current_xconnection |
| 117 |
-->callmacro Verify_increase %READ_BYTES1% `SUM_NUMBER_OF_BYTES_READ` socket_current_xconnection |
| 118 |
-->callmacro Verify_increase %READ_BYTES1% `SUM_NUMBER_OF_BYTES_READ` socket_current_xconnection |
| 119 |
-->callmacro Verify_increase %READ_BYTES1% `SUM_NUMBER_OF_BYTES_READ` socket_current_xconnection |
| 120 |
|
| 121 |
-->varlet %WRITE_BYTES% 0 |
| 122 |
-->callmacro Verify_increase %WRITE_BYTES% `SUM_NUMBER_OF_BYTES_WRITE` socket_current_xconnection |
| 123 |
-->callmacro Verify_increase %WRITE_BYTES% `SUM_NUMBER_OF_BYTES_WRITE` socket_current_xconnection |
| 124 |
-->callmacro Verify_increase %WRITE_BYTES% `SUM_NUMBER_OF_BYTES_WRITE` socket_current_xconnection |
| 125 |
-->callmacro Verify_increase %WRITE_BYTES% `SUM_NUMBER_OF_BYTES_WRITE` socket_current_xconnection |
| 126 |
|
| 127 |
-->varlet %READ_TIME% 0 |
| 128 |
-->callmacro Verify_greater_or_equal %READ_TIME% `SUM_TIMER_READ` `socket_summary_by_instance` 'wait/io/socket/mysqlx/client_connection' |
| 129 |
-->callmacro Verify_greater_or_equal %READ_TIME% `SUM_TIMER_READ` `socket_summary_by_instance` 'wait/io/socket/mysqlx/client_connection' |
| 130 |
-->callmacro Verify_greater_or_equal %READ_TIME% `SUM_TIMER_READ` `socket_summary_by_instance` 'wait/io/socket/mysqlx/client_connection' |
| 131 |
-->callmacro Verify_greater_or_equal %READ_TIME% `SUM_TIMER_READ` `socket_summary_by_instance` 'wait/io/socket/mysqlx/client_connection' |
| 132 |
|
| 133 |
-->varlet %WRITE_TIME% 0 |
| 134 |
-->callmacro Verify_greater_or_equal %WRITE_TIME% `SUM_TIMER_WRITE` `socket_summary_by_instance` 'wait/io/socket/mysqlx/client_connection' |
| 135 |
-->callmacro Verify_greater_or_equal %WRITE_TIME% `SUM_TIMER_WRITE` `socket_summary_by_instance` 'wait/io/socket/mysqlx/client_connection' |
| 136 |
-->callmacro Verify_greater_or_equal %WRITE_TIME% `SUM_TIMER_WRITE` `socket_summary_by_instance` 'wait/io/socket/mysqlx/client_connection' |
| 137 |
-->callmacro Verify_greater_or_equal %WRITE_TIME% `SUM_TIMER_WRITE` `socket_summary_by_instance` 'wait/io/socket/mysqlx/client_connection' |
| 138 |
|
| 139 |
-->newsession second_session x_root |
| 140 |
-->varlet %READ_BYTES2% 0 |
| 141 |
-->repeat 40 |
| 142 |
-->callmacro Verify_increase %READ_BYTES2% `SUM_NUMBER_OF_BYTES_READ` socket_current_xconnection |
| 143 |
-->endrepeat |
| 144 |
|
| 145 |
-->varlet %ACCETP_COUNT% 0 |
| 146 |
-->repeat 40 |
| 147 |
-->newsession temporary_connection x_root |
| 148 |
-->callmacro Verify_increase %ACCETP_COUNT% `COUNT_MISC` socket_tcp_xlisten |
| 149 |
-->closesession |
| 150 |
-->endrepeat |
| 151 |
|
| 152 |
-->varlet %READ_BYTES% 0 |
| 153 |
-->varinc %READ_BYTES% %READ_BYTES1% |
| 154 |
-->varinc %READ_BYTES% %READ_BYTES2% |
| 155 |
|
| 156 |
-->echo Verify summary table |
| 157 |
-->callmacro Verify_greater_or_equal %READ_BYTES% `SUM_NUMBER_OF_BYTES_READ` `socket_summary_by_event_name` 'wait/io/socket/mysqlx/client_connection' |
| 158 |
EOF |
| 159 |
|
| 160 |
--echo Verify [No socket from X Plugin should be reported] |
| 161 |
--let $XPlugin_socket_count_when_no_Xconnection= query_get_value(SELECT count(*) as Num FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/client_connection', Num, 1) |
| 162 |
|
| 163 |
if ( $XPlugin_socket_count_when_no_Xconnection != 0) { |
| 164 |
--echo got $XPlugin_socket_count_when_no_Xconnection active connections |
| 165 |
--die Reported size should be zero |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
--echo Verify [Check the IP and PORT of TCP socket] |
| 170 |
--let $XPlugin_ip= query_get_value(SELECT * FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/tcpip_socket' and STATE='ACTIVE', IP, 1) |
| 171 |
--let $XPlugin_port= query_get_value(SELECT * FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/tcpip_socket', PORT, 1) |
| 172 |
|
| 173 |
if ($XPlugin_ip != "::") { |
| 174 |
--echo X Plugin IP is set to $XPlugin_ip |
| 175 |
--die X Plugins TCP server IP should be set to :: |
| 176 |
} |
| 177 |
|
| 178 |
--let $XPlugin_port_expected= query_get_value(SELECT @@mysqlx_port as value, value, 1) |
| 179 |
|
| 180 |
if ( $XPlugin_port != $XPlugin_port_expected) { |
| 181 |
--echo X Plugin tcp-port is set to $XPlugin_port, was expecting $XPlugin_port_expected |
| 182 |
--die X Plugins TCP server port has a wrong value |
| 183 |
} |
| 184 |
|
| 185 |
--echo Check if clinet_socket are reported in proper way in PFS |
| 186 |
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/performance_schema_socket_num.xpl 2>&1 |
| 187 |
|
| 188 |
--echo No socket should be reported by X Plugin |
| 189 |
let $wait_condition= |
| 190 |
SELECT count(*)= 0 as Num FROM performance_schema.socket_instances WHERE EVENT_NAME LIKE 'wait/io/socket/mysqlx/client_connection'; |
| 191 |
--source include/wait_condition_or_abort.inc |
| 192 |
|
| 193 |
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/performance_schema_socket_io_stats.xpl 2>&1 |
| 194 |
|
| 195 |
## Cleanup |
| 196 |
--source ../include/xplugin_cleanup.inc |