File: gr_single_primary_mysqlbinlog.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 (143 lines) | stat: -rw-r--r-- 5,776 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
################################################################################
# WL9426: MySQL NG: Single Primary Mode in Group Replication
# Test SECONDARY(RO) fails gracefully upon executing DDL/DML via mysqlbinlog.
#
# Test:
# 0. This test requires three servers.
# 1. Bootstrap start GR on server3 (Primary).
# -  Execute some transactions.
# -  Stop GR on server3.
# -  Save mysqlbinlog output in a file.
# 2. Bootstrap start GR on server1 (Primary). Start GR on server2 (Secondary).
# 3. Try executing mysqlbinlog output of server3 on server2(RO). Expect Error.
# 4. Try executing mysqlbinlog output of server3 on server1(RW). Expect Success.
# 5. Join server3 to the group.
# 6. Cleanup.
################################################################################

--source include/big_test.inc
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--let $rpl_server_count= 3
--let $rpl_group_replication_single_primary_mode=1
--source include/group_replication.inc

--echo #
--echo # Bootstrap start GR on server3 (Primary). And, execute some transactions
--echo # on server3. Then, stop GR on server3.
--echo #
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
# Bootstrap start GR on server3
--source include/start_and_bootstrap_group_replication.inc

# Execute some transactions on server3
--replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME
--eval SET GTID_NEXT= "$group_replication_group_name:2"
BEGIN;
COMMIT;
SET GTID_NEXT= "AUTOMATIC";
CREATE TABLE test.t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO test.t1 VALUES (1);

# Stop GR on server3
--source include/stop_group_replication.inc

--let $assert_text= GTID_EXECUTED must contain GROUP_UUID:1-4
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4"
--source include/assert.inc

# Save mysqlbinlog output in a file
--let $server3_datadir= `SELECT @@DATADIR`
--let $server3_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
--exec $MYSQL_BINLOG --force-if-open $server3_datadir/$server3_binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_grtest.binlog

--echo #
--echo # Bootstrap start GR on server1 (Primary). Start GR on server2 (Secondary).
--echo #
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $server1_uuid= `SELECT @@server_uuid`
--source include/start_and_bootstrap_group_replication.inc

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

# Make sure server1 is Primary
--let $assert_text= Verify group_replication_primary_member is SERVER_UUID
--let $assert_cond= "[SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE VARIABLE_NAME= \'group_replication_primary_member\', VARIABLE_VALUE, 1]" = "$server1_uuid"
--source include/assert.inc

--echo #
--echo # Try executing mysqlbinlog output of server3 on server2(RO). Expect ERROR.
--echo #
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $server2_connection_args= --user=root --host=127.0.0.1 --port=$SERVER_MYPORT_2
--error 1 #ER_OPTION_PREVENTS_STATEMENT
--exec $MYSQL $server2_connection_args -e "source $MYSQLTEST_VARDIR/tmp/mysqlbinlog_grtest.binlog"

# Check no changes in GTID_EXECUTED
--let $assert_text= GTID_EXECUTED must contain GROUP_UUID:1-2
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-2"
--source include/assert.inc

--echo #
--echo # Try executing mysqlbinlog output of server3 on server1(RW). Expect SUCCESS.
--echo #
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $server1_connection_args= --user=root --host=127.0.0.1 --port=$SERVER_MYPORT_1
--exec $MYSQL $server1_connection_args -e "source $MYSQLTEST_VARDIR/tmp/mysqlbinlog_grtest.binlog"

# Check if data has been applied on server1
--echo Wait until server1 applies the single row of table t1
--let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.tables WHERE TABLE_SCHEMA="test" AND TABLE_NAME="t1";
--source include/wait_condition.inc
--let $wait_condition= SELECT COUNT(*)=1 FROM test.t1
--source include/wait_condition.inc

--let $assert_text= GTID_EXECUTED must contain GROUP_UUID:1-4
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4"
--source include/assert.inc

# Check if data has been applied in the group
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--echo Wait until server2 applies the single row of table t1
--let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.tables WHERE TABLE_SCHEMA="test" AND TABLE_NAME="t1";
--source include/wait_condition.inc
--let $wait_condition= SELECT COUNT(*)=1 FROM test.t1
--source include/wait_condition.inc

--let $assert_text= GTID_EXECUTED must contain GROUP_UUID:1-4
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-4"
--source include/assert.inc

--echo #
--echo # Join server3 to the group. Expect SUCCESS.
--echo #
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
--source include/start_group_replication.inc

# Make sure number of servers in the group is 3
--let $group_replication_number_of_members= 3
--source include/gr_wait_for_number_of_members.inc

--let $assert_text= GTID_EXECUTED must contain GROUP_UUID:1-5
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-5"
--source include/assert.inc

# Clean up.
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
# Remove binlog file which is not required now
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_grtest.binlog
DROP TABLE test.t1;

--source include/group_replication_end.inc