File: gr_primary_mode_group_operations_03.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (252 lines) | stat: -rw-r--r-- 9,071 bytes parent folder | download
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
###############################################################################
#
# If the configuration change is invoked with a server UUID, that
# value shall be valid and must belong to a member of the group. An
# error shall be outputted otherwise.
#
# Test:
#   0. This test requires two servers.
#   1. Execute switch to single primary mode:
#   1.1. With extra arguments it must fail.
#   1.2. With invalid uuid it must fail.
#   1.3. With an unknown uuid it must fail.
#   1.4. With NULL it must fail.
#   1.5. With empty string it must fail.
#
#   2. Change to single primary mode to test action of set as primary and
#      switch to multi primary
#
#   3. Execute action of set a new primary:
#   3.1. With extra arguments it must fail.
#   3.2. With invalid uuid it must fail.
#   3.3. With an unknown uuid it must fail.
#   3.4. With NULL it must fail.
#   3.5. With empty string it must fail.
#   3.6. With blank value it must fail.
#
#   4. Execute action to switch to multi primary mode:
#   4.1. With extra arguments it must fail.
#   4.2. With invalid uuid it must fail.
#   4.3. With an unknown uuid it must fail.
#   4.4. With NULL it must fail.
#   4.5. With empty string it must fail.
#   4.6. With valid known uuid it must fail.
#
#   5. Change to multi primary mode to test action with output of a table.
#
#   6. Create a table to test the functions with SQL outputs
#
#   7. Test group_replication_switch_to_single_primary_mode output (SQL parameter).
#   7.1. With invalid uuid it must fail.
#   7.2. With an unknown uuid it must fail.
#   7.3. With NULL it must fail.
#   7.4. With empty string it must fail.
#   7.5. Mode switched to single-primary successfully.
#   7.6. Already in single-primary mode.
#
#   8. Test group_replication_switch_to_multi_primary_mode output (SQL parameter).
#
#   9. Test group_replication_set_as_primary output (SQL parameter).
#   9.1. With invalid uuid it must fail.
#   9.2. With an unknown uuid it must fail.
#   9.3. With NULL it must fail.
#   9.4. With empty string it must fail.
#   9.5. Already the primary member
#   9.6. Switch to another member
#
#   10. Cleanup.
#
###############################################################################

--source include/have_group_replication_plugin.inc
--source include/group_replication.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)

--echo
--echo # 1. Execute switch to single primary mode:
--echo # 1.1. With extra arguments it must fail.

--replace_result $server1_uuid MEMBER1_UUID
--error ER_CANT_INITIALIZE_UDF
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid", "extra", "arguments")

--echo # 1.2. With invalid uuid it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_single_primary_mode("not an uuid");

--echo # 1.3. With an unknown uuid it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_single_primary_mode("aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa");

--echo # 1.4. With NULL it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_single_primary_mode(NULL);

--echo # 1.5. With empty string it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_set_as_primary("");

--echo
--echo # 2. Change to single primary mode to test action of set as primary and
--echo #    switch to multi primary

--replace_result $server1_uuid MEMBER1_UUID
--eval SELECT group_replication_switch_to_single_primary_mode("$server1_uuid")

--echo
--echo # 3. Execute action of set a new primary:
--echo # 3.1. With extra arguments it must fail.

--replace_result $server1_uuid MEMBER1_UUID
--error ER_CANT_INITIALIZE_UDF
--eval SELECT group_replication_set_as_primary("$server1_uuid", "extra", "arguments")

--echo # 3.2. With invalid uuid it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_set_as_primary("not an uuid");

--echo # 3.3. With an unknown uuid it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_set_as_primary("aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa");

--echo # 3.4. With NULL it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_set_as_primary(NULL);

--echo # 3.5. With empty string it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_set_as_primary("");

--echo # 3.6. With blank value it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_set_as_primary();

--echo
--echo # 4. Execute action to switch to multi primary mode:
--echo # 4.1. With extra arguments it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_multi_primary_mode("extra", "arguments");

--echo # 4.2. With invalid uuid it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_multi_primary_mode("not an uuid");

--echo # 4.3. With an unknown uuid it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_multi_primary_mode("aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa");

--echo # 4.4. With NULL it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_multi_primary_mode(NULL);

--echo # 4.5. With empty string it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_multi_primary_mode("");

--echo # 4.6. With valid and known uuid it must fail.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_multi_primary_mode("$server1_uuid");

--echo
--echo # 5. Change to multi primary mode to test action with output of a table.

SELECT group_replication_switch_to_multi_primary_mode();

--echo
--echo # 6. Create a table to test the functions with SQL outputs

CREATE TABLE test.t1 (a INT PRIMARY KEY NOT NULL AUTO_INCREMENT, b CHAR(36));
--disable_query_log
INSERT INTO test.t1 VALUES (1, "Not a valid uuid");                     # Invalid uuid.
INSERT INTO test.t1 VALUES (2, "aaaaaaaa-bbbb-aaaa-aaaa-aaaaaaaaaaaa"); # Valid but unknown uuid.
INSERT INTO test.t1 VALUES (3, NULL);                                   # NULL.
INSERT INTO test.t1 VALUES (4, "");                                     # Empty string.
--eval INSERT INTO test.t1 VALUES (5, "$server1_uuid")                  # Valid M1 uuid.
--eval INSERT INTO test.t1 VALUES (6, "$server2_uuid")                  # Valid M2 uuid.
--enable_query_log

--echo
--echo # 7. Test group_replication_switch_to_single_primary_mode output (SQL parameter).

--echo # 7.1. With invalid uuid it must fail.
--error ER_GRP_RPL_UDF_ERROR
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=1;

--echo # 7.2. With an unknown uuid it must fail.
--error ER_GRP_RPL_UDF_ERROR
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=2;

--echo # 7.3. With NULL it must fail.
--error ER_GRP_RPL_UDF_ERROR
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=3;

--echo # 7.4. With empty string it must fail.
--error ER_GRP_RPL_UDF_ERROR
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=4;

--echo # 7.5. Mode switched to single-primary successfully.
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=5;

--echo # 7.6. Already in single-primary mode.
SELECT group_replication_switch_to_single_primary_mode(b) FROM test.t1 WHERE a=6;

--echo
--echo # 8.Test group_replication_switch_to_multi_primary_mode output.
--error ER_CANT_INITIALIZE_UDF
SELECT group_replication_switch_to_multi_primary_mode(b) FROM test.t1 ORDER BY a LIMIT 1;

--echo
--echo # 9. Test group_replication_set_as_primary output (SQL parameter).

--echo # 9.1. With invalid uuid it must fail.
--error ER_GRP_RPL_UDF_ERROR
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=1;

--echo # 9.2. With an unknown uuid it must fail.
--error ER_GRP_RPL_UDF_ERROR
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=2;

--echo # 9.3. With NULL it must fail.
--error ER_GRP_RPL_UDF_ERROR
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=3;

--echo # 9.4. With empty string it must fail.
--error ER_GRP_RPL_UDF_ERROR
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=4;

--echo # 9.5. Already the primary member
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=5;

--echo # 9.6. Switch to another member
--replace_result $server2_uuid MEMBER2_UUID
SELECT group_replication_set_as_primary(b) FROM test.t1 WHERE a=6;

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--source include/gr_assert_secondary_member.inc

--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--source include/gr_assert_primary_member.inc

--echo
--echo # 10. Cleanup

DROP TABLE test.t1;

--source include/rpl_sync.inc

--let $rpl_group_replication_single_primary_mode=1
--let $rpl_group_replication_reset_persistent_vars=1
--source include/group_replication_end.inc