mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 05:29:30 +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
162 lines
4.2 KiB
Perl
162 lines
4.2 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 Transformers;
|
|
use QueryReview;
|
|
use QueryRewriter;
|
|
use TableParser;
|
|
use Quoter;
|
|
use SlowLogParser;
|
|
use DSNParser;
|
|
use Sandbox;
|
|
use PerconaTest;
|
|
|
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
|
my $dbh = $sb->get_dbh_for('master', {no_lc=>1, AutoCommit => 1});
|
|
|
|
if ( !$dbh ) {
|
|
plan skip_all => "Cannot connect to sandbox master";
|
|
}
|
|
|
|
$sb->create_dbs($dbh, ['test']);
|
|
$sb->load_file('master', "t/lib/samples/query_review.sql");
|
|
my $output = "";
|
|
my $qr = new QueryRewriter();
|
|
my $lp = new SlowLogParser;
|
|
my $q = new Quoter();
|
|
my $tp = new TableParser(Quoter => $q);
|
|
|
|
my $tbl_struct = $tp->parse(
|
|
$tp->get_create_table($dbh, 'test', 'query_review'));
|
|
|
|
my $qv = new QueryReview(
|
|
dbh => $dbh,
|
|
db_tbl => '`test`.`query_review`',
|
|
tbl_struct => $tbl_struct,
|
|
ts_default => "'2009-01-01'",
|
|
quoter => $q,
|
|
);
|
|
|
|
isa_ok($qv, 'QueryReview');
|
|
|
|
my $callback = sub {
|
|
my ( $event ) = @_;
|
|
my $fp = $qr->fingerprint($event->{arg});
|
|
$qv->set_review_info(
|
|
fingerprint => $fp,
|
|
sample => $event->{arg},
|
|
first_seen => $event->{ts},
|
|
last_seen => $event->{ts},
|
|
);
|
|
};
|
|
|
|
my $event = {};
|
|
my $more_events = 1;
|
|
my $log;
|
|
open $log, '<', "$trunk/t/lib/samples/slowlogs/slow006.txt" or die $OS_ERROR;
|
|
while ( $more_events ) {
|
|
$event = $lp->parse_event(
|
|
next_event => sub { return <$log>; },
|
|
tell => sub { return tell $log; },
|
|
oktorun => sub { $more_events = $_[0]; },
|
|
);
|
|
$callback->($event) if $event;
|
|
}
|
|
close $log;
|
|
$more_events = 1;
|
|
open $log, '<', "$trunk/t/lib/samples/slowlogs/slow021.txt" or die $OS_ERROR;
|
|
while ( $more_events ) {
|
|
$event = $lp->parse_event(
|
|
next_event => sub { return <$log>; },
|
|
tell => sub { return tell $log; },
|
|
oktorun => sub { $more_events = $_[0]; },
|
|
);
|
|
$callback->($event) if $event;
|
|
}
|
|
close $log;
|
|
|
|
my $res = $dbh->selectall_arrayref(
|
|
'SELECT checksum, first_seen, last_seen FROM query_review order by checksum',
|
|
{ Slice => {} });
|
|
is_deeply(
|
|
$res,
|
|
[ { checksum => '3E4FB43148C4B07CD4CD74934382A184',
|
|
last_seen => '2007-12-18 11:49:07',
|
|
first_seen => '2005-12-19 16:56:31'
|
|
},
|
|
{ checksum => '538CA093E701E0CBA20C29AF174CE545',
|
|
last_seen => '2007-12-18 11:49:30',
|
|
first_seen => '2007-12-18 11:48:27'
|
|
},
|
|
{ checksum => 'A853B50CDEB4866B3A99CC42AEDCCFCD',
|
|
last_seen => '2007-10-15 21:45:10',
|
|
first_seen => '2007-10-15 21:45:10'
|
|
},
|
|
{ checksum => 'AE9D6BB6AF470B997F7D57ACDD8A346E',
|
|
last_seen => '2009-01-01 00:00:00',
|
|
first_seen => '2009-01-01 00:00:00'
|
|
},
|
|
],
|
|
'Updates last_seen'
|
|
);
|
|
|
|
$event = {
|
|
arg => "UPDATE foo SET bar='nada' WHERE 1",
|
|
ts => '081222 13:13:13',
|
|
};
|
|
my $fp = $qr->fingerprint($event->{arg});
|
|
my $checksum = Transformers::make_checksum($fp);
|
|
$qv->set_review_info(
|
|
fingerprint => $fp,
|
|
sample => $event->{arg},
|
|
first_seen => $event->{ts},
|
|
last_seen => $event->{ts},
|
|
);
|
|
|
|
$res = $qv->get_review_info($fp);
|
|
is_deeply(
|
|
$res,
|
|
{
|
|
checksum_conv => '1C094E0B4F345C8DD3A1C1CD468791EE',
|
|
first_seen => '2008-12-22 13:13:13',
|
|
last_seen => '2008-12-22 13:13:13',
|
|
reviewed_by => undef,
|
|
reviewed_on => undef,
|
|
comments => undef,
|
|
},
|
|
'Stores a new event with default values'
|
|
);
|
|
|
|
is_deeply([$qv->review_cols],
|
|
[qw(first_seen last_seen reviewed_by reviewed_on comments)],
|
|
'review columns');
|
|
|
|
# #############################################################################
|
|
# Done.
|
|
# #############################################################################
|
|
{
|
|
local *STDERR;
|
|
open STDERR, '>', \$output;
|
|
$qv->_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");
|
|
done_testing;
|
|
exit;
|