[Commits] 42f0bbf: MDEV-9099: Test encryption.innodb_encryption_discard_import fails on buildbot

Jan Lindström jan.lindstrom at mariadb.com
Fri Oct 28 13:59:57 EEST 2016


revision-id: 42f0bbff7e18bc8aa2aeb373dd698a29ae791399 (mariadb-10.1.18-20-g42f0bbf)
parent(s): 08a469337fe2b4c1f6a393351d4307acb55ba827
author: Jan Lindström
committer: Jan Lindström
timestamp: 2016-10-28 13:59:35 +0300
message:

MDEV-9099: Test encryption.innodb_encryption_discard_import fails on buildbot

---
 mysql-test/suite/encryption/include/innodb-util.pl | 126 +++++++++++++++++++++
 .../r/innodb_encryption_discard_import.result      |  43 ++-----
 .../t/innodb_encryption_discard_import.test        |  93 +++------------
 3 files changed, 152 insertions(+), 110 deletions(-)

diff --git a/mysql-test/suite/encryption/include/innodb-util.pl b/mysql-test/suite/encryption/include/innodb-util.pl
new file mode 100644
index 0000000..241545d
--- /dev/null
+++ b/mysql-test/suite/encryption/include/innodb-util.pl
@@ -0,0 +1,126 @@
+#
+# Utility functions to copy files for WL#5522
+#
+# All the tables must be in the same database, you can call it like so:
+# ib_backup_tablespaces("test", "t1", "blah", ...).
+
+use File::Copy;
+use File::Spec;
+
+sub ib_normalize_path {
+    my ($path) = @_;
+}
+
+sub ib_backup_tablespace {
+    my ($db, $table) = @_;
+    my $datadir = $ENV{'MYSQLD_DATADIR'};
+    my $cfg_file = sprintf("%s.cfg", $table);
+    my $ibd_file = sprintf("%s.ibd", $table);
+    my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
+
+    my @args = (File::Spec->catfile($datadir, $db, $ibd_file),
+		File::Spec->catfile($tmpd, $ibd_file));
+
+    copy(@args) or die "copy @args failed: $!";
+
+    my @args = (File::Spec->catfile($datadir, $db, $cfg_file),
+	        File::Spec->catfile($tmpd, $cfg_file));
+
+    copy(@args) or die "copy @args failed: $!";
+}
+
+sub ib_cleanup {
+    my ($db, $table) = @_;
+    my $datadir = $ENV{'MYSQLD_DATADIR'};
+    my $cfg_file = sprintf("%s.cfg", $table);
+
+    print "unlink: $cfg_file\n";
+
+    # These may or may not exist
+    unlink(File::Spec->catfile($datadir, $db, $cfg_file));
+}
+
+sub ib_unlink_tablespace {
+    my ($db, $table) = @_;
+    my $datadir = $ENV{'MYSQLD_DATADIR'};
+    my $ibd_file = sprintf("%s.ibd", $table);
+
+    print "unlink: $ibd_file\n";
+    # This may or may not exist
+    unlink(File::Spec->catfile($datadir, $db, $ibd_file));
+
+    ib_cleanup($db, $table);
+}
+
+sub ib_backup_tablespaces {
+    my ($db, @tables) = @_;
+
+    foreach my $table (@tables) {
+	print "backup: $table\n";
+	ib_backup_tablespace($db, $table);
+    }
+}
+
+sub ib_discard_tablespace { }
+
+sub ib_discard_tablespaces { }
+
+sub ib_restore_cfg_file {
+    my ($tmpd, $datadir, $db, $table) = @_;
+    my $cfg_file = sprintf("%s.cfg", $table);
+
+    my @args = (File::Spec->catfile($tmpd, $cfg_file),
+		File::Spec->catfile($datadir, "$db", $cfg_file));
+
+    copy(@args) or die "copy @args failed: $!";
+}
+
+sub ib_restore_ibd_file {
+    my ($tmpd, $datadir, $db, $table) = @_;
+    my $ibd_file = sprintf("%s.ibd", $table);
+
+    my @args = (File::Spec->catfile($tmpd, $ibd_file),
+		File::Spec->catfile($datadir, $db, $ibd_file));
+
+    copy(@args) or die "copy @args failed: $!";
+}
+
+sub ib_restore_tablespace {
+    my ($db, $table) = @_;
+    my $datadir = $ENV{'MYSQLD_DATADIR'};
+    my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
+
+    ib_restore_cfg_file($tmpd, $datadir, $db, $table);
+    ib_restore_ibd_file($tmpd, $datadir, $db, $table);
+}
+
+sub ib_restore_tablespaces {
+    my ($db, @tables) = @_;
+
+    foreach my $table (@tables) {
+        print "restore: $table .ibd and .cfg files\n";
+        ib_restore_tablespace($db, $table);
+    }
+}
+
+sub ib_restore_cfg_files {
+    my ($db, @tables) = @_;
+    my $datadir = $ENV{'MYSQLD_DATADIR'};
+    my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
+
+    foreach my $table (@tables) {
+      print "restore: $table .cfg file\n";
+      ib_restore_cfg_file($tmpd, $datadir, $db, $table);
+    }
+}
+
+sub ib_restore_ibd_files {
+    my ($db, @tables) = @_;
+    my $datadir = $ENV{'MYSQLD_DATADIR'};
+    my $tmpd = $ENV{'MYSQLTEST_VARDIR'} . "/tmp";
+
+    foreach my $table (@tables) {
+        print "restore: $table .ibd file\n";
+        ib_restore_ibd_file($tmpd, $datadir, $db, $table);
+    }
+}
diff --git a/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result b/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result
index f8c59b7..40284db 100644
--- a/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result
+++ b/mysql-test/suite/encryption/r/innodb_encryption_discard_import.result
@@ -28,62 +28,41 @@ NOT FOUND /foobar/ in t1.ibd
 NOT FOUND /temp/ in t2.ibd
 # t3 ... on expecting NOT FOUND
 NOT FOUND /barfoo/ in t3.ibd
