mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 21:19:59 +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
197 lines
5.0 KiB
Perl
197 lines
5.0 KiB
Perl
#!/usr/bin/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 Test::More;
|
|
|
|
use ReportFormatter;
|
|
use Transformers;
|
|
use DSNParser;
|
|
use Sandbox;
|
|
use CompareQueryTimes;
|
|
use PerconaTest;
|
|
|
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
|
my $dbh = $sb->get_dbh_for('master');
|
|
|
|
if ( !$dbh ) {
|
|
plan skip_all => "Cannot connect to sandbox master";
|
|
}
|
|
else {
|
|
plan tests => 25;
|
|
}
|
|
|
|
$sb->create_dbs($dbh, ['test']);
|
|
|
|
Transformers->import(qw(make_checksum));
|
|
|
|
my $ct;
|
|
my $report;
|
|
my $hosts = [
|
|
{ dbh => $dbh, name => 'server1' },
|
|
{ dbh => $dbh, name => 'server2' },
|
|
];
|
|
|
|
sub get_id {
|
|
return make_checksum(@_);
|
|
}
|
|
|
|
# #############################################################################
|
|
# Test it.
|
|
# #############################################################################
|
|
|
|
# diag(`/tmp/12345/use < samples/compare-warnings.sql`);
|
|
|
|
$ct = new CompareQueryTimes(
|
|
get_id => \&get_id,
|
|
);
|
|
|
|
isa_ok($ct, 'CompareQueryTimes');
|
|
|
|
# #############################################################################
|
|
# Test query time comparison.
|
|
# #############################################################################
|
|
sub compare {
|
|
my ( $t1, $t2 ) = @_;
|
|
return $ct->compare(
|
|
events => [
|
|
{ fingerprint => 'foo', Query_time => $t1, },
|
|
{ fingerprint => 'foo', Query_time => $t2, },
|
|
],
|
|
);
|
|
}
|
|
|
|
sub test_compare_query_times {
|
|
my ( $t1, $t2, $diff, $comment ) = @_;
|
|
my %diff = compare($t1, $t2);
|
|
my $msg = sprintf("compare t %.6f vs. %.6f %s",
|
|
$t1, $t2, ($comment || ''));
|
|
is(
|
|
$diff{different_query_times},
|
|
$diff,
|
|
$msg,
|
|
);
|
|
}
|
|
|
|
test_compare_query_times(0, 0, 0);
|
|
test_compare_query_times(0, 0.000001, 1, 'increase from zero');
|
|
test_compare_query_times(0.000001, 0.000005, 0, 'no increase in bucket');
|
|
test_compare_query_times(0.000001, 0.000010, 1, '1 bucket diff on edge');
|
|
test_compare_query_times(0.000008, 0.000018, 1, '1 bucket diff');
|
|
test_compare_query_times(0.000001, 10, 1, 'full bucket range diff on edges');
|
|
test_compare_query_times(0.000008, 1000000, 1, 'huge diff');
|
|
|
|
# Thresholds
|
|
test_compare_query_times(0.000001, 0.000006, 1, '1us threshold');
|
|
test_compare_query_times(0.000010, 0.000020, 1, '10us threshold');
|
|
test_compare_query_times(0.000100, 0.000200, 1, '100us threshold');
|
|
test_compare_query_times(0.001000, 0.006000, 1, '1ms threshold');
|
|
test_compare_query_times(0.010000, 0.015000, 1, '10ms threshold');
|
|
test_compare_query_times(0.100000, 0.150000, 1, '100ms threshold');
|
|
test_compare_query_times(1.000000, 1.200000, 1, '1s threshold');
|
|
test_compare_query_times(10.0, 10.1, 1, '10s threshold');
|
|
|
|
# #############################################################################
|
|
# Test the main actions, which don't do much.
|
|
# #############################################################################
|
|
my $event = {
|
|
fingerprint => 'set @a=?',
|
|
arg => 'set @a=3',
|
|
sampleno => 4,
|
|
};
|
|
|
|
$dbh->do('set @a=1');
|
|
is_deeply(
|
|
$dbh->selectcol_arrayref('select @a'),
|
|
[1],
|
|
'@a set'
|
|
);
|
|
|
|
is_deeply(
|
|
$ct->before_execute(event => $event),
|
|
$event,
|
|
"before_execute() doesn't modify event"
|
|
);
|
|
|
|
$ct->execute(event => $event, dbh => $dbh);
|
|
|
|
ok(
|
|
exists $event->{Query_time}
|
|
&& $event->{Query_time} >= 0,
|
|
'execute() set Query_time'
|
|
);
|
|
|
|
is_deeply(
|
|
$dbh->selectcol_arrayref('select @a'),
|
|
[3],
|
|
'Query was actually executed'
|
|
);
|
|
|
|
is_deeply(
|
|
$ct->after_execute(event => $event),
|
|
$event,
|
|
"after_execute() doesn't modify event"
|
|
);
|
|
|
|
|
|
# #############################################################################
|
|
# Test the reports.
|
|
# #############################################################################
|
|
$ct->reset();
|
|
compare(0.000100, 0.000250);
|
|
|
|
$report = <<EOF;
|
|
# Significant query time differences
|
|
# Query ID host1 host2 %Increase %Threshold
|
|
# ================================== ===== ===== ========= ==========
|
|
# ACBD18DB4CC2F85CEDEF654FCCC4A4D8-0 100us 250us 150.00 100
|
|
EOF
|
|
|
|
is(
|
|
$ct->report(hosts => $hosts),
|
|
$report,
|
|
'report in bucket difference'
|
|
);
|
|
|
|
$ct->reset();
|
|
compare(0.000100, 1.100251);
|
|
|
|
$report = <<EOF;
|
|
# Big query time differences
|
|
# Query ID host1 host2 Difference
|
|
# ================================== ===== ===== ==========
|
|
# ACBD18DB4CC2F85CEDEF654FCCC4A4D8-0 100us 1s 1s
|
|
EOF
|
|
|
|
is(
|
|
$ct->report(hosts => $hosts),
|
|
$report,
|
|
'report in bucket difference'
|
|
);
|
|
|
|
# #############################################################################
|
|
# Done.
|
|
# #############################################################################
|
|
my $output = '';
|
|
{
|
|
local *STDERR;
|
|
open STDERR, '>', \$output;
|
|
$ct->_d('Complete test coverage');
|
|
}
|
|
like(
|
|
$output,
|
|
qr/Complete test coverage/,
|
|
'_d() works'
|
|
);
|
|
$sb->wipe_clean($dbh);
|
|
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
|
exit;
|