File: rpl_network_namespace.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 (173 lines) | stat: -rw-r--r-- 7,605 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#####################################################################
#                                                                   #
# The aim of this test is to check support for usage of network     #
# namespaces introduced by WL#12720 in a replication connection.    #
# It includes verifying that replication works on using the         #
# NETWORK_NAMESPACE clause added to the CHANGE REPLICATION SOURCE   #
# command and that details about the network namespace used for the #
# replication is reflected through SHOW SLAVE STATUS and below      #
# tables -                                                          #
# - performance_schema.replication_connection_configuration         #
# - mysql.slave_master_info                                         #
#                                                                   #
# The test requires following conditions to be met in order for     #
# it to run :-                                                      #
# 1. mysqld has been granted the capability to switch network       #
#    namespaces.                                                    #
# 2. Two network namespaces are created with specific IP addresses  #
#    and are accessible i.e.,                                       #
#    - a namespace named 'red' containing the IP '10.0.2.1'         #
#    - a namespace named 'blue' containing the IP '10.0.2.1'        #
#                                                                   #
# Creation Date: 2019-02-20                                         #
# Author: Srikanth B R                                              #
#                                                                   #
#####################################################################

# Network namespaces is a feature of Linux.
# So, ignore this test on any platform except Linux.
--source include/linux.inc

--source ../include/have_network_namespaces.inc
--source include/not_group_replication_plugin.inc

--let $rpl_skip_start_slave= 1
--source include/master-slave.inc

call mtr.add_suppression("Hostname .* does not resolve to");
call mtr.add_suppression("IP address .* could not be resolved");

--echo # Add a bind address in the 'red' network namespace to master
--let $rpl_server_number=1
--let $rpl_server_parameters= --bind-address=127.0.0.1,10.0.2.1/red
--source include/rpl_restart_server.inc

--echo # Add a bind address in the 'blue' network namespace to the slave
--let $rpl_server_parameters= --bind-address=127.0.0.1,10.0.1.1/blue
--let $rpl_server_number=2
--source include/rpl_restart_server.inc

--connection slave
--source include/start_slave.inc

--connection master

--echo # Create tables and users.

CREATE TABLE t1(a int primary key, b varchar(10));
CREATE USER root@10.0.2.1;
GRANT ALL ON *.* TO root@10.0.2.1;
CREATE USER root@10.0.1.1;
GRANT ALL ON *.* TO root@10.0.1.1;

--echo #Insert via connection to the address 127.0.0.1 from the default network namespace
INSERT INTO t1 VALUES (1, 'abc');

--echo #Insert via connection to the address 10.0.2.1 from the 'red' network namespace
--replace_result $MASTER_MYPORT MASTER_PORT
--exec $EXE_MYSQL --no-defaults -u root  --port $MASTER_MYPORT --host 10.0.2.1 --network-namespace=red test -e "INSERT INTO t1 VALUES (2, 'cdf');"

SHOW CREATE TABLE t1;

--echo [ connection slave ]
--source include/sync_slave_sql_with_master.inc

SHOW CREATE TABLE t1;

--echo # Check network namspace of currently connected master
SELECT network_namespace AS master_network_namespace FROM performance_schema.replication_connection_configuration;
SELECT Network_namespace FROM mysql.slave_master_info;
--let $slave_status_namespace= query_get_value(SHOW SLAVE STATUS,Network_Namespace, 1)
--echo Namespace from 'SHOW SLAVE STATUS' : $slave_status_namespace

--echo # Check slave connection on the 'blue' namespace
--replace_result $SLAVE_MYPORT SLAVE_PORT
--exec $EXE_MYSQL --no-defaults -u root  --port $SLAVE_MYPORT --host 10.0.1.1 --network-namespace=blue test -e "SELECT * FROM t1"

--echo # Stop slave and run change master to listen to the master on socket
--echo # created in the 'red' namespace
--source include/stop_slave.inc

