| 1 |
################################################################################ |
| 2 |
# |
| 3 |
# This test proves notifications are transmitted during mode change. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. The test requires two servers: M1 and M2. |
| 7 |
# 1. Start server M1 and M2 with gms_listener service implementation. |
| 8 |
# Set M2 member weight to 90. M2 becomes primary during mode change. |
| 9 |
# Delete all notifications on M1 and M2. |
| 10 |
# 2. Change mode to SPM. M2 becomes primary due to weight. |
| 11 |
# Assert ROLE notification is broadcasted. |
| 12 |
# 3. Change mode to MPM. |
| 13 |
# Assert ROLE notification is broadcasted. |
| 14 |
# 4. Change mode to SPM specifying server1 as primary. |
| 15 |
# Assert ROLE notification is broadcasted. |
| 16 |
# 5. Switch primary. |
| 17 |
# Assert ROLE notification is broadcasted. |
| 18 |
# 6. Cleanup. |
| 19 |
################################################################################ |
| 20 |
|
| 21 |
--source include/have_debug.inc |
| 22 |
--source include/not_have_privilege_checks_user.inc |
| 23 |
--source include/force_restart.inc |
| 24 |
--source include/have_group_replication_plugin.inc |
| 25 |
--let $rpl_skip_group_replication_start= 1 |
| 26 |
--source include/group_replication.inc |
| 27 |
|
| 28 |
--echo |
| 29 |
--echo # 1. Start server M1 and M2 with gms_listener service implementation. |
| 30 |
--echo # Set M2 member weight to 90. M2 becomes primary during mode change. |
| 31 |
--echo # Delete all notifications on M1 and M2. |
| 32 |
--echo |
| 33 |
|
| 34 |
--let $truncate_notification_table= 1 |
| 35 |
|
| 36 |
--let $debug_point= register_gms_listener_example |
| 37 |
--source include/add_debug_point.inc |
| 38 |
|
| 39 |
--let $server1_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 40 |
SET SQL_LOG_BIN=0; |
| 41 |
CREATE TABLE test.gms_listener_example(log_message TEXT); |
| 42 |
SET SQL_LOG_BIN=1; |
| 43 |
|
| 44 |
--source include/start_and_bootstrap_group_replication.inc |
| 45 |
|
| 46 |
--let $rpl_connection_name= server2 |
| 47 |
--source include/rpl_connection.inc |
| 48 |
|
| 49 |
--let $server2_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 50 |
SET @member_weight2_save= @@GLOBAL.group_replication_member_weight; |
| 51 |
SET GLOBAL group_replication_member_weight= 90; |
| 52 |
|
| 53 |
--let $debug_point= register_gms_listener_example |
| 54 |
--source include/add_debug_point.inc |
| 55 |
|
| 56 |
SET SQL_LOG_BIN=0; |
| 57 |
CREATE TABLE test.gms_listener_example(log_message TEXT); |
| 58 |
SET SQL_LOG_BIN=1; |
| 59 |
|
| 60 |
--source include/start_group_replication.inc |
| 61 |
|
| 62 |
--let $expected_notifications= 2,STATE %:2|1,VIEW %:% |
| 63 |
--source ../include/assert_notifications.inc |
| 64 |
|
| 65 |
--let $rpl_connection_name= server1 |
| 66 |
--source include/rpl_connection.inc |
| 67 |
|
| 68 |
--let $expected_notifications= 2,STATE %:2|2,STATE %:1|2,VIEW %:% |
| 69 |
--source ../include/assert_notifications.inc |
| 70 |
|
| 71 |
--echo |
| 72 |
--echo # 2. Change mode to SPM. M2 becomes primary due to weight. |
| 73 |
--echo # Assert ROLE notification is broadcasted. |
| 74 |
--echo |
| 75 |
|
| 76 |
SELECT group_replication_switch_to_single_primary_mode(); |
| 77 |
|
| 78 |
--source include/gr_assert_secondary_member.inc |
| 79 |
# role changed |
| 80 |
--let $expected_notifications= 1,ROLE %:% |
| 81 |
--source ../include/assert_notifications.inc |
| 82 |
|
| 83 |
--let $rpl_connection_name= server2 |
| 84 |
--source include/rpl_connection.inc |
| 85 |
|
| 86 |
--source include/gr_assert_primary_member.inc |
| 87 |
# role changed |
| 88 |
--let $expected_notifications= 1,ROLE %:% |
| 89 |
--source ../include/assert_notifications.inc |
| 90 |
|
| 91 |
--echo |
| 92 |
--echo # 3. Change mode to MPM. |
| 93 |
--echo # Assert ROLE notification is broadcasted. |
| 94 |
--echo |
| 95 |
|
| 96 |
--let $rpl_connection_name= server1 |
| 97 |
--source include/rpl_connection.inc |
| 98 |
|
| 99 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 100 |
|
| 101 |
--source include/gr_assert_multi_primary_mode.inc |
| 102 |
# role changed |
| 103 |
--let $expected_notifications= 1,ROLE %:% |
| 104 |
--source ../include/assert_notifications.inc |
| 105 |
|
| 106 |
--let $rpl_connection_name= server2 |
| 107 |
--source include/rpl_connection.inc |
| 108 |
|
| 109 |
--source include/gr_assert_multi_primary_mode.inc |
| 110 |
# role changed |
| 111 |
--let $expected_notifications= 1,ROLE %:% |
| 112 |
--source ../include/assert_notifications.inc |
| 113 |
|
| 114 |
--echo |
| 115 |
--echo # 4. Change mode to SPM specifying server1 as primary. |
| 116 |
--echo # Assert ROLE notification is broadcasted. |
| 117 |
--echo |
| 118 |
|
| 119 |
--let $rpl_connection_name= server1 |
| 120 |
--source include/rpl_connection.inc |
| 121 |
|
| 122 |
--replace_result $server1_uuid MEMBER1_UUID |
| 123 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid"); |
| 124 |
|
| 125 |
--source include/gr_assert_primary_member.inc |
| 126 |
# role changed |
| 127 |
--let $expected_notifications= 1,ROLE %:% |
| 128 |
--source ../include/assert_notifications.inc |
| 129 |
|
| 130 |
--let $rpl_connection_name= server2 |
| 131 |
--source include/rpl_connection.inc |
| 132 |
|
| 133 |
--source include/gr_assert_secondary_member.inc |
| 134 |
# role changed |
| 135 |
--let $expected_notifications= 1,ROLE %:% |
| 136 |
--source ../include/assert_notifications.inc |
| 137 |
|
| 138 |
--echo |
| 139 |
--echo # 5. Switch primary. |
| 140 |
--echo # Assert ROLE notification is broadcasted. |
| 141 |
--echo |
| 142 |
|
| 143 |
--let $rpl_connection_name= server1 |
| 144 |
--source include/rpl_connection.inc |
| 145 |
|
| 146 |
--replace_result $server2_uuid MEMBER2_UUID |
| 147 |
--eval SELECT group_replication_set_as_primary("$server2_uuid") |
| 148 |
|
| 149 |
--source include/gr_assert_secondary_member.inc |
| 150 |
# role changed |
| 151 |
--let $expected_notifications= 1,ROLE %:% |
| 152 |
--source ../include/assert_notifications.inc |
| 153 |
|
| 154 |
--let $rpl_connection_name= server2 |
| 155 |
--source include/rpl_connection.inc |
| 156 |
|
| 157 |
--source include/gr_assert_primary_member.inc |
| 158 |
# role changed |
| 159 |
--let $expected_notifications= 1,ROLE %:% |
| 160 |
--source ../include/assert_notifications.inc |
| 161 |
|
| 162 |
--echo |
| 163 |
--echo # 6. Cleanup. |
| 164 |
--echo |
| 165 |
|
| 166 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 167 |
|
| 168 |
SET SQL_LOG_BIN=0; |
| 169 |
DROP TABLE test.gms_listener_example; |
| 170 |
SET SQL_LOG_BIN=1; |
| 171 |
|
| 172 |
SET @@GLOBAL.group_replication_member_weight= @member_weight2_save; |
| 173 |
|
| 174 |
--source include/stop_group_replication.inc |
| 175 |
--let $debug_point= register_gms_listener_example |
| 176 |
--source include/remove_debug_point.inc |
| 177 |
|
| 178 |
--let $rpl_connection_name= server1 |
| 179 |
--source include/rpl_connection.inc |
| 180 |
|
| 181 |
SET SQL_LOG_BIN=0; |
| 182 |
DROP TABLE test.gms_listener_example; |
| 183 |
SET SQL_LOG_BIN=1; |
| 184 |
|
| 185 |
--source include/stop_group_replication.inc |
| 186 |
--let $debug_point= register_gms_listener_example |
| 187 |
--source include/remove_debug_point.inc |
| 188 |
|
| 189 |
--let $truncate_notification_table= |
| 190 |
|
| 191 |
--source include/group_replication_end.inc |