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
|
################################################################################
#
# This test proves notifications are transmitted during mode change.
#
# Test:
# 0. The test requires two servers: M1 and M2.
# 1. Start server M1 and M2 with gms_listener service implementation.
# Set M2 member weight to 90. M2 becomes primary during mode change.
# Delete all notifications on M1 and M2.
# 2. Change mode to SPM. M2 becomes primary due to weight.
# Assert ROLE notification is broadcasted.
# 3. Change mode to MPM.
# Assert ROLE notification is broadcasted.
# 4. Change mode to SPM specifying server1 as primary.
# Assert ROLE notification is broadcasted.
# 5. Switch primary.
# Assert ROLE notification is broadcasted.
# 6. Cleanup.
################################################################################
--source include/have_debug.inc
--source include/not_have_privilege_checks_user.inc
--source include/force_restart.inc
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--source include/group_replication.inc
--echo
--echo # 1. Start server M1 and M2 with gms_listener service implementation.
--echo # Set M2 member weight to 90. M2 becomes primary during mode change.
--echo # Delete all notifications on M1 and M2.
--echo
--let $truncate_notification_table= 1
--let $debug_point= register_gms_listener_example
--source include/add_debug_point.inc
--let $server1_uuid= `SELECT @@GLOBAL.SERVER_UUID`
SET SQL_LOG_BIN=0;
CREATE TABLE test.gms_listener_example(log_message TEXT);
SET SQL_LOG_BIN=1;
--source include/start_and_bootstrap_group_replication.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $server2_uuid= `SELECT @@GLOBAL.SERVER_UUID`
SET @member_weight2_save= @@GLOBAL.group_replication_member_weight;
SET GLOBAL group_replication_member_weight= 90;
--let $debug_point= register_gms_listener_example
--source include/add_debug_point.inc
SET SQL_LOG_BIN=0;
CREATE TABLE test.gms_listener_example(log_message TEXT);
SET SQL_LOG_BIN=1;
--source include/start_group_replication.inc
--let $expected_notifications= 2,STATE %:2|1,VIEW %:%
--source ../include/assert_notifications.inc
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $expected_notifications= 2,STATE %:2|2,STATE %:1|2,VIEW %:%
--source ../include/assert_notifications.inc
--echo
--echo # 2. Change mode to SPM. M2 becomes primary due to weight.
--echo # Assert ROLE notification is broadcasted.
--echo
SELECT group_replication_switch_to_single_primary_mode();
--source include/gr_assert_secondary_member.inc
# role changed
--let $expected_notifications= 1,ROLE %:%
--source ../include/assert_notifications.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/gr_assert_primary_member.inc
# role changed
--let $expected_notifications= 1,ROLE %:%
--source ../include/assert_notifications.inc
--echo
--echo # 3. Change mode to MPM.
--echo # Assert ROLE notification is broadcasted.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
SELECT group_replication_switch_to_multi_primary_mode();
--source include/gr_assert_multi_primary_mode.inc
# role changed
--let $expected_notifications= 1,ROLE %:%
--source ../include/assert_notifications.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/gr_assert_multi_primary_mode.inc
# role changed
--let $expected_notifications= 1,ROLE %:%
--source ../include/assert_notifications.inc
--echo
--echo # 4. Change mode to SPM specifying server1 as primary.
--echo # Assert ROLE notification is broadcasted.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--replace_result $server1_uuid MEMBER1_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid");
--source include/gr_assert_primary_member.inc
# role changed
--let $expected_notifications= 1,ROLE %:%
--source ../include/assert_notifications.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/gr_assert_secondary_member.inc
# role changed
--let $expected_notifications= 1,ROLE %:%
--source ../include/assert_notifications.inc
--echo
--echo # 5. Switch primary.
--echo # Assert ROLE notification is broadcasted.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--replace_result $server2_uuid MEMBER2_UUID
--eval SELECT group_replication_set_as_primary("$server2_uuid")
--source include/gr_assert_secondary_member.inc
# role changed
--let $expected_notifications= 1,ROLE %:%
--source ../include/assert_notifications.inc
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--source include/gr_assert_primary_member.inc
# role changed
--let $expected_notifications= 1,ROLE %:%
--source ../include/assert_notifications.inc
--echo
--echo # 6. Cleanup.
--echo
SELECT group_replication_switch_to_multi_primary_mode();
SET SQL_LOG_BIN=0;
DROP TABLE test.gms_listener_example;
SET SQL_LOG_BIN=1;
SET @@GLOBAL.group_replication_member_weight= @member_weight2_save;
--source include/stop_group_replication.inc
--let $debug_point= register_gms_listener_example
--source include/remove_debug_point.inc
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
SET SQL_LOG_BIN=0;
DROP TABLE test.gms_listener_example;
SET SQL_LOG_BIN=1;
--source include/stop_group_replication.inc
--let $debug_point= register_gms_listener_example
--source include/remove_debug_point.inc
--let $truncate_notification_table=
--source include/group_replication_end.inc
|