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:
Daniel Nichter
2012-06-07 12:38:45 -04:00
parent 8d4354090e
commit 79c716d358
9 changed files with 203 additions and 175 deletions

View File

@@ -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;
}
# ###########################################################################

View File

@@ -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;
}
# ###########################################################################