From b6526f67395cebb65e4bb2606ee46da8f1d9274e Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Fri, 11 May 2018 11:58:47 -0300 Subject: [PATCH] PT-1536 Updated samples for mysql-summary tests --- bin/pt-mysql-summary | 15 ++++++++++ lib/bash/report_mysql_info.sh | 17 +++++++++++ t/pt-mysql-summary/pt-mysql-summary.t | 29 ++++++++++++++++--- .../samples/expected_output_temp002.txt | 3 ++ .../samples/expected_output_temp003.txt | 3 ++ .../samples/expected_output_temp004.txt | 3 ++ .../samples/expected_output_temp005.txt | 3 ++ .../samples/expected_output_temp006.txt | 3 ++ .../samples/expected_output_temp007.txt | 3 ++ 9 files changed, 75 insertions(+), 4 deletions(-) diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 30d5fe3a..b0da1ee0 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -1185,6 +1185,10 @@ collect_encrypted_tables() { $CMD_MYSQL $EXT_ARGV --table -ss -e "SELECT TABLE_SCHEMA, TABLE_NAME, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE CREATE_OPTIONS LIKE '%ENCRYPTION=\"Y\"%';" } +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;" +} + _NO_FALSE_NEGATIVES="" @@ -1630,6 +1634,14 @@ format_encrypted_tables() { fi } +format_encrypted_tablespaces() { + local encrypted_tablespaces="$1" + if [ ! -z "$encrypted_tablespaces" ]; then + echo "Encrypted tablespaces:" + echo "$encrypted_tablespaces" + fi +} + format_mysql_roles() { local file=$1 [ -e "$file" ] || return @@ -2510,12 +2522,15 @@ report_mysql_summary () { section "Encryption" local keyring_plugins="$(collect_keyring_plugins)" local encrypted_tables="" + local encrypted_tablespaces="" if [ ${OPT_LIST_ENCRYPTED_TABLES} == 'yes' ]; then encrypted_tables="$(collect_encrypted_tables)" + encrypted_tablespaces="$(collect_encrypted_tablespaces)" fi format_keyring_plugins "$keyring_plugins" "$encrypted_tables" format_encrypted_tables "$encrypted_tables" + format_encrypted_tablespaces "$encrypted_tablespaces" section "Binary Logging" diff --git a/lib/bash/report_mysql_info.sh b/lib/bash/report_mysql_info.sh index 11776096..660b039d 100644 --- a/lib/bash/report_mysql_info.sh +++ b/lib/bash/report_mysql_info.sh @@ -115,6 +115,12 @@ collect_encrypted_tables() { $CMD_MYSQL $EXT_ARGV --table -ss -e "SELECT TABLE_SCHEMA, TABLE_NAME, CREATE_OPTIONS FROM INFORMATION_SCHEMA.TABLES WHERE CREATE_OPTIONS LIKE '%ENCRYPTION=\"Y\"%';" } +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". +# 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;" +} + # ############################################################################## # Functions for parsing specific files and getting desired info from them. @@ -597,6 +603,14 @@ format_encrypted_tables() { fi } +format_encrypted_tablespaces() { + local encrypted_tablespaces="$1" + if [ ! -z "$encrypted_tablespaces" ]; then + echo "Encrypted tablespaces:" + echo "$encrypted_tablespaces" + fi +} + format_mysql_roles() { local file=$1 [ -e "$file" ] || return @@ -1568,12 +1582,15 @@ report_mysql_summary () { section "Encryption" local keyring_plugins="$(collect_keyring_plugins)" local encrypted_tables="" + local encrypted_tablespaces="" if [ ${OPT_LIST_ENCRYPTED_TABLES} == 'yes' ]; then encrypted_tables="$(collect_encrypted_tables)" + encrypted_tablespaces="$(collect_encrypted_tablespaces)" fi format_keyring_plugins "$keyring_plugins" "$encrypted_tables" format_encrypted_tables "$encrypted_tables" + format_encrypted_tablespaces "$encrypted_tablespaces" # ######################################################################## # Binary Logging diff --git a/t/pt-mysql-summary/pt-mysql-summary.t b/t/pt-mysql-summary/pt-mysql-summary.t index 09b9b022..c9b15920 100644 --- a/t/pt-mysql-summary/pt-mysql-summary.t +++ b/t/pt-mysql-summary/pt-mysql-summary.t @@ -9,16 +9,37 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); - use PerconaTest; - -my ($tool) = $PROGRAM_NAME =~ m/([\w-]+)\.t$/; - +use Sandbox; +use DSNParser; +require VersionParser; use Test::More; use File::Temp qw( tempdir ); local $ENV{PTDEBUG} = ""; +my $dp = new DSNParser(opts=>$dsn_opts); +my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp); +my $master_dbh = $sb->get_dbh_for('master'); +my $has_keyring_plugin; + +my $db_flavor = VersionParser->new($master_dbh)->flavor(); +if ( $db_flavor =~ m/Percona Server/ ) { + my $rows = $master_dbh->selectall_hashref("SHOW PLUGINS", "name"); + while (my ($key, $values) = each %$rows) { + if ($key =~ m/^keyring_/) { + $has_keyring_plugin=1; + last; + } + } +} + +if ($has_keyring_plugin) { + plan skip_all => 'Keyring plugins are enabled.'; +} + +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. diff --git a/t/pt-mysql-summary/samples/expected_output_temp002.txt b/t/pt-mysql-summary/samples/expected_output_temp002.txt index c2de552c..070af6a3 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp002.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp002.txt @@ -222,6 +222,8 @@ Uptime 90000 1 1 # Security ################################################### Users | 6 users, 0 anon, 1 w/o pw, 1 old pw Old Passwords | OFF +# Encryption ################################################# +No keyring plugins found # Binary Logging ############################################# # Noteworthy Variables ####################################### Auto-Inc Incr/Offset | 1/1 @@ -275,4 +277,5 @@ report-port = 12345 log-error = mysqld.log innodb_lock_wait_timeout = 3 # Memory management library ################################## +Jemalloc library not found # The End #################################################### diff --git a/t/pt-mysql-summary/samples/expected_output_temp003.txt b/t/pt-mysql-summary/samples/expected_output_temp003.txt index 6b69a004..0e919522 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp003.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp003.txt @@ -156,6 +156,8 @@ Specify --databases or --all-databases to dump and summarize schemas # Security ################################################### Users | 2 users, 0 anon, 0 w/o pw, 0 old pw Old Passwords | OFF +# Encryption ################################################# +No keyring plugins found # Binary Logging ############################################# Binlogs | 1 Zero-Sized | 0 @@ -218,4 +220,5 @@ report-port = 12345 log-error = mysqld.log innodb_lock_wait_timeout = 3 # Memory management library ################################## +Jemalloc library not found # The End #################################################### diff --git a/t/pt-mysql-summary/samples/expected_output_temp004.txt b/t/pt-mysql-summary/samples/expected_output_temp004.txt index 82492fa8..6961496d 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp004.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp004.txt @@ -155,6 +155,8 @@ Specify --databases or --all-databases to dump and summarize schemas # Security ################################################### Users | 2 users, 0 anon, 0 w/o pw, 0 old pw Old Passwords | OFF +# Encryption ################################################# +No keyring plugins found # Binary Logging ############################################# Binlogs | 2 Zero-Sized | 0 @@ -217,4 +219,5 @@ report-port = 12345 log-error = mysqld.log innodb_lock_wait_timeout = 3 # Memory management library ################################## +Jemalloc library not found # The End #################################################### diff --git a/t/pt-mysql-summary/samples/expected_output_temp005.txt b/t/pt-mysql-summary/samples/expected_output_temp005.txt index b72db51d..95cbb20f 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp005.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp005.txt @@ -228,6 +228,8 @@ Uptime 90000 1 1 # Security ################################################### Users | 2 users, 0 anon, 0 w/o pw, 0 old pw Old Passwords | OFF +# Encryption ################################################# +No keyring plugins found # Binary Logging ############################################# Binlogs | 1 Zero-Sized | 0 @@ -290,4 +292,5 @@ report-port = 12345 log-error = mysqld.log innodb_lock_wait_timeout = 3 # Memory management library ################################## +Jemalloc library not found # The End #################################################### diff --git a/t/pt-mysql-summary/samples/expected_output_temp006.txt b/t/pt-mysql-summary/samples/expected_output_temp006.txt index e82e85e9..d8788b2b 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp006.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp006.txt @@ -304,6 +304,8 @@ wsrep_cluster_size 100 # Security ################################################### Users | 2 users, 0 anon, 0 w/o pw, 0 old pw Old Passwords | OFF +# Encryption ################################################# +No keyring plugins found # Binary Logging ############################################# Binlogs | 1 Zero-Sized | 0 @@ -339,4 +341,5 @@ log_queries_not_using_indexes | OFF # Configuration File ######################################### Config File | Cannot autodetect or find, giving up # Memory management library ################################## +Jemalloc library not found # The End #################################################### diff --git a/t/pt-mysql-summary/samples/expected_output_temp007.txt b/t/pt-mysql-summary/samples/expected_output_temp007.txt index 40f0d9bf..50116ee3 100644 --- a/t/pt-mysql-summary/samples/expected_output_temp007.txt +++ b/t/pt-mysql-summary/samples/expected_output_temp007.txt @@ -258,6 +258,8 @@ wsrep_local_index 4000000000000 45000000 # Security ################################################### Users | 2 users, 0 anon, 0 w/o pw, 0 old pw Old Passwords | OFF +# Encryption ################################################# +No keyring plugins found # Binary Logging ############################################# Binlogs | 1 Zero-Sized | 0 @@ -293,4 +295,5 @@ log_queries_not_using_indexes | OFF # Configuration File ######################################### Config File | Cannot autodetect or find, giving up # Memory management library ################################## +Jemalloc library not found # The End ####################################################