mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 13:11:32 +00:00
Remove pt-table-sync/issue_79.t (it was broken but coincidentally working) and write better tests in filters.t. Add subs to Sandbox and PerconaTest to clear and parse tables used from the general logs. Set log=genlog in the sandbox configs.
This commit is contained in:
@@ -753,6 +753,27 @@ sub full_output {
|
||||
return ($output, $status);
|
||||
}
|
||||
|
||||
sub tables_used {
|
||||
my ($file) = @_;
|
||||
local $INPUT_RECORD_SEPARATOR = '';
|
||||
open my $fh, '<', $file or die "Cannot open $file: $OS_ERROR";
|
||||
my %tables;
|
||||
while ( defined(my $chunk = <$fh>) ) {
|
||||
map {
|
||||
my $db_tbl = $_;
|
||||
$db_tbl =~ s/^\s*`?//; # strip leading space and `
|
||||
$db_tbl =~ s/\s*`?$//; # strip trailing space and `
|
||||
$db_tbl =~ s/`\.`/./; # strip inner `.`
|
||||
$tables{$db_tbl} = 1;
|
||||
}
|
||||
grep {
|
||||
m/(?:\w\.\w|`\.`)/ # only db.tbl, not just db
|
||||
}
|
||||
$chunk =~ m/(?:FROM|INTO|UPDATE)\s+(\S+)/gi;
|
||||
}
|
||||
return [ sort keys %tables ];
|
||||
}
|
||||
|
||||
1;
|
||||
}
|
||||
# ###########################################################################
|
||||
|
@@ -374,6 +374,28 @@ sub verify_test_data {
|
||||
return;
|
||||
}
|
||||
|
||||
sub dsn_for {
|
||||
my ($self, $host) = @_;
|
||||
_check_server($host);
|
||||
return "h=127.1,P=$port_for{$host},u=msandbox,p=msandbox";
|
||||
}
|
||||
|
||||
sub genlog {
|
||||
my ($self, $host) = @_;
|
||||
_check_server($host);
|
||||
return "/tmp/$port_for{$host}/data/genlog";
|
||||
}
|
||||
|
||||
sub clear_genlogs {
|
||||
my ($self, @hosts) = @_;
|
||||
@hosts = qw(master slave1 slave2) unless scalar @hosts;
|
||||
foreach my $host ( @hosts ) {
|
||||
PTDEVDEBUG && _d('Clearing general log on', $host);
|
||||
Test::More::diag(`echo > /tmp/$port_for{$host}/data/genlog`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
}
|
||||
# ###########################################################################
|
||||
|
Reference in New Issue
Block a user