| 1 |
################################################################################ |
| 2 |
# InnoDB transparent tablespace data encryption for general shared tablespace. |
| 3 |
# This test case will test, during resume operation, |
| 4 |
# - Test 1 : Crash just before flushing page 0 at the end of (un)encryption |
| 5 |
# - Test 2 : Crash just after flushing page 0 at the end of (un)encryption |
| 6 |
# - Test 3 : Crash just before resetting progress on page 0 |
| 7 |
# - Test 4 : Crash just before updating tablespace flags on page 0 |
| 8 |
# - Test 5 : Crash before starting encryption processing |
| 9 |
# - Test 6 : Crash after finishing encryption processing |
| 10 |
# - Test 7 : Crash just after inserting DDL Log Entry |
| 11 |
################################################################################ |
| 12 |
|
| 13 |
--source include/big_test.inc |
| 14 |
--source include/have_debug.inc |
| 15 |
# --source include/no_valgrind_without_big.inc |
| 16 |
# Disable in valgrind because of timeout, cf. Bug#22760145 |
| 17 |
--source include/not_valgrind.inc |
| 18 |
# Waiting time when (re)starting the server |
| 19 |
--let $explicit_default_wait_counter=10000 |
| 20 |
|
| 21 |
--disable_query_log |
| 22 |
call mtr.add_suppression("ibd can't be decrypted, please confirm the keyring is loaded."); |
| 23 |
call mtr.add_suppression("\\[ERROR\\] \\[[^]]*\\] \\[[^]]*\\] Encryption can't find master key, please check the keyring is loaded."); |
| 24 |
call mtr.add_suppression("\\[ERROR\\] \\[[^]]*\\] \\[[^]]*\\] Check keyring fail, please check the keyring is loaded."); |
| 25 |
--enable_query_log |
| 26 |
|
| 27 |
--echo # START : WITHOUT KEYRING PLUGIN |
| 28 |
--echo |
| 29 |
--echo ######### |
| 30 |
--echo # SETUP # |
| 31 |
--echo ######### |
| 32 |
|
| 33 |
let $MYSQLD_DATADIR= `select @@datadir`; |
| 34 |
|
| 35 |
--write_file $MYSQLTEST_VARDIR/tmp/encryption_error_log.inc ERROR_LOG |
| 36 |
# Search the pattern in error log |
| 37 |
--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err |
| 38 |
--let SEARCH_PATTERN=Resuming ENCRYPTION for tablespace encrypt_ts |
| 39 |
--source include/search_pattern.inc |
| 40 |
--let SEARCH_PATTERN=Finished ENCRYPTION for tablespace encrypt_ts |
| 41 |
--source include/search_pattern.inc |
| 42 |
--remove_file $MYSQLTEST_VARDIR/log/my_restart.err |
| 43 |
ERROR_LOG |
| 44 |
|
| 45 |
--write_file $MYSQLTEST_VARDIR/tmp/unencryption_error_log.inc ERROR_LOG |
| 46 |
# Search the pattern in error log |
| 47 |
--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err |
| 48 |
--let SEARCH_PATTERN=Resuming DECRYPTION for tablespace encrypt_ts |
| 49 |
--source include/search_pattern.inc |
| 50 |
--let SEARCH_PATTERN=Finished DECRYPTION for tablespace encrypt_ts |
| 51 |
--source include/search_pattern.inc |
| 52 |
--remove_file $MYSQLTEST_VARDIR/log/my_restart.err |
| 53 |
ERROR_LOG |
| 54 |
|
| 55 |
# Create an Unencrypted tablespace |
| 56 |
CREATE TABLESPACE encrypt_ts ADD DATAFILE 'encrypt_ts.ibd' ENGINE=InnoDB ENCRYPTION="N"; |
| 57 |
# Create an unencrypted table in tablespace |
| 58 |
CREATE TABLE t1(c1 char(100)) ENGINE=InnoDB TABLESPACE encrypt_ts; |
| 59 |
# Insert few rows in table |
| 60 |
--disable_query_log |
| 61 |
INSERT INTO t1 VALUES ("SOME VALUES"); |
| 62 |
let $counter=12; |
| 63 |
while ($counter>0) |
| 64 |
{ |
| 65 |
INSERT INTO test.t1 SELECT * FROM test.t1; |
| 66 |
dec $counter; |
| 67 |
} |
| 68 |
--enable_query_log |
| 69 |
|
| 70 |
# Make sure ts file is updated with new records in table |
| 71 |
set global innodb_buf_flush_list_now = 1; |
| 72 |
|
| 73 |
SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts'; |
| 74 |
SELECT * FROM t1 LIMIT 10; |
| 75 |
|
| 76 |
# Try to alter tablespace to be encrypted. Should fail as keyring is not laoded. |
| 77 |
--error ER_CANNOT_FIND_KEY_IN_KEYRING |
| 78 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; |
| 79 |
|
| 80 |
--let $rc=1 |
| 81 |
--echo #-------------------------- TEST 1 -------------------------------------# |
| 82 |
|
| 83 |
--echo # RESTART $rc : WITH KEYRING PLUGIN |
| 84 |
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT; |
| 85 |
--source include/restart_mysqld_no_echo.inc |
| 86 |
--inc $rc |
| 87 |
|
| 88 |
--let $crash_point=alter_encrypt_tablespace_crash_before_flushing_page_0 |
| 89 |
--let $crash_point_desc=just before flushing page 0 at the end |
| 90 |
--source suite/innodb/include/resume_test_encryption.inc |
| 91 |
--source suite/innodb/include/resume_test_unencryption.inc |
| 92 |
|
| 93 |
--echo #-------------------------- TEST 2 -------------------------------------# |
| 94 |
|
| 95 |
--echo # RESTART $rc : WITH KEYRING PLUGIN |
| 96 |
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT; |
| 97 |
--source include/restart_mysqld_no_echo.inc |
| 98 |
--inc $rc |
| 99 |
|
| 100 |
--let $crash_point=alter_encrypt_tablespace_crash_after_flushing_page_0 |
| 101 |
--let $crash_point_desc=just after flushing page 0 at the end |
| 102 |
--source suite/innodb/include/resume_test_encryption.inc |
| 103 |
--source suite/innodb/include/resume_test_unencryption.inc |
| 104 |
|
| 105 |
--echo #-------------------------- TEST 3 -------------------------------------# |
| 106 |
|
| 107 |
--echo # RESTART $rc : WITH KEYRING PLUGIN |
| 108 |
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT; |
| 109 |
--source include/restart_mysqld_no_echo.inc |
| 110 |
--inc $rc |
| 111 |
|
| 112 |
--let $crash_point=alter_encrypt_tablespace_crash_before_resetting_progress |
| 113 |
--let $crash_point_desc=just before resetting_progress on page 0 |
| 114 |
--source suite/innodb/include/resume_test_encryption.inc |
| 115 |
--source suite/innodb/include/resume_test_unencryption.inc |
| 116 |
|
| 117 |
--echo #-------------------------- TEST 4 -------------------------------------# |
| 118 |
|
| 119 |
--echo # RESTART $rc : WITH KEYRING PLUGIN |
| 120 |
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT; |
| 121 |
--source include/restart_mysqld_no_echo.inc |
| 122 |
--inc $rc |
| 123 |
|
| 124 |
--echo # Encrypt the tablespace. |
| 125 |
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y'; |
| 126 |
|
| 127 |
--let $crash_point=alter_encrypt_tablespace_crash_before_updating_flags |
| 128 |
--let $crash_point_desc=just before updating flags |
| 129 |
--source suite/innodb/include/resume_test_unencryption.inc |
| 130 |
|
| 131 |
--echo #-------------------------- TEST 5 -------------------------------------# |
| 132 |
|
| 133 |
--echo # RESTART $rc : WITH KEYRING PLUGIN |
| 134 |
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT; |
| 135 |
--source include/restart_mysqld_no_echo.inc |
| 136 |
--inc $rc |
| 137 |
|
| 138 |
--let $crash_point=alter_encrypt_tablespace_crash_before_processing |
| 139 |
--let $crash_point_desc=just before encryption processing is started |
| 140 |
--source suite/innodb/include/resume_test_encryption.inc |
| 141 |
--source suite/innodb/include/resume_test_unencryption.inc |
| 142 |
|
| 143 |
--echo #-------------------------- TEST 6 -------------------------------------# |
| 144 |
|
| 145 |
--echo # RESTART $rc : WITH KEYRING PLUGIN |
| 146 |
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT; |
| 147 |
--source include/restart_mysqld_no_echo.inc |
| 148 |
--inc $rc |
| 149 |
|
| 150 |
--let $crash_point=alter_encrypt_tablespace_crash_after_processing |
| 151 |
--let $crash_point_desc=just after encryption processing is finished |
| 152 |
--source suite/innodb/include/resume_test_encryption.inc |
| 153 |
--source suite/innodb/include/resume_test_unencryption.inc |
| 154 |
|
| 155 |
--echo #-------------------------- TEST 7 -------------------------------------# |
| 156 |
|
| 157 |
--echo # RESTART $rc : WITH KEYRING PLUGIN |
| 158 |
let $restart_parameters = restart: --early-plugin-load=keyring_file=$KEYRING_PLUGIN --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring $KEYRING_PLUGIN_OPT; |
| 159 |
--source include/restart_mysqld_no_echo.inc |
| 160 |
--inc $rc |
| 161 |
|
| 162 |
--let $crash_point=alter_encrypt_tablespace_crash_after_ddl_entry |
| 163 |
--let $crash_point_desc=just after inserting DDL Log Entry |
| 164 |
--source suite/innodb/include/resume_test_encryption.inc |
| 165 |
--source suite/innodb/include/resume_test_unencryption.inc |
| 166 |
|
| 167 |
--echo ########### |
| 168 |
--echo # Cleanup # |
| 169 |
--echo ########### |
| 170 |
DROP TABLE t1; |
| 171 |
DROP TABLESPACE encrypt_ts; |
| 172 |
|
| 173 |
--echo # RESTART $rc : final |
| 174 |
let $restart_parameters = restart:; |
| 175 |
--source include/restart_mysqld_no_echo.inc |
| 176 |
--remove_file $MYSQLTEST_VARDIR/tmp/encryption_error_log.inc |
| 177 |
--remove_file $MYSQLTEST_VARDIR/tmp/unencryption_error_log.inc |
| 178 |
--remove_file $MYSQL_TMP_DIR/mysecret_keyring |