| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Test case for checking the behavior of binary log cache when encrypted. |
| 4 |
# |
| 5 |
# It will generate a workload doing many SAVEPOINT/ROLLBACK TO SAVEPOINT |
| 6 |
# and then committing the transactions. This will be done with binlog_encryption |
| 7 |
# OFF and ON. |
| 8 |
# |
| 9 |
# After the workloads, it would ensure SHOW BINLOG EVENTS works fine for both |
| 10 |
# binary log files and will sync master and slave comparing their tables |
| 11 |
# contents. |
| 12 |
# |
| 13 |
# ==== Related Bugs and Worklogs ==== |
| 14 |
# |
| 15 |
# WL#12079: Binary log cache encryption at rest |
| 16 |
# |
| 17 |
|
| 18 |
# Adding big test option for this test. |
| 19 |
--source include/big_test.inc |
| 20 |
--let $rpl_skip_start_slave= 1 |
| 21 |
--source include/master-slave.inc |
| 22 |
|
| 23 |
# Setup test case variables |
| 24 |
--let $keyring_master= $MYSQL_TMP_DIR/keyring_master |
| 25 |
--let $keyring_slave= $MYSQL_TMP_DIR/keyring_slave |
| 26 |
--let $keyring_original_file= $MYSQL_TEST_DIR/std_data/rpl_nogtid_encryption_keyring_master |
| 27 |
--let $encrypted_binlog_file= $MYSQL_TEST_DIR/std_data/rpl_nogtid_encryption_master-bin.000002 |
| 28 |
--let $MASTER_DATADIR= `select @@datadir` |
| 29 |
--source include/rpl_connection_slave.inc |
| 30 |
--let $SLAVE_DATADIR= `select @@datadir` |
| 31 |
--source include/rpl_connection_master.inc |
| 32 |
|
| 33 |
|
| 34 |
--write_file $MYSQLTEST_VARDIR/tmp/rpl_binlog_cache_encryption.inc PROCEDURE |
| 35 |
--disable_query_log |
| 36 |
--let $trx=50 |
| 37 |
--echo # Inserting 50 transactions with save points |
| 38 |
while ($trx) |
| 39 |
{ |
| 40 |
BEGIN; |
| 41 |
--let $string=`SELECT REPEAT('MySQL123',1024)` |
| 42 |
--let $savepoints=5 |
| 43 |
--let $data_size=400 |
| 44 |
while ($savepoints) |
| 45 |
{ |
| 46 |
--dec $savepoints |
| 47 |
--let $before_savepoint=20 |
| 48 |
while ($before_savepoint > 9) |
| 49 |
{ |
| 50 |
--dec $before_savepoint |
| 51 |
--expr $length = $before_savepoint * $data_size |
| 52 |
--eval INSERT INTO t1 (c2) VALUES (LEFT("$string",$length)) |
| 53 |
} |
| 54 |
--eval SAVEPOINT point$savepoints |
| 55 |
--let $until_rollback=20 |
| 56 |
while ($until_rollback > 9) |
| 57 |
{ |
| 58 |
--dec $until_rollback |
| 59 |
--expr $length = $until_rollback * $data_size |
| 60 |
--eval INSERT INTO t1 (c2) VALUES (LEFT("$string",$length)) |
| 61 |
} |
| 62 |
--eval ROLLBACK TO SAVEPOINT point$savepoints |
| 63 |
--let $after_rollback=20 |
| 64 |
while ($after_rollback > 9) |
| 65 |
{ |
| 66 |
--dec $after_rollback |
| 67 |
--expr $length = $after_rollback * $data_size |
| 68 |
--eval INSERT INTO t1 (c2) VALUES (LEFT("$string",$length)) |
| 69 |
} |
| 70 |
} |
| 71 |
COMMIT; |
| 72 |
--dec $trx |
| 73 |
} |
| 74 |
--enable_query_log |
| 75 |
#END OF |
| 76 |
PROCEDURE |
| 77 |
|
| 78 |
--echo # Part 1 - binlog_encryption = OFF |
| 79 |
--let $plain_master_file=query_get_value(SHOW MASTER STATUS, File, 1) |
| 80 |
CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT, c2 TEXT); |
| 81 |
|
| 82 |
--source $MYSQLTEST_VARDIR/tmp/rpl_binlog_cache_encryption.inc |
| 83 |
|
| 84 |
--echo SHOW BINLOG EVENTS shall not fail on the un-encrypted binlog file |
| 85 |
--disable_result_log |
| 86 |
--replace_result $plain_master_file PLAIN_MASTER_FILE |
| 87 |
--eval SHOW BINLOG EVENTS IN '$plain_master_file' |
| 88 |
--enable_result_log |
| 89 |
|
| 90 |
--echo # Restarting the server with "--binlog_encryption=ON" and keyring |
| 91 |
--let $rpl_server_number= 1 |
| 92 |
--let $rpl_server_parameters= $KEYRING_PLUGIN_OPT $KEYRING_PLUGIN_LOAD --keyring_file_data=$keyring_master --binlog_encryption=ON |
| 93 |
--let $rpl_omit_print_server_parameters= 1 |
| 94 |
--source include/rpl_restart_server.inc |
| 95 |
|
| 96 |
--let $assert_text=binlog_encryption option shall be ON |
| 97 |
--let $option_value = `SELECT variable_value FROM performance_schema.global_variables WHERE variable_name = "binlog_encryption"` |
| 98 |
--let $assert_cond= "$option_value" = "ON" |
| 99 |
--source include/assert.inc |
| 100 |
|
| 101 |
--let $encrypted_master_file=query_get_value(SHOW MASTER STATUS, File, 1) |
| 102 |
--let $rpl_log_file=$MASTER_DATADIR$encrypted_master_file |
| 103 |
--source include/rpl_get_log_encryption_key_id.inc |
| 104 |
--let $assert_text=Binary log is encrypted using 1st master key |
| 105 |
--let $assert_cond= RIGHT("$rpl_encryption_key_id", 2) = "_1" |
| 106 |
--source include/assert.inc |
| 107 |
|
| 108 |
--echo # Part 2 - binlog_encryption = ON |
| 109 |
|
| 110 |
--source $MYSQLTEST_VARDIR/tmp/rpl_binlog_cache_encryption.inc |
| 111 |
|
| 112 |
--echo SHOW BINLOG EVENTS shall not fail on the encrypted binlog file |
| 113 |
--disable_result_log |
| 114 |
--replace_result $encrypted_master_file ENCRYPTED_MASTER_FILE |
| 115 |
--eval SHOW BINLOG EVENTS IN '$encrypted_master_file' |
| 116 |
--enable_result_log |
| 117 |
|
| 118 |
# Restart the server loading the keyring |
| 119 |
--echo # Restarting the server without "--binlog_encryption=ON" |
| 120 |
--let $rpl_server_number= 1 |
| 121 |
--let $rpl_server_parameters= $KEYRING_PLUGIN_OPT $KEYRING_PLUGIN_LOAD --keyring_file_data=$keyring_master |
| 122 |
--let $rpl_omit_print_server_parameters= 1 |
| 123 |
--source include/rpl_restart_server.inc |
| 124 |
|
| 125 |
--source include/rpl_connection_slave.inc |
| 126 |
--source include/start_slave.inc |
| 127 |
--source include/rpl_connection_master.inc |
| 128 |
--source include/sync_slave_sql_with_master.inc |
| 129 |
|
| 130 |
# Table diff |
| 131 |
--let $diff_tables= master:t1, slave:t1 |
| 132 |
--source include/diff_tables.inc |
| 133 |
|
| 134 |
# Cleanup |
| 135 |
--source include/rpl_connection_master.inc |
| 136 |
UNINSTALL PLUGIN keyring_file; |
| 137 |
--remove_file $keyring_master |
| 138 |
--remove_file $MYSQLTEST_VARDIR/tmp/rpl_binlog_cache_encryption.inc |
| 139 |
|
| 140 |
DROP TABLE t1; |
| 141 |
--source include/rpl_end.inc |