-FLUSH TABLE t1, t2, t3 FOR EXPORT;
-# List before copying files
-t1.cfg
 t1.frm
 t1.ibd
-t2.cfg
 t2.frm
 t2.ibd
-t3.cfg
 t3.frm
 t3.ibd
-UNLOCK TABLES;
-# Restarting server
-# Done restarting server
-# List before t1 DISCARD
+FLUSH TABLES t1, t2, t3 FOR EXPORT;
+backup: t1
+backup: t2
+backup: t3
+t1.cfg
 t1.frm
 t1.ibd
+t2.cfg
 t2.frm
 t2.ibd
+t3.cfg
 t3.frm
 t3.ibd
-SET GLOBAL innodb_file_format = `Barracuda`;
-SET GLOBAL innodb_file_per_table = ON;
+UNLOCK TABLES;
 ALTER TABLE t1 DISCARD TABLESPACE;
 ALTER TABLE t2 DISCARD TABLESPACE;
 ALTER TABLE t3 DISCARD TABLESPACE;
-# List after t1 DISCARD
-t1.frm
-t2.frm
-t3.frm
-# Restarting server
-# Done restarting server
-SET GLOBAL innodb_file_format = `Barracuda`;
-SET GLOBAL innodb_file_per_table = ON;
-# Tablespaces should be still encrypted
-# t1 yes on expecting NOT FOUND
-NOT FOUND /foobar/ in t1.ibd
-# t2 ... on expecting NOT FOUND
-NOT FOUND /temp/ in t2.ibd
-# t3 ... on expecting NOT FOUND
-NOT FOUND /barfoo/ in t3.ibd
+restore: t1 .ibd and .cfg files
+restore: t2 .ibd and .cfg files
+restore: t3 .ibd and .cfg files
 ALTER TABLE t1 IMPORT TABLESPACE;
-Warnings:
-Warning	1814	Tablespace has been discarded for table 't1'
 SELECT COUNT(1) FROM t1;
 COUNT(1)
 10000
 ALTER TABLE t2 IMPORT TABLESPACE;
-Warnings:
-Warning	1814	Tablespace has been discarded for table 't2'
 SELECT COUNT(1) FROM t2;
 COUNT(1)
 10000
 ALTER TABLE t3 IMPORT TABLESPACE;
-Warnings:
-Warning	1814	Tablespace has been discarded for table 't3'
 SELECT COUNT(1) FROM t3;
 COUNT(1)
 10000
diff --git a/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test b/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test
index def3665..a3789ea 100644
--- a/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test
+++ b/mysql-test/suite/encryption/t/innodb_encryption_discard_import.test
@@ -2,12 +2,12 @@
 -- source include/have_example_key_management_plugin.inc
 -- source include/not_valgrind.inc
 -- source include/not_embedded.inc
--- source include/not_windows.inc
 
 call mtr.add_suppression("InnoDB: Table .* tablespace is set as discarded.");
 
---let $MYSQLD_TMPDIR = `SELECT @@tmpdir`
---let $MYSQLD_DATADIR = `SELECT @@datadir`
+let $MYSQLD_TMPDIR = `SELECT @@tmpdir`;
+let $MYSQLD_DATADIR = `SELECT @@datadir`;
+
 --let SEARCH_RANGE = 10000000
 --let $id = `SELECT RAND()`
 --let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd
@@ -66,88 +66,25 @@ set autocommit=1;
 -- let SEARCH_FILE=$t3_IBD
 -- source include/search_pattern_in_file.inc
 
