Commit 7e34bb5c authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-11905: Simplify encryption.innodb_encrypt_discard_import

The test was populating unnecessarily large tables and
restarting the server several times for no real reason.

Let us hope that a smaller version of the test will produce more
stable results. Occasionally, some unencrypted contents in the table t2
was revealed in the old test.
parent 9bf50a0e
...@@ -13,11 +13,13 @@ set current_num = current_num + 1; ...@@ -13,11 +13,13 @@ set current_num = current_num + 1;
end while; end while;
end// end//
commit; commit;
set autocommit=0; begin;
call innodb_insert_proc(10000); set statement unique_checks=0, foreign_key_checks=0 for
call innodb_insert_proc(100);
commit; commit;
set autocommit=1; DROP PROCEDURE innodb_insert_proc;
# Wait max 10 min for key encryption threads to encrypt all spaces # Wait max 10 min for key encryption threads to encrypt all spaces
FLUSH TABLES t1, t2, t3 FOR EXPORT;
# tablespaces should be now encrypted # tablespaces should be now encrypted
# t1 yes on expecting NOT FOUND # t1 yes on expecting NOT FOUND
NOT FOUND /foobar/ in t1.ibd NOT FOUND /foobar/ in t1.ibd
...@@ -25,15 +27,16 @@ NOT FOUND /foobar/ in t1.ibd ...@@ -25,15 +27,16 @@ NOT FOUND /foobar/ in t1.ibd
NOT FOUND /temp/ in t2.ibd NOT FOUND /temp/ in t2.ibd
# t3 ... on expecting NOT FOUND # t3 ... on expecting NOT FOUND
NOT FOUND /barfoo/ in t3.ibd NOT FOUND /barfoo/ in t3.ibd
# restart
db.opt db.opt
t1.cfg
t1.frm t1.frm
t1.ibd t1.ibd
t2.cfg
t2.frm t2.frm
t2.ibd t2.ibd
t3.cfg
t3.frm t3.frm
t3.ibd t3.ibd
FLUSH TABLES t1, t2, t3 FOR EXPORT;
backup: t1 backup: t1
backup: t2 backup: t2
backup: t3 backup: t3
...@@ -55,17 +58,18 @@ restore: t1 .ibd and .cfg files ...@@ -55,17 +58,18 @@ restore: t1 .ibd and .cfg files
restore: t2 .ibd and .cfg files restore: t2 .ibd and .cfg files
restore: t3 .ibd and .cfg files restore: t3 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE; ALTER TABLE t1 IMPORT TABLESPACE;
SELECT COUNT(1) FROM t1; SELECT COUNT(*) FROM t1;
COUNT(1) COUNT(*)
10000 100
ALTER TABLE t2 IMPORT TABLESPACE; ALTER TABLE t2 IMPORT TABLESPACE;
SELECT COUNT(1) FROM t2; SELECT COUNT(*) FROM t2;
COUNT(1) COUNT(*)
10000 100
ALTER TABLE t3 IMPORT TABLESPACE; ALTER TABLE t3 IMPORT TABLESPACE;
SELECT COUNT(1) FROM t3; SELECT COUNT(*) FROM t3;
COUNT(1) COUNT(*)
10000 100
FLUSH TABLES t1, t2, t3 FOR EXPORT;
# tablespaces should remain encrypted after import # tablespaces should remain encrypted after import
# t1 yes on expecting NOT FOUND # t1 yes on expecting NOT FOUND
NOT FOUND /foobar/ in t1.ibd NOT FOUND /foobar/ in t1.ibd
...@@ -73,8 +77,8 @@ NOT FOUND /foobar/ in t1.ibd ...@@ -73,8 +77,8 @@ NOT FOUND /foobar/ in t1.ibd
NOT FOUND /temp/ in t2.ibd NOT FOUND /temp/ in t2.ibd
# t3 ... on expecting NOT FOUND # t3 ... on expecting NOT FOUND
NOT FOUND /barfoo/ in t3.ibd NOT FOUND /barfoo/ in t3.ibd
# restart UNLOCK TABLES;
ALTER TABLE t1 ENGINE InnoDB; ALTER TABLE t1 FORCE;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -82,7 +86,7 @@ t1 CREATE TABLE `t1` ( ...@@ -82,7 +86,7 @@ t1 CREATE TABLE `t1` (
`a` varchar(255) DEFAULT NULL, `a` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `encrypted`=yes ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci `encrypted`=yes
ALTER TABLE t2 ENGINE InnoDB; ALTER TABLE t2 FORCE;
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
...@@ -90,7 +94,7 @@ t2 CREATE TABLE `t2` ( ...@@ -90,7 +94,7 @@ t2 CREATE TABLE `t2` (
`a` varchar(255) DEFAULT NULL, `a` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
ALTER TABLE t3 ENGINE InnoDB; ALTER TABLE t3 FORCE;
SHOW CREATE TABLE t3; SHOW CREATE TABLE t3;
Table Create Table Table Create Table
t3 CREATE TABLE `t3` ( t3 CREATE TABLE `t3` (
...@@ -98,30 +102,17 @@ t3 CREATE TABLE `t3` ( ...@@ -98,30 +102,17 @@ t3 CREATE TABLE `t3` (
`a` varchar(255) DEFAULT NULL, `a` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPRESSED `encrypted`=yes ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPRESSED `encrypted`=yes
# Restarting server
# restart
# Done restarting server
# Verify that tables are still usable # Verify that tables are still usable
SELECT COUNT(1) FROM t1; CHECK TABLE t1, t2, t3 EXTENDED;
COUNT(1) Table Op Msg_type Msg_text
10000 test.t1 check status OK
SELECT COUNT(1) FROM t2; test.t2 check status OK
COUNT(1) test.t3 check status OK
10000 FLUSH TABLES t1, t2, t3 FOR EXPORT;
SELECT COUNT(1) FROM t3;
COUNT(1)
10000
# Tablespaces should be encrypted after restart
# t1 yes on expecting NOT FOUND # t1 yes on expecting NOT FOUND
NOT FOUND /foobar/ in t1.ibd NOT FOUND /foobar/ in t1.ibd
# t2 ... on expecting NOT FOUND # t2 ... on expecting NOT FOUND
NOT FOUND /temp/ in t2.ibd NOT FOUND /temp/ in t2.ibd
# t3 ... on expecting NOT FOUND # t3 ... on expecting NOT FOUND
NOT FOUND /barfoo/ in t3.ibd UNLOCK TABLES;
# restart
# Wait max 10 min for key encryption threads to encrypt all spaces
# Success!
# Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0
# restart: --innodb_encrypt_tables=0 --innodb_encryption_threads=0
DROP PROCEDURE innodb_insert_proc;
DROP TABLE t1, t2, t3; DROP TABLE t1, t2, t3;
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
let MYSQLD_DATADIR = `SELECT @@datadir`; let MYSQLD_DATADIR = `SELECT @@datadir`;
--let SEARCH_RANGE = 10000000 --let SEARCH_RANGE = 10000000
--let $id = `SELECT RAND()`
--let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd --let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd
--let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd --let t2_IBD = $MYSQLD_DATADIR/test/t2.ibd
--let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd --let t3_IBD = $MYSQLD_DATADIR/test/t3.ibd
...@@ -30,19 +29,18 @@ end// ...@@ -30,19 +29,18 @@ end//
delimiter ;// delimiter ;//
commit; commit;
set autocommit=0; begin;
call innodb_insert_proc(10000); set statement unique_checks=0, foreign_key_checks=0 for
call innodb_insert_proc(100);
commit; commit;
set autocommit=1; DROP PROCEDURE innodb_insert_proc;
--echo # Wait max 10 min for key encryption threads to encrypt all spaces --echo # Wait max 10 min for key encryption threads to encrypt all spaces
--let $wait_timeout= 600 --let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING <> 0 --let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING <> 0
--source include/wait_condition.inc --source include/wait_condition.inc
# shutdown so that grep is safe FLUSH TABLES t1, t2, t3 FOR EXPORT;
--source include/shutdown_mysqld.inc
--echo # tablespaces should be now encrypted --echo # tablespaces should be now encrypted
--let SEARCH_PATTERN=foobar --let SEARCH_PATTERN=foobar
--echo # t1 yes on expecting NOT FOUND --echo # t1 yes on expecting NOT FOUND
...@@ -57,11 +55,8 @@ set autocommit=1; ...@@ -57,11 +55,8 @@ set autocommit=1;
-- let SEARCH_FILE=$t3_IBD -- let SEARCH_FILE=$t3_IBD
-- source include/search_pattern_in_file.inc -- source include/search_pattern_in_file.inc
--source include/start_mysqld.inc
let MYSQLD_DATADIR =`SELECT @@datadir`; let MYSQLD_DATADIR =`SELECT @@datadir`;
--list_files $MYSQLD_DATADIR/test --list_files $MYSQLD_DATADIR/test
FLUSH TABLES t1, t2, t3 FOR EXPORT;
perl; perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1","t2","t3"); ib_backup_tablespaces("test", "t1","t2","t3");
...@@ -80,14 +75,13 @@ ib_restore_tablespaces("test", "t1","t2","t3"); ...@@ -80,14 +75,13 @@ ib_restore_tablespaces("test", "t1","t2","t3");
EOF EOF
ALTER TABLE t1 IMPORT TABLESPACE; ALTER TABLE t1 IMPORT TABLESPACE;
SELECT COUNT(1) FROM t1; SELECT COUNT(*) FROM t1;
ALTER TABLE t2 IMPORT TABLESPACE; ALTER TABLE t2 IMPORT TABLESPACE;
SELECT COUNT(1) FROM t2; SELECT COUNT(*) FROM t2;
ALTER TABLE t3 IMPORT TABLESPACE; ALTER TABLE t3 IMPORT TABLESPACE;
SELECT COUNT(1) FROM t3; SELECT COUNT(*) FROM t3;
# shutdown so that grep is safe FLUSH TABLES t1, t2, t3 FOR EXPORT;
--source include/shutdown_mysqld.inc
--echo # tablespaces should remain encrypted after import --echo # tablespaces should remain encrypted after import
--let SEARCH_PATTERN=foobar --let SEARCH_PATTERN=foobar
...@@ -103,28 +97,18 @@ SELECT COUNT(1) FROM t3; ...@@ -103,28 +97,18 @@ SELECT COUNT(1) FROM t3;
-- let SEARCH_FILE=$t3_IBD -- let SEARCH_FILE=$t3_IBD
-- source include/search_pattern_in_file.inc -- source include/search_pattern_in_file.inc
--source include/start_mysqld.inc UNLOCK TABLES;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 ENGINE InnoDB;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
ALTER TABLE t2 ENGINE InnoDB; ALTER TABLE t2 FORCE;
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
ALTER TABLE t3 ENGINE InnoDB; ALTER TABLE t3 FORCE;
SHOW CREATE TABLE t3; SHOW CREATE TABLE t3;
--echo # Restarting server
-- source include/restart_mysqld.inc
--echo # Done restarting server
--echo # Verify that tables are still usable --echo # Verify that tables are still usable
SELECT COUNT(1) FROM t1; CHECK TABLE t1, t2, t3 EXTENDED;
SELECT COUNT(1) FROM t2; FLUSH TABLES t1, t2, t3 FOR EXPORT;
SELECT COUNT(1) FROM t3;
# shutdown so that grep is safe
--source include/shutdown_mysqld.inc
--echo # Tablespaces should be encrypted after restart
--let SEARCH_PATTERN=foobar --let SEARCH_PATTERN=foobar
--echo # t1 yes on expecting NOT FOUND --echo # t1 yes on expecting NOT FOUND
-- let SEARCH_FILE=$t1_IBD -- let SEARCH_FILE=$t1_IBD
...@@ -136,19 +120,7 @@ SELECT COUNT(1) FROM t3; ...@@ -136,19 +120,7 @@ SELECT COUNT(1) FROM t3;
--echo # t3 ... on expecting NOT FOUND --echo # t3 ... on expecting NOT FOUND
--let SEARCH_PATTERN=barfoo --let SEARCH_PATTERN=barfoo
-- let SEARCH_FILE=$t3_IBD -- let SEARCH_FILE=$t3_IBD
-- source include/search_pattern_in_file.inc
--source include/start_mysqld.inc
--echo # Wait max 10 min for key encryption threads to encrypt all spaces
--let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING <> 0
--source include/wait_condition.inc
--echo # Success! UNLOCK TABLES;
--echo # Restart mysqld --innodb_encrypt_tables=0 --innodb_encryption_threads=0
-- let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=0
-- source include/restart_mysqld.inc
DROP PROCEDURE innodb_insert_proc;
DROP TABLE t1, t2, t3; DROP TABLE t1, t2, t3;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment