File: gr_to_binlogless_slave.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 (122 lines) | stat: -rw-r--r-- 4,767 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
################################################################################
# BUG#22045032 - SQL_THREAD OF BINLOG-LESS SLAVE FAILS WITHOUT ANY MESSAGE FOR
#                VIEW_CHANGE EVENT
#
# This test verifies that the slave server with binlog disabled is able to
# skip the view change events when replicating from a member which is part of
# a Group.
#
# Bug#24754462	- ADD MTR TEST RELATED TO MYSQLBINLOG IN GR
# This test  also checks replaying of mysqlbinlog output of GR member on a
# binlog-less server and verifies that binlogless server cannot be added to
# the GR group.
#
# Test:
# 0. The test requires three servers: M1, M2 and M3.
# 1. Bootstrap start a group on M1. Start GR on M2 and add some data.
# 2. Connect the third server to one of the member of the group, establishing
#    an asynchronous replication connection (M1->M3). Start slave on M3.
# 3. On the slave (M3), test that the data is properly replicated after the
#    start slave is completed. Diff check the table on M1 and M3.
# 4. Verify if the available backup (binlog file) can be later restored
#    successfully on a binlogless-server.
# 5. Verify if binlogless-server cannot be added to the GR group
# 6. Ensure that the test is cleaned up and closed.
################################################################################

--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--let $rpl_server_count= 4
--source include/group_replication.inc

# Start the first member here
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_and_bootstrap_group_replication.inc

# Start the second node. Add some data and sync it in the group.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/start_group_replication.inc
CREATE TABLE t1 (i INT PRIMARY KEY);
INSERT INTO t1 VALUES(1);
--source include/rpl_sync.inc

# Establish an async connection between the third server and member 1 of
# the group.
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

SET SESSION sql_log_bin=0;
call mtr.add_suppression("You need to use --log-bin to make");
SET SESSION sql_log_bin=1;

# Make this server the slave of the first server which belongs to the group.
--disable_warnings
--replace_result $MASTER_MYPORT MASTER_PORT
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root'
--enable_warnings

--source include/start_slave.inc

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $sync_slave_connection= server3
--source include/sync_slave_sql_with_master.inc

--echo # On the slave (server3), test that the data is properly replicated
--echo # after the start slave is complete.
--let $diff_tables= server1:test.t1, server3:test.t1
--source include/diff_tables.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

# Get the binlog file
--let $server2_datadir= `SELECT @@DATADIR`
--let $server2_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)

--echo
--let $rpl_connection_name= server4
--source include/rpl_connection.inc
# Restore the backup onto a server outside the GR group
set sql_log_bin=0;
call mtr.add_suppression("\\[ERROR\\] \\[MY-[^]]*\\] \\[Repl\\] Plugin group_replication reported: 'Binlog must be enabled for Group Replication'");
call mtr.add_suppression("You need to use --log-bin to make --binlog-format work.");
set sql_log_bin=1;

# Setting the arguments to connect to server4
--let $server4_connection_args= --user=root --host=127.0.0.1 --port=$SERVER_MYPORT_4
# Restoring the backup file on server4 using mysqlbinlog client and the connection arguments set above
--exec $MYSQL_BINLOG $server2_datadir/$server2_binlog_file | $MYSQL $server4_connection_args

# See if the data has been properly restored on server4
--echo # check that t1 exists and has same values in all servers
--let $diff_tables=server1:test.t1 ,server2:test.t1 ,server3:test.t1 ,server4:test.t1
--source include/diff_tables.inc

# Add server4 to GR group
# This operation will fail as binlog is disabled in server4
--replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME
--eval SET GLOBAL group_replication_group_name= "$group_replication_group_name"
--error ER_GROUP_REPLICATION_CONFIGURATION
START GROUP_REPLICATION;

# Drop table
DROP TABLE t1;

--let $rpl_connection_name= server1
--source include/rpl_connection.inc
DROP TABLE t1;

--let $sync_slave_connection= server3
--source include/sync_slave_sql_with_master.inc
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--source include/stop_slave.inc
--source include/rpl_reset_slave.inc

--source include/group_replication_end.inc