Debian Codegraph @

mysql-test/suite/group_replication/t/gr_recovery.test

raw
1 ################################################################################
2 # Multi Master recovery test
3 # This test focus on the recovery feature of multi master groups.
4 # The basic functioning of this test consists in loading some data to a group
5 # and then verify if a new joining member contains also this data after recovery.
6 # Three specific scenarios are tested:
7 # 1) A brand new member joins the group and recovers
8 # 2) The donor on 1) leaves and returns being now a joiner.
9 # 3) The joiner in 1) leaves and returns, doing a second round of recovery.
10 #
11 # Test:
12 # 0. The test requires three servers: M1, M2 and M3.
13 # 1. Test the recovery of new members:
14 # - Bootstrap start GR on M1. Add some data for recovery.
15 # - Start GR on M2 and M3. Check after recovery all members must see each other
16 # - Validate data is present on all the members.
17 # - Test group responds to requests well.
18 # - All members must have the same GTID set.
19 # - Check if the data is the same on joiner(M2) and donor(M1).
20 # 2. Test recovery on a member that left and now returns:
21 # - Stop GR on M1, who never went through recovery.
22 # - Add some data on M2 for recovery.
23 # - Start GR on M1. Validate data.
24 # - Test group responds to requests well. Sync group.
25 # - Check if the data is the same on M1 and M2.
26 # 3. Testing a second recovery round on a member:
27 # - Stop GR on M2.
28 # - Add some data on M1 for recovery.
29 # - Start GR on M2. Validate data.
30 # - Test group responds to requests well.
31 # - Check if the data is the same on M1 and M2.
32 # 4. Clean up.
33 ################################################################################
34
35 --source include/big_test.inc
36 --source include/have_group_replication_gtid_assignment_block_size_1.inc
37 --let $group_replication_group_name= 36236980-4307-11e4-916c-0800200c9a66
38 --source include/have_group_replication_plugin.inc
39 --let $rpl_skip_group_replication_start= 1
40 --let $rpl_server_count= 3
41 --source include/group_replication.inc
42
43 --echo #
44 --echo # Setup a new group
45 --echo #
46
47 --connection server1
48 --echo server1
49 --source include/start_and_bootstrap_group_replication.inc
50
51 --echo # Add some data for recovery
52
53 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
54 BEGIN;
55 INSERT INTO t1 VALUES (1);
56 INSERT INTO t1 VALUES (2);
57 COMMIT;
58 INSERT INTO t1 VALUES (3);
59
60 --echo #
61 --echo # 1) Testing the recovery of a new member
62 --echo #
63
64 --echo #Add 2 more members
65 --connection server2
66 --echo server2
67 --source include/start_group_replication.inc
68
69 --connection server3
70 --echo server3
71 --source include/start_group_replication.inc
72
73 --echo #After recovery all members must see 3 other members
74 --let $server_count=3
75 while ($server_count)
76 {
77 --connection server$server_count
78 --let $group_replication_number_of_members= 3
79 --source include/gr_wait_for_number_of_members.inc
80
81 --dec $server_count
82 }
83
84 --echo #After recovery all members must have the data present in the donor.
85 --let $server_count=3
86 while ($server_count)
87 {
88 --connection server$server_count
89 --let $assert_text= On all members, the table should exist and have 3 elements
90 --let $assert_cond= [select count(*) from t1] = 3;
91 --source include/assert.inc
92 --dec $server_count
93 }
94
95 --echo #Test if the group responds to requests
96 --connection server1
97 --echo server1
98
99 INSERT INTO t1 VALUES (4);
100
101 --connection server2
102 --echo server2
103
104 INSERT INTO t1 VALUES (5);
105
106 --connection server3
107 --echo server3
108
109 --let $wait_condition= select count(*) = 5 from t1;
110 --source include/wait_condition.inc
111
112 --source include/rpl_sync.inc
113
114 --echo #All members must have the same GTID set
115 --let $server_count=3
116 while ($server_count)
117 {
118 --connection server$server_count
119 --let $assert_text= On member $server_count, all executed GTID should belong to the group
120 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "36236980-4307-11e4-916c-0800200c9a66:1-8";
121 --source include/assert.inc
122 --dec $server_count
123 }
124
125 --echo #Check if the data is the same on joiner and donor
126 --let $diff_tables= server1:test.t1, server2:test.t1
127 --source include/diff_tables.inc
128
129 --echo #
130 --echo # 2) Testing recovery on a member that left and now returns
131 --echo #
132
133 --echo #Stop the member 1, who never went through recovery
134 --connection server1
135 --echo server1
136
137 --source include/stop_group_replication.inc
138
139 --echo #Add some data to the future donor
140 --connection server2
141 --echo server2
142
143 INSERT INTO t1 VALUES (6);
144
145 --connection server1
146 --echo server1
147 --source include/start_group_replication.inc
148
149 --let $assert_text= On the recovered member, the table should contain 6 elements
150 --let $assert_cond= [select count(*) from t1] = 6;
151 --source include/assert.inc
152
153 --echo #Test if the group responds to requests
154 --connection server2
155 --echo server2
156
157 INSERT INTO t1 VALUES (7);
158
159 --let $wait_condition= select count(*) = 7 from t1;
160 --source include/wait_condition.inc
161
162 # we are using this because we want to sync a pair of servers instead of the
163 # whole group. sync_slave_with_master is a legacy name.
164
165 --let $sync_slave_connection= server1
166 --source include/sync_slave_sql_with_master.inc
167
168 --let $sync_slave_connection= server3
169 --source include/sync_slave_sql_with_master.inc
170
171 connection server2;
172 --let $diff_tables= server1:test.t1, server2:test.t1
173 --source include/diff_tables.inc
174
175 --echo #
176 --echo # 3) Testing a second recovery round on a member
177 --echo #
178
179 --echo #Stop the member 2 making it go through recovery again
180 --source include/stop_group_replication.inc
181
182 --echo #Add some data to the future donor
183 --connection server1
184 --echo server1
185
186 INSERT INTO t1 VALUES (8);
187
188 --connection server2
189 --echo server2
190
191 --source include/start_group_replication.inc
192
193 --let $assert_text= On the recovered member, the table should contain 8 elements
194 --let $assert_cond= [select count(*) from t1] = 8;
195 --source include/assert.inc
196
197 --echo #Test if the group responds to requests
198 INSERT INTO t1 VALUES (9);
199
200 --connection server1
201 --echo server1
202
203 --let $wait_condition= select count(*) = 9 from t1;
204 --source include/wait_condition.inc
205
206 --let $diff_tables= server1:test.t1, server2:test.t1
207 --source include/diff_tables.inc
208
209 --echo #
210 --echo # Cleaning up
211 --echo #
212
213 DROP TABLE t1;
214
215 --source include/group_replication_end.inc