mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 17:04:00 +00:00
Test pt-upgrade host-to-host. Implement diff_query_times(). Export $test_diff from PerconaTest instead of doing diag() in no_diff().
This commit is contained in:
260
bin/pt-upgrade
260
bin/pt-upgrade
@@ -5407,19 +5407,19 @@ has 'classes' => (
|
|||||||
sub save_diffs {
|
sub save_diffs {
|
||||||
my ($self, %args) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
my $event = $args{event};
|
my $event = $args{event};
|
||||||
my $query_time_diff = $args{query_time_diff};
|
my $query_time_diffs = $args{query_time_diffs};
|
||||||
my $warning_diffs = $args{warning_diffs};
|
my $warning_diffs = $args{warning_diffs};
|
||||||
my $row_diffs = $args{row_diffs};
|
my $row_diffs = $args{row_diffs};
|
||||||
|
|
||||||
my $class = $self->class(event => $event);
|
my $class = $self->class(event => $event);
|
||||||
|
|
||||||
if ( my $query = $self->_can_save(event => $event, class => $class) ) {
|
if ( my $query = $self->_can_save(event => $event, class => $class) ) {
|
||||||
if ( $query_time_diff
|
if ( $query_time_diffs
|
||||||
&& scalar @{$class->{query_time_diffs}} < $self->max_examples ) {
|
&& scalar @{$class->{query_time_diffs}} < $self->max_examples ) {
|
||||||
push @{$class->{query_time_diffs}}, [
|
push @{$class->{query_time_diffs}}, [
|
||||||
$query,
|
$query,
|
||||||
@$query_time_diff,
|
@$query_time_diffs,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5640,24 +5640,21 @@ sub report_class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( scalar @{$class->{errors}} ) {
|
if ( scalar @{$class->{errors}} ) {
|
||||||
$self->_print_diffs(
|
$self->_print_errors(
|
||||||
diffs => $class->{errors},
|
errors => $class->{errors},
|
||||||
name => 'Query error',
|
|
||||||
inline => 0,
|
|
||||||
default_value => 'No error',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( scalar @{$class->{query_time_diffs}} ) {
|
if ( scalar @{$class->{query_time_diffs}} ) {
|
||||||
$self->_print_diffs(
|
$self->_print_diffs(
|
||||||
diffs => $class->{query_time_diffs},
|
diffs => $class->{query_time_diffs},
|
||||||
name => 'Query time',
|
name => 'Query time',
|
||||||
inline => 1,
|
formatter => \&_format_query_times,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( scalar @{$class->{warning_diffs}} ) {
|
if ( scalar @{$class->{warning_diffs}} ) {
|
||||||
$self->_print_multiple_diffs(
|
$self->_print_diffs(
|
||||||
diffs => $class->{warning_diffs},
|
diffs => $class->{warning_diffs},
|
||||||
name => 'Warning',
|
name => 'Warning',
|
||||||
formatter => \&_format_warnings,
|
formatter => \&_format_warnings,
|
||||||
@@ -5665,7 +5662,7 @@ sub report_class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( scalar @{$class->{row_diffs}} ) {
|
if ( scalar @{$class->{row_diffs}} ) {
|
||||||
$self->_print_multiple_diffs(
|
$self->_print_diffs(
|
||||||
diffs => $class->{row_diffs},
|
diffs => $class->{row_diffs},
|
||||||
name => 'Row',
|
name => 'Row',
|
||||||
formatter => \&_format_rows,
|
formatter => \&_format_rows,
|
||||||
@@ -5732,56 +5729,6 @@ sub _print_diff_header {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _print_diffs {
|
|
||||||
my ($self, %args) = @_;
|
|
||||||
my $diffs = $args{diffs};
|
|
||||||
my $name = $args{name};
|
|
||||||
my $inline = $args{inline};
|
|
||||||
my $default_value = $args{default_value} || '?';
|
|
||||||
|
|
||||||
$self->_print_diff_header(
|
|
||||||
name => $name,
|
|
||||||
count => scalar @$diffs,
|
|
||||||
);
|
|
||||||
|
|
||||||
my $fmt = $inline ? "\n%s vs. %s\n" : "\n%s\n\nvs.\n\n%s\n";
|
|
||||||
|
|
||||||
my $diffno = 1;
|
|
||||||
foreach my $diff ( @$diffs ) {
|
|
||||||
print "\n-- $diffno.\n";
|
|
||||||
printf $fmt,
|
|
||||||
($diff->[1] || $default_value),
|
|
||||||
($diff->[2] || $default_value);
|
|
||||||
print "\n" . ($diff->[0] || '?') . "\n";
|
|
||||||
$diffno++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _print_multiple_diffs {
|
|
||||||
my ($self, %args) = @_;
|
|
||||||
my $diffs = $args{diffs};
|
|
||||||
my $name = $args{name};
|
|
||||||
my $formatter = $args{formatter};
|
|
||||||
|
|
||||||
$self->_print_diff_header(
|
|
||||||
name => $name,
|
|
||||||
count => scalar @$diffs,
|
|
||||||
);
|
|
||||||
|
|
||||||
my $diffno = 1;
|
|
||||||
foreach my $diff ( @$diffs ) {
|
|
||||||
print "\n-- $diffno.\n";
|
|
||||||
my $formatted_diff = $formatter->($diff->[1]);
|
|
||||||
print $formatted_diff || '?';
|
|
||||||
print "\n" . ($diff->[0] || '?') . "\n";
|
|
||||||
$diffno++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _print_failures {
|
sub _print_failures {
|
||||||
my ($self, %args) = @_;
|
my ($self, %args) = @_;
|
||||||
my $failures = $args{failures};
|
my $failures = $args{failures};
|
||||||
@@ -5808,6 +5755,53 @@ sub _print_failures {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _print_errors {
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
my $errors = $args{errors};
|
||||||
|
|
||||||
|
$self->_print_diff_header(
|
||||||
|
name => 'Query errors',
|
||||||
|
count => scalar @$errors,
|
||||||
|
);
|
||||||
|
|
||||||
|
my $fmt = "\n%s\n\nvs.\n\n%s\n";
|
||||||
|
|
||||||
|
my $errorno = 1;
|
||||||
|
foreach my $error ( @$errors ) {
|
||||||
|
print "\n-- $errorno.\n";
|
||||||
|
printf $fmt,
|
||||||
|
($error->[1] || 'No error'),
|
||||||
|
($error->[2] || 'No error');
|
||||||
|
print "\n" . ($error->[0] || '?') . "\n";
|
||||||
|
$errorno++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _print_diffs {
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
my $diffs = $args{diffs};
|
||||||
|
my $name = $args{name};
|
||||||
|
my $formatter = $args{formatter};
|
||||||
|
|
||||||
|
$self->_print_diff_header(
|
||||||
|
name => $name,
|
||||||
|
count => scalar @$diffs,
|
||||||
|
);
|
||||||
|
|
||||||
|
my $diffno = 1;
|
||||||
|
foreach my $diff ( @$diffs ) {
|
||||||
|
print "\n-- $diffno.\n";
|
||||||
|
my $formatted_diff = $formatter->($diff->[1]);
|
||||||
|
print $formatted_diff || '?';
|
||||||
|
print "\n" . ($diff->[0] || '?') . "\n";
|
||||||
|
$diffno++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
my $warning_format = <<'EOL';
|
my $warning_format = <<'EOL';
|
||||||
Code: %s
|
Code: %s
|
||||||
Level: %s
|
Level: %s
|
||||||
@@ -5846,18 +5840,41 @@ sub _format_rows {
|
|||||||
return unless $rows && @$rows;
|
return unless $rows && @$rows;
|
||||||
my @diffs;
|
my @diffs;
|
||||||
foreach my $row ( @$rows ) {
|
foreach my $row ( @$rows ) {
|
||||||
my $rowno = $row->[0];
|
if ( !defined $row->[1] || !defined $row->[2] ) {
|
||||||
my $cols1 = $row->[1];
|
my $n_missing_rows = $row->[0];
|
||||||
my $cols2 = $row->[2];
|
my $missing_rows = $row->[1] || $row->[2];
|
||||||
my $diff
|
my $dir = !defined $row->[1] ? '>' : '<';
|
||||||
= "@ row " . ($rowno || '?') . "\n"
|
my $diff
|
||||||
. '< ' . join(',', map {defined $_ ? $_ : 'NULL'} @$cols1) . "\n"
|
= '@ first ' . scalar @$missing_rows
|
||||||
. '> ' . join(',', map {defined $_ ? $_ : 'NULL'} @$cols2) . "\n";
|
. ' of ' . ($n_missing_rows || '?') . " missing rows\n";
|
||||||
push @diffs, $diff;
|
foreach my $row ( @$missing_rows ) {
|
||||||
|
$diff .= "$dir "
|
||||||
|
. join(',', map {defined $_ ? $_ : 'NULL'} @$row) . "\n";
|
||||||
|
}
|
||||||
|
push @diffs, $diff;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my $rowno = $row->[0];
|
||||||
|
my $cols1 = $row->[1];
|
||||||
|
my $cols2 = $row->[2];
|
||||||
|
my $diff
|
||||||
|
= "@ row " . ($rowno || '?') . "\n"
|
||||||
|
. '< ' . join(',', map {defined $_ ? $_ : 'NULL'} @$cols1) . "\n"
|
||||||
|
. '> ' . join(',', map {defined $_ ? $_ : 'NULL'} @$cols2) . "\n";
|
||||||
|
push @diffs, $diff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "\n" . join("\n", @diffs);
|
return "\n" . join("\n", @diffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _format_query_times {
|
||||||
|
my ($query_times) = @_;
|
||||||
|
return unless $query_times && @$query_times;
|
||||||
|
my $fmt = "%s vs. %s seconds (%s increase)\n";
|
||||||
|
return "\n" .
|
||||||
|
my @diffs;
|
||||||
|
}
|
||||||
|
|
||||||
sub _d {
|
sub _d {
|
||||||
my ($package, undef, $line) = caller 0;
|
my ($package, undef, $line) = caller 0;
|
||||||
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
||||||
@@ -5888,6 +5905,7 @@ use warnings FATAL => 'all';
|
|||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
|
|
||||||
use Time::HiRes qw(time);
|
use Time::HiRes qw(time);
|
||||||
|
use List::Util qw(min);
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
$Data::Dumper::Indent = 1;
|
$Data::Dumper::Indent = 1;
|
||||||
$Data::Dumper::Sortkeys = 1;
|
$Data::Dumper::Sortkeys = 1;
|
||||||
@@ -6164,7 +6182,7 @@ sub compare_host_to_host {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $query_time_diff = diff_query_times(
|
my $query_time_diffs = diff_query_times(
|
||||||
query_time1 => $results1->{query_time},
|
query_time1 => $results1->{query_time},
|
||||||
query_time2 => $results2->{query_time},
|
query_time2 => $results2->{query_time},
|
||||||
);
|
);
|
||||||
@@ -6192,17 +6210,17 @@ sub compare_host_to_host {
|
|||||||
PTDEBUG && _d($EVAL_ERROR);
|
PTDEBUG && _d($EVAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $query_time_diff
|
if ( ($query_time_diffs && scalar @$query_time_diffs)
|
||||||
|| ($warning_diffs && scalar @$warning_diffs)
|
|| ($warning_diffs && scalar @$warning_diffs)
|
||||||
|| ($row_diffs && scalar @$row_diffs) )
|
|| ($row_diffs && scalar @$row_diffs) )
|
||||||
{
|
{
|
||||||
PTDEBUG && _d('Query diffs');
|
PTDEBUG && _d('Query diffs');
|
||||||
$stats->{queries_with_diffs}++;
|
$stats->{queries_with_diffs}++;
|
||||||
$results->save_diffs(
|
$results->save_diffs(
|
||||||
event => $event,
|
event => $event,
|
||||||
query_time_diff => $query_time_diff,
|
query_time_diffs => $query_time_diffs,
|
||||||
warning_diffs => $warning_diffs,
|
warning_diffs => $warning_diffs,
|
||||||
row_diffs => $row_diffs,
|
row_diffs => $row_diffs,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -6261,10 +6279,23 @@ sub diff_query_times {
|
|||||||
foreach my $arg ( @required_args ) {
|
foreach my $arg ( @required_args ) {
|
||||||
die "I need a $arg argument" unless defined $args{$arg};
|
die "I need a $arg argument" unless defined $args{$arg};
|
||||||
}
|
}
|
||||||
PTDEBUG && _d('Diff query times');
|
my $t1 = $args{query_time1};
|
||||||
my $query_time1 = $args{query_time1};
|
my $t2 = $args{query_time2};
|
||||||
my $query_time2 = $args{query_time2};
|
PTDEBUG && _d('Diff query times', $t1, $t2);
|
||||||
return;
|
|
||||||
|
return unless $t1 && $t2 && $t1 != $t2;
|
||||||
|
|
||||||
|
# We only care if the 2nd query time is greater. The first query
|
||||||
|
# time should be the base/reference system.
|
||||||
|
return if $t2 < $t1;
|
||||||
|
|
||||||
|
my $incr = $t2 / $t1;
|
||||||
|
return if $incr < 10;
|
||||||
|
return [
|
||||||
|
$t1,
|
||||||
|
$t2,
|
||||||
|
sprintf('%.1f', $incr),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub diff_warnings {
|
sub diff_warnings {
|
||||||
@@ -6312,27 +6343,53 @@ sub diff_rows {
|
|||||||
my $max_diffs = $args{max_diffs} || 3;
|
my $max_diffs = $args{max_diffs} || 3;
|
||||||
|
|
||||||
PTDEBUG && _d('Diff rows');
|
PTDEBUG && _d('Diff rows');
|
||||||
|
|
||||||
my $rowno = 0;
|
|
||||||
my @diffs;
|
my @diffs;
|
||||||
while ( scalar(@diffs) < $max_diffs ) {
|
|
||||||
my $row1 = $sth1->fetchrow_arrayref();
|
|
||||||
my $row2 = $sth2->fetchrow_arrayref();
|
|
||||||
|
|
||||||
last if !defined $row1 || !defined $row2;
|
my $rows1 = $sth1->fetchall_arrayref();
|
||||||
|
my $rows2 = $sth2->fetchall_arrayref();
|
||||||
|
|
||||||
$rowno++;
|
my $n_rows1 = scalar @$rows1;
|
||||||
|
my $n_rows2 = scalar @$rows2;
|
||||||
|
my $max_rowno = min($n_rows1, $n_rows2);
|
||||||
|
if ( $n_rows1 != $n_rows2 ) {
|
||||||
|
my @missing_rows;
|
||||||
|
if ( $n_rows1 > $n_rows2 ) {
|
||||||
|
PTDEBUG && _d('host1 has more rows; host2 is missing rows');
|
||||||
|
my $nth_missing_row = $n_rows1 < ($max_rowno + $max_diffs - 1)
|
||||||
|
? $n_rows1 - 1
|
||||||
|
: $max_rowno + $max_diffs - 1;
|
||||||
|
@missing_rows = @{$rows1}[$max_rowno..$nth_missing_row];
|
||||||
|
push @diffs, [
|
||||||
|
$n_rows1 - $n_rows2,
|
||||||
|
\@missing_rows,
|
||||||
|
undef,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PTDEBUG && _d('host2 has more rows; host1 is missing rows');
|
||||||
|
my $nth_missing_row = $n_rows2 < ($max_rowno + $max_diffs - 1)
|
||||||
|
? $n_rows2 - 1
|
||||||
|
: $max_rowno + $max_diffs - 1;
|
||||||
|
@missing_rows = @{$rows2}[$max_rowno..$nth_missing_row];
|
||||||
|
push @diffs, [
|
||||||
|
$n_rows2 - $n_rows1,
|
||||||
|
undef,
|
||||||
|
\@missing_rows,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
my $rowno = -1; # so first ++ will incr to 0
|
||||||
|
while ( ++$rowno < $max_rowno && scalar(@diffs) < $max_diffs ) {
|
||||||
|
my $row1 = $rows1->[$rowno];
|
||||||
|
my $row2 = $rows2->[$rowno];
|
||||||
if ( !identical_rows($row1, $row2) ) {
|
if ( !identical_rows($row1, $row2) ) {
|
||||||
PTDEBUG && _d('Row diff:', Dumper($row1), Dumper($row2));
|
PTDEBUG && _d('Row diff:', Dumper($row1), Dumper($row2));
|
||||||
# "Note that the same array reference is returned for each fetch,
|
|
||||||
# so don't store the reference and then use it after a later fetch."
|
|
||||||
my @copy_row1 = $row1 ? @$row1 : ();
|
|
||||||
my @copy_row2 = $row2 ? @$row2 : ();
|
|
||||||
push @diffs, [
|
push @diffs, [
|
||||||
$rowno,
|
($rowno + 1), # rows are 1-index, not zero-indexed
|
||||||
\@copy_row1,
|
$row1,
|
||||||
\@copy_row2,
|
$row2,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6343,6 +6400,9 @@ sub diff_rows {
|
|||||||
sub identical_rows {
|
sub identical_rows {
|
||||||
my ($array1, $array2) = @_;
|
my ($array1, $array2) = @_;
|
||||||
|
|
||||||
|
return 0 if ($array1 && !$array2) || (!$array1 && $array2);
|
||||||
|
return 1 if !$array1 && !$array2;
|
||||||
|
|
||||||
my $size_array1 = scalar @$array1;
|
my $size_array1 = scalar @$array1;
|
||||||
my $size_array2 = scalar @$array2;
|
my $size_array2 = scalar @$array2;
|
||||||
if ( $size_array1 != $size_array2 ) {
|
if ( $size_array1 != $size_array2 ) {
|
||||||
|
@@ -70,6 +70,7 @@ our @EXPORT = qw(
|
|||||||
$dsn_opts
|
$dsn_opts
|
||||||
$sandbox_version
|
$sandbox_version
|
||||||
$can_load_data
|
$can_load_data
|
||||||
|
$test_diff
|
||||||
);
|
);
|
||||||
|
|
||||||
our $trunk = $ENV{PERCONA_TOOLKIT_BRANCH};
|
our $trunk = $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||||
@@ -82,6 +83,8 @@ eval {
|
|||||||
|
|
||||||
our $can_load_data = can_load_data();
|
our $can_load_data = can_load_data();
|
||||||
|
|
||||||
|
our $test_diff = '';
|
||||||
|
|
||||||
our $dsn_opts = [
|
our $dsn_opts = [
|
||||||
{
|
{
|
||||||
key => 'A',
|
key => 'A',
|
||||||
@@ -622,7 +625,7 @@ sub no_diff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# diff the outputs.
|
# diff the outputs.
|
||||||
my $out = `diff $res_file $cmp_file`;
|
$test_diff = `diff $res_file $cmp_file 2>&1`;
|
||||||
my $retval = $?;
|
my $retval = $?;
|
||||||
|
|
||||||
# diff returns 0 if there were no differences,
|
# diff returns 0 if there were no differences,
|
||||||
@@ -630,7 +633,6 @@ sub no_diff {
|
|||||||
$retval = $retval >> 8;
|
$retval = $retval >> 8;
|
||||||
|
|
||||||
if ( $retval ) {
|
if ( $retval ) {
|
||||||
diag($out);
|
|
||||||
if ( $ENV{UPDATE_SAMPLES} || $args{update_sample} ) {
|
if ( $ENV{UPDATE_SAMPLES} || $args{update_sample} ) {
|
||||||
`cat $tmp_file > $expected_output`;
|
`cat $tmp_file > $expected_output`;
|
||||||
diag("Updated $expected_output");
|
diag("Updated $expected_output");
|
||||||
@@ -642,11 +644,11 @@ sub no_diff {
|
|||||||
unless $ENV{KEEP_OUTPUT} || $args{keep_output};
|
unless $ENV{KEEP_OUTPUT} || $args{keep_output};
|
||||||
|
|
||||||
if ( $res_file ne $tmp_file ) {
|
if ( $res_file ne $tmp_file ) {
|
||||||
1 while unlink $res_file;
|
unlink $res_file if -f $res_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $cmp_file ne $expected_output ) {
|
if ( $cmp_file ne $expected_output ) {
|
||||||
1 while unlink $cmp_file;
|
unlink $cmp_file if -f $cmp_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !$retval;
|
return !$retval;
|
||||||
|
@@ -62,6 +62,8 @@ my %port_for = (
|
|||||||
node7 => 2903,
|
node7 => 2903,
|
||||||
cmaster => 12349, # master -> cluster
|
cmaster => 12349, # master -> cluster
|
||||||
cslave1 => 12348, # cluster -> slave
|
cslave1 => 12348, # cluster -> slave
|
||||||
|
host1 => 12345, # pt-upgrade
|
||||||
|
host2 => 12348, # pt-upgrade
|
||||||
);
|
);
|
||||||
|
|
||||||
my %server_type = (
|
my %server_type = (
|
||||||
|
@@ -51,19 +51,19 @@ has 'classes' => (
|
|||||||
sub save_diffs {
|
sub save_diffs {
|
||||||
my ($self, %args) = @_;
|
my ($self, %args) = @_;
|
||||||
|
|
||||||
my $event = $args{event};
|
my $event = $args{event};
|
||||||
my $query_time_diff = $args{query_time_diff};
|
my $query_time_diffs = $args{query_time_diffs};
|
||||||
my $warning_diffs = $args{warning_diffs};
|
my $warning_diffs = $args{warning_diffs};
|
||||||
my $row_diffs = $args{row_diffs};
|
my $row_diffs = $args{row_diffs};
|
||||||
|
|
||||||
my $class = $self->class(event => $event);
|
my $class = $self->class(event => $event);
|
||||||
|
|
||||||
if ( my $query = $self->_can_save(event => $event, class => $class) ) {
|
if ( my $query = $self->_can_save(event => $event, class => $class) ) {
|
||||||
if ( $query_time_diff
|
if ( $query_time_diffs
|
||||||
&& scalar @{$class->{query_time_diffs}} < $self->max_examples ) {
|
&& scalar @{$class->{query_time_diffs}} < $self->max_examples ) {
|
||||||
push @{$class->{query_time_diffs}}, [
|
push @{$class->{query_time_diffs}}, [
|
||||||
$query,
|
$query,
|
||||||
@$query_time_diff,
|
@$query_time_diffs,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,24 +284,21 @@ sub report_class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( scalar @{$class->{errors}} ) {
|
if ( scalar @{$class->{errors}} ) {
|
||||||
$self->_print_diffs(
|
$self->_print_errors(
|
||||||
diffs => $class->{errors},
|
errors => $class->{errors},
|
||||||
name => 'Query error',
|
|
||||||
inline => 0,
|
|
||||||
default_value => 'No error',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( scalar @{$class->{query_time_diffs}} ) {
|
if ( scalar @{$class->{query_time_diffs}} ) {
|
||||||
$self->_print_diffs(
|
$self->_print_diffs(
|
||||||
diffs => $class->{query_time_diffs},
|
diffs => $class->{query_time_diffs},
|
||||||
name => 'Query time',
|
name => 'Query time',
|
||||||
inline => 1,
|
formatter => \&_format_query_times,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( scalar @{$class->{warning_diffs}} ) {
|
if ( scalar @{$class->{warning_diffs}} ) {
|
||||||
$self->_print_multiple_diffs(
|
$self->_print_diffs(
|
||||||
diffs => $class->{warning_diffs},
|
diffs => $class->{warning_diffs},
|
||||||
name => 'Warning',
|
name => 'Warning',
|
||||||
formatter => \&_format_warnings,
|
formatter => \&_format_warnings,
|
||||||
@@ -309,7 +306,7 @@ sub report_class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( scalar @{$class->{row_diffs}} ) {
|
if ( scalar @{$class->{row_diffs}} ) {
|
||||||
$self->_print_multiple_diffs(
|
$self->_print_diffs(
|
||||||
diffs => $class->{row_diffs},
|
diffs => $class->{row_diffs},
|
||||||
name => 'Row',
|
name => 'Row',
|
||||||
formatter => \&_format_rows,
|
formatter => \&_format_rows,
|
||||||
@@ -381,56 +378,6 @@ sub _print_diff_header {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _print_diffs {
|
|
||||||
my ($self, %args) = @_;
|
|
||||||
my $diffs = $args{diffs};
|
|
||||||
my $name = $args{name};
|
|
||||||
my $inline = $args{inline};
|
|
||||||
my $default_value = $args{default_value} || '?';
|
|
||||||
|
|
||||||
$self->_print_diff_header(
|
|
||||||
name => $name,
|
|
||||||
count => scalar @$diffs,
|
|
||||||
);
|
|
||||||
|
|
||||||
my $fmt = $inline ? "\n%s vs. %s\n" : "\n%s\n\nvs.\n\n%s\n";
|
|
||||||
|
|
||||||
my $diffno = 1;
|
|
||||||
foreach my $diff ( @$diffs ) {
|
|
||||||
print "\n-- $diffno.\n";
|
|
||||||
printf $fmt,
|
|
||||||
($diff->[1] || $default_value),
|
|
||||||
($diff->[2] || $default_value);
|
|
||||||
print "\n" . ($diff->[0] || '?') . "\n";
|
|
||||||
$diffno++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _print_multiple_diffs {
|
|
||||||
my ($self, %args) = @_;
|
|
||||||
my $diffs = $args{diffs};
|
|
||||||
my $name = $args{name};
|
|
||||||
my $formatter = $args{formatter};
|
|
||||||
|
|
||||||
$self->_print_diff_header(
|
|
||||||
name => $name,
|
|
||||||
count => scalar @$diffs,
|
|
||||||
);
|
|
||||||
|
|
||||||
my $diffno = 1;
|
|
||||||
foreach my $diff ( @$diffs ) {
|
|
||||||
print "\n-- $diffno.\n";
|
|
||||||
my $formatted_diff = $formatter->($diff->[1]);
|
|
||||||
print $formatted_diff || '?';
|
|
||||||
print "\n" . ($diff->[0] || '?') . "\n";
|
|
||||||
$diffno++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub _print_failures {
|
sub _print_failures {
|
||||||
my ($self, %args) = @_;
|
my ($self, %args) = @_;
|
||||||
my $failures = $args{failures};
|
my $failures = $args{failures};
|
||||||
@@ -457,6 +404,53 @@ sub _print_failures {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _print_errors {
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
my $errors = $args{errors};
|
||||||
|
|
||||||
|
$self->_print_diff_header(
|
||||||
|
name => 'Query errors',
|
||||||
|
count => scalar @$errors,
|
||||||
|
);
|
||||||
|
|
||||||
|
my $fmt = "\n%s\n\nvs.\n\n%s\n";
|
||||||
|
|
||||||
|
my $errorno = 1;
|
||||||
|
foreach my $error ( @$errors ) {
|
||||||
|
print "\n-- $errorno.\n";
|
||||||
|
printf $fmt,
|
||||||
|
($error->[1] || 'No error'),
|
||||||
|
($error->[2] || 'No error');
|
||||||
|
print "\n" . ($error->[0] || '?') . "\n";
|
||||||
|
$errorno++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _print_diffs {
|
||||||
|
my ($self, %args) = @_;
|
||||||
|
my $diffs = $args{diffs};
|
||||||
|
my $name = $args{name};
|
||||||
|
my $formatter = $args{formatter};
|
||||||
|
|
||||||
|
$self->_print_diff_header(
|
||||||
|
name => $name,
|
||||||
|
count => scalar @$diffs,
|
||||||
|
);
|
||||||
|
|
||||||
|
my $diffno = 1;
|
||||||
|
foreach my $diff ( @$diffs ) {
|
||||||
|
print "\n-- $diffno.\n";
|
||||||
|
my $formatted_diff = $formatter->($diff->[1]);
|
||||||
|
print $formatted_diff || '?';
|
||||||
|
print "\n" . ($diff->[0] || '?') . "\n";
|
||||||
|
$diffno++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
my $warning_format = <<'EOL';
|
my $warning_format = <<'EOL';
|
||||||
Code: %s
|
Code: %s
|
||||||
Level: %s
|
Level: %s
|
||||||
@@ -495,18 +489,43 @@ sub _format_rows {
|
|||||||
return unless $rows && @$rows;
|
return unless $rows && @$rows;
|
||||||
my @diffs;
|
my @diffs;
|
||||||
foreach my $row ( @$rows ) {
|
foreach my $row ( @$rows ) {
|
||||||
my $rowno = $row->[0];
|
if ( !defined $row->[1] || !defined $row->[2] ) {
|
||||||
my $cols1 = $row->[1];
|
# missing rows
|
||||||
my $cols2 = $row->[2];
|
my $n_missing_rows = $row->[0];
|
||||||
my $diff
|
my $missing_rows = $row->[1] || $row->[2];
|
||||||
= "@ row " . ($rowno || '?') . "\n"
|
my $dir = !defined $row->[1] ? '>' : '<';
|
||||||
. '< ' . join(',', map {defined $_ ? $_ : 'NULL'} @$cols1) . "\n"
|
my $diff
|
||||||
. '> ' . join(',', map {defined $_ ? $_ : 'NULL'} @$cols2) . "\n";
|
= '@ first ' . scalar @$missing_rows
|
||||||
push @diffs, $diff;
|
. ' of ' . ($n_missing_rows || '?') . " missing rows\n";
|
||||||
|
foreach my $row ( @$missing_rows ) {
|
||||||
|
$diff .= "$dir "
|
||||||
|
. join(',', map {defined $_ ? $_ : 'NULL'} @$row) . "\n";
|
||||||
|
}
|
||||||
|
push @diffs, $diff;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# diff rows
|
||||||
|
my $rowno = $row->[0];
|
||||||
|
my $cols1 = $row->[1];
|
||||||
|
my $cols2 = $row->[2];
|
||||||
|
my $diff
|
||||||
|
= "@ row " . ($rowno || '?') . "\n"
|
||||||
|
. '< ' . join(',', map {defined $_ ? $_ : 'NULL'} @$cols1) . "\n"
|
||||||
|
. '> ' . join(',', map {defined $_ ? $_ : 'NULL'} @$cols2) . "\n";
|
||||||
|
push @diffs, $diff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "\n" . join("\n", @diffs);
|
return "\n" . join("\n", @diffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _format_query_times {
|
||||||
|
my ($query_times) = @_;
|
||||||
|
return unless $query_times && @$query_times;
|
||||||
|
my $fmt = "%s vs. %s seconds (%s increase)\n";
|
||||||
|
return "\n" .
|
||||||
|
my @diffs;
|
||||||
|
}
|
||||||
|
|
||||||
sub _d {
|
sub _d {
|
||||||
my ($package, undef, $line) = caller 0;
|
my ($package, undef, $line) = caller 0;
|
||||||
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
||||||
|
@@ -4,201 +4,95 @@ BEGIN {
|
|||||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||||
|
$ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use File::Basename;
|
||||||
|
|
||||||
use PerconaTest;
|
use PerconaTest;
|
||||||
use Sandbox;
|
use Sandbox;
|
||||||
require "$trunk/bin/pt-upgrade";
|
require "$trunk/bin/pt-upgrade";
|
||||||
|
|
||||||
# This runs immediately if the server is already running, else it starts it.
|
# This runs immediately if the server is already running, else it starts it.
|
||||||
diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
# diag(`$trunk/sandbox/start-sandbox master 12348 >/dev/null`);
|
||||||
|
|
||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||||
my $dbh1 = $sb->get_dbh_for('master');
|
my $dbh1 = $sb->get_dbh_for('host1');
|
||||||
my $dbh2 = $sb->get_dbh_for('master1');
|
my $dbh2 = $sb->get_dbh_for('host2');
|
||||||
|
|
||||||
if ( !$dbh1 ) {
|
if ( !$dbh1 ) {
|
||||||
plan skip_all => 'Cannot connect to sandbox master';
|
plan skip_all => 'Cannot connect to sandbox host1';
|
||||||
}
|
}
|
||||||
elsif ( !$dbh2 ) {
|
elsif ( !$dbh2 ) {
|
||||||
plan skip_all => 'Cannot connect to second sandbox master';
|
plan skip_all => 'Cannot connect to sandbox host2';
|
||||||
}
|
}
|
||||||
|
|
||||||
my @host_args = ('h=127.1,P=12345,L=1', 'P=12348');
|
my $host1_dsn = $sb->dsn_for('host1');
|
||||||
my @op_args = (qw(-u msandbox -p msandbox),
|
my $host2_dsn = $sb->dsn_for('host2');
|
||||||
'--compare', 'results,warnings',
|
|
||||||
'--zero-query-times',
|
|
||||||
);
|
|
||||||
my @args = (@host_args, @op_args);
|
|
||||||
my $sample = "t/pt-upgrade/samples";
|
|
||||||
my $log = "$trunk/$sample";
|
|
||||||
|
|
||||||
# ###########################################################################
|
my $sample = "t/pt-upgrade/samples";
|
||||||
# Basic run.
|
my $samples_dir = "$trunk/t/pt-upgrade/samples";
|
||||||
# ###########################################################################
|
|
||||||
$sb->load_file('master', "$sample/001/tables.sql");
|
|
||||||
$sb->load_file('master1', "$sample/001/tables.sql");
|
|
||||||
|
|
||||||
ok(
|
opendir(my $dh, $samples_dir) or die "Cannot open $samples_dir: $OS_ERROR";
|
||||||
no_diff(
|
|
||||||
sub { pt_upgrade::main(@args, "$log/001/select-one.log") },
|
|
||||||
"$sample/001/select-one.txt",
|
|
||||||
),
|
|
||||||
'Report for a single query (checksum method)'
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
while ( my $sampleno = readdir $dh ) {
|
||||||
no_diff(
|
next unless $sampleno =~ m/^\d+$/;
|
||||||
sub { pt_upgrade::main(@args, "$log/001/select-everyone.log") },
|
if ( -f "$samples_dir/$sampleno/tables.sql" ) {
|
||||||
"$sample/001/select-everyone.txt"
|
$sb->load_file('host1', "$sample/$sampleno/tables.sql", undef, no_wait => 1);
|
||||||
),
|
$sb->load_file('host2', "$sample/$sampleno/tables.sql", undef, no_wait => 1);
|
||||||
'Report for multiple queries (checksum method)'
|
}
|
||||||
);
|
if ( -f "$samples_dir/$sampleno/host1.sql" ) {
|
||||||
|
$sb->load_file('host1', "$sample/$sampleno/host1.sql", undef, no_wait => 1);
|
||||||
|
}
|
||||||
|
if ( -f "$samples_dir/$sampleno/host2.sql" ) {
|
||||||
|
$sb->load_file('host2', "$sample/$sampleno/host2.sql", undef, no_wait => 1);
|
||||||
|
}
|
||||||
|
|
||||||
ok(
|
my $conf = "$samples_dir/$sampleno/conf";
|
||||||
no_diff(
|
|
||||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-one.log",
|
|
||||||
"--compare-results-method", "rows") },
|
|
||||||
"$sample/001/select-one-rows.txt"
|
|
||||||
),
|
|
||||||
'Report for a single query (rows method)'
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
foreach my $log ( glob("$samples_dir/$sampleno/*.log") ) {
|
||||||
no_diff(
|
(my $basename = basename($log)) =~ s/\.\S+$//;
|
||||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
my $sed;
|
||||||
"--compare-results-method", "rows") },
|
if ( -f "$samples_dir/$sampleno/$basename.sed" ) {
|
||||||
"$sample/001/select-everyone-rows.txt"
|
chomp($sed = `cat $samples_dir/$sampleno/$basename.sed`);
|
||||||
),
|
}
|
||||||
'Report for multiple queries (rows method)'
|
|
||||||
);
|
|
||||||
|
|
||||||
ok(
|
my $output = output(
|
||||||
no_diff(
|
sub { pt_upgrade::main(
|
||||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
(-f $conf ? ('--config', $conf) : ()),
|
||||||
"--reports", "queries,differences,errors") },
|
$log,
|
||||||
"$sample/001/select-everyone-no-stats.txt"
|
$host1_dsn,
|
||||||
),
|
$host2_dsn,
|
||||||
'Report without statistics'
|
) },
|
||||||
);
|
stderr => 1,
|
||||||
|
);
|
||||||
|
|
||||||
ok(
|
if ( -f "$samples_dir/$sampleno/$basename.txt" ) {
|
||||||
no_diff(
|
ok(
|
||||||
sub { pt_upgrade::main(@args, "$trunk/$sample/001/select-everyone.log",
|
no_diff(
|
||||||
"--reports", "differences,errors,statistics") },
|
$output,
|
||||||
"$sample/001/select-everyone-no-queries.txt"
|
"$sample/$sampleno/$basename.txt",
|
||||||
),
|
cmd_output => 1,
|
||||||
'Report without per-query reports'
|
($sed ? (sed => [ $sed ]) : ()),
|
||||||
);
|
),
|
||||||
|
"$sampleno: $basename.txt"
|
||||||
|
) or diag("diff:\n", $test_diff, "\noutput:\n", $output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sb->wipe_clean($dbh1);
|
close $dh;
|
||||||
$sb->wipe_clean($dbh2);
|
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# Issue 951: mk-upgrade "I need a db argument" error with
|
|
||||||
# compare-results-method=rows
|
|
||||||
# #############################################################################
|
|
||||||
$sb->load_file('master', "$sample/002/tables.sql");
|
|
||||||
$sb->load_file('master1', "$sample/002/tables.sql");
|
|
||||||
|
|
||||||
# Make a difference on one host so diff_rows() is called.
|
|
||||||
$dbh1->do('insert into test.t values (5)');
|
|
||||||
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
|
||||||
'h=127.1,P=12345,D=test,L=1', 'P=12348,D=test',
|
|
||||||
qw(--compare-results-method rows --temp-database test)) },
|
|
||||||
"$sample/002/report-01.txt",
|
|
||||||
),
|
|
||||||
'No db, compare results row, DSN D, --temp-database (issue 951)'
|
|
||||||
);
|
|
||||||
|
|
||||||
$sb->load_file('master', "$sample/002/tables.sql");
|
|
||||||
$sb->load_file('master1', "$sample/002/tables.sql");
|
|
||||||
$dbh1->do('insert into test.t values (5)');
|
|
||||||
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_upgrade::main(@op_args, "$log/002/no-db.log",
|
|
||||||
'h=127.1,P=12345,D=test,L=1', 'P=12348,D=test',
|
|
||||||
qw(--compare-results-method rows --temp-database tmp_db)) },
|
|
||||||
"$sample/002/report-01.txt",
|
|
||||||
),
|
|
||||||
'No db, compare results row, DSN D'
|
|
||||||
);
|
|
||||||
|
|
||||||
is_deeply(
|
|
||||||
$dbh1->selectall_arrayref('show tables from `test`'),
|
|
||||||
[['t']],
|
|
||||||
"Didn't create temp table in event's db"
|
|
||||||
);
|
|
||||||
|
|
||||||
is_deeply(
|
|
||||||
$dbh1->selectall_arrayref('show tables from `tmp_db`'),
|
|
||||||
[['mk_upgrade_left']],
|
|
||||||
"Createed temp table in --temp-database"
|
|
||||||
);
|
|
||||||
|
|
||||||
$sb->wipe_clean($dbh1);
|
|
||||||
$sb->wipe_clean($dbh2);
|
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# Bug 926598: DBD::mysql bug causes pt-upgrade to use wrong
|
|
||||||
# precision (M) and scale (D)
|
|
||||||
# #############################################################################
|
|
||||||
$sb->load_file('master', "$sample/003/tables.sql");
|
|
||||||
$sb->load_file('master1', "$sample/003/tables.sql");
|
|
||||||
|
|
||||||
# Make a difference on one host so diff_rows() is called.
|
|
||||||
$dbh1->do('insert into test.t values (4, 1.00)');
|
|
||||||
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_upgrade::main(@args, "$log/003/double.log",
|
|
||||||
qw(--compare-results-method rows)) },
|
|
||||||
"$sample/003/report001.txt",
|
|
||||||
),
|
|
||||||
'M, D diff (bug 926598)',
|
|
||||||
);
|
|
||||||
|
|
||||||
my $row = $dbh1->selectrow_arrayref("show create table test.mk_upgrade_left");
|
|
||||||
like(
|
|
||||||
$row->[1],
|
|
||||||
qr/[`"]SUM\(total\)[`"]\s+double\sDEFAULT/i,
|
|
||||||
"No M,D in table def (bug 926598)"
|
|
||||||
);
|
|
||||||
|
|
||||||
# #############################################################################
|
|
||||||
# SELECT FUNC(), so there are no tables.
|
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1060774
|
|
||||||
# #############################################################################
|
|
||||||
$sb->load_file('master', "$sample/004/tables.sql");
|
|
||||||
$sb->load_file('master1', "$sample/004/tables.sql");
|
|
||||||
|
|
||||||
ok(
|
|
||||||
no_diff(
|
|
||||||
sub { pt_upgrade::main(@args,
|
|
||||||
qw(--compare-results-method rows),
|
|
||||||
qw(--no-clear-warnings),
|
|
||||||
"$log/004/select-func.log") },
|
|
||||||
"$sample/004/select-func.txt",
|
|
||||||
),
|
|
||||||
'SELECT FUNC() (bug 1060774)'
|
|
||||||
);
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
diag(`rm /tmp/left-outfile.txt /tmp/right-outfile.txt 2>/dev/null`);
|
#$sb->wipe_clean($dbh2);
|
||||||
diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
|
#$sb->wipe_clean($dbh1);
|
||||||
$sb->wipe_clean($dbh1);
|
#diag(`$trunk/sandbox/stop-sandbox 12348 >/dev/null`);
|
||||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
#ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||||
done_testing;
|
done_testing;
|
||||||
exit;
|
|
||||||
|
85
t/pt-upgrade/diff_query_times.t
Normal file
85
t/pt-upgrade/diff_query_times.t
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#!/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 Data::Dumper;
|
||||||
|
|
||||||
|
use PerconaTest;
|
||||||
|
use Sandbox;
|
||||||
|
$Data::Dumper::Indent = 1;
|
||||||
|
$Data::Dumper::Sortkeys = 1;
|
||||||
|
$Data::Dumper::Quotekeys = 0;
|
||||||
|
|
||||||
|
require "$trunk/bin/pt-upgrade";
|
||||||
|
|
||||||
|
sub test_diff_query_times {
|
||||||
|
my (%args) = @_;
|
||||||
|
|
||||||
|
my $diff = pt_upgrade::diff_query_times(
|
||||||
|
query_time1 => $args{t1},
|
||||||
|
query_time2 => $args{t2},
|
||||||
|
);
|
||||||
|
is_deeply(
|
||||||
|
$diff,
|
||||||
|
$args{expect},
|
||||||
|
"$args{t1} vs. $args{t2}"
|
||||||
|
) or diag(Dumper($diff));
|
||||||
|
}
|
||||||
|
|
||||||
|
test_diff_query_times(
|
||||||
|
t1 => 0,
|
||||||
|
t2 => 0,
|
||||||
|
expect => undef,
|
||||||
|
);
|
||||||
|
|
||||||
|
test_diff_query_times(
|
||||||
|
t1 => 1,
|
||||||
|
t2 => 1,
|
||||||
|
expect => undef,
|
||||||
|
);
|
||||||
|
|
||||||
|
test_diff_query_times(
|
||||||
|
t1 => 23,
|
||||||
|
t2 => 82,
|
||||||
|
expect => undef,
|
||||||
|
);
|
||||||
|
|
||||||
|
test_diff_query_times(
|
||||||
|
t1 => 23,
|
||||||
|
t2 => 820,
|
||||||
|
expect => [ 23, 820, 35.7 ],
|
||||||
|
);
|
||||||
|
|
||||||
|
# Just .01 shy of 1 order of mag. diff.
|
||||||
|
test_diff_query_times(
|
||||||
|
t1 => 0.09,
|
||||||
|
t2 => 0.89,
|
||||||
|
expect => undef,
|
||||||
|
);
|
||||||
|
|
||||||
|
# Exactly 1 order of mag. diff.
|
||||||
|
test_diff_query_times(
|
||||||
|
t1 => 0.09,
|
||||||
|
t2 => 0.9,
|
||||||
|
expect => [ 0.09, 0.9, '10.0' ],
|
||||||
|
);
|
||||||
|
|
||||||
|
# An order of mag. decrease, which is ok.
|
||||||
|
test_diff_query_times(
|
||||||
|
t1 => 0.9,
|
||||||
|
t2 => 0.09,
|
||||||
|
expect => undef,
|
||||||
|
);
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Done.
|
||||||
|
# #############################################################################
|
||||||
|
done_testing;
|
@@ -10,13 +10,13 @@ use strict;
|
|||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Data::Dumper;
|
||||||
use PerconaTest;
|
|
||||||
use Sandbox;
|
|
||||||
$Data::Dumper::Indent = 1;
|
$Data::Dumper::Indent = 1;
|
||||||
$Data::Dumper::Sortkeys = 1;
|
$Data::Dumper::Sortkeys = 1;
|
||||||
$Data::Dumper::Quotekeys = 0;
|
$Data::Dumper::Quotekeys = 0;
|
||||||
|
|
||||||
|
use PerconaTest;
|
||||||
|
use Sandbox;
|
||||||
require "$trunk/bin/pt-upgrade";
|
require "$trunk/bin/pt-upgrade";
|
||||||
|
|
||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
@@ -82,10 +82,33 @@ test_diff (
|
|||||||
);
|
);
|
||||||
|
|
||||||
test_diff (
|
test_diff (
|
||||||
name => "Stops when there's not 2 rows",
|
name => 'Host1 missing a row',
|
||||||
query1 => "select user from mysql.user where user='msandbox' order by user",
|
query1 => "select user from mysql.user where user='msandbox' order by user",
|
||||||
query2 => 'select user from mysql.user order by user',
|
query2 => 'select user from mysql.user order by user',
|
||||||
expect => [],
|
expect => [
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
undef,
|
||||||
|
[
|
||||||
|
[qw(root)],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
test_diff (
|
||||||
|
name => 'Host2 missing a row',
|
||||||
|
query1 => 'select user from mysql.user order by user',
|
||||||
|
query2 => "select user from mysql.user where user='msandbox' order by user",
|
||||||
|
expect => [
|
||||||
|
[
|
||||||
|
1,
|
||||||
|
[
|
||||||
|
[qw(root)],
|
||||||
|
],
|
||||||
|
undef,
|
||||||
|
],
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
12
t/pt-upgrade/samples/001/insert.txt
Normal file
12
t/pt-upgrade/samples/001/insert.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Stats
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
failed_queries 0
|
||||||
|
not_select 1
|
||||||
|
queries_filtered 0
|
||||||
|
queries_no_diffs 0
|
||||||
|
queries_read 1
|
||||||
|
queries_with_diffs 0
|
||||||
|
queries_with_errors 0
|
@@ -1,112 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0xC11622E1B2607157 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# checksums 0
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 7 7
|
|
||||||
# min 7 7
|
|
||||||
# max 7 7
|
|
||||||
# avg 7 7
|
|
||||||
# pct_95 7 7
|
|
||||||
# stddev 0 0
|
|
||||||
# median 7 7
|
|
||||||
# Converted non-SELECT:
|
|
||||||
# delete from t where id is not null
|
|
||||||
# Fingerprint
|
|
||||||
# select * from t where id is not ?
|
|
||||||
select * from t where id is not null
|
|
||||||
|
|
||||||
# Query 2: ID 0xD7D2F2B7AB4602A4 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# checksums 0
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 2 2
|
|
||||||
# min 2 2
|
|
||||||
# max 2 2
|
|
||||||
# avg 2 2
|
|
||||||
# pct_95 2 2
|
|
||||||
# stddev 0 0
|
|
||||||
# median 2 2
|
|
||||||
# Fingerprint
|
|
||||||
# select id from test.t where id > ?
|
|
||||||
use `test`;
|
|
||||||
select id from test.t where id > 3
|
|
||||||
|
|
||||||
# Query 3: ID 0x37BA5C52702C61C6 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# checksums 0
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 1 1
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
# Converted non-SELECT:
|
|
||||||
# update t set name='changed' where id=0
|
|
||||||
# Fingerprint
|
|
||||||
# select name=? from t where id=?
|
|
||||||
select name='changed' from t where id=0
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# convert_to_select_failed 2
|
|
||||||
# convert_to_select_ok 2
|
|
||||||
# events 5
|
|
@@ -1,16 +0,0 @@
|
|||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
use test;
|
|
||||||
select id from test.t where id > 3;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
insert into t values (9, 'nine', now());
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
update t set name='changed' where id=0;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
delete from t where id is not null;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
truncate table t;
|
|
@@ -1,37 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0xD7D2F2B7AB4602A4 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# checksums 0
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 2 2
|
|
||||||
# min 2 2
|
|
||||||
# max 2 2
|
|
||||||
# avg 2 2
|
|
||||||
# pct_95 2 2
|
|
||||||
# stddev 0 0
|
|
||||||
# median 2 2
|
|
||||||
use `test`;
|
|
||||||
select id from test.t where id > 3
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# events 5
|
|
||||||
# not_select 4
|
|
@@ -1,63 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0x3B323396273BC4C7 at byte 0 _______________________________
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
|
|
||||||
# Errors 1 1
|
|
||||||
# Warnings 1 1
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
select borked
|
|
||||||
/* 3B323396273BC4C7-1 */ select borked
|
|
||||||
|
|
||||||
# Query 2: ID 0x30B1FA07C660C2A8 at byte 0 _______________________________
|
|
||||||
# Found 0 differences in 2 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 2 2
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
select * from t where name='jane'
|
|
||||||
|
|
||||||
# Errors
|
|
||||||
# Query ID Host Error
|
|
||||||
# ================== ================================ ========================
|
|
||||||
# 3B323396273BC4C7-1 P=12348,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at mk-upgrade line 0, <$fh> line 2.
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# CompareResults_after_execute_skipped 2
|
|
||||||
# CompareResults_execute_error 2
|
|
||||||
# events 3
|
|
@@ -1,10 +0,0 @@
|
|||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
|
|
||||||
use test;
|
|
||||||
select * from t where name='bob';
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 0 Rows_examined: 0
|
|
||||||
select borked;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select * from t where name='jane';
|
|
@@ -1,66 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0x3B323396273BC4C7 at byte 0 _______________________________
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
|
|
||||||
# Errors 1 1
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
select borked
|
|
||||||
/* 3B323396273BC4C7-1 */ select borked
|
|
||||||
|
|
||||||
# Query 2: ID 0x30B1FA07C660C2A8 at byte 0 _______________________________
|
|
||||||
# Found 0 differences in 2 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# P=12345,h=127.1,p=...,u=msandbox P=12348,h=127.1,p=...,u=msandbox
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 2 2
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
select * from t where name='jane'
|
|
||||||
|
|
||||||
# Errors
|
|
||||||
# Query ID Host Error
|
|
||||||
# ================== ================================ ========================
|
|
||||||
# 3B323396273BC4C7-1 P=12348,h=127.1,p=...,u=msandbox Failed to execute query: DBD::mysql::st execute failed: Unknown column 'borked' in 'field list' [for Statement "select borked"] at ../mk-upgrade line 7059, <$fh> line 2.
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# CompareResults_after_execute_skipped 2
|
|
||||||
# CompareResults_execute_error 2
|
|
||||||
# CompareWarnings_after_execute_skipped 2
|
|
||||||
# CompareWarnings_before_execute_error 2
|
|
||||||
# CompareWarnings_execute_skipped 2
|
|
||||||
# events 3
|
|
@@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
# Statistics
|
|
||||||
# events 7
|
|
@@ -1,32 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0x4AF1501167533D97 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 7 samples:
|
|
||||||
# checksums 0
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 7 7
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
select id, name, last_login from test.t where id=5
|
|
@@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0x4AF1501167533D97 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 7 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 7 7
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
select id, name, last_login from test.t where id=5
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# events 7
|
|
@@ -1,22 +0,0 @@
|
|||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
use test;
|
|
||||||
select id, name, last_login from test.t where id=-1;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select id, name, last_login from test.t where id=0;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select id, name, last_login from test.t where id=1;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select id, name, last_login from test.t where id=2;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select id, name, last_login from test.t where id=3;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select id, name, last_login from test.t where id=4;
|
|
||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select id, name, last_login from test.t where id=5;
|
|
@@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0x4AF1501167533D97 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 7 samples:
|
|
||||||
# checksums 0
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 7 7
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
select id, name, last_login from test.t where id=5
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# events 7
|
|
@@ -1,36 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0x4AF1501167533D97 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 1 1
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
use `test`;
|
|
||||||
select id, name, last_login from test.t where id=0
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# events 1
|
|
@@ -1,4 +0,0 @@
|
|||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
use test;
|
|
||||||
select id, name, last_login from test.t where id=0;
|
|
@@ -1,36 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0x4AF1501167533D97 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# checksums 0
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 1 1
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
use `test`;
|
|
||||||
select id, name, last_login from test.t where id=0
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# events 1
|
|
11
t/pt-upgrade/samples/001/select.txt
Normal file
11
t/pt-upgrade/samples/001/select.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Stats
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
failed_queries 0
|
||||||
|
queries_filtered 0
|
||||||
|
queries_no_diffs 1
|
||||||
|
queries_read 1
|
||||||
|
queries_with_diffs 0
|
||||||
|
queries_with_errors 0
|
@@ -1,18 +1,16 @@
|
|||||||
DROP DATABASE IF EXISTS test;
|
DROP DATABASE IF EXISTS test;
|
||||||
CREATE DATABASE test;
|
CREATE DATABASE test;
|
||||||
USE test;
|
USE test;
|
||||||
DROP TABLE IF EXISTS t;
|
CREATE TABLE t (
|
||||||
CREATE TABLE `t` (
|
id int(10) NOT NULL AUTO_INCREMENT,
|
||||||
`id` int(10) NOT NULL,
|
username varchar(8) default NULL,
|
||||||
`username` varchar(32) default NULL,
|
last_login datetime default NULL,
|
||||||
`last_login` datetime default NULL,
|
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
);
|
);
|
||||||
INSERT INTO t VALUES
|
INSERT INTO t VALUES
|
||||||
(-1, 'banned', '2009-11-06 10:37:17'),
|
(null, 'a', '2013-01-01 00:00:01'),
|
||||||
(0, 'admin', '2001-11-07 12:01:40'),
|
(null, 'b', '2013-01-01 00:00:02'),
|
||||||
(1, 'bob', '2009-10-07 10:37:47'),
|
(null, 'c', '2013-01-01 00:00:03'),
|
||||||
(2, 'jane', '2009-11-07 11:37:97'),
|
(null, 'd', '2013-01-01 00:00:04'),
|
||||||
(3, 'susan', '2009-04-09 10:00:47'),
|
(null, 'e', '2013-01-01 00:00:05'),
|
||||||
(4, 'rick', '2009-10-03 10:37:22'),
|
(null, 'f', '2013-01-01 00:00:06');
|
||||||
(5, 'tom', '2009-12-07 10:37:74');
|
|
||||||
|
9
t/pt-upgrade/samples/002/host2.sql
Normal file
9
t/pt-upgrade/samples/002/host2.sql
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
USE test;
|
||||||
|
|
||||||
|
-- Add 5 more rows so 01select.log causes a row diff.
|
||||||
|
INSERT INTO t VALUES
|
||||||
|
(null, 'g', '2013-01-01 00:00:07'),
|
||||||
|
(null, 'h', '2013-01-01 00:00:08'),
|
||||||
|
(null, 'i', '2013-01-01 00:00:09'),
|
||||||
|
(null, 'j', '2013-01-01 00:00:10'),
|
||||||
|
(null, 'k', '2013-01-01 00:00:11');
|
@@ -1,3 +0,0 @@
|
|||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
select i from t where i is not null
|
|
@@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0x3C830E3839B916D7 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 1 differences in 1 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 0
|
|
||||||
# row counts 1
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 4 3
|
|
||||||
# min 4 3
|
|
||||||
# max 4 3
|
|
||||||
# avg 4 3
|
|
||||||
# pct_95 4 3
|
|
||||||
# stddev 0 0
|
|
||||||
# median 4 3
|
|
||||||
use `test`;
|
|
||||||
select i from t where i is not null
|
|
||||||
|
|
||||||
/* 3C830E3839B916D7-1 */ select i from t where i is not null
|
|
||||||
|
|
||||||
|
|
||||||
# Row count differences
|
|
||||||
# Query ID host1 host2
|
|
||||||
# ================== ===== =====
|
|
||||||
# 3C830E3839B916D7-1 4 3
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# events 1
|
|
4
t/pt-upgrade/samples/002/select_missing_rows.log
Normal file
4
t/pt-upgrade/samples/002/select_missing_rows.log
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# User@Host: root[root] @ localhost []
|
||||||
|
# Query_time: 1 Lock_time: 0 Rows_sent: 7 Rows_examined: 7
|
||||||
|
use test;
|
||||||
|
select * from test.t order by id;
|
35
t/pt-upgrade/samples/002/select_missing_rows.txt
Normal file
35
t/pt-upgrade/samples/002/select_missing_rows.txt
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
########################################################################
|
||||||
|
# Query class 483E7FA163F8DA7B
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
Reporting class because it has diffs, but hasn't been reported yet.
|
||||||
|
|
||||||
|
Total queries 1
|
||||||
|
Unique queries 1
|
||||||
|
Discarded queries 0
|
||||||
|
|
||||||
|
select * from test.t order by id
|
||||||
|
|
||||||
|
##
|
||||||
|
## Row diffs: 1
|
||||||
|
##
|
||||||
|
|
||||||
|
-- 1.
|
||||||
|
|
||||||
|
@ first 3 of 5 missing rows
|
||||||
|
> 7,g,2013-01-01 00:00:07
|
||||||
|
> 8,h,2013-01-01 00:00:08
|
||||||
|
> 9,i,2013-01-01 00:00:09
|
||||||
|
|
||||||
|
select * from test.t order by id
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Stats
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
failed_queries 0
|
||||||
|
queries_filtered 0
|
||||||
|
queries_no_diffs 0
|
||||||
|
queries_read 1
|
||||||
|
queries_with_diffs 1
|
||||||
|
queries_with_errors 0
|
@@ -1,8 +1,16 @@
|
|||||||
DROP DATABASE IF EXISTS test;
|
DROP DATABASE IF EXISTS test;
|
||||||
CREATE DATABASE test;
|
CREATE DATABASE test;
|
||||||
USE test;
|
USE test;
|
||||||
create table t (i int);
|
CREATE TABLE t (
|
||||||
insert into t values (1), (2), (3);
|
id int(10) NOT NULL AUTO_INCREMENT,
|
||||||
|
username varchar(8) default NULL,
|
||||||
DROP DATABASE IF EXISTS tmp_db;
|
last_login datetime default NULL,
|
||||||
CREATE DATABASE tmp_db;
|
PRIMARY KEY (`id`)
|
||||||
|
);
|
||||||
|
INSERT INTO t VALUES
|
||||||
|
(null, 'a', '2013-01-01 00:00:01'),
|
||||||
|
(null, 'b', '2013-01-01 00:00:02'),
|
||||||
|
(null, 'c', '2013-01-01 00:00:03'),
|
||||||
|
(null, 'd', '2013-01-01 00:00:04'),
|
||||||
|
(null, 'e', '2013-01-01 00:00:05'),
|
||||||
|
(null, 'f', '2013-01-01 00:00:06');
|
||||||
|
1
t/pt-upgrade/samples/003/conf
Normal file
1
t/pt-upgrade/samples/003/conf
Normal file
@@ -0,0 +1 @@
|
|||||||
|
no-read-only
|
@@ -1,4 +0,0 @@
|
|||||||
# User@Host: root[root] @ localhost []
|
|
||||||
# Query_time: 1 Lock_time: 0 Rows_sent: 1 Rows_examined: 1
|
|
||||||
use test;
|
|
||||||
SELECT SUM(total) FROM test.t WHERE id > 0
|
|
5
t/pt-upgrade/samples/003/host2.sql
Normal file
5
t/pt-upgrade/samples/003/host2.sql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
USE test;
|
||||||
|
|
||||||
|
-- Increase column size from 8 to 16 so insert.log causes
|
||||||
|
-- a warning diff (value is truncated on host1).
|
||||||
|
ALTER TABLE t CHANGE COLUMN username username varchar(16) default NULL;
|
38
t/pt-upgrade/samples/003/insert_truncate.warning.txt
Normal file
38
t/pt-upgrade/samples/003/insert_truncate.warning.txt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
########################################################################
|
||||||
|
# Query class AAD020567F8398EE
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
Reporting class because it has diffs, but hasn't been reported yet.
|
||||||
|
|
||||||
|
Total queries 1
|
||||||
|
Unique queries 1
|
||||||
|
Discarded queries 0
|
||||||
|
|
||||||
|
insert into t (id, username) values(?+)
|
||||||
|
|
||||||
|
##
|
||||||
|
## Warning diffs: 1
|
||||||
|
##
|
||||||
|
|
||||||
|
-- 1.
|
||||||
|
|
||||||
|
Code: 1265
|
||||||
|
Level: Warning
|
||||||
|
Message: Data truncated for column 'username' at row 1
|
||||||
|
|
||||||
|
vs.
|
||||||
|
|
||||||
|
No warning 1265
|
||||||
|
|
||||||
|
INSERT INTO t (id, username) VALUES (NULL, 'long_username')
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Stats
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
failed_queries 0
|
||||||
|
queries_filtered 0
|
||||||
|
queries_no_diffs 0
|
||||||
|
queries_read 1
|
||||||
|
queries_with_diffs 1
|
||||||
|
queries_with_errors 0
|
4
t/pt-upgrade/samples/003/insert_truncate_warning.log
Normal file
4
t/pt-upgrade/samples/003/insert_truncate_warning.log
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# User@Host: root[root] @ localhost []
|
||||||
|
# Query_time: 1 Lock_time: 0 Rows_sent: 0 Rows_examined: 1
|
||||||
|
use test;
|
||||||
|
INSERT INTO t (id, username) VALUES (NULL, 'long_username');
|
@@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0xC1B1E457814417E4 at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 1 differences in 1 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 1
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 1 1
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
use `test`;
|
|
||||||
SELECT SUM(total) FROM test.t WHERE id > 0
|
|
||||||
|
|
||||||
/* C1B1E457814417E4-1 */ SELECT SUM(total) FROM test.t WHERE id > 0
|
|
||||||
|
|
||||||
|
|
||||||
# Column value differences
|
|
||||||
# Query ID Column host1 host2
|
|
||||||
# ================== ========== ===== =====
|
|
||||||
# C1B1E457814417E4-1 SUM(total) 14.68 13.68
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# events 1
|
|
@@ -2,10 +2,8 @@ DROP DATABASE IF EXISTS test;
|
|||||||
CREATE DATABASE test;
|
CREATE DATABASE test;
|
||||||
USE test;
|
USE test;
|
||||||
CREATE TABLE t (
|
CREATE TABLE t (
|
||||||
id INT NOT NULL PRIMARY KEY,
|
id int(10) NOT NULL AUTO_INCREMENT,
|
||||||
total DOUBLE NOT NULL
|
username varchar(8) default NULL,
|
||||||
) ENGINE=InnoDB;
|
PRIMARY KEY (`id`)
|
||||||
INSERT INTO test.t VALUES
|
);
|
||||||
(1, 1.23),
|
INSERT INTO t VALUES (1, 'username');
|
||||||
(2, 4.56),
|
|
||||||
(3, 7.89);
|
|
||||||
|
@@ -1,36 +0,0 @@
|
|||||||
|
|
||||||
# Query 1: ID 0xF05C9711D543F5BF at byte 0 _______________________________
|
|
||||||
# host1: 127.1:12345
|
|
||||||
# host2: 127.1:12348
|
|
||||||
# Found 0 differences in 1 samples:
|
|
||||||
# column counts 0
|
|
||||||
# column types 0
|
|
||||||
# column values 0
|
|
||||||
# row counts 0
|
|
||||||
# warning counts 0
|
|
||||||
# warning levels 0
|
|
||||||
# warnings 0
|
|
||||||
# host1 host2
|
|
||||||
# Errors 0 0
|
|
||||||
# Warnings 0 0
|
|
||||||
# Query_time
|
|
||||||
# sum 0 0
|
|
||||||
# min 0 0
|
|
||||||
# max 0 0
|
|
||||||
# avg 0 0
|
|
||||||
# pct_95 0 0
|
|
||||||
# stddev 0 0
|
|
||||||
# median 0 0
|
|
||||||
# row_count
|
|
||||||
# sum 1 1
|
|
||||||
# min 1 1
|
|
||||||
# max 1 1
|
|
||||||
# avg 1 1
|
|
||||||
# pct_95 1 1
|
|
||||||
# stddev 0 0
|
|
||||||
# median 1 1
|
|
||||||
use `test`;
|
|
||||||
SELECT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60, SLEEP(1)
|
|
||||||
|
|
||||||
# Statistics
|
|
||||||
# events 1
|
|
1
t/pt-upgrade/samples/004/select_function.sed
Normal file
1
t/pt-upgrade/samples/004/select_function.sed
Normal file
@@ -0,0 +1 @@
|
|||||||
|
-e 's/< [0-9.]*/< 0/' -e 's/> [0-9.]*/> 0/'
|
34
t/pt-upgrade/samples/004/select_function.txt
Normal file
34
t/pt-upgrade/samples/004/select_function.txt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
########################################################################
|
||||||
|
# Query class F05C9711D543F5BF
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
Reporting class because it has diffs, but hasn't been reported yet.
|
||||||
|
|
||||||
|
Total queries 1
|
||||||
|
Unique queries 1
|
||||||
|
Discarded queries 0
|
||||||
|
|
||||||
|
select (unix_timestamp(now()) ? unix_timestamp(?)) / ?, sleep(?)
|
||||||
|
|
||||||
|
##
|
||||||
|
## Row diffs: 1
|
||||||
|
##
|
||||||
|
|
||||||
|
-- 1.
|
||||||
|
|
||||||
|
@ row 1
|
||||||
|
< 0,0
|
||||||
|
> 0,0
|
||||||
|
|
||||||
|
SELECT (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP('2012-09-16 10:16:36')) / 60, SLEEP(1)
|
||||||
|
|
||||||
|
########################################################################
|
||||||
|
# Stats
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
failed_queries 0
|
||||||
|
queries_filtered 0
|
||||||
|
queries_no_diffs 0
|
||||||
|
queries_read 1
|
||||||
|
queries_with_diffs 1
|
||||||
|
queries_with_errors 0
|
@@ -1,2 +0,0 @@
|
|||||||
DROP DATABASE IF EXISTS test;
|
|
||||||
CREATE DATABASE test;
|
|
Reference in New Issue
Block a user