File: tablespace_encrypt_10.inc

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 (176 lines) | stat: -rw-r--r-- 6,996 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
################################################################################
# InnoDB transparent tablespace data encryption for general shared tablespace.
# This test case will test, during resume operation,
#    - Test 1 : Crash just before flushing page 0 at the end of (un)encryption
#    - Test 2 : Crash just after flushing page 0 at the end of (un)encryption
#    - Test 3 : Crash just before resetting progress on page 0
#    - Test 4 : Crash just before updating tablespace flags on page 0
#    - Test 5 : Crash before starting encryption processing
#    - Test 6 : Crash after finishing encryption processing
#    - Test 7 : Crash just after inserting DDL Log Entry
################################################################################

# Waiting time when (re)starting the server
--let $explicit_default_wait_counter=10000

--disable_query_log
call mtr.add_suppression("ibd can't be decrypted, please confirm that keyring is loaded.");
call mtr.add_suppression("\\[ERROR\\] \\[[^]]*\\] \\[[^]]*\\] Encryption can't find master key, please check the keyring is loaded.");
call mtr.add_suppression("\\[ERROR\\] \\[[^]]*\\] \\[[^]]*\\] Check keyring fail, please check the keyring is loaded.");
--enable_query_log

--echo # START : WITHOUT KEYRING
--echo
--echo #########
--echo # SETUP #
--echo #########
--source include/keyring_tests/helper/instance_backup_manifest.inc
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc

let $MYSQLD_DATADIR= `select @@datadir`;

--write_file $MYSQLTEST_VARDIR/tmp/encryption_error_log.inc ERROR_LOG
# Search the pattern in error log
--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err
--let SEARCH_PATTERN=Resuming ENCRYPTION for tablespace encrypt_ts
--source include/search_pattern.inc
--let SEARCH_PATTERN=Finished ENCRYPTION for tablespace encrypt_ts
--source include/search_pattern.inc
--remove_file $MYSQLTEST_VARDIR/log/my_restart.err
ERROR_LOG

--write_file $MYSQLTEST_VARDIR/tmp/unencryption_error_log.inc ERROR_LOG
# Search the pattern in error log
--let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err
--let SEARCH_PATTERN=Resuming DECRYPTION for tablespace encrypt_ts
--source include/search_pattern.inc
--let SEARCH_PATTERN=Finished DECRYPTION for tablespace encrypt_ts
--source include/search_pattern.inc
--remove_file $MYSQLTEST_VARDIR/log/my_restart.err
ERROR_LOG

# Create an Unencrypted tablespace
CREATE TABLESPACE encrypt_ts ADD DATAFILE 'encrypt_ts.ibd' ENGINE=InnoDB ENCRYPTION="N";
# Create an unencrypted table in tablespace
CREATE TABLE t1(c1 char(100)) ENGINE=InnoDB TABLESPACE encrypt_ts;
# Insert few rows in table
--disable_query_log
INSERT INTO t1 VALUES ("SOME VALUES");
let $counter=12;
while ($counter>0)
{
  INSERT INTO test.t1 SELECT * FROM test.t1;
  dec $counter;
}
--enable_query_log

# Make sure ts file is updated with new records in table
set global innodb_buf_flush_list_now = 1;

SELECT NAME, ENCRYPTION FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME='encrypt_ts';
SELECT * FROM t1 LIMIT 10;

# Try to alter tablespace to be encrypted. Should fail as keyring is not laoded.
--error ER_CANNOT_FIND_KEY_IN_KEYRING
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y';

--let $rc=1
--echo #-------------------------- TEST 1 -------------------------------------#

--echo # RESTART $rc : WITH KEYRING
--source include/keyring_tests/helper/instance_restore_manifest.inc
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc
--inc $rc

--let $crash_point=alter_encrypt_tablespace_crash_before_flushing_page_0
--let $crash_point_desc=just before flushing page 0 at the end
--source suite/innodb/include/resume_test_encryption.inc
--source suite/innodb/include/resume_test_unencryption.inc

--echo #-------------------------- TEST 2 -------------------------------------#

--echo # RESTART $rc : WITH KEYRING
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc
--inc $rc

--let $crash_point=alter_encrypt_tablespace_crash_after_flushing_page_0
--let $crash_point_desc=just after flushing page 0 at the end
--source suite/innodb/include/resume_test_encryption.inc
--source suite/innodb/include/resume_test_unencryption.inc

--echo #-------------------------- TEST 3 -------------------------------------#

--echo # RESTART $rc : WITH KEYRING
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc
--inc $rc

--let $crash_point=alter_encrypt_tablespace_crash_before_resetting_progress
--let $crash_point_desc=just before resetting_progress on page 0
--source suite/innodb/include/resume_test_encryption.inc
--source suite/innodb/include/resume_test_unencryption.inc

--echo #-------------------------- TEST 4 -------------------------------------#

--echo # RESTART $rc : WITH KEYRING
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc
--inc $rc

--echo # Encrypt the tablespace.
ALTER TABLESPACE encrypt_ts ENCRYPTION='Y';

--let $crash_point=alter_encrypt_tablespace_crash_before_updating_flags
--let $crash_point_desc=just before updating flags
--source suite/innodb/include/resume_test_unencryption.inc

--echo #-------------------------- TEST 5 -------------------------------------#

--echo # RESTART $rc : WITH KEYRING
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc
--inc $rc

--let $crash_point=alter_encrypt_tablespace_crash_before_processing
--let $crash_point_desc=just before encryption processing is started
--source suite/innodb/include/resume_test_encryption.inc
--source suite/innodb/include/resume_test_unencryption.inc

--echo #-------------------------- TEST 6 -------------------------------------#

--echo # RESTART $rc : WITH KEYRING
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc
--inc $rc

--let $crash_point=alter_encrypt_tablespace_crash_after_processing
--let $crash_point_desc=just after encryption processing is finished
--source suite/innodb/include/resume_test_encryption.inc
--source suite/innodb/include/resume_test_unencryption.inc

--echo #-------------------------- TEST 7 -------------------------------------#

--echo # RESTART $rc : WITH KEYRING
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc
--inc $rc

--let $crash_point=alter_encrypt_tablespace_crash_after_ddl_entry
--let $crash_point_desc=just after inserting DDL Log Entry
--source suite/innodb/include/resume_test_encryption.inc
--source suite/innodb/include/resume_test_unencryption.inc

--echo ###########
--echo # Cleanup #
--echo ###########
DROP TABLE t1;
DROP TABLESPACE encrypt_ts;

--echo # RESTART $rc : final
let $restart_parameters = restart: $PLUGIN_DIR_OPT;
--source include/restart_mysqld_no_echo.inc
--remove_file $MYSQLTEST_VARDIR/tmp/encryption_error_log.inc
--remove_file $MYSQLTEST_VARDIR/tmp/unencryption_error_log.inc