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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
################################################################################
# Multi Master recovery test
# This test focus on the recovery feature of multi master groups.
# The basic functioning of this test consists in loading some data to a group
# and then verify if a new joining member contains also this data after recovery.
# Three specific scenarios are tested:
# 1) A brand new member joins the group and recovers
# 2) The donor on 1) leaves and returns being now a joiner.
# 3) The joiner in 1) leaves and returns, doing a second round of recovery.
#
# Test:
# 0. The test requires three servers: M1, M2 and M3.
# 1. Test the recovery of new members:
# - Bootstrap start GR on M1. Add some data for recovery.
# - Start GR on M2 and M3. Check after recovery all members must see each other
# - Validate data is present on all the members.
# - Test group responds to requests well.
# - All members must have the same GTID set.
# - Check if the data is the same on joiner(M2) and donor(M1).
# 2. Test recovery on a member that left and now returns:
# - Stop GR on M1, who never went through recovery.
# - Add some data on M2 for recovery.
# - Start GR on M1. Validate data.
# - Test group responds to requests well. Sync group.
# - Check if the data is the same on M1 and M2.
# 3. Testing a second recovery round on a member:
# - Stop GR on M2.
# - Add some data on M1 for recovery.
# - Start GR on M2. Validate data.
# - Test group responds to requests well.
# - Check if the data is the same on M1 and M2.
# 4. Clean up.
################################################################################
--source include/big_test.inc
--source include/have_group_replication_gtid_assignment_block_size_1.inc
--let $group_replication_group_name= 36236980-4307-11e4-916c-0800200c9a66
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--let $rpl_server_count= 3
--source include/group_replication.inc
--echo #
--echo # Setup a new group
--echo #
--connection server1
--echo server1
--source include/start_and_bootstrap_group_replication.inc
--echo # Add some data for recovery
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
COMMIT;
INSERT INTO t1 VALUES (3);
--echo #
--echo # 1) Testing the recovery of a new member
--echo #
--echo #Add 2 more members
--connection server2
--echo server2
--source include/start_group_replication.inc
--connection server3
--echo server3
--source include/start_group_replication.inc
--echo #After recovery all members must see 3 other members
--let $server_count=3
while ($server_count)
{
--connection server$server_count
--let $group_replication_number_of_members= 3
--source include/gr_wait_for_number_of_members.inc
--dec $server_count
}
--echo #After recovery all members must have the data present in the donor.
--let $server_count=3
while ($server_count)
{
--connection server$server_count
--let $assert_text= On all members, the table should exist and have 3 elements
--let $assert_cond= [select count(*) from t1] = 3;
--source include/assert.inc
--dec $server_count
}
--echo #Test if the group responds to requests
--connection server1
--echo server1
INSERT INTO t1 VALUES (4);
--connection server2
--echo server2
INSERT INTO t1 VALUES (5);
--connection server3
--echo server3
--let $wait_condition= select count(*) = 5 from t1;
--source include/wait_condition.inc
--source include/rpl_sync.inc
--echo #All members must have the same GTID set
--let $server_count=3
while ($server_count)
{
--connection server$server_count
--let $assert_text= On member $server_count, all executed GTID should belong to the group
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "36236980-4307-11e4-916c-0800200c9a66:1-8";
--source include/assert.inc
--dec $server_count
}
--echo #Check if the data is the same on joiner and donor
--let $diff_tables= server1:test.t1, server2:test.t1
--source include/diff_tables.inc
--echo #
--echo # 2) Testing recovery on a member that left and now returns
--echo #
--echo #Stop the member 1, who never went through recovery
--connection server1
--echo server1
--source include/stop_group_replication.inc
--echo #Add some data to the future donor
--connection server2
--echo server2
INSERT INTO t1 VALUES (6);
--connection server1
--echo server1
--source include/start_group_replication.inc
--let $assert_text= On the recovered member, the table should contain 6 elements
--let $assert_cond= [select count(*) from t1] = 6;
--source include/assert.inc
--echo #Test if the group responds to requests
--connection server2
--echo server2
INSERT INTO t1 VALUES (7);
--let $wait_condition= select count(*) = 7 from t1;
--source include/wait_condition.inc
# we are using this because we want to sync a pair of servers instead of the
# whole group. sync_slave_with_master is a legacy name.
--let $sync_slave_connection= server1
--source include/sync_slave_sql_with_master.inc
--let $sync_slave_connection= server3
--source include/sync_slave_sql_with_master.inc
connection server2;
--let $diff_tables= server1:test.t1, server2:test.t1
--source include/diff_tables.inc
--echo #
--echo # 3) Testing a second recovery round on a member
--echo #
--echo #Stop the member 2 making it go through recovery again
--source include/stop_group_replication.inc
--echo #Add some data to the future donor
--connection server1
--echo server1
INSERT INTO t1 VALUES (8);
--connection server2
--echo server2
--source include/start_group_replication.inc
--let $assert_text= On the recovered member, the table should contain 8 elements
--let $assert_cond= [select count(*) from t1] = 8;
--source include/assert.inc
--echo #Test if the group responds to requests
INSERT INTO t1 VALUES (9);
--connection server1
--echo server1
--let $wait_condition= select count(*) = 9 from t1;
--source include/wait_condition.inc
--let $diff_tables= server1:test.t1, server2:test.t1
--source include/diff_tables.inc
--echo #
--echo # Cleaning up
--echo #
DROP TABLE t1;
--source include/group_replication_end.inc
|