File: rpl_connection_error_message.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (139 lines) | stat: -rw-r--r-- 4,910 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# ==== Requirements ====
#
# R1. When slave fails to connect to master, the error message shown in
#     performance_schema.replication_connection_status/LAST_ERROR_MESSAGE,
#     and in SHOW SLAVE STATUS/LAST_IO_ERROR, should contain the reason
#     for the failure.
#
# R2. When slave fails to connect to master, the messages in
#     performance_schema.replication_connection_status/LAST_ERROR_MESSAGE,
#     and in SHOW SLAVE STATUS/LAST_IO_ERROR, should both be identical.
#
# ==== Implementation ====
#
# 1. Try to connect using a non-existing user.
# 2. Try to connect on an invalid port.
# 3. Try to connect to a non-existing host.
#
# In each of the cases:
# - Verify that the error message in performance_schema contains
#   'Access denied'/'Cant connect to MySQL'/'Unknown MySQL server host'
# - Verify that the error message in SHOW SLAVE STATUS contains the same.
#
# ==== References ====
#
# BUG#26580064	CONFUSING ERROR MESSAGE IN REPLICATION WHEN CONNECTING WITH MASTER

# Test should only run once.
--source include/have_binlog_format_row.inc
--let $rpl_skip_start_slave = 1
--source include/master-slave.inc


# Verify that the message has the expected form.
#
# This asserts that $message contains $expected_message,
# but ignores single quotes, numbers, and dots.
#
# Usage:
#  --let $message = "message text from mysql server"
#  --let $expected_message = "the text that we expect to see"
#  --source $script_dir/check_message.inc

--let $script_dir = $MYSQLTEST_VARDIR
--write_file $script_dir/check_message.inc
  if ($message == '') {
    --die !!!ERROR IN TEST: you must set $message
  }
  if ($expected_message == '') {
    --die !!!ERROR IN TEST: you must set $expected_message
  }
  # Remove quotes (which confuse assert.inc) from the message.
  --let $message_noquotes = `SELECT REPLACE("$message", "'", '')`
  # Remove numbers (which are nondeterministic) from the message.
  --let $message_nonumbers = `SELECT REGEXP_REPLACE("$message_noquotes", "[0-9\.]*", '')`
  --let $assert_cond = "$message_nonumbers" LIKE "%$expected_message%"
  --let $assert_text = Error should contain the reason ($expected_message) for connection failure
  --source include/assert.inc
EOF

# Check messages in both performance_schema and SHOW SLAVE STATUS.
#
# This will check that the receiver error in performance_schema and
# SHOW SLAVE STATUS contains $expected_message. It also checks that
# both performance_schema and SHOW SLAVE STATUS contain literally the
# same message.
#
# Usage:
#   --let $expected_message = "the text that we expect to see"
#   --source $script_dir/check_both_messages.inc
#
# Side effects:
# - Sets $message_noquotes to the message with quotes removed.
--write_file $script_dir/check_both_messages.inc
  if ($expected_message == '') {
    --die !!!ERROR IN TEST: you must set $expected_message
  }
  START SLAVE IO_THREAD;
  --source include/wait_for_slave_io_error.inc

  --echo ---- Check performance_schema ----

  --let $message = `SELECT LAST_ERROR_MESSAGE FROM performance_schema.replication_connection_status`
  # Remove quotes since they confuse assert.inc
  --source $script_dir/check_message.inc
  --let $message_ps = $message_noquotes

  --echo ---- Check SHOW SLAVE STATUS ----

  --let $message = query_get_value(SHOW SLAVE STATUS, Last_IO_Error, 1)
  --source $script_dir/check_message.inc
  --let $message_sss = $message_noquotes

  --echo ---- Check that messages are the same in both places ----

  --let $assert_cond = "$message_ps" = "$message_sss"
  --let $assert_text = Error should be the same in both SSS and P_S
  --source include/assert.inc
EOF

CHANGE REPLICATION SOURCE TO SOURCE_CONNECT_RETRY = 1, SOURCE_RETRY_COUNT = 1;


--echo #### Test 1: invalid credentials ####

--source include/rpl_connection_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_USER = 'foo';
--let $slave_io_errno = convert_error(ER_ACCESS_DENIED_ERROR)
--let $expected_message = Access denied for user foo
--source $script_dir/check_both_messages.inc


--echo #### Test 2: invalid port ####

--source include/rpl_connection_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_PORT = 1;
--let $slave_io_errno = 2003 # CR_CONN_HOST_ERROR
--let $expected_message = Cant connect to MySQL server on
--source $script_dir/check_both_messages.inc


--echo #### Test 3: invalid host ####

--source include/rpl_connection_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_HOST = '999.999.999.999';
--let $slave_io_errno = 2005 # CR_UNKNOWN_HOST
--let $expected_message = Unknown MySQL server host
--source $script_dir/check_both_messages.inc


--echo #### Clean up ####

RESET SLAVE;
--remove_file $script_dir/check_message.inc
--remove_file $script_dir/check_both_messages.inc
--replace_result $MASTER_MYPORT PORT
eval CHANGE REPLICATION SOURCE TO SOURCE_HOST = '127.0.0.1', SOURCE_PORT = $MASTER_MYPORT, SOURCE_USER = 'root';
--source include/start_slave.inc

--source include/rpl_end.inc