--echo [ connection master ]
--connection master
# Some more DML's on the master
--echo #Insert via connection to the address 127.0.0.1 from the default network namespace
--let $MASTER_LOG_POS= query_get_value(SHOW MASTER STATUS, Position, 1)

INSERT INTO t1 VALUES (3, 'ghi');

--echo #Insert via connection to the address 10.0.2.1 from the 'red' network namespace
--exec $EXE_MYSQL --no-defaults -u root  --port $MASTER_MYPORT --host 10.0.2.1 --network-namespace=red test -e "INSERT INTO t1 VALUES (4, 'jkl');"

--echo [ connection slave ]
--connection slave
--echo # Change master to listen to the master on IP '10.0.2.1' in the 'red' namespace
--replace_result $MASTER_MYPORT MASTER_PORT $MASTER_LOG_POS MASTER_LOG_POS
--let $chm= CHANGE REPLICATION SOURCE TO SOURCE_HOST='10.0.2.1', SOURCE_USER='root', SOURCE_PORT=$MASTER_MYPORT, NETWORK_NAMESPACE='red'
if ( `SELECT @@GLOBAL.GTID_MODE = "OFF"` )
{
 --let $chm= $chm, SOURCE_LOG_POS=$MASTER_LOG_POS
}
--exec $EXE_MYSQL --no-defaults -u root --port $SLAVE_MYPORT --host 10.0.1.1 --network-namespace=blue test -e "$chm"
--source include/start_slave.inc

# Now sync slave with master
--connection master
--source include/sync_slave_sql_with_master.inc

--echo # Check network namspace of currently connected master
SELECT network_namespace AS master_network_namespace FROM performance_schema.replication_connection_configuration;
SELECT Network_namespace FROM mysql.slave_master_info;
--let $slave_status_namespace= query_get_value(SHOW SLAVE STATUS,Network_Namespace, 1)
--echo Namespace from 'SHOW SLAVE STATUS' : $slave_status_namespace 

--echo # Check slave connection on the 'blue' namespace
--exec $EXE_MYSQL --no-defaults -u root --port $SLAVE_MYPORT --host 10.0.1.1 --network-namespace=blue test -e "SELECT * FROM t1"

--echo # Check that the table is replicated properly
--let $diff_tables = master:t1, slave:t1
--source include/diff_tables.inc

--source include/stop_slave.inc

--echo [ connection master ]
--connection master
--let $MASTER_LOG_POS= query_get_value(SHOW MASTER STATUS, Position, 1)

--echo [ connection slave ]
--connection slave
--echo # Change master to original connection
--replace_result $MASTER_MYPORT MASTER_PORT $MASTER_LOG_POS MASTER_LOG_POS
--let $chm= CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_PORT=$MASTER_MYPORT, NETWORK_NAMESPACE=''
if ( `SELECT @@GLOBAL.GTID_MODE = "OFF"` )
{
 --let $chm= $chm, SOURCE_LOG_POS=$MASTER_LOG_POS
}
--exec $EXE_MYSQL --no-defaults -u root --port $SLAVE_MYPORT --host 10.0.1.1 --network-namespace=blue test -e "$chm"

--source include/start_slave.inc

# Now sync slave with master
--connection master
INSERT INTO t1 VALUES (5, 'mno');
--source include/sync_slave_sql_with_master.inc

--echo # Check network namspace of currently connected master
SELECT network_namespace AS master_network_namespace FROM performance_schema.replication_connection_configuration;
SELECT Network_namespace FROM mysql.slave_master_info;
--let $slave_status_namespace= query_get_value(SHOW SLAVE STATUS,Network_Namespace, 1)
--echo Namespace from 'SHOW SLAVE STATUS' : $slave_status_namespace

--echo # Check that the table is replicated properly
--let $diff_tables = master:t1, slave:t1
--source include/diff_tables.inc

--echo # Cleanup

connection master;
DROP USER root@10.0.2.1;
DROP USER root@10.0.1.1;
DROP TABLE t1;

--source include/sync_slave_sql_with_master.inc
--source include/rpl_end.inc