File: binlog_rotate_binlog_master_key_errors.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 (394 lines) | stat: -rw-r--r-- 18,253 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# ==== Purpose ====
#
# To cover error branches when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' on a
# server with binary log enabled.
#
# ==== Implementation ====
#
# Please see binlog_rotate_binlog_master_key_errors.inc
#
# ==== References ====
#
# Wl#12080 Add support to binary log encryption key rotation and cleanup

--source include/have_binlog_format_row.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc

--let $MASTER_DATADIR= `select @@datadir`

CREATE TABLE t1 (c1 INT);

--let $first_encrypted_binary_log=query_get_value(SHOW MASTER STATUS, File, 1)
--let $rpl_log_file=$MASTER_DATADIR$first_encrypted_binary_log
--source include/rpl_get_log_encryption_key_id.inc
--let $assert_text=the first encrypted binary log is encrypted using first master key
--let $assert_cond= RIGHT("$rpl_encryption_key_id", 2) = "_1"
--source include/assert.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when setting old master key seqno on keyring.
--echo # Part 1: fail_to_set_old_master_key_seqno_on_keyring
--let $debug_point=fail_to_set_old_master_key_seqno_on_keyring
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
--let $current_master_key_id=1
--let $current_comparison_digit=2
--let $rotated_master_key_id=2
--let $rotated_comparison_digit=2
--let $rotate_binary_log=0
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# decrypting file password when re-encrypting a log file.
--echo # Part 2: fail_to_decrypt_file_password
--let $debug_point=fail_to_decrypt_file_password
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=3
--let $rotated_master_key_id=4
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# resetting file stream when re-encrypting a log file.
--echo # Part 3: fail_to_reset_file_stream
--let $debug_point=fail_to_reset_file_stream
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=5
--let $rotated_master_key_id=6
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# encrypting the file password with current encryption key when
# re-encrypting a log file.
--echo # Part 4: fail_to_encrypt_file_password
--let $debug_point=fail_to_encrypt_file_password
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=7
--let $rotated_master_key_id=8
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# writing the new reencrypted file header when re-encrypting a log file.
--echo # Part 5: fail_to_write_reencrypted_header
--let $debug_point=fail_to_write_reencrypted_header
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=9
--let $rotated_master_key_id=10
--let $rotated_comparison_digit=3
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# flushing the new reencrypted file header when re-encrypting a log file.
--echo # Part 6: fail_to_flush_reencrypted_header
--let $debug_point=fail_to_flush_reencrypted_header
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=11
--let $current_comparison_digit=3
--let $rotated_master_key_id=12
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# synchronizing the new reencrypted file header when re-encrypting
# a log file.
--echo # Part 7: fail_to_sync_reencrypted_header
--let $debug_point=fail_to_sync_reencrypted_header
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=13
--let $rotated_master_key_id=14
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when opening a log file for re-encryption.
--echo # Part 8: fail_to_open_log_file
--let $debug_point=fail_to_open_log_file
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=15
--let $rotated_master_key_id=16
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when reading an index file.
--echo # Part 9: fail_to_open_index_file
--let $debug_point=fail_to_open_index_file
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=17
--let $rotated_master_key_id=18
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_ROTATE_LOGS'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when rotating binary log.
--echo # Part 10: fail_to_rotate_binary_log
--let $debug_point=fail_to_rotate_binary_log
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_ROTATE_LOGS
--let $current_master_key_id=19
--let $rotated_master_key_id=20
--let $rotate_binary_log=1
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when fetching key on keyring.
--echo # Part 11: fail_to_fetch_key_from_keyring
--let $debug_point=fail_to_fetch_key_from_keyring
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
--let $current_master_key_id=20
--let $rotated_master_key_id=21
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when setting new master key seqno on keyring.
--echo # Part 12: fail_to_set_new_master_key_seqno_on_keyring

--let $debug_point=fail_to_set_new_master_key_seqno_on_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

# Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# on removing old master key seqno from keyring. This happens if
# a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
# failed to set new master key seqno on keyring.
--let $debug_point=fail_to_remove_old_master_key_seqno_from_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

# Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# on fetching master key seqno from keyring. This happens if a
# previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
# failed to set new master key seqno on keyring.
--let $debug_point=failed_to_fetch_master_key_seqno_from_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

# Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# on fetching old master key seqno from keyring. This happens if
# a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
# failed to set new master key seqno on keyring.
--let $debug_point=failed_to_fetch_old_master_key_seqno_from_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

FLUSH BINARY LOGS;
--let $current_master_key_id=21
--let $rotated_master_key_id=22
--source suite/binlog/include/binlog_rotate_binlog_master_key_work.inc

--echo #
--echo # Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
--echo # is emitted to the client side when executing the command
--echo # 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
--echo # error when generating key on keyring.
--echo #
--echo # Part 13: fail_to_generate_key_on_keyring
--let $debug_point=fail_to_generate_key_on_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

# Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# on removing new master key seqno from keyring. This happens if
# a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
# failed to generate key on keyring.
--let $debug_point=fail_to_remove_new_master_key_seqno_from_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_RPL_ENCRYPTION_FAILED_TO_REMOVE_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

# Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# on fetching new master key seqno from keyring. This happens if
# a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' statement
# failed to generate key on keyring.
--let $debug_point=failed_to_fetch_new_master_key_seqno_from_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_RPL_ENCRYPTION_FAILED_TO_FETCH_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

FLUSH BINARY LOGS;
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
--let $current_master_key_id=22
--let $rotated_master_key_id=23
--source suite/binlog/include/binlog_rotate_binlog_master_key_work.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when removing master key from keyring.
--echo # Part 14: fail_to_remove_master_key_from_keyring
--let $debug_point=fail_to_remove_master_key_from_keyring
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
--let $current_master_key_id=24
--let $rotated_master_key_id=25
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when getting last purged master key seqno from keyring.
--echo # Part 15: fail_to_get_purged_seqno_from_keyring
--let $debug_point=fail_to_get_purged_seqno_from_keyring
--let $expected_error=0
--let $current_master_key_id=26
--let $rotated_master_key_id=27
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc
# The following test cases do not need to rotate binary log.
--let $rotate_binary_log=0

# Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when getting key from keyring.
--echo # Part 16: fail_to_get_key_from_keyring
--let $debug_point=fail_to_get_key_from_keyring
--let $expected_error=0
--let $current_master_key_id=28
--let $rotated_master_key_id=29
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when removing unused key from keyring.
--echo # Part 17: fail_to_remove_unused_key_from_keyring
--let $debug_point=fail_to_remove_unused_key_from_keyring
--let $expected_error=0
--let $current_master_key_id=30
--let $rotated_master_key_id=31
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when removing last purged seqno from keyring.
--echo # Part 18: fail_to_remove_last_purged_seqno_from_keyring
--let $debug_point=fail_to_remove_last_purged_seqno_from_keyring
--let $expected_error=0
--let $current_master_key_id=32
--let $rotated_master_key_id=33
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_AUX_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when removing old master key seqno from keyring.
--echo # Part 19: fail_to_remove_old_master_key_seqno_from_keyring
--let $debug_point=fail_to_remove_old_master_key_seqno_from_keyring
--let $expected_error=0
--let $current_master_key_id=34
--let $rotated_master_key_id=35
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_AUX_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when removing new master key seqno from keyring.
--echo # Part 20: fail_to_remove_new_master_key_seqno_from_keyring
--let $debug_point=fail_to_remove_new_master_key_seqno_from_keyring
--let $expected_error=0
--let $current_master_key_id=36
--let $rotated_master_key_id=37
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that a warning 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_CLEANUP_UNUSED_KEYS'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when setting last purged master key seqno on keyring.
--echo # Part 21: fail_to_set_last_purged_master_key_seqno_on_keyring
--let $debug_point=fail_to_set_last_purged_master_key_seqno_on_keyring
--let $expected_error=0
--let $current_master_key_id=38
--let $rotated_master_key_id=39
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when setting master key seqno on keyring.
--echo # Part 22: fail_to_set_master_key_seqno_on_keyring
--let $debug_point=fail_to_set_master_key_seqno_on_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_OPERATE_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

# Verify that an error 'ER_RPL_ENCRYPTION_FAILED_TO_STORE_KEY'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an error
# on restoring master key seqno on keyring with its backup. This
# happens if a previous 'ALTER INSTANCE ROTATE BINLOG MASTER KEY'
# statement failed to store master key seqno on keyring after
# removing it from keyring.
--let $debug_point=fail_to_set_master_key_seqno_on_keyring
--source include/add_debug_point.inc
--replace_result \\ /
--error ER_RPL_ENCRYPTION_FAILED_TO_STORE_KEY
ALTER INSTANCE ROTATE BINLOG MASTER KEY;
--source include/remove_debug_point.inc

--let $current_master_key_id=39
--let $rotated_master_key_id=41
--source suite/binlog/include/binlog_rotate_binlog_master_key_work.inc


# Verify that an error 'ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG'
# is emitted to the client side when executing the command
# 'ALTER INSTANCE ROTATE BINLOG MASTER KEY' if there is an
# error when reading an index file during re-encryption.
--echo # Part 23: fail_to_read_index_file
--let $debug_point=fail_to_read_index_file
--let $expected_error=ER_BINLOG_MASTER_KEY_ROTATION_FAIL_TO_REENCRYPT_LOG
--let $current_master_key_id=42
--let $rotated_master_key_id=43
--source suite/binlog/include/binlog_rotate_binlog_master_key_errors.inc

DROP TABLE t1;