| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# If the configuration change is invoked with a server UUID, that |
| 4 |
# value shall be valid and must belong to a member of the group. An |
| 5 |
# error shall be outputted otherwise. |
| 6 |
# |
| 7 |
# Test: |
| 8 |
# 0. This test requires two servers. |
| 9 |
# 1. Execute switch to single primary mode: |
| 10 |
# 1.1. With extra arguments it must fail. |
| 11 |
# 1.2. With invalid uuid it must fail. |
| 12 |
# 1.3. With an unknown uuid it must fail. |
| 13 |
# 1.4. With NULL it must fail. |
| 14 |
# 1.5. With empty string it must fail. |
| 15 |
# |
| 16 |
# 2. Change to single primary mode to test action of set as primary and |
| 17 |
# switch to multi primary |
| 18 |
# |
| 19 |
# 3. Execute action of set a new primary: |
| 20 |
# 3.1. With extra arguments it must fail. |
| 21 |
# 3.2. With invalid uuid it must fail. |
| 22 |
# 3.3. With an unknown uuid it must fail. |
| 23 |
# 3.4. With NULL it must fail. |
| 24 |
# 3.5. With empty string it must fail. |
| 25 |
# 3.6. With blank value it must fail. |
| 26 |
# |
| 27 |
# 4. Execute action to switch to multi primary mode: |
| 28 |
# 4.1. With extra arguments it must fail. |
| 29 |
# 4.2. With invalid uuid it must fail. |
| 30 |
# 4.3. With an unknown uuid it must fail. |
| 31 |
# 4.4. With NULL it must fail. |
| 32 |
# 4.5. With empty string it must fail. |
| 33 |
# 4.6. With valid known uuid it must fail. |
| 34 |
# |
| 35 |
# 5. Change to multi primary mode to test action with output of a table. |
| 36 |
# |
| 37 |
# 6. Create a table to test the functions with SQL outputs |
| 38 |
# |
| 39 |
# 7. Test group_replication_switch_to_single_primary_mode output (SQL parameter). |
| 40 |
# 7.1. With invalid uuid it must fail. |
| 41 |
# 7.2. With an unknown uuid it must fail. |
| 42 |
# 7.3. With NULL it must fail. |
| 43 |
# 7.4. With empty string it must fail. |
| 44 |
# 7.5. Mode switched to single-primary successfully. |
| 45 |
# 7.6. Already in single-primary mode. |
| 46 |
# |
| 47 |
# 8. Test group_replication_switch_to_multi_primary_mode output (SQL parameter). |
| 48 |
# |
| 49 |
# 9. Test group_replication_set_as_primary output (SQL parameter). |
| 50 |
# 9.1. With invalid uuid it must fail. |
| 51 |
# 9.2. With an unknown uuid it must fail. |
| 52 |
# 9.3. With NULL it must fail. |
| 53 |
# 9.4. With empty string it must fail. |
| 54 |
# 9.5. Already the primary member |
| 55 |
# 9.6. Switch to another member |
| 56 |
# |
| 57 |
# 10. Cleanup. |
| 58 |
# |
| 59 |
############################################################################### |
| 60 |
|
| 61 |
--source include/have_group_replication_plugin.inc |
| 62 |
--source include/group_replication.inc |
| 63 |
|
| 64 |
--let $rpl_connection_name= server2 |
| 65 |
--source include/rpl_connection.inc |
| 66 |
|
| 67 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 68 |
|
| 69 |
--let $rpl_connection_name= server1 |
| 70 |
--source include/rpl_connection.inc |
| 71 |
|
| 72 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 73 |
|
| 74 |
--echo |
| 75 |
--echo # 1. Execute switch to single primary mode: |
| 76 |
--echo # 1.1. With extra arguments it must fail. |
| 77 |
|
| 78 |
--replace_result $server1_uuid MEMBER1_UUID |
| 79 |
--error ER_CANT_INITIALIZE_UDF |
| 80 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid", "extra", "arguments") |
| 81 |
|
| 82 |
--echo # 1.2. With invalid uuid it must fail. |
| 83 |
--error ER_CANT_INITIALIZE_UDF |
| 84 |
SELECT group_replication_switch_to_single_primary_mode("not an uuid"); |
| 85 |
|
| 86 |
--echo # 1.3. With an unknown uuid it must fail. |
| 87 |
--error ER_CANT_INITIALIZE_UDF |
| 88 |
SELECT group_replication_switch_to_single_primary_mode("aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa"); |
| 89 |
|
| 90 |
--echo # 1.4. With NULL it must fail. |
| 91 |
--error ER_CANT_INITIALIZE_UDF |
| 92 |
SELECT group_replication_switch_to_single_primary_mode(NULL); |
| 93 |
|
| 94 |
--echo # 1.5. With empty string it must fail. |
| 95 |
--error ER_CANT_INITIALIZE_UDF |
| 96 |
SELECT group_replication_set_as_primary(""); |
| 97 |
|
| 98 |
--echo |
| 99 |
--echo # 2. Change to single primary mode to test action of set as primary and |
| 100 |
--echo # switch to multi primary |
| 101 |
|
| 102 |
--replace_result $server1_uuid MEMBER1_UUID |
| 103 |
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid") |
| 104 |
|
| 105 |
--echo |
| 106 |
--echo # 3. Execute action of set a new primary: |
| 107 |
--echo # 3.1. With extra arguments it must fail. |
| 108 |
|
| 109 |
--replace_result $server1_uuid MEMBER1_UUID |
| 110 |
--error ER_CANT_INITIALIZE_UDF |
| 111 |
--eval SELECT group_replication_set_as_primary("$server1_uuid", "extra", "arguments") |
| 112 |
|
| 113 |
--echo # 3.2. With invalid uuid it must fail. |
| 114 |
--error ER_CANT_INITIALIZE_UDF |
| 115 |
SELECT group_replication_set_as_primary("not an uuid"); |
| 116 |
|
| 117 |
--echo # 3.3. With an unknown uuid it must fail. |
| 118 |
--error ER_CANT_INITIALIZE_UDF |
| 119 |
SELECT group_replication_set_as_primary("aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa"); |
| 120 |
|
| 121 |
--echo # 3.4. With NULL it must fail. |
| 122 |
--error ER_CANT_INITIALIZE_UDF |
| 123 |
SELECT group_replication_set_as_primary(NULL); |
| 124 |
|
| 125 |
--echo # 3.5. With empty string it must fail. |
| 126 |
--error ER_CANT_INITIALIZE_UDF |
| 127 |
SELECT group_replication_set_as_primary(""); |
| 128 |
|
| 129 |
--echo # 3.6. With blank value it must fail. |
| 130 |
--error ER_CANT_INITIALIZE_UDF |
| 131 |
SELECT group_replication_set_as_primary(); |
| 132 |
|
| 133 |
--echo |
| 134 |
--echo # 4. Execute action to switch to multi primary mode: |
| 135 |
--echo # 4.1. With extra arguments it must fail. |
| 136 |
--error ER_CANT_INITIALIZE_UDF |
| 137 |
SELECT group_replication_switch_to_multi_primary_mode("extra", "arguments"); |
| 138 |
|
| 139 |
--echo # 4.2. With invalid uuid it must fail. |
| 140 |
--error ER_CANT_INITIALIZE_UDF |
| 141 |
SELECT group_replication_switch_to_multi_primary_mode("not an uuid"); |
| 142 |
|
| 143 |
--echo # 4.3. With an unknown uuid it must fail. |
| 144 |
--error ER_CANT_INITIALIZE_UDF |
| 145 |
SELECT group_replication_switch_to_multi_primary_mode("aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa"); |
| 146 |
|
| 147 |
--echo # 4.4. With NULL it must fail. |
| 148 |
--error ER_CANT_INITIALIZE_UDF |
| 149 |
SELECT group_replication_switch_to_multi_primary_mode(NULL); |
| 150 |
|
| 151 |
--echo # 4.5. With empty string it must fail. |
| 152 |
--error ER_CANT_INITIALIZE_UDF |
| 153 |
SELECT group_replication_switch_to_multi_primary_mode(""); |
| 154 |
|
| 155 |
--echo # 4.6. With valid and known uuid it must fail. |
| 156 |
--error ER_CANT_INITIALIZE_UDF |
| 157 |
SELECT group_replication_switch_to_multi_primary_mode("$server1_uuid"); |
| 158 |
|
| 159 |
--echo |
| 160 |
--echo # 5. Change to multi primary mode to test action with output of a table. |
| 161 |
|
| 162 |
SELECT group_replication_switch_to_multi_primary_mode(); |
| 163 |
|
| 164 |
--echo |
| 165 |
--echo # 6. Create a table to test the functions with SQL outputs |
| 166 |
|
| 167 |
CREATE TABLE test.t1 (a INT PRIMARY KEY NOT NULL AUTO_INCREMENT, b CHAR(36)); |
| 168 |
--disable_query_log |
| 169 |
INSERT INTO test.t1 VALUES (1, "Not a valid uuid"); # Invalid uuid. |
| 170 |
INSERT INTO test.t1 VALUES (2, "aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa"); # Valid but unknown uuid. |
| 171 |
INSERT INTO test.t1 VALUES (3, NULL); # NULL. |
| 172 |
INSERT INTO test.t1 VALUES (4, ""); # Empty string. |
| 173 |
--eval INSERT INTO test.t1 VALUES (5, "$server1_uuid") # Valid M1 uuid. |
| 174 |
--eval INSERT INTO test.t1 VALUES (6, "$server2_uuid") # Valid M2 uuid. |
| 175 |
--enable_query_log |
| 176 |
|
| 177 |
--echo |
| 178 |
--echo # 7. Test group_replication_switch_to_single_primary_mode output (SQL parameter). |
| 179 |
|
| 180 |
--echo # 7.1. With invalid uuid it must fail. |
| 181 |
--error ER_GRP_RPL_UDF_ERROR |
| 182 |
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=1; |
| 183 |
|
| 184 |
--echo # 7.2. With an unknown uuid it must fail. |
| 185 |
--error ER_GRP_RPL_UDF_ERROR |
| 186 |
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=2; |
| 187 |
|
| 188 |
--echo # 7.3. With NULL it must fail. |
| 189 |
--error ER_GRP_RPL_UDF_ERROR |
| 190 |
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=3; |
| 191 |
|
| 192 |
--echo # 7.4. With empty string it must fail. |
| 193 |
--error ER_GRP_RPL_UDF_ERROR |
| 194 |
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=4; |
| 195 |
|
| 196 |
--echo # 7.5. Mode switched to single-primary successfully. |
| 197 |
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=5; |
| 198 |
|
| 199 |
--echo # 7.6. Already in single-primary mode. |
| 200 |
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=6; |
| 201 |
|
| 202 |
--echo |
| 203 |
--echo # 8.Test group_replication_switch_to_multi_primary_mode output. |
| 204 |
--error ER_CANT_INITIALIZE_UDF |
| 205 |
SELECT group_replication_switch_to_multi_primary_mode(b) FROM test.t1 ORDER BY a LIMIT 1; |
| 206 |
|
| 207 |
--echo |
| 208 |
--echo # 9. Test group_replication_set_as_primary output (SQL parameter). |
| 209 |
|
| 210 |
--echo # 9.1. With invalid uuid it must fail. |
| 211 |
--error ER_GRP_RPL_UDF_ERROR |
| 212 |
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=1; |
| 213 |
|
| 214 |
--echo # 9.2. With an unknown uuid it must fail. |
| 215 |
--error ER_GRP_RPL_UDF_ERROR |
| 216 |
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=2; |
| 217 |
|
| 218 |
--echo # 9.3. With NULL it must fail. |
| 219 |
--error ER_GRP_RPL_UDF_ERROR |
| 220 |
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=3; |
| 221 |
|
| 222 |
--echo # 9.4. With empty string it must fail. |
| 223 |
--error ER_GRP_RPL_UDF_ERROR |
| 224 |
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=4; |
| 225 |
|
| 226 |
--echo # 9.5. Already the primary member |
| 227 |
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=5; |
| 228 |
|
| 229 |
--echo # 9.6. Switch to another member |
| 230 |
--replace_result $server2_uuid MEMBER2_UUID |
| 231 |
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=6; |
| 232 |
|
| 233 |
--let $rpl_connection_name= server1 |
| 234 |
--source include/rpl_connection.inc |
| 235 |
|
| 236 |
--source include/gr_assert_secondary_member.inc |
| 237 |
|
| 238 |
--let $rpl_connection_name= server2 |
| 239 |
--source include/rpl_connection.inc |
| 240 |
|
| 241 |
--source include/gr_assert_primary_member.inc |
| 242 |
|
| 243 |
--echo |
| 244 |
--echo # 10. Cleanup |
| 245 |
|
| 246 |
DROP TABLE test.t1; |
| 247 |
|
| 248 |
--source include/rpl_sync.inc |
| 249 |
|
| 250 |
--let $rpl_group_replication_single_primary_mode=1 |
| 251 |
--let $rpl_group_replication_reset_persistent_vars=1 |
| 252 |
--source include/group_replication_end.inc |