|
| 1 | +# ==== Requirements ==== |
| 2 | +# |
| 3 | +# R1. When slave fails to connect to master, the error message shown in |
| 4 | +# performance_schema.replication_connection_status/LAST_ERROR_MESSAGE, |
| 5 | +# and in SHOW SLAVE STATUS/LAST_IO_ERROR, should contain the reason |
| 6 | +# for the failure. |
| 7 | +# |
| 8 | +# R2. When slave fails to connect to master, the messages in |
| 9 | +# performance_schema.replication_connection_status/LAST_ERROR_MESSAGE, |
| 10 | +# and in SHOW SLAVE STATUS/LAST_IO_ERROR, should both be identical. |
| 11 | +# |
| 12 | +# ==== Implementation ==== |
| 13 | +# |
| 14 | +# 1. Try to connect using a non-existing user. |
| 15 | +# 2. Try to connect on an invalid port. |
| 16 | +# 3. Try to connect to a non-existing host. |
| 17 | +# |
| 18 | +# In each of the cases: |
| 19 | +# - Verify that the error message in performance_schema contains |
| 20 | +# 'Access denied'/'Cant connect to MySQL'/'Unknown MySQL server host' |
| 21 | +# - Verify that the error message in SHOW SLAVE STATUS contains the same. |
| 22 | +# |
| 23 | +# ==== References ==== |
| 24 | +# |
| 25 | +# BUG#26580064 CONFUSING ERROR MESSAGE IN REPLICATION WHEN CONNECTING WITH MASTER |
| 26 | + |
| 27 | +# Test should only run once. |
| 28 | +--source include/have_binlog_format_row.inc |
| 29 | +--let $rpl_skip_start_slave = 1 |
| 30 | +--source include/master-slave.inc |
| 31 | + |
| 32 | + |
| 33 | +# Verify that the message has the expected form. |
| 34 | +# |
| 35 | +# This asserts that $message contains $expected_message, |
| 36 | +# but ignores single quotes, numbers, and dots. |
| 37 | +# |
| 38 | +# Usage: |
| 39 | +# --let $message = "message text from mysql server" |
| 40 | +# --let $expected_message = "the text that we expect to see" |
| 41 | +# --source $script_dir/check_message.inc |
| 42 | + |
| 43 | +--let $script_dir = $MYSQLTEST_VARDIR |
| 44 | +--write_file $script_dir/check_message.inc |
| 45 | + if ($message == '') { |
| 46 | + --die !!!ERROR IN TEST: you must set $message |
| 47 | + } |
| 48 | + if ($expected_message == '') { |
| 49 | + --die !!!ERROR IN TEST: you must set $expected_message |
| 50 | + } |
| 51 | + # Remove quotes (which confuse assert.inc) from the message. |
| 52 | + --let $message_noquotes = `SELECT REPLACE("$message", "'", '')` |
| 53 | + # Remove numbers (which are nondeterministic) from the message. |
| 54 | + --let $message_nonumbers = `SELECT REGEXP_REPLACE("$message_noquotes", "[0-9\.]*", '')` |
| 55 | + --let $assert_cond = "$message_nonumbers" LIKE "%$expected_message%" |
| 56 | + --let $assert_text = Error should contain the reason ($expected_message) for connection failure |
| 57 | + --source include/assert.inc |
| 58 | +EOF |
| 59 | + |
| 60 | +# Check messages in both performance_schema and SHOW SLAVE STATUS. |
| 61 | +# |
| 62 | +# This will check that the receiver error in performance_schema and |
| 63 | +# SHOW SLAVE STATUS contains $expected_message. It also checks that |
| 64 | +# both performance_schema and SHOW SLAVE STATUS contain literally the |
| 65 | +# same message. |
| 66 | +# |
| 67 | +# Usage: |
| 68 | +# --let $expected_message = "the text that we expect to see" |
| 69 | +# --source $script_dir/check_both_messages.inc |
| 70 | +# |
| 71 | +# Side effects: |
| 72 | +# - Sets $message_noquotes to the message with quotes removed. |
| 73 | +--write_file $script_dir/check_both_messages.inc |
| 74 | + if ($expected_message == '') { |
| 75 | + --die !!!ERROR IN TEST: you must set $expected_message |
| 76 | + } |
| 77 | + START SLAVE IO_THREAD; |
| 78 | + --source include/wait_for_slave_io_error.inc |
| 79 | + |
| 80 | + --echo ---- Check performance_schema ---- |
| 81 | + |
| 82 | + --let $message = `SELECT LAST_ERROR_MESSAGE FROM performance_schema.replication_connection_status` |
| 83 | + # Remove quotes since they confuse assert.inc |
| 84 | + --source $script_dir/check_message.inc |
| 85 | + --let $message_ps = $message_noquotes |
| 86 | + |
| 87 | + --echo ---- Check SHOW SLAVE STATUS ---- |
| 88 | + |
| 89 | + --let $message = query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1) |
| 90 | + --source $script_dir/check_message.inc |
| 91 | + --let $message_sss = $message_noquotes |
| 92 | + |
| 93 | + --echo ---- Check that messages are the same in both places ---- |
| 94 | + |
| 95 | + --let $assert_cond = "$message_ps" = "$message_sss" |
| 96 | + --let $assert_text = Error should be the same in both SSS and P_S |
| 97 | + --source include/assert.inc |
| 98 | +EOF |
| 99 | + |
| 100 | +CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY = 1, SOURCE_RETRY_COUNT = 1; |
| 101 | + |
| 102 | + |
| 103 | +--echo #### Test 1: invalid credentials #### |
| 104 | + |
| 105 | +--source include/rpl_connection_slave.inc |
| 106 | +CHANGE REPLICATION SOURCE TO SOURCE_USER = 'foo'; |
| 107 | +--let $slave_io_errno = convert_error(ER_ACCESS_DENIED_ERROR) |
| 108 | +--let $expected_message = Access denied for user foo |
| 109 | +--source $script_dir/check_both_messages.inc |
| 110 | + |
| 111 | + |
| 112 | +--echo #### Test 2: invalid port #### |
| 113 | + |
| 114 | +--source include/rpl_connection_slave.inc |
| 115 | +CHANGE REPLICATION SOURCE TO SOURCE_PORT = 1; |
| 116 | +--let $slave_io_errno = 2003 # CR_CONN_HOST_ERROR |
| 117 | +--let $expected_message = Cant connect to MySQL server on |
| 118 | +--source $script_dir/check_both_messages.inc |
| 119 | + |
| 120 | + |
| 121 | +--echo #### Test 3: invalid host #### |
| 122 | + |
| 123 | +--source include/rpl_connection_slave.inc |
| 124 | +CHANGE REPLICATION SOURCE TO SOURCE_HOST = '999.999.999.999'; |
| 125 | +--let $slave_io_errno = 2005 # CR_UNKNOWN_HOST |
| 126 | +--let $expected_message = Unknown MySQL server host |
| 127 | +--source $script_dir/check_both_messages.inc |
| 128 | + |
| 129 | + |
| 130 | +--echo #### Clean up #### |
| 131 | + |
| 132 | +RESET SLAVE; |
| 133 | +--remove_file $script_dir/check_message.inc |
| 134 | +--remove_file $script_dir/check_both_messages.inc |
| 135 | +--replace_result $MASTER_MYPORT PORT |
| 136 | +eval CHANGE REPLICATION SOURCE TO SOURCE_HOST = '127.0.0.1', SOURCE_PORT = $MASTER_MYPORT, SOURCE_USER = 'root'; |
| 137 | +--source include/start_slave.inc |
| 138 | + |
| 139 | +--source include/rpl_end.inc |
0 commit comments