mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-13 06:30:10 +00:00

* PT-2156 - Fix tests for lib Fixed tests, broken by putting fix for PT-1554 into the library code, mostly by updating checksums. Added AutoCommit option for test lib/QueryReview.t Reset SQL mode to empty to allow TableChunker to work with invalid and zero dates * PT-2156 - Fix tests for lib Adjusted t/lib/SchemaIterator.t to work with version 8.0 * PT-2156 - Fix tests for lib Adjusted b/t/lib/Processlist.t, so it reflects fix for PT-981 * PT-2156 - Fix tests for lib Adjusted t/lib/HTTP/Micro.t, so it works with different order of parameters, returned at v.percona.com/ Adjusted test for empty files in t/lib/bash/collect.t Disabled mysqladmin debug test in t/lib/bash/collect.t, because of PT-2242 * PT-2156 - Fix tests for lib Added LC_NUMERRIC=POSIX into t/lib/bash/report_system_info.sh, so reports in tests are not environment-dependent Updated expected results in t/lib/bash/report_system_info.sh, so they reflect new information, collected by pt-summary * PT-2156 - Fix tests for lib - Improved fix for PT-76, so it handles inline comments - Added test case for PT-76 - Improved fix for PT-1720, so it ignores unrecognizable option only if it comes from the toolkit-wide files and still errors out if wrong option was passed via command line or the tool-specific option file. * PT-2156 - Fix tests for lib - Improved fix for PT-2102, so it finds running instance configuration file using PID and also does not break t/lib/bash/report_mysql_info.t test - Removed unnecessary copy-paste from t/pt-mysql-summary/pt-2102.t test - Adjusted number of collected files in t/lib/bash/collect_mysql_info.sh * PT-2156 - Fix tests for lib - Fix for PT-1543 and MyRocks collection were originally put only into lib/bash/report_mysql_info.shthat broke the logic of collecting data first, then formatting report from this data. This, in its turn, broke test t/lib/bash/report_mysql_info.sh/t/lib/bash/report_mysql_info.t, because CMD_MYSQL is not defined in this library. I rewrote these fixes, so they follow original logic of the tool (pt-mysql-summary) - Added tests for keyring plugin, encrypted tables, and MyRocks for t/lib/bash/report_mysql_info.sh and t/pt-mysql-summary/pt-mysql-summary_encryption.t * PT-2156 - Fix tests for lib - Added FLUSH TABLES to t/lib/bash/collect.sh, so it does not fail opentables tests if run when more than 1000 tables open in the sandbox environment - Changed number of expected sample files to reflect keyring colletion file * PT-2156 - Fix tests for lib - Added skip to some tests in lib that file when run with PXC, because not supported to work with PXC - Adjusted configuration files for PXC, so they allow LOAD DATA/SELECT INTO OUTFILE commands - Adjusted data samples, so they do not depend on auto increment values - Fixed lib tests, failing with PXC * PT-2156 - Fix tests for lib Updated tests for pt-online-schema-change, so they work with PXC and skipped if designed for semi-synchronous replication setup * PT-2156 - Fix tests for lib - Added cluster-specific samples for t/lib/SchemaIterator.t - Removed extra debugging print from t/pt-table-checksum/pt-1728.t * PT-2156 - Fix tests for lib Evgeniy's review on July 20 * Update t/lib/TableSyncer.t Removed comment left after debugging * Update t/pt-mysql-summary/pt-mysql-summary_encryption.t Removed extra debug output * PT-2156 - Fix tests for lib Tabs to spaces
164 lines
4.3 KiB
Perl
164 lines
4.3 KiB
Perl
#!/usr/bin/env perl
|
|
|
|
BEGIN {
|
|
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
|
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
|
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
|
};
|
|
|
|
use strict;
|
|
use warnings FATAL => 'all';
|
|
use English qw(-no_match_vars);
|
|
use PerconaTest;
|
|
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 not enabled.';
|
|
} elsif ( $sandbox_version lt '5.7' || $db_flavor !~ m/Percona Server/) {
|
|
plan skip_all => 'These tests need Percona Server 5.7+';
|
|
}
|
|
|
|
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.
|
|
# 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
|
|
#
|
|
|
|
my $dir = tempdir( "percona-testXXXXXXXX", CLEANUP => 1 );
|
|
|
|
`$env $trunk/bin/$tool --sleep 1 --save-samples $dir -- --defaults-file=/tmp/12345/my.sandbox.cnf`;
|
|
|
|
ok(
|
|
-e $dir,
|
|
"Using --save-samples doesn't mistakenly delete the target dir"
|
|
);
|
|
|
|
# If the box has a default my.cnf (e.g. /etc/my.cnf) there
|
|
# should be 15 files, else 14.
|
|
my @files = glob("$dir/*");
|
|
my $n_files = scalar @files;
|
|
ok(
|
|
$n_files >= 15 && $n_files <= 19,
|
|
"And leaves all files in there"
|
|
) or diag($n_files, `ls -l $dir`);
|
|
|
|
undef($dir); # rm the dir because CLEANUP => 1
|
|
|
|
#
|
|
# --databases
|
|
#
|
|
|
|
my $out = `$env $trunk/bin/$tool --sleep 1 --databases mysql 2>/dev/null -- --defaults-file=/tmp/12345/my.sandbox.cnf`;
|
|
|
|
like(
|
|
$out,
|
|
qr/Database Tables Views SPs Trigs Funcs FKs Partn\s+\Qmysql\E/,
|
|
"--databases works"
|
|
);
|
|
|
|
like(
|
|
$out,
|
|
qr/# InnoDB #.*Version.*# MyISAM #/s,
|
|
"InnoDB section present"
|
|
);
|
|
|
|
like(
|
|
$out,
|
|
qr/Users \| 2/,
|
|
"Security works"
|
|
);
|
|
|
|
# --read-samples
|
|
for my $i (2..9) {
|
|
ok(
|
|
no_diff(
|
|
sub {
|
|
local $ENV{_NO_FALSE_NEGATIVES} = 1;
|
|
print `$env $trunk/bin/$tool --read-samples $trunk/t/pt-mysql-summary/samples/temp_enc00$i -- --defaults-file=/tmp/12345/my.sandbox.cnf | tail -n+3 | perl -wlnpe 's/Skipping schema analysis.*/Specify --databases or --all-databases to dump and summarize schemas/'`
|
|
},
|
|
"t/pt-mysql-summary/samples/expected_output_temp_enc00$i.txt",
|
|
),
|
|
"--read-samples works for t/pt-mysql-summary/temp_enc00$i",
|
|
) or diag($test_diff);
|
|
}
|
|
|
|
# Test that --help works under sh
|
|
|
|
my $sh = `sh $trunk/bin/$tool --help`;
|
|
my $bash = `bash $trunk/bin/$tool --help`;
|
|
|
|
is(
|
|
$sh,
|
|
$bash,
|
|
"--help works under sh and bash"
|
|
);
|
|
|
|
$master_dbh->do("DROP DATABASE IF EXISTS test");
|
|
$master_dbh->do("CREATE DATABASE test");
|
|
$master_dbh->do("CREATE TABLE test.t1(a INT PRIMARY KEY) ENCRYPTION='Y'");
|
|
$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 -- --defaults-file=/tmp/12345/my.sandbox.cnf`;
|
|
|
|
like(
|
|
$out,
|
|
qr/Encryption/,
|
|
"Encryption section included in report"
|
|
) or diag $out;
|
|
|
|
like(
|
|
$out,
|
|
qr/Keyring plugins:/,
|
|
"Keyring plugins included in report"
|
|
) or diag $out;
|
|
|
|
like(
|
|
$out,
|
|
qr/Encrypted tables:/,
|
|
"Encrypted tables included in report"
|
|
) or diag $out;
|
|
|
|
like(
|
|
$out,
|
|
qr/Encrypted tablespaces:/,
|
|
"Encrypted tablespaces included in report"
|
|
) or diag $out;
|
|
|
|
$master_dbh->do("DROP TABLE IF EXISTS test.t1");
|
|
$master_dbh->do("DROP TABLE IF EXISTS test.t2");
|
|
$master_dbh->do("DROP DATABASE IF EXISTS test");
|
|
$master_dbh->do("DROP TABLESPACE foo");
|
|
|
|
done_testing;
|