Debian Codegraph @

mysql-test/suite/network_namespace/t/rpl_network_namespace_debug.test

raw
1 # ==== Purpose ====
2 #
3 # Verify that replication connection happens on the configured network
4 # namespace, even in case of reconnection.
5 #
6 # ==== Requirements ====
7 #
8 # R1. Replica should be able to connect to source through network namespaces.
9 # R2. Replica should be able to automatically reconnect to source through
10 # network namespaces.
11 #
12 # ==== Implementation ====
13 #
14 # Setup replication connection using network namespaces.
15 # Disconnect source, by shutting it down.
16 # Verify that replica's automatic reconnection happens on the same network
17 # namespace.
18 #
19 # ==== References ====
20 #
21 # BUG 31954087 - CHANNEL IN A NETWORK NAMESPACE DOES NOT RECONNECT TO MASTER
22
23 # Network namespaces is a feature of Linux.
24 # So, ignore this test on any platform except Linux.
25 --source include/linux.inc
26 # Test involves shutdown and restart of servers, so disable valgrind.
27 --source include/not_valgrind.inc
28 --source include/have_debug.inc
29 --source include/have_debug_sync.inc
30 --source ../include/have_network_namespaces.inc
31 --source include/not_group_replication_plugin.inc
32
33 --let $rpl_skip_start_slave = 1
34 --source include/master-slave.inc
35
36 --echo ==== Configure ====
37
38 call mtr.add_suppression("Hostname .* does not resolve to");
39 call mtr.add_suppression("IP address .* could not be resolved");
40
41 --echo # Add a bind address in the 'red' network namespace to master
42 --let $rpl_server_number = 1
43 --let $rpl_server_parameters = --bind-address=127.0.0.1,10.0.2.1/red
44 --source include/rpl_restart_server.inc
45
46 --echo # Add a bind address in the 'blue' network namespace to the slave
47 --let $rpl_server_parameters = --bind-address=127.0.0.1,10.0.1.1/blue
48 --let $rpl_server_number = 2
49 --source include/rpl_restart_server.inc
50
51 --source include/rpl_connection_slave.inc
52 call mtr.add_suppression("Replica I/O for channel '': Source command COM_REGISTER_REPLICA failed: .*");
53 --source include/start_slave.inc
54
55 # ==== Procedure verify_namespace_configuration ====
56 #
57 # Usage:
58 # --let $namespace = NAME
59 # --source $verify_namespace_configuration
60 #
61 # This asserts that the configured network namespace for replication
62 # is equal to NAME, both according to performance_schema, SHOW REPLICA STATUS,
63 # and the replication repository.
64 --let $verify_namespace_configuration = $MYSQL_TMP_DIR/verify_namespace_configuration.inc
65 --write_file $verify_namespace_configuration END_OF_PROCEDURE
66 --let $assert_text = Performance_schema should show that the network namespace for the replication connection is configured to '$namespace'.
67 --let $assert_cond = "[SELECT network_namespace FROM performance_schema.replication_connection_configuration]" = "$namespace"
68 --source include/assert.inc
69
70 --let $assert_text = The replication repository should show that the network namespace for the replication connection is configured to '$namespace'.
71 --let $assert_cond = "[SELECT Network_namespace FROM mysql.slave_master_info]" = "$namespace"
72 --source include/assert.inc
73
74 --let $assert_text = SHOW REPLICA STATUS should show that the network namespace for the replication connection is configured to '$namespace'.
75 --let $assert_cond = "[SHOW REPLICA STATUS, Network_Namespace, 1]" = "$namespace"
76 --source include/assert.inc
77 END_OF_PROCEDURE
78
79 --echo ==== Scenario 1: without namespaces ====
80
81 --source include/rpl_connection_master.inc
82
83 --echo # Create users.
84 CREATE USER [email protected];
85 GRANT ALL ON *.* TO [email protected];
86 CREATE USER [email protected];
87 GRANT ALL ON *.* TO [email protected];
88
89 --echo [connection slave]
90 --source include/sync_slave_sql_with_master.inc
91
92 --let $namespace =
93 --source $verify_namespace_configuration
94
95 --echo ==== Scenario 2: source uses a namespace ====
96
97 --echo # Stop slave and run CHANGE MASTER to listen to the source on socket
98 --echo # created in the 'red' namespace
99 --source include/stop_slave.inc
100
101 --source include/rpl_connection_master.inc
102 --let $MASTER_LOG_POS = query_get_value(SHOW MASTER STATUS, Position, 1)
103
104 --source include/rpl_connection_slave.inc
105 --echo # Change master to listen to the source on IP '10.0.2.1' in the 'red' namespace
106 --replace_result $MASTER_MYPORT MASTER_PORT $MASTER_LOG_POS MASTER_LOG_POS
107 --let $chm = CHANGE MASTER TO MASTER_HOST='10.0.2.1', MASTER_USER='root', MASTER_PORT=$MASTER_MYPORT, NETWORK_NAMESPACE='red'
108 if ( `SELECT @@GLOBAL.GTID_MODE = "OFF"` )
109 {
110 --let $chm = $chm, MASTER_LOG_POS=$MASTER_LOG_POS
111 }
112 --exec $EXE_MYSQL --no-defaults -u root --port $SLAVE_MYPORT --host 10.0.1.1 --network-namespace=blue test -e "$chm"
113 --source include/start_slave.inc
114 --source include/rpl_connection_master.inc
115 --source include/sync_slave_sql_with_master.inc
116
117 --let $namespace = red
118 --source $verify_namespace_configuration
119
120 --echo ==== Scenario 3: reconnection while using a namespace ====
121
122 # Simulate network disconnection by shutting down source, and verify
123 # we reconnect in the same namespace.
124
125 --source include/rpl_connection_master.inc
126 --let $MASTER_LOG_POS = query_get_value(SHOW MASTER STATUS, Position, 1)
127
128 --source include/rpl_connection_slave.inc
129 --source include/stop_slave.inc
130
131 # Make receiver thread pause after it has connected
132 --let $debug_point = dbug.before_get_SOURCE_UUID
133 --source include/add_debug_point.inc
134
135 --source include/start_slave.inc
136
137 --let $rpl_server_number = 1
138 --source include/rpl_stop_server.inc
139
140 --echo # Unblock receiver thread
141 eval SET DEBUG_SYNC = 'now SIGNAL signal.get_source_uuid';
142
143 --echo # Check network error happened here
144 # '2013' CR_SERVER_LOST
145 # '2003' CR_CONN_HOST_ERROR
146 # '2002' CR_CONNECTION_ERROR
147 # '2006' CR_SERVER_GONE_ERROR
148 # '1040' ER_CON_COUNT_ERROR
149 # '1053' ER_SERVER_SHUTDOWN
150 --let $slave_io_errno = 1040, 1053, 2002, 2003, 2006, 2013
151 --let $slave_io_error_is_nonfatal = 1
152 --source include/wait_for_slave_io_error.inc
153
154 # clean up sync points
155 --let $debug_point = dbug.before_get_SOURCE_UUID
156 --source include/remove_debug_point.inc
157
158 --let $rpl_server_number = 1
159 --let $rpl_server_parameters = --bind-address=127.0.0.1,10.0.2.1/red
160 --source include/rpl_start_server.inc
161 --source include/wait_for_slave_io_to_start.inc
162
163 --let $namespace = red
164 --source $verify_namespace_configuration
165
166 --echo ==== Scenario 4: restore to connection without namespace ====
167
168 --source include/stop_slave.inc
169
170 --source include/rpl_connection_master.inc
171 --let $MASTER_LOG_POS = query_get_value(SHOW MASTER STATUS, Position, 1)
172
173 --source include/rpl_connection_slave.inc
174 --echo # Change master to original connection
175 --replace_result $MASTER_MYPORT MASTER_PORT $MASTER_LOG_POS MASTER_LOG_POS
176 --let $chm = CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$MASTER_MYPORT, NETWORK_NAMESPACE=''
177 if (`SELECT @@GLOBAL.GTID_MODE = "OFF"`)
178 {
179 --let $chm = $chm, MASTER_LOG_POS=$MASTER_LOG_POS
180 }
181 # Connect via the 'blue' namespace and execute the command.
182 --exec $EXE_MYSQL --no-defaults -u root --port $SLAVE_MYPORT --host 10.0.1.1 --network-namespace=blue test -e "$chm"
183
184 --source include/start_slave.inc
185 --source include/rpl_connection_master.inc
186 --source include/sync_slave_sql_with_master.inc
187
188 --let $namespace =
189 --source $verify_namespace_configuration
190
191 --echo ==== Cleanup ====
192
193 --remove_file $verify_namespace_configuration
194 --source include/rpl_connection_master.inc
195 DROP USER [email protected];
196 DROP USER [email protected];
197
198 --source include/sync_slave_sql_with_master.inc
199 --source include/rpl_end.inc