Debian Codegraph @

mysql-test/suite/binlog/t/binlog_rotate_binlog_master_key_errors.test

raw
1 # ==== Purpose ====
2 #
3 # To cover error branches when executing the command
4 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' on a
5 # server with binary log enabled.
6 #
7 # ==== Implementation ====
8 #
9 # Please see binlog_rotate_binlog_master_key_errors.inc
10 #
11 # ==== References ====
12 #
13 # Wl#12080 Add support to binary log encryption key rotation and cleanup
14
15 --source include/have_binlog_format_row.inc
16 --source include/have_debug.inc
17 --source include/have_debug_sync.inc
18
19 --let $MASTER_DATADIR= `select @@datadir`
20
21 CREATE TABLE t1 (c1 INT);
22
23 --let $first_encrypted_binary_log=query_get_value(SHOW MASTER STATUS, File, 1)
24 --let $rpl_log_file=$MASTER_DATADIR$first_encrypted_binary_log
25 --source include/rpl_get_log_encryption_key_id.inc
26 --let $assert_text=the first encrypted binary log is encrypted using first master key
27 --let $assert_cond= RIGHT("$rpl_encryption_key_id", 2) = "_1"
28 --source include/assert.inc
29
30 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
31 # is emitted to the client side when executing the command
32 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
33 # error when setting old master key seqno on keyring.
34 --echo # Part 1: fail_to_set_old_master_key_seqno_on_keyring
35 --let $debug_point=fail_to_set_old_master_key_seqno_on_keyring
36 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
37 --let $current_master_key_id=1
38 --let $current_comparison_digit=2
39 --let $rotated_master_key_id=2
40 --let $rotated_comparison_digit=2
41 --let $rotate_binary_log=0
42 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
43
44 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
45 # is emitted to the client side when executing the command
46 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
47 # decrypting file password when re-encrypting a log file.
48 --echo # Part 2: fail_to_decrypt_file_password
49 --let $debug_point=fail_to_decrypt_file_password
50 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
51 --let $current_master_key_id=3
52 --let $rotated_master_key_id=4
53 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
54
55 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
56 # is emitted to the client side when executing the command
57 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
58 # resetting file stream when re-encrypting a log file.
59 --echo # Part 3: fail_to_reset_file_stream
60 --let $debug_point=fail_to_reset_file_stream
61 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
62 --let $current_master_key_id=5
63 --let $rotated_master_key_id=6
64 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
65
66 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
67 # is emitted to the client side when executing the command
68 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
69 # encrypting the file password with current encryption key when
70 # re-encrypting a log file.
71 --echo # Part 4: fail_to_encrypt_file_password
72 --let $debug_point=fail_to_encrypt_file_password
73 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
74 --let $current_master_key_id=7
75 --let $rotated_master_key_id=8
76 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
77
78 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
79 # is emitted to the client side when executing the command
80 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
81 # writing the new reencrypted file header when re-encrypting a log file.
82 --echo # Part 5: fail_to_write_reencrypted_header
83 --let $debug_point=fail_to_write_reencrypted_header
84 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
85 --let $current_master_key_id=9
86 --let $rotated_master_key_id=10
87 --let $rotated_comparison_digit=3
88 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
89
90 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
91 # is emitted to the client side when executing the command
92 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
93 # flushing the new reencrypted file header when re-encrypting a log file.
94 --echo # Part 6: fail_to_flush_reencrypted_header
95 --let $debug_point=fail_to_flush_reencrypted_header
96 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
97 --let $current_master_key_id=11
98 --let $current_comparison_digit=3
99 --let $rotated_master_key_id=12
100 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
101
102 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
103 # is emitted to the client side when executing the command
104 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
105 # synchronizing the new reencrypted file header when re-encrypting
106 # a log file.
107 --echo # Part 7: fail_to_sync_reencrypted_header
108 --let $debug_point=fail_to_sync_reencrypted_header
109 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
110 --let $current_master_key_id=13
111 --let $rotated_master_key_id=14
112 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
113
114 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
115 # is emitted to the client side when executing the command
116 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
117 # error when opening a log file for re-encryption.
118 --echo # Part 8: fail_to_open_log_file
119 --let $debug_point=fail_to_open_log_file
120 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
121 --let $current_master_key_id=15
122 --let $rotated_master_key_id=16
123 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
124
125 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
126 # is emitted to the client side when executing the command
127 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
128 # error when reading an index file.
129 --echo # Part 9: fail_to_open_index_file
130 --let $debug_point=fail_to_open_index_file
131 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
132 --let $current_master_key_id=17
133 --let $rotated_master_key_id=18
134 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
135
136 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_ROTATE_LOGS'
137 # is emitted to the client side when executing the command
138 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
139 # error when rotating binary log.
140 --echo # Part 10: fail_to_rotate_binary_log
141 --let $debug_point=fail_to_rotate_binary_log
142 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_ROTATE_LOGS
143 --let $current_master_key_id=19
144 --let $rotated_master_key_id=20
145 --let $rotate_binary_log=1
146 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
147
148 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
149 # is emitted to the client side when executing the command
150 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
151 # error when fetching key on keyring.
152 --echo # Part 11: fail_to_fetch_key_from_keyring
153 --let $debug_point=fail_to_fetch_key_from_keyring
154 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
155 --let $current_master_key_id=20
156 --let $rotated_master_key_id=21
157 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
158
159 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
160 # is emitted to the client side when executing the command
161 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
162 # error when setting new master key seqno on keyring.
163 --echo # Part 12: fail_to_set_new_master_key_seqno_on_keyring
164
165 --let $debug_point=fail_to_set_new_master_key_seqno_on_keyring
166 --source include/add_debug_point.inc
167 --replace_result \\ /
168 --error ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
169 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
170 --source include/remove_debug_point.inc
171
172 # Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY'
173 # is emitted to the client side when executing the command
174 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
175 # on removing old master key seqno from keyring. This happens if
176 # a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
177 # failed to set new master key seqno on keyring.
178 --let $debug_point=fail_to_remove_old_master_key_seqno_from_keyring
179 --source include/add_debug_point.inc
180 --replace_result \\ /
181 --error ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY
182 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
183 --source include/remove_debug_point.inc
184
185 # Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY'
186 # is emitted to the client side when executing the command
187 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
188 # on fetching master key seqno from keyring. This happens if a
189 # previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
190 # failed to set new master key seqno on keyring.
191 --let $debug_point=failed_to_fetch_master_key_seqno_from_keyring
192 --source include/add_debug_point.inc
193 --replace_result \\ /
194 --error ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY
195 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
196 --source include/remove_debug_point.inc
197
198 # Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY'
199 # is emitted to the client side when executing the command
200 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
201 # on fetching old master key seqno from keyring. This happens if
202 # a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
203 # failed to set new master key seqno on keyring.
204 --let $debug_point=failed_to_fetch_old_master_key_seqno_from_keyring
205 --source include/add_debug_point.inc
206 --replace_result \\ /
207 --error ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY
208 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
209 --source include/remove_debug_point.inc
210
211 FLUSH BINARY LOGS;
212 --let $current_master_key_id=21
213 --let $rotated_master_key_id=22
214 --source suite/binlog/include/binlog_rotate_binlog_master_key_work.inc
215
216 --echo #
217 --echo # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
218 --echo # is emitted to the client side when executing the command
219 --echo # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
220 --echo # error when generating key on keyring.
221 --echo #
222 --echo # Part 13: fail_to_generate_key_on_keyring
223 --let $debug_point=fail_to_generate_key_on_keyring
224 --source include/add_debug_point.inc
225 --replace_result \\ /
226 --error ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
227 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
228 --source include/remove_debug_point.inc
229
230 # Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY'
231 # is emitted to the client side when executing the command
232 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
233 # on removing new master key seqno from keyring. This happens if
234 # a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
235 # failed to generate key on keyring.
236 --let $debug_point=fail_to_remove_new_master_key_seqno_from_keyring
237 --source include/add_debug_point.inc
238 --replace_result \\ /
239 --error ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY
240 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
241 --source include/remove_debug_point.inc
242
243 # Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY'
244 # is emitted to the client side when executing the command
245 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
246 # on fetching new master key seqno from keyring. This happens if
247 # a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
248 # failed to generate key on keyring.
249 --let $debug_point=failed_to_fetch_new_master_key_seqno_from_keyring
250 --source include/add_debug_point.inc
251 --replace_result \\ /
252 --error ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY
253 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
254 --source include/remove_debug_point.inc
255
256 FLUSH BINARY LOGS;
257 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
258 --let $current_master_key_id=22
259 --let $rotated_master_key_id=23
260 --source suite/binlog/include/binlog_rotate_binlog_master_key_work.inc
261
262 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
263 # is emitted to the client side when executing the command
264 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
265 # error when removing master key from keyring.
266 --echo # Part 14: fail_to_remove_master_key_from_keyring
267 --let $debug_point=fail_to_remove_master_key_from_keyring
268 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
269 --let $current_master_key_id=24
270 --let $rotated_master_key_id=25
271 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
272
273 # Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
274 # is emitted to the client side when executing the command
275 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
276 # error when getting last purged master key seqno from keyring.
277 --echo # Part 15: fail_to_get_purged_seqno_from_keyring
278 --let $debug_point=fail_to_get_purged_seqno_from_keyring
279 --let $expected_error=0
280 --let $current_master_key_id=26
281 --let $rotated_master_key_id=27
282 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
283 # The following test cases do not need to rotate binary log.
284 --let $rotate_binary_log=0
285
286 # Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
287 # is emitted to the client side when executing the command
288 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
289 # error when getting key from keyring.
290 --echo # Part 16: fail_to_get_key_from_keyring
291 --let $debug_point=fail_to_get_key_from_keyring
292 --let $expected_error=0
293 --let $current_master_key_id=28
294 --let $rotated_master_key_id=29
295 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
296
297 # Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
298 # is emitted to the client side when executing the command
299 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
300 # error when removing unused key from keyring.
301 --echo # Part 17: fail_to_remove_unused_key_from_keyring
302 --let $debug_point=fail_to_remove_unused_key_from_keyring
303 --let $expected_error=0
304 --let $current_master_key_id=30
305 --let $rotated_master_key_id=31
306 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
307
308 # Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
309 # is emitted to the client side when executing the command
310 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
311 # error when removing last purged seqno from keyring.
312 --echo # Part 18: fail_to_remove_last_purged_seqno_from_keyring
313 --let $debug_point=fail_to_remove_last_purged_seqno_from_keyring
314 --let $expected_error=0
315 --let $current_master_key_id=32
316 --let $rotated_master_key_id=33
317 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
318
319 # Verify that an warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_AUX_KEY'
320 # is emitted to the client side when executing the command
321 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
322 # error when removing old master key seqno from keyring.
323 --echo # Part 19: fail_to_remove_old_master_key_seqno_from_keyring
324 --let $debug_point=fail_to_remove_old_master_key_seqno_from_keyring
325 --let $expected_error=0
326 --let $current_master_key_id=34
327 --let $rotated_master_key_id=35
328 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
329
330 # Verify that an warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_AUX_KEY'
331 # is emitted to the client side when executing the command
332 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
333 # error when removing new master key seqno from keyring.
334 --echo # Part 20: fail_to_remove_new_master_key_seqno_from_keyring
335 --let $debug_point=fail_to_remove_new_master_key_seqno_from_keyring
336 --let $expected_error=0
337 --let $current_master_key_id=36
338 --let $rotated_master_key_id=37
339 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
340
341 # Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
342 # is emitted to the client side when executing the command
343 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
344 # error when setting last purged master key seqno on keyring.
345 --echo # Part 21: fail_to_set_last_purged_master_key_seqno_on_keyring
346 --let $debug_point=fail_to_set_last_purged_master_key_seqno_on_keyring
347 --let $expected_error=0
348 --let $current_master_key_id=38
349 --let $rotated_master_key_id=39
350 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
351
352 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
353 # is emitted to the client side when executing the command
354 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
355 # error when setting master key seqno on keyring.
356 --echo # Part 22: fail_to_set_master_key_seqno_on_keyring
357 --let $debug_point=fail_to_set_master_key_seqno_on_keyring
358 --source include/add_debug_point.inc
359 --replace_result \\ /
360 --error ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
361 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
362 --source include/remove_debug_point.inc
363
364 # Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_STORE_KEY'
365 # is emitted to the client side when executing the command
366 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
367 # on restoring master key seqno on keyring with its backup. This
368 # happens if a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY'
369 # statement failed to store master key seqno on keyring after
370 # removing it from keyring.
371 --let $debug_point=fail_to_set_master_key_seqno_on_keyring
372 --source include/add_debug_point.inc
373 --replace_result \\ /
374 --error ER_RPL_ENCRYPTION_FAILED_TO_STORE_KEY
375 ALTER INSTANCE ROTATE BINLOG MASTER KEY;
376 --source include/remove_debug_point.inc
377
378 --let $current_master_key_id=39
379 --let $rotated_master_key_id=41
380 --source suite/binlog/include/binlog_rotate_binlog_master_key_work.inc
381
382
383 # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
384 # is emitted to the client side when executing the command
385 # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
386 # error when reading an index file during re-encryption.
387 --echo # Part 23: fail_to_read_index_file
388 --let $debug_point=fail_to_read_index_file
389 --let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
390 --let $current_master_key_id=42
391 --let $rotated_master_key_id=43
392 --source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
393
394 DROP TABLE t1;