PT-2150 Fix tests for pt-mysql-summary (#582)

* PT-2150 Fix tests for pt-mysql-summary

- Added POSIX environment to tests, so they do not depend on the local user environment
- Enabled keyring plugin on 8.0
- Fixed encryption information collection in 8.0, see also PT-1588

* PT-2150 Fix tests for pt-mysql-summary

- Added support of the environment variable DISABLE_KEYRING, so we can diable keyring plugin in sandbox/servers/start

* PT-2150 Fix tests for pt-mysql-summary

- Reverted changes in the expected output for tests 006 and 007 made by commit 9190b5e6ac
Because the tool now works properly again and can parse Percona XtraDB Cluster data

* PT-2150 Fix tests for pt-mysql-summary

- Added comment '--read-samples' back to the test cases
This commit is contained in:
Sveta Smirnova
2023-02-06 17:11:42 +03:00
committed by GitHub
parent 01de987154
commit a12d4aecea
9 changed files with 66 additions and 17 deletions

View File

@@ -1185,7 +1185,12 @@ collect_encrypted_tables() {
}
collect_encrypted_tablespaces() {
$CMD_MYSQL $EXT_ARGV --table -ss -e "SELECT SPACE, NAME, SPACE_TYPE from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES where FLAG&8192 = 8192;"
local version="$1"
if [ "$version" '<' "8.0" ]; then
$CMD_MYSQL $EXT_ARGV --table -ss -e "SELECT SPACE, NAME, SPACE_TYPE from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES where FLAG&8192 = 8192;"
else
$CMD_MYSQL $EXT_ARGV --table -ss -e "SELECT SPACE, NAME, SPACE_TYPE from INFORMATION_SCHEMA.INNODB_TABLESPACES where FLAG&8192 = 8192;"
fi
}
@@ -2521,8 +2526,9 @@ report_mysql_summary () {
local encrypted_tables=""
local encrypted_tablespaces=""
if [ "${OPT_LIST_ENCRYPTED_TABLES}" = 'yes' ]; then
local mysql_version="$(get_var version "$dir/mysql-variables")"
encrypted_tables="$(collect_encrypted_tables)"
encrypted_tablespaces="$(collect_encrypted_tablespaces)"
encrypted_tablespaces="$(collect_encrypted_tablespaces ${mysql_version})"
fi
format_keyring_plugins "$keyring_plugins" "$encrypted_tables"

View File

@@ -116,9 +116,14 @@ collect_encrypted_tables() {
}
collect_encrypted_tablespaces() {
# I_S.INNODB_SYS_TABLESPACES has a "flag" field. Encrypted tablespace has bit 14 set. You can check it with "flag & 8192".
local version="$1"
# I_S.INNODB_[SYS_]TABLESPACES has a "flag" field. Encrypted tablespace has bit 14 set. You can check it with "flag & 8192".
# And seems like MySQL is capable of bitwise operations. https://dev.mysql.com/doc/refman/5.7/en/bit-functions.html
$CMD_MYSQL $EXT_ARGV --table -ss -e "SELECT SPACE, NAME, SPACE_TYPE from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES where FLAG&8192 = 8192;"
if [ "$version" '<' "8.0" ]; then
$CMD_MYSQL $EXT_ARGV --table -ss -e "SELECT SPACE, NAME, SPACE_TYPE from INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES where FLAG&8192 = 8192;"
else
$CMD_MYSQL $EXT_ARGV --table -ss -e "SELECT SPACE, NAME, SPACE_TYPE from INFORMATION_SCHEMA.INNODB_TABLESPACES where FLAG&8192 = 8192;"
fi
}
@@ -1580,8 +1585,9 @@ report_mysql_summary () {
local encrypted_tables=""
local encrypted_tablespaces=""
if [ "${OPT_LIST_ENCRYPTED_TABLES}" = 'yes' ]; then
local mysql_version="$(get_var version "$dir/mysql-variables")"
encrypted_tables="$(collect_encrypted_tables)"
encrypted_tablespaces="$(collect_encrypted_tablespaces)"
encrypted_tablespaces="$(collect_encrypted_tablespaces ${mysql_version})"
fi
format_keyring_plugins "$keyring_plugins" "$encrypted_tables"

View File

@@ -57,21 +57,26 @@ plugins_dir_cmd=""
plugins_cmd=""
keyring_cmd=""
if [ -e "${BASEDIR}/lib/mysql/plugin/keyring_file.so" ]; then
encryption_plugins="${BASEDIR}/lib/mysql/plugin/keyring_file.so"
fi
if [ -z "${DISABLE_KEYRING}" ]; then
if [ -e "${BASEDIR}/lib/mysql/plugin/keyring_file.so" ]; then
encryption_plugins="${BASEDIR}/lib/mysql/plugin/keyring_file.so"
plugins_dir_cmd="--plugin-dir=${BASEDIR}/lib/mysql/plugin/"
elif [ -e "${BASEDIR}/lib/plugin/keyring_file.so" ]; then
encryption_plugins="keyring_file.so"
plugins_dir_cmd="--plugin-dir=${BASEDIR}/lib/plugin/"
fi
if [ ! -z "$encryption_plugins" ]; then
plugins_cmd="--early-plugin-load=${encryption_plugins}"
keyring_cmd="--keyring_file_data=/tmp/PORT/data/keyring"
plugins_dir_cmd="--plugin-dir=${BASEDIR}/lib/mysql/plugin/"
if [ ! -z "$encryption_plugins" ]; then
plugins_cmd="--early-plugin-load=${encryption_plugins}"
keyring_cmd="--loose-keyring_file_data=/tmp/PORT/data/keyring"
fi
fi
init_file="/tmp/PORT/mysql-init"
if [ -e $init_file ]; then
$BASEDIR/bin/mysqld --defaults-file=/tmp/PORT/my.sandbox.cnf -u root --init-file $init_file $plugins_cmd $plugins_dir_cmd $keyring_cmd &
$BASEDIR/bin/mysqld --defaults-file=/tmp/PORT/my.sandbox.cnf -u root --init-file $init_file $plugins_dir_cmd $plugins_cmd $keyring_cmd &
else
$BASEDIR/bin/mysqld --defaults-file=/tmp/PORT/my.sandbox.cnf $plugins_cmd $plugins_dir_cmd $keyring_cmd > /dev/null 2>&1 &
$BASEDIR/bin/mysqld --defaults-file=/tmp/PORT/my.sandbox.cnf $plugins_dir_cmd $plugins_cmd $keyring_cmd > /dev/null 2>&1 &
fi
cd $PWD

View File

@@ -43,7 +43,9 @@ my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/;
# mysqldump from earlier versions doesn't seem to work with 5.6,
# so use the actual mysqldump from each MySQL bin which should
# always be compatible with itself.
my $env = qq\CMD_MYSQLDUMP="$ENV{PERCONA_TOOLKIT_SANDBOX}/bin/mysqldump"\;
# We need LC_NUMERIC=POSIX, so test does not fail in environment
# which use , insead of . for numbers.
my $env = qq\CMD_MYSQLDUMP="$ENV{PERCONA_TOOLKIT_SANDBOX}/bin/mysqldump" LC_NUMERIC=POSIX\;
#
# --save-samples

View File

@@ -45,7 +45,9 @@ my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)_encryption\.t$/;
# mysqldump from earlier versions doesn't seem to work with 5.6,
# so use the actual mysqldump from each MySQL bin which should
# always be compatible with itself.
my $env = qq\CMD_MYSQLDUMP="$ENV{PERCONA_TOOLKIT_SANDBOX}/bin/mysqldump"\;
# We need LC_NUMERIC=POSIX, so test does not fail in environment
# which use , insead of . for numbers.
my $env = qq\CMD_MYSQLDUMP="$ENV{PERCONA_TOOLKIT_SANDBOX}/bin/mysqldump" LC_NUMERIC=POSIX\;
#
# --save-samples
@@ -127,7 +129,7 @@ $master_dbh->do("CREATE TABLESPACE foo ADD DATAFILE 'foo.ibd' ENCRYPTION='Y'");
$master_dbh->do("ALTER TABLE test.t1 TABLESPACE=foo");
$master_dbh->do("CREATE TABLE test.t2(a INT PRIMARY KEY) ENCRYPTION='Y'");
$out = `bash $trunk/bin/$tool --list-encrypted-tables`;
$out = `bash $trunk/bin/$tool --list-encrypted-tables -- --defaults-file=/tmp/12345/my.sandbox.cnf`;
like(
$out,

View File

@@ -201,6 +201,19 @@ wsrep_cluster_size 100
HandlerSocket NoSQL | Not Supported
Fast Hash UDFs | Unknown
# Percona XtraDB Cluster #####################################
Cluster Name | pt_sandbox_cluster
Cluster Address | gcomm://
Cluster Size | 3
Cluster Nodes | 192.168.0.100,192.168.0.100,192.168.0.100
Node Name | 12345
Node Status | Primary
SST Method | rsync
Slave Threads | 2
Ignore Split Brain | false
Ignore Quorum | false
gcache Size | 128M
gcache Directory | /tmp/12345/data/
gcache Name | /tmp/12345/data//galera.cache
# Plugins ####################################################
InnoDB compression | ACTIVE
# Query cache ################################################

View File

@@ -167,6 +167,7 @@ wsrep_local_index 4000000000000 45000000
HandlerSocket NoSQL | Not Supported
Fast Hash UDFs | Unknown
# Percona XtraDB Cluster #####################################
wsrep_on | OFF
# Plugins ####################################################
InnoDB compression | ACTIVE
# Query cache ################################################

View File

@@ -201,6 +201,19 @@ wsrep_cluster_size 100
HandlerSocket NoSQL | Not Supported
Fast Hash UDFs | Unknown
# Percona XtraDB Cluster #####################################
Cluster Name | pt_sandbox_cluster
Cluster Address | gcomm://
Cluster Size | 3
Cluster Nodes | 192.168.0.100,192.168.0.100,192.168.0.100
Node Name | 12345
Node Status | Primary
SST Method | rsync
Slave Threads | 2
Ignore Split Brain | false
Ignore Quorum | false
gcache Size | 128M
gcache Directory | /tmp/12345/data/
gcache Name | /tmp/12345/data//galera.cache
# Plugins ####################################################
InnoDB compression | ACTIVE
# Query cache ################################################

View File

@@ -167,6 +167,7 @@ wsrep_local_index 4000000000000 45000000
HandlerSocket NoSQL | Not Supported
Fast Hash UDFs | Unknown
# Percona XtraDB Cluster #####################################
wsrep_on | OFF
# Plugins ####################################################
InnoDB compression | ACTIVE
# Query cache ################################################