-FLUSH TABLE t1, t2, t3 FOR EXPORT;
-
---echo # List before copying files
+let MYSQLD_DATADIR =`SELECT @@datadir`;
 --list_files $MYSQLD_DATADIR/test
---disable_result_log
---error 0,1,2
---remove_file $MYSQLD_TMPDIR/t1.cfg
---error 0,1,2
---remove_file $MYSQLD_TMPDIR/t1.ibd
---error 0,1,2
---remove_file $MYSQLD_TMPDIR/t2.cfg
---error 0,1,2
---remove_file $MYSQLD_TMPDIR/t2.ibd
---error 0,1,2
---remove_file $MYSQLD_TMPDIR/t3.cfg
---error 0,1,2
---remove_file $MYSQLD_TMPDIR/t3.ibd
---enable_result_log
---copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_TMPDIR/t1$id.cfg
---copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_TMPDIR/t1$id.ibd
---copy_file $MYSQLD_DATADIR/test/t2.cfg $MYSQLD_TMPDIR/t2$id.cfg
---copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_TMPDIR/t2$id.ibd
---copy_file $MYSQLD_DATADIR/test/t3.cfg $MYSQLD_TMPDIR/t3$id.cfg
---copy_file $MYSQLD_DATADIR/test/t3.ibd $MYSQLD_TMPDIR/t3$id.ibd
-UNLOCK TABLES;
-
---echo # Restarting server
--- source include/restart_mysqld.inc
---echo # Done restarting server
---echo # List before t1 DISCARD
+FLUSH TABLES t1, t2, t3 FOR EXPORT;
+perl;
+do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
+ib_backup_tablespaces("test", "t1","t2","t3");
+EOF
 --list_files $MYSQLD_DATADIR/test
-
-SET GLOBAL innodb_file_format = `Barracuda`;
-SET GLOBAL innodb_file_per_table = ON;
+UNLOCK TABLES;
 
 ALTER TABLE t1 DISCARD TABLESPACE;
 ALTER TABLE t2 DISCARD TABLESPACE;
 ALTER TABLE t3 DISCARD TABLESPACE;
 
---echo # List after t1 DISCARD
---list_files $MYSQLD_DATADIR/test
---error 0,1,2
---remove_file $MYSQLD_DATADIR/test/t1.cfg
---error 0,1,2
---remove_file $MYSQLD_DATADIR/test/t1.ibd
---error 0,1,2
---remove_file $MYSQLD_DATADIR/test/t2.cfg
---error 0,1,2
---remove_file $MYSQLD_DATADIR/test/t2.ibd
---error 0,1,2
---remove_file $MYSQLD_DATADIR/test/t3.cfg
---error 0,1,2
---remove_file $MYSQLD_DATADIR/test/t3.ibd
---enable_result_log
---echo # Restarting server
--- source include/restart_mysqld.inc
---echo # Done restarting server
-
-SET GLOBAL innodb_file_format = `Barracuda`;
-SET GLOBAL innodb_file_per_table = ON;
-
---copy_file $MYSQLD_TMPDIR/t1$id.cfg $MYSQLD_DATADIR/test/t1.cfg
---copy_file $MYSQLD_TMPDIR/t1$id.ibd $MYSQLD_DATADIR/test/t1.ibd
---copy_file $MYSQLD_TMPDIR/t2$id.cfg $MYSQLD_DATADIR/test/t2.cfg
---copy_file $MYSQLD_TMPDIR/t2$id.ibd $MYSQLD_DATADIR/test/t2.ibd
---copy_file $MYSQLD_TMPDIR/t3$id.cfg $MYSQLD_DATADIR/test/t3.cfg
---copy_file $MYSQLD_TMPDIR/t3$id.ibd $MYSQLD_DATADIR/test/t3.ibd
-
---sleep 5
---echo # Tablespaces should be still encrypted
---let SEARCH_PATTERN=foobar
---echo # t1 yes on expecting NOT FOUND
--- let SEARCH_FILE=$t1_IBD
--- source include/search_pattern_in_file.inc
---let SEARCH_PATTERN=temp
---echo # t2 ... on expecting NOT FOUND
--- let SEARCH_FILE=$t2_IBD
--- source include/search_pattern_in_file.inc
---echo # t3 ... on expecting NOT FOUND
---let SEARCH_PATTERN=barfoo
--- let SEARCH_FILE=$t3_IBD
--- source include/search_pattern_in_file.inc
+perl;
+do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
+ib_discard_tablespaces("test", "t1","t2","t3");
+ib_restore_tablespaces("test", "t1","t2","t3");
+EOF
 
 ALTER TABLE t1 IMPORT TABLESPACE;
 SELECT COUNT(1) FROM t1;


More information about the commits mailing list