Debian Codegraph @

mysql-test/suite/group_replication/t/gr_start_gr_with_credentials_3.test

raw
1 ################################################################################
2 # This test proves USER option is mandatory with PASSWORD option in
3 # START GROUP_REPLICATION command and tests the password limit of 32 character.
4 # This test also check DEFAULT_AUTH picks credentials from
5 # CHANGE MASTER if USER and PASSWORD option are not provided in
6 # START GROUP_REPLICATION command.
7 #
8 # Test:
9 # 1. Bootstrap M1. And create new users.
10 # 2. Reset recovery interval to 1 and count to 2 for M2.
11 # 3. Test empty USER is not accepted by START GR.
12 # 3. Test password limits.
13 # Test username displayed is correct in ps table.
14 # 4. Test credentials without USER are not accepted.
15 # 5. Test DEFAULT_AUTH without USER.
16 # Credentials are not set in CHANGE MASTER so START GR fails.
17 # 6. Set credentials in CHANGE MASTER.
18 # Pass only DEFAULT_AUTH in START GR.
19 # Credentials are picked from CHANGE MASTER.
20 # 7. Cleanup.
21 ################################################################################
22
23 --source include/big_test.inc
24 --source include/have_debug_sync.inc
25 --source include/have_group_replication_xcom_communication_stack.inc
26 --source include/have_group_replication_plugin.inc
27 --let $rpl_skip_group_replication_start= 1
28 --source include/group_replication.inc
29
30 --echo
31 --echo # 1. Bootstrap M1. And create new users.
32
33 --let $rpl_connection_name= server1
34 --source include/rpl_connection.inc
35
36 --replace_result $PLUGIN_AUTH PLUGIN_AUTH
37 --eval INSTALL PLUGIN test_plugin_server SONAME '$PLUGIN_AUTH'
38
39 --source include/start_and_bootstrap_group_replication.inc
40
41 SET SQL_LOG_BIN=0;
42
43 CREATE USER 'regular_user_p' IDENTIFIED BY '012345678901234567890123456789ab';
44 CREATE USER 'regular_user_wp' IDENTIFIED BY '';
45 CREATE USER 'plug_user_p' IDENTIFIED WITH 'test_plugin_server' AS 'proxy_user_p';
46 CREATE USER 'plug_user_wp' IDENTIFIED WITH 'test_plugin_server' AS 'proxy_user_wp';
47 CREATE USER 'proxy_user_p' IDENTIFIED BY 'password';
48 CREATE USER 'proxy_user_wp' IDENTIFIED BY '';
49
50 GRANT REPLICATION SLAVE ON *.* TO "regular_user_p";
51 GRANT REPLICATION SLAVE ON *.* TO "regular_user_wp";
52 GRANT ALL PRIVILEGES ON *.* TO 'proxy_user_p';
53 GRANT ALL PRIVILEGES ON *.* TO 'proxy_user_wp';
54 GRANT PROXY ON 'proxy_user_p' to 'plug_user_p';
55 GRANT PROXY ON 'proxy_user_wp' to 'plug_user_wp';
56 GRANT REPLICATION SLAVE ON *.* TO 'plug_user_p';
57 GRANT REPLICATION SLAVE ON *.* TO 'plug_user_wp';
58
59 SET SQL_LOG_BIN=1;
60
61 --echo
62 --echo # 2. Reset recovery interval to 1 and count to 2 for M2.
63
64 --let $rpl_connection_name= server2
65 --source include/rpl_connection.inc
66
67 --replace_result $PLUGIN_AUTH PLUGIN_AUTH
68 --eval INSTALL PLUGIN test_plugin_server SONAME '$PLUGIN_AUTH'
69
70 SET @saved_group_replication_recovery_reconnect_interval = @@GLOBAL.group_replication_recovery_reconnect_interval;
71 SET @saved_gr_recovery_retry_count = @@GLOBAL.group_replication_recovery_retry_count;
72 SET @old_log_output= @@log_output;
73 SET GLOBAL log_output= 'TABLE,FILE';
74
75 SET GLOBAL group_replication_recovery_reconnect_interval= 1;
76 SET GLOBAL group_replication_recovery_retry_count= 2;
77 --replace_result $group_replication_group_name GROUP_REPLICATION_GROUP_NAME
78 --eval SET GLOBAL group_replication_group_name= "$group_replication_group_name"
79
80 RESET SLAVE ALL FOR CHANNEL 'group_replication_recovery';
81
82 --echo
83 --echo # 3. Test empty USER is not accepted by START GR.
84 --echo # Test username displayed is correct in ps table.
85
86
87 SET GLOBAL super_read_only= FALSE;
88 SET SQL_LOG_BIN=0;
89 TRUNCATE mysql.general_log;
90 SET SQL_LOG_BIN=1;
91 --error ER_GROUP_REPLICATION_USER_EMPTY_MSG
92 START GROUP_REPLICATION USER='';
93 --let $assert_text= Command is not logged.
94 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION%"]" = "0"
95 --source include/assert.inc
96
97 SET GLOBAL super_read_only= FALSE;
98 SET SQL_LOG_BIN=0;
99 TRUNCATE mysql.general_log;
100 SET SQL_LOG_BIN=1;
101 --error ER_PARSE_ERROR
102 START GROUP_REPLICATION USER;
103 --let $assert_text= Command is not logged.
104 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION%"]" = "0"
105 --source include/assert.inc
106
107 --echo
108 --echo # 3. Test password limits.
109
110 # Test max password length is 32, password length 33 throws error
111 SET GLOBAL super_read_only= FALSE;
112 SET SQL_LOG_BIN=0;
113 TRUNCATE mysql.general_log;
114 SET SQL_LOG_BIN=1;
115 --error ER_GROUP_REPLICATION_PASSWORD_LENGTH
116 START GROUP_REPLICATION USER='regular_user_p' , PASSWORD='012345678901234567890123456789abc';
117 --let $assert_text= Command is not logged.
118 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION%"]" = "0"
119 --source include/assert.inc
120
121 # Test max password length is 32, password length 32 works
122 SET GLOBAL super_read_only= FALSE;
123 SET SQL_LOG_BIN=0;
124 TRUNCATE mysql.general_log;
125 SET SQL_LOG_BIN=1;
126
127 --let $rpl_connection_name= server1
128 --source include/rpl_connection.inc
129 SET @@GLOBAL.DEBUG='+d,block_applier_updates';
130
131 --let $rpl_connection_name= server2
132 --source include/rpl_connection.inc
133 START GROUP_REPLICATION USER='regular_user_p' , PASSWORD='012345678901234567890123456789ab';
134
135 --let $wait_condition=SELECT SERVICE_STATE="ON" FROM performance_schema.replication_connection_status WHERE CHANNEL_NAME='group_replication_recovery'
136 --source include/wait_condition.inc
137
138 --let $assert_text= User name displayed is of supplied in command.
139 --let $assert_cond= "[SELECT USER FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME="group_replication_recovery"]" = "regular_user_p"
140 --source include/assert.inc
141
142 --let $rpl_connection_name= server1
143 --source include/rpl_connection.inc
144 SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked";
145 SET @@GLOBAL.DEBUG='-d,block_applier_updates';
146 SET DEBUG_SYNC = "now SIGNAL resume_applier_read";
147
148 --let $rpl_connection_name= server2
149 --source include/rpl_connection.inc
150 --let $group_replication_member_state = ONLINE
151 --source include/gr_wait_for_member_state.inc
152
153 --let $rpl_connection_name= server1
154 --source include/rpl_connection.inc
155 SET DEBUG_SYNC= 'RESET';
156
157 --let $rpl_connection_name= server2
158 --source include/rpl_connection.inc
159 --let $assert_text= User name displayed is empty.
160 --let $assert_cond= "[SELECT USER FROM performance_schema.replication_connection_configuration WHERE CHANNEL_NAME="group_replication_recovery"]" = ""
161 --source include/assert.inc
162
163 --source include/stop_group_replication.inc
164 --let $assert_text= Password is not logged.
165 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION %PASSWORD_=%012345678901234567890123456789ab%"]" = "0"
166 --source include/assert.inc
167 --let $assert_text= Password is logged as secret.
168 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION %PASSWORD_=%<secret>%"]" = "1"
169 --source include/assert.inc
170
171 --echo
172 --echo # 4. Test credentials without USER are not accepted.
173
174 SET GLOBAL super_read_only= FALSE;
175 SET SQL_LOG_BIN=0;
176 TRUNCATE mysql.general_log;
177 SET SQL_LOG_BIN=1;
178 --error ER_GROUP_REPLICATION_USER_MANDATORY_MSG
179 START GROUP_REPLICATION PASSWORD='wrong';
180 --let $assert_text= Password is not logged.
181 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION %PASSWORD_=%012345678901234567890123456789ab%"]" = "0"
182 --source include/assert.inc
183 --let $assert_text= Password is logged as secret.
184 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION %PASSWORD_=%<secret>%"]" = "1"
185 --source include/assert.inc
186
187 SET GLOBAL super_read_only= FALSE;
188 SET SQL_LOG_BIN=0;
189 TRUNCATE mysql.general_log;
190 SET SQL_LOG_BIN=1;
191 --error ER_GROUP_REPLICATION_USER_EMPTY_MSG
192 START GROUP_REPLICATION USER='',PASSWORD='wrong';
193 --let $assert_text= Command is not logged.
194 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION%"]" = "0"
195 --source include/assert.inc
196
197 --echo
198 --echo # 5. Test DEFAULT_AUTH without USER.
199 --echo # Credentials are not set in CHANGE MASTER so START GR fails.
200
201 # Below command fails because username and password are not stored in
202 # CHANGE MASTER, same command later succeed when username and password
203 # are saved via CHANGE MASTER.
204 # Quote is not added in logs if USER and PASSWORD options are not provided.
205 SET GLOBAL super_read_only= FALSE;
206 SET SQL_LOG_BIN=0;
207 TRUNCATE mysql.general_log;
208 SET SQL_LOG_BIN=1;
209 START GROUP_REPLICATION DEFAULT_AUTH='auth_test_plugin';
210 --let $group_replication_member_state = ERROR
211 --source include/gr_wait_for_member_state.inc
212 --source include/stop_group_replication.inc
213 --let $assert_text= User is not logged.
214 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION %USER%"]" = "0"
215 --source include/assert.inc
216 --let $assert_text= Password is not logged.
217 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION %PASSWORD%"]" = "0"
218 --source include/assert.inc
219 --let $assert_text= Quote is not present before DEFAULT_AUTH.
220 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION DEFAULT_AUTH%"]" = "1"
221 --source include/assert.inc
222
223 --echo
224 --echo # 6. Set credentials in CHANGE MASTER.
225 --echo # Pass only DEFAULT_AUTH in START GR.
226 --echo # Credentials are picked from CHANGE MASTER.
227
228 CHANGE REPLICATION SOURCE TO SOURCE_USER='plug_user_p' , SOURCE_PASSWORD='proxy_user_p' FOR CHANNEL 'group_replication_recovery';
229
230 # Quote is not added in logs if USER and PASSWORD options are not provided.
231 SET GLOBAL super_read_only= FALSE;
232 SET SQL_LOG_BIN=0;
233 TRUNCATE mysql.general_log;
234 SET SQL_LOG_BIN=1;
235 START GROUP_REPLICATION DEFAULT_AUTH='auth_test_plugin';
236 --let $group_replication_member_state = ONLINE
237 --source include/gr_wait_for_member_state.inc
238 --source include/stop_group_replication.inc
239 --let $assert_text= User is not logged.
240 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION %USER%"]" = "0"
241 --source include/assert.inc
242 --let $assert_text= Password is not logged.
243 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION %PASSWORD%"]" = "0"
244 --source include/assert.inc
245 --let $assert_text= Quote is not present before DEFAULT_AUTH.
246 --let $assert_cond= "[SELECT COUNT(*) FROM mysql.general_log WHERE argument LIKE "START GROUP_REPLICATION DEFAULT_AUTH%"]" = "1"
247 --source include/assert.inc
248
249 # Below command proves value of DEFAULT_AUTH matters.
250 START GROUP_REPLICATION DEFAULT_AUTH='wrong';
251 --let $group_replication_member_state = ONLINE
252 --source include/gr_wait_for_member_state.inc
253 --source include/stop_group_replication.inc
254
255 --echo
256 --echo # 7. Cleanup.
257
258 CHANGE REPLICATION SOURCE TO SOURCE_USER='root' , SOURCE_PASSWORD='' FOR CHANNEL 'group_replication_recovery';
259
260 SET SESSION sql_log_bin = 0;
261 call mtr.add_suppression("Replica I/O for channel 'group_replication_recovery': Fatal error: Invalid .* username when attempting to connect to the source server.*");
262 call mtr.add_suppression("There was an error when connecting to the donor server. Please check that group_replication_recovery channel credentials and all MEMBER_HOST column values of performance_schema.replication_group_members table are correct and DNS resolvable.");
263 call mtr.add_suppression("For details please check performance_schema.replication_connection_status table and error log messages of Replica I/O for channel group_replication_recovery.");
264 call mtr.add_suppression("Maximum number of retries when trying to connect to a donor reached. Aborting group replication incremental recovery.");
265 call mtr.add_suppression("Fatal error during the incremental recovery process of Group Replication. The server will leave the group.");
266 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
267 call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
268 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
269 SET SESSION sql_log_bin = 1;
270
271 SET @@GLOBAL.group_replication_recovery_reconnect_interval = @saved_group_replication_recovery_reconnect_interval;
272 SET @@GLOBAL.group_replication_recovery_retry_count = @saved_gr_recovery_retry_count;
273 SET GLOBAL log_output= @old_log_output;
274 UNINSTALL PLUGIN test_plugin_server;
275
276 --let $rpl_connection_name= server1
277 --source include/rpl_connection.inc
278
279 SET SQL_LOG_BIN=0;
280
281 DROP USER 'regular_user_p';
282 DROP USER 'regular_user_wp';
283
284 DROP USER 'plug_user_p';
285 DROP USER 'plug_user_wp';
286 DROP USER 'proxy_user_p';
287 DROP USER 'proxy_user_wp';
288
289 SET SQL_LOG_BIN=1;
290 UNINSTALL PLUGIN test_plugin_server;
291
292 --source include/group_replication_end.inc
293
294 --let $rpl_connection_name= server2
295 --source include/rpl_connection.inc
296 TRUNCATE mysql.general_log;