| 1 |
# |
| 2 |
# Test case to verify when roles changes in Group Replication |
| 3 |
# then weight is re-assigned based on role change. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. This test needs 3 servers: |
| 7 |
# server1: primary |
| 8 |
# server2: secondary |
| 9 |
# server3: single server replica |
| 10 |
# 1. Start GR on M1(primary) and M2(secondary) |
| 11 |
# 2. Add asynchronous connection failover servers and |
| 12 |
# verify that they are inserted successfully in |
| 13 |
# performance_schema.replication_asynchronous_connection_failover. |
| 14 |
# 3. Create and start new channel ch1_3: M3(replica), M1(source) |
| 15 |
# and verify channel ch1_3 IO and SQL THREADS are ON. |
| 16 |
# 4. Verify 2 senders are added automatically to |
| 17 |
# replication_asynchronous_connection_failover table. |
| 18 |
# 5. Make M2 primary. |
| 19 |
# 6. Verify M2 is new source with higher weight in |
| 20 |
# performance_schema.replication_asynchronous_connection_failover |
| 21 |
# 7. Switch to multi primary mode. |
| 22 |
# 8. Verify M1 and M2 both have same primary_weight. |
| 23 |
# 9. Switch to single primary mode with M1 as primary. |
| 24 |
# 10. Verify M1 has higher weight and M2 has lower weight. |
| 25 |
# Verify M1 is new source. |
| 26 |
# 11. Cleanup. |
| 27 |
# |
| 28 |
|
| 29 |
--source include/have_group_replication_plugin.inc |
| 30 |
--let $rpl_skip_group_replication_start= 1 |
| 31 |
--let $rpl_group_replication_single_primary_mode=1 |
| 32 |
--let $rpl_server_count= 3 |
| 33 |
--source include/group_replication.inc |
| 34 |
|
| 35 |
|
| 36 |
--echo |
| 37 |
--echo # 1. Start GR on M1(primary) and M2(secondary) |
| 38 |
--echo |
| 39 |
|
| 40 |
--let $rpl_connection_name= server1 |
| 41 |
--source include/rpl_connection.inc |
| 42 |
|
| 43 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 44 |
|
| 45 |
--source include/start_and_bootstrap_group_replication.inc |
| 46 |
|
| 47 |
--let $rpl_connection_name= server2 |
| 48 |
--source include/rpl_connection.inc |
| 49 |
|
| 50 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 51 |
|
| 52 |
--source include/start_group_replication.inc |
| 53 |
|
| 54 |
--let $rpl_connection_name= server3 |
| 55 |
--source include/rpl_connection.inc |
| 56 |
|
| 57 |
SET SESSION sql_log_bin = 0; |
| 58 |
call mtr.add_suppression("The source.*for channel.*has joined the group.*and so added its entry into replication_asynchronous_connection_failover table"); |
| 59 |
call mtr.add_suppression("The group .* for the channel .* has been removed, and so removed its entry from replication_asynchronous_connection_failover_managed and all the group members from replication_asynchronous_connection_failover table."); |
| 60 |
call mtr.add_suppression("The group .* for the channel .* has been added, and so added its entry in replication_asynchronous_connection_failover_managed and source to replication_asynchronous_connection_failover table."); |
| 61 |
SET SESSION sql_log_bin = 1; |
| 62 |
|
| 63 |
--echo |
| 64 |
--echo # 2. Add asynchronous connection failover servers and |
| 65 |
--echo # verify that they are inserted successfully in |
| 66 |
--echo # performance_schema.replication_asynchronous_connection_failover. |
| 67 |
--echo |
| 68 |
|
| 69 |
--let $rpl_connection_name= server1 |
| 70 |
--source include/rpl_connection.inc |
| 71 |
--let $_tmp_gr_group_name1= `SELECT @@GLOBAL.group_replication_group_name` |
| 72 |
|
| 73 |
--let $rpl_connection_name= server3 |
| 74 |
--source include/rpl_connection.inc |
| 75 |
--replace_result $SERVER_MYPORT_1 SERVER_MYPORT_1 $_tmp_gr_group_name1 GROUP_NAME |
| 76 |
--eval SELECT asynchronous_connection_failover_add_managed('ch1_3', 'GroupReplication', '$_tmp_gr_group_name1', '127.0.0.1', $SERVER_MYPORT_1, '', 70, 60); |
| 77 |
|
| 78 |
--let $assert_text= 'There is one row in performance_schema.replication_asynchronous_connection_failover' |
| 79 |
--let $assert_cond= [SELECT COUNT(*) count FROM performance_schema.replication_asynchronous_connection_failover, count, 1] = 1 |
| 80 |
--source include/assert.inc |
| 81 |
|
| 82 |
--echo |
| 83 |
--echo # 3. Create and start new channel ch1_3: M3(replica), M1(source) |
| 84 |
--echo # and verify channel ch1_3 IO and SQL THREADS are ON. |
| 85 |
--echo |
| 86 |
|
| 87 |
--let $rpl_connection_name= server3 |
| 88 |
--source include/rpl_connection.inc |
| 89 |
|
| 90 |
--replace_result $SERVER_MYPORT_1 SERVER_1_PORT |
| 91 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_AUTO_POSITION=1, SOURCE_CONNECTION_AUTO_FAILOVER=1, SOURCE_PORT=$SERVER_MYPORT_1, SOURCE_CONNECT_RETRY=1, SOURCE_RETRY_COUNT=2 for channel 'ch1_3' |
| 92 |
--let $rpl_channel_name='ch1_3' |
| 93 |
--source include/start_slave.inc |
| 94 |
--let $rpl_channel_name= |
| 95 |
|
| 96 |
--let $assert_text= Verify channel ch1_3 IO_THREAD is ON |
| 97 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name = \'ch1_3\', SERVICE_STATE, 1]" = "ON" |
| 98 |
--source include/assert.inc |
| 99 |
|
| 100 |
--let $assert_text= Verify channel ch1_3 SQL_THREAD is ON |
| 101 |
--let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch1_3\', SERVICE_STATE, 1]" = "ON" |
| 102 |
--source include/assert.inc |
| 103 |
|
| 104 |
--echo |
| 105 |
--echo # 4. Verify 2 senders are added automatically to |
| 106 |
--echo # replication_asynchronous_connection_failover table. |
| 107 |
--echo |
| 108 |
|
| 109 |
--let $rpl_connection_name= server3 |
| 110 |
--source include/rpl_connection.inc |
| 111 |
|
| 112 |
--let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover; |
| 113 |
--source include/wait_condition.inc |
| 114 |
|
| 115 |
--let $assert_text= 'Connected to server1 now.' |
| 116 |
--let $assert_cond= [SELECT Port FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME = \'ch1_3\', Port, 1] = $SERVER_MYPORT_1 |
| 117 |
--source include/assert.inc |
| 118 |
|
| 119 |
--echo |
| 120 |
--echo # 5. Make M2 primary. |
| 121 |
--echo |
| 122 |
|
| 123 |
--let $rpl_connection_name= server1 |
| 124 |
--source include/rpl_connection.inc |
| 125 |
|
| 126 |
--replace_result $server2_uuid MEMBER2_UUID |
| 127 |
--eval SELECT group_replication_set_as_primary("$server2_uuid") |
| 128 |
|
| 129 |
--echo |
| 130 |
--echo # 6. Verify M2 is new source with higher weight in |
| 131 |
--echo # performance_schema.replication_asynchronous_connection_failover |
| 132 |
--echo |
| 133 |
|
| 134 |
--let $rpl_connection_name= server3 |
| 135 |
--source include/rpl_connection.inc |
| 136 |
|
| 137 |
--let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_asynchronous_connection_failover; |
| 138 |
--source include/wait_condition.inc |
| 139 |
|
| 140 |
--let $wait_condition= SELECT WEIGHT=60 FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT = $SERVER_MYPORT_1; |
| 141 |
--source include/wait_condition.inc |
| 142 |
|
| 143 |
--let $wait_condition= SELECT WEIGHT=70 FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT = $SERVER_MYPORT_2; |
| 144 |
--source include/wait_condition.inc |
| 145 |
|
| 146 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_configuration WHERE HOST = '127.0.0.1' AND PORT = $SERVER_MYPORT_2 |
| 147 |
--source include/wait_condition.inc |
| 148 |
|
| 149 |
|
| 150 |
--echo |
| 151 |
--echo # 7. Switch to multi primary mode. |
| 152 |
--echo |
| 153 |
|
| 154 |
--let $rpl_connection_name= server2 |
| 155 |
--source include/rpl_connection.inc |
| 156 |
|
| 157 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 158 |
|
| 159 |
--echo |
| 160 |
--echo # 8. Verify M1 and M2 both have same primary_weight. |
| 161 |
--echo |
| 162 |
|
| 163 |
--let $rpl_connection_name= server3 |
| 164 |
--source include/rpl_connection.inc |
| 165 |
|
| 166 |
--let $wait_condition= SELECT WEIGHT=70 FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT = $SERVER_MYPORT_2; |
| 167 |
--source include/wait_condition.inc |
| 168 |
|
| 169 |
--let $wait_condition= SELECT WEIGHT=70 FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT = $SERVER_MYPORT_1; |
| 170 |
--source include/wait_condition.inc |
| 171 |
|
| 172 |
--echo |
| 173 |
--echo # 9. Switch to single primary mode with M1 as primary. |
| 174 |
--echo |
| 175 |
|
| 176 |
--let $rpl_connection_name= server2 |
| 177 |
--source include/rpl_connection.inc |
| 178 |
|
| 179 |
--replace_result $server1_uuid MEMBER1_UUID |
| 180 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 181 |
|
| 182 |
--echo |
| 183 |
--echo # 10. Verify M1 has higher weight and M2 has lower weight. |
| 184 |
--echo # Verify M1 is new source. |
| 185 |
--echo |
| 186 |
|
| 187 |
--let $rpl_connection_name= server3 |
| 188 |
--source include/rpl_connection.inc |
| 189 |
|
| 190 |
--let $wait_condition= SELECT WEIGHT=70 FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT = $SERVER_MYPORT_1; |
| 191 |
--source include/wait_condition.inc |
| 192 |
|
| 193 |
--let $wait_condition= SELECT WEIGHT=60 FROM performance_schema.replication_asynchronous_connection_failover WHERE PORT = $SERVER_MYPORT_2; |
| 194 |
--source include/wait_condition.inc |
| 195 |
|
| 196 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_configuration WHERE HOST = '127.0.0.1' AND PORT = $SERVER_MYPORT_1 |
| 197 |
--source include/wait_condition.inc |
| 198 |
|
| 199 |
--echo |
| 200 |
--echo # 11. Cleanup. |
| 201 |
--echo |
| 202 |
|
| 203 |
--let $rpl_connection_name= server3 |
| 204 |
--source include/rpl_connection.inc |
| 205 |
|
| 206 |
--let $rpl_channel_name='ch1_3' |
| 207 |
--source include/stop_slave.inc |
| 208 |
|
| 209 |
--let $rpl_reset_slave_all= 1 |
| 210 |
--let $rpl_multi_source= 1 |
| 211 |
--source include/rpl_reset_slave.inc |
| 212 |
--let $rpl_channel_name= |
| 213 |
--let $rpl_reset_slave_all= |
| 214 |
--let $rpl_multi_source= |
| 215 |
|
| 216 |
--replace_result $group_replication_group_name GROUP_NAME |
| 217 |
--eval SELECT asynchronous_connection_failover_delete_managed('ch1_3', '$group_replication_group_name') |
| 218 |
|
| 219 |
--replace_result $SERVER_MYPORT_1 SERVER_1_PORT |
| 220 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_PORT=$SERVER_MYPORT_1 FOR CHANNEL 'ch1_3' |
| 221 |
|
| 222 |
--let $skip_recovery_configuration= 1 |
| 223 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 224 |
--source include/group_replication_end.inc |