| 1 |
# InnoDB transparent encryption on redo log. |
| 2 |
# This test case will check innodb_redo_log_encrypt=ON/OFF with bootstrap |
| 3 |
# and start server by setting innodb_redo_log_encrypt=ON/OFF |
| 4 |
|
| 5 |
--source include/no_valgrind_without_big.inc |
| 6 |
--source include/have_innodb_max_16k.inc |
| 7 |
|
| 8 |
# Suppress following messages from myslqd log |
| 9 |
--disable_query_log |
| 10 |
call mtr.add_suppression("keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file or keyring file can be created in the specified location. The keyring_file will stay unusable until correct path to the keyring file gets provided"); |
| 11 |
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed"); |
| 12 |
call mtr.add_suppression("Encryption can't find master key, please check the keyring plugin is loaded."); |
| 13 |
call mtr.add_suppression("Resizing redo log from"); |
| 14 |
call mtr.add_suppression("Redo log has been requested to resize"); |
| 15 |
call mtr.add_suppression("Starting to delete and rewrite redo log files."); |
| 16 |
call mtr.add_suppression("New redo log files created, LSN="); |
| 17 |
call mtr.add_suppression("Can't set redo log files to be encrypted."); |
| 18 |
--enable_query_log |
| 19 |
|
| 20 |
let $old_innodb_file_per_table = `SELECT @@innodb_file_per_table`; |
| 21 |
let $old_innodb_redo_log_encrypt = `SELECT @@innodb_redo_log_encrypt`; |
| 22 |
let $START_PAGE_SIZE= `select @@innodb_page_size`; |
| 23 |
let $LOG_CAPACITY= `select @@innodb_redo_log_capacity`; |
| 24 |
let $MYSQLD_BASEDIR= `select @@basedir`; |
| 25 |
|
| 26 |
--mkdir $MYSQL_TMP_DIR/log_encrypt_dir1 |
| 27 |
--mkdir $MYSQL_TMP_DIR/log_encrypt_dir2 |
| 28 |
--mkdir $MYSQL_TMP_DIR/log_encrypt_dir3 |
| 29 |
|
| 30 |
let $MYSQLD_DATADIR1 = $MYSQL_TMP_DIR/log_encrypt_dir1; |
| 31 |
let $MYSQLD_DATADIR2 = $MYSQL_TMP_DIR/log_encrypt_dir2; |
| 32 |
let $MYSQLD_DATADIR3 = $MYSQL_TMP_DIR/log_encrypt_dir3; |
| 33 |
|
| 34 |
let BOOTSTRAP_SQL=$MYSQL_TMP_DIR/boot.sql; |
| 35 |
|
| 36 |
--echo # create bootstrap file |
| 37 |
write_file $BOOTSTRAP_SQL; |
| 38 |
CREATE DATABASE test; |
| 39 |
EOF |
| 40 |
--echo # Stop the MTR default DB server |
| 41 |
--source include/shutdown_mysqld.inc |
| 42 |
|
| 43 |
let NEW_CMD = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --innodb_redo_log_capacity=$LOG_CAPACITY --innodb_page_size=$START_PAGE_SIZE --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR1 --init-file=$BOOTSTRAP_SQL --secure-file-priv="" --innodb_redo_log_encrypt=ON --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/my_key_redo4 $KEYRING_PLUGIN_OPT </dev/null>>$MYSQLTEST_VARDIR/tmp/bootstrap1.log 2>&1; |
| 44 |
|
| 45 |
--echo # Run the bootstrap command of datadir1 |
| 46 |
--exec $NEW_CMD |
| 47 |
|
| 48 |
--echo # Start the DB server with datadir1 |
| 49 |
--replace_result $MYSQL_TMP_DIR TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH $MYSQLD_DATADIR1 DATADIR1 $START_PAGE_SIZE PAGE_SIZE $LOG_CAPACITY LOG_CAPACITY |
| 50 |
--let $restart_parameters="restart: --early-plugin-load="keyring_file=$KEYRING_PLUGIN" $KEYRING_PLUGIN_OPT --keyring_file_data=$MYSQL_TMP_DIR/my_key_redo4 --innodb_redo_log_encrypt=ON --datadir=$MYSQLD_DATADIR1 --innodb_page_size=$START_PAGE_SIZE --innodb_redo_log_capacity=$LOG_CAPACITY" |
| 51 |
--replace_regex /\.dll/.so/ |
| 52 |
--source include/start_mysqld_no_echo.inc |
| 53 |
|
| 54 |
SELECT @@global.innodb_redo_log_encrypt ; |
| 55 |
|
| 56 |
USE test; |
| 57 |
CREATE TABLE tab1(c1 INT, c2 VARCHAR(30)); |
| 58 |
INSERT INTO tab1 VALUES(1, 'Test consistency undo*'); |
| 59 |
SELECT * FROM tab1; |
| 60 |
CREATE TABLE tab2(c1 INT, c2 VARCHAR(30)) ENCRYPTION="Y"; |
| 61 |
INSERT INTO tab2 VALUES(1, 'Test consistency undo*'); |
| 62 |
SELECT * FROM tab2; |
| 63 |
DROP TABLE tab1,tab2; |
| 64 |
|
| 65 |
--let $restart_parameters= restart: |
| 66 |
--source include/restart_mysqld.inc |
| 67 |
|
| 68 |
--force-rmdir $MYSQL_TMP_DIR/log_encrypt_dir1 |
| 69 |
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap1.log |
| 70 |
--remove_file $MYSQL_TMP_DIR/my_key_redo4 |
| 71 |
#------------------------------------------------------------------------------ |
| 72 |
|
| 73 |
|
| 74 |
--echo # Stop the MTR default DB server |
| 75 |
--source include/shutdown_mysqld.inc |
| 76 |
|
| 77 |
#bootstrap should fail if keyring plugin is not loaded along with |
| 78 |
#innodb_redo_log_encrypt=ON |
| 79 |
let NEW_CMD = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR2 --init-file=$BOOTSTRAP_SQL --secure-file-priv="" --innodb_redo_log_encrypt=ON </dev/null>>$MYSQLTEST_VARDIR/tmp/bootstrap2.log 2>&1; |
| 80 |
|
| 81 |
--echo # Run the bootstrap command of datadir2, it should fail since the keyring is not loaded. |
| 82 |
--error 1,42 |
| 83 |
--exec $NEW_CMD |
| 84 |
|
| 85 |
--force-rmdir $MYSQL_TMP_DIR/log_encrypt_dir2 |
| 86 |
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap2.log |
| 87 |
|
| 88 |
let NEW_CMD = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --innodb_redo_log_capacity=$LOG_CAPACITY --innodb_page_size=$START_PAGE_SIZE --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR2 --init-file=$BOOTSTRAP_SQL --secure-file-priv="" --innodb_redo_log_encrypt=ON --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/my_key_redo4 $KEYRING_PLUGIN_OPT </dev/null>>$MYSQLTEST_VARDIR/tmp/bootstrap2.log 2>&1; |
| 89 |
|
| 90 |
--echo # Run the bootstrap command of datadir2 |
| 91 |
--exec $NEW_CMD |
| 92 |
|
| 93 |
--echo # Start the DB server with datadir2 |
| 94 |
--replace_result $MYSQL_TMP_DIR TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH $MYSQLD_DATADIR2 DATADIR2 $START_PAGE_SIZE PAGE_SIZE $LOG_CAPACITY LOG_CAPACITY |
| 95 |
--let $restart_parameters="restart: --early-plugin-load="keyring_file=$KEYRING_PLUGIN" $KEYRING_PLUGIN_OPT --keyring_file_data=$MYSQL_TMP_DIR/my_key_redo4 --innodb_redo_log_encrypt=ON --datadir=$MYSQLD_DATADIR2 --innodb_page_size=$START_PAGE_SIZE --innodb_redo_log_capacity=$LOG_CAPACITY" |
| 96 |
--replace_regex /\.dll/.so/ |
| 97 |
--source include/start_mysqld_no_echo.inc |
| 98 |
|
| 99 |
SELECT @@global.innodb_redo_log_encrypt ; |
| 100 |
|
| 101 |
USE test; |
| 102 |
CREATE TABLE tab1(c1 INT, c2 VARCHAR(30)); |
| 103 |
INSERT INTO tab1 VALUES(1, 'Test consistency undo*'); |
| 104 |
SELECT * FROM tab1; |
| 105 |
CREATE TABLE tab2(c1 INT, c2 VARCHAR(30)) ENCRYPTION="Y"; |
| 106 |
INSERT INTO tab2 VALUES(1, 'Test consistency undo*'); |
| 107 |
SELECT * FROM tab2; |
| 108 |
DROP TABLE tab1,tab2; |
| 109 |
|
| 110 |
|
| 111 |
--let $restart_parameters= restart: |
| 112 |
--source include/restart_mysqld.inc |
| 113 |
|
| 114 |
--force-rmdir $MYSQL_TMP_DIR/log_encrypt_dir2 |
| 115 |
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap2.log |
| 116 |
--remove_file $MYSQL_TMP_DIR/my_key_redo4 |
| 117 |
|
| 118 |
#------------------------------------------------------------------------------ |
| 119 |
--echo # Stop the MTR default DB server |
| 120 |
--source include/shutdown_mysqld.inc |
| 121 |
|
| 122 |
let NEW_CMD = $MYSQLD --no-defaults --innodb_dedicated_server=OFF --initialize-insecure --innodb_redo_log_capacity=$LOG_CAPACITY --innodb_page_size=$START_PAGE_SIZE --basedir=$MYSQLD_BASEDIR --datadir=$MYSQLD_DATADIR3 --init-file=$BOOTSTRAP_SQL --secure-file-priv="" --innodb_redo_log_encrypt=ON --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --keyring_file_data=$MYSQL_TMP_DIR/my_key_redo4 $KEYRING_PLUGIN_OPT </dev/null>>$MYSQLTEST_VARDIR/tmp/bootstrap3.log 2>&1; |
| 123 |
|
| 124 |
--echo # Run the bootstrap command of datadir3 |
| 125 |
--exec $NEW_CMD |
| 126 |
|
| 127 |
--echo # Start the DB server with datadir3 and keyring loaded. |
| 128 |
--replace_result $MYSQL_TMP_DIR TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH $MYSQLD_DATADIR3 DATADIR3 $START_PAGE_SIZE PAGE_SIZE $LOG_CAPACITY LOG_CAPACITY |
| 129 |
--let $restart_parameters="restart: --early-plugin-load="keyring_file=$KEYRING_PLUGIN" $KEYRING_PLUGIN_OPT --keyring_file_data=$MYSQL_TMP_DIR/my_key_redo4 --datadir=$MYSQLD_DATADIR3 --innodb_page_size=$START_PAGE_SIZE --innodb_redo_log_capacity=$LOG_CAPACITY" |
| 130 |
--replace_regex /\.dll/.so/ |
| 131 |
--source include/start_mysqld_no_echo.inc |
| 132 |
|
| 133 |
SELECT @@global.innodb_redo_log_encrypt ; |
| 134 |
|
| 135 |
USE test; |
| 136 |
CREATE TABLE tab1(c1 INT, c2 VARCHAR(30)); |
| 137 |
INSERT INTO tab1 VALUES(1, 'Test consistency undo*'); |
| 138 |
SELECT * FROM tab1; |
| 139 |
CREATE TABLE tab2(c1 INT, c2 VARCHAR(30)) ENCRYPTION="Y"; |
| 140 |
DROP TABLE tab1; |
| 141 |
|
| 142 |
--let $restart_parameters= restart: |
| 143 |
--source include/restart_mysqld.inc |
| 144 |
|
| 145 |
--force-rmdir $MYSQL_TMP_DIR/log_encrypt_dir3 |
| 146 |
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap3.log |
| 147 |
--remove_file $MYSQL_TMP_DIR/my_key_redo4 |
| 148 |
--remove_file $BOOTSTRAP_SQL |
| 149 |
|
| 150 |
# Cleanup |
| 151 |
--disable_query_log |
| 152 |
eval SET GLOBAL innodb_file_per_table=$old_innodb_file_per_table; |
| 153 |
eval SET GLOBAL innodb_redo_log_encrypt=$old_innodb_redo_log_encrypt; |
| 154 |
--enable_query_log |