PT-2295 - Fix tests on distributions

- Fixed sporadic pt-tc failures on rolled back SHOW MASTER STATUS code
- Added better diagnostic info for sporadically failing t/pt-table-checksum/basics.t
- Decreased chunk size it t/pt-table-checksum/progress.t, so this test
  has less chances to fail, because pt-osc finishes faster than expected
This commit is contained in:
Sveta Smirnova
2024-02-08 17:06:10 +03:00
parent d07d6c00ff
commit 19baa34872
6 changed files with 43 additions and 20 deletions

View File

@@ -5604,8 +5604,14 @@ sub get_master_status {
return; return;
} }
my $sth = $self->{sths}->{$dbh}->{MASTER_STATUS} my $sth;
if ( $self->{sths}->{$dbh} && $dbh && $self->{sths}->{$dbh} == $dbh ) {
$sth = $self->{sths}->{$dbh}->{MASTER_STATUS}
||= $dbh->prepare('SHOW MASTER STATUS'); ||= $dbh->prepare('SHOW MASTER STATUS');
}
else {
$sth = $dbh->prepare('SHOW MASTER STATUS');
}
PTDEBUG && _d($dbh, 'SHOW MASTER STATUS'); PTDEBUG && _d($dbh, 'SHOW MASTER STATUS');
$sth->execute(); $sth->execute();
my ($ms) = @{$sth->fetchall_arrayref({})}; my ($ms) = @{$sth->fetchall_arrayref({})};

View File

@@ -538,8 +538,14 @@ sub get_master_status {
return; return;
} }
my $sth = $self->{sths}->{$dbh}->{MASTER_STATUS} my $sth;
if ( $self->{sths}->{$dbh} && $dbh && $self->{sths}->{$dbh} == $dbh ) {
$sth = $self->{sths}->{$dbh}->{MASTER_STATUS}
||= $dbh->prepare('SHOW MASTER STATUS'); ||= $dbh->prepare('SHOW MASTER STATUS');
}
else {
$sth = $dbh->prepare('SHOW MASTER STATUS');
}
PTDEBUG && _d($dbh, 'SHOW MASTER STATUS'); PTDEBUG && _d($dbh, 'SHOW MASTER STATUS');
$sth->execute(); $sth->execute();
my ($ms) = @{$sth->fetchall_arrayref({})}; my ($ms) = @{$sth->fetchall_arrayref({})};

View File

@@ -317,6 +317,8 @@ collect_system_data_loop() {
# Sleep between collect cycles. # Sleep between collect cycles.
# Synchronize ourselves onto the clock tick, so the sleeps are 1-second # Synchronize ourselves onto the clock tick, so the sleeps are 1-second
sleep $(date +'%s.%N' | awk "{print $OPT_SLEEP_COLLECT - (\$1 % $OPT_SLEEP_COLLECT)}") sleep $(date +'%s.%N' | awk "{print $OPT_SLEEP_COLLECT - (\$1 % $OPT_SLEEP_COLLECT)}")
log "In collect_system_data_loop"
log $(date +'%s.%N' | awk "{print $OPT_SLEEP_COLLECT - (\$1 % $OPT_SLEEP_COLLECT)}")
ts="$(date +"TS %s.%N %F %T")" ts="$(date +"TS %s.%N %F %T")"
# ##################################################################### # #####################################################################

View File

@@ -173,6 +173,25 @@ parse_options "$BIN_DIR/pt-stalk" --run-time 2 -- --defaults-file=/tmp/12345/my.
rm $PT_TMPDIR/collect/* rm $PT_TMPDIR/collect/*
collect "$PT_TMPDIR/collect" "2011_12_05" > $p-output 2>&1
cat $p-output
iters=$(cat $p-df | grep -c '^TS ')
is "$iters" "2" "2 iteration/2s run time"
if [ -f "$p-vmstat" ]; then
n=$(awk '/[ ]*[0-9]/ { n += 1 } END { print n }' "$p-vmstat")
is \
"$n" \
"2" \
"vmstat runs for --run-time seconds (bug 955860)"
else
is "1" "1" "SKIP vmstat not installed"
fi
rm $PT_TMPDIR/collect/*
fake_opcontrol="$PT_TMPDIR/collect/fake_opcontrol" fake_opcontrol="$PT_TMPDIR/collect/fake_opcontrol"
fake_out="$PT_TMPDIR/collect/pt-faked-opcontrol-out" fake_out="$PT_TMPDIR/collect/pt-faked-opcontrol-out"
cat <<FAKE_EXEC > "$fake_opcontrol" cat <<FAKE_EXEC > "$fake_opcontrol"
@@ -192,25 +211,13 @@ collect "$PT_TMPDIR/collect" "2011_12_05" > $p-output 2>&1
CMD_OPCONTROL="" CMD_OPCONTROL=""
OPT_COLLECT_OPROFILE="" OPT_COLLECT_OPROFILE=""
cat $p-df | grep -c '^TS '
iters=$(cat $p-df | grep -c '^TS ')
is "$iters" "2" "2 iteration/2s run time"
is \ is \
"$(cat "$fake_out")" \ "$(cat "$fake_out")" \
"Faked opcontrol: --init" \ "Faked opcontrol: --init" \
"Bug 986847: Can manually set which commands pt-stalk uses" "Bug 986847: Can manually set which commands pt-stalk uses"
if [ -f "$p-vmstat" ]; then
n=$(awk '/[ ]*[0-9]/ { n += 1 } END { print n }' "$p-vmstat")
is \
"$n" \
"2" \
"vmstat runs for --run-time seconds (bug 955860)"
else
is "1" "1" "SKIP vmstat not installed"
fi
# ############################################################################ # ############################################################################
# Done # Done
# ############################################################################ # ############################################################################
rm $PT_TMPDIR/collect/*

View File

@@ -85,16 +85,18 @@ sub reset_repl_db {
# So we will re-run failed code if test does not pass. # So we will re-run failed code if test does not pass.
my $cmd = sub { pt_table_checksum::main(@args) }; my $cmd = sub { pt_table_checksum::main(@args) };
diag(output($cmd)) if not ok( #diag(output($cmd))
ok(
no_diff( no_diff(
$cmd, $cmd,
"$sample/default-results-$sandbox_version.txt", "$sample/default-results-$sandbox_version.txt",
sed_out => '\'/mysql.plugin$/d; /percona_test.checksums$/d; /mysql.help_category$/d; /mysql.help_keyword$/d; /mysql.help_relation$/d; /mysql.help_topic$/d\'', sed_out => '\'/mysql.plugin$/d; /percona_test.checksums$/d; /mysql.help_category$/d; /mysql.help_keyword$/d; /mysql.help_relation$/d; /mysql.help_topic$/d\'',
post_pipe => 'sed \'/mysql.plugin$/d; /percona_test.checksums$/d; /mysql.help_category$/d; /mysql.help_keyword$/d; /mysql.help_relation$/d; /mysql.help_topic$/d; /mysql.ndb_binlog_index$/d; /mysql.global_grants$/d\' | ' . post_pipe => 'sed \'/mysql.plugin$/d; /percona_test.checksums$/d; /mysql.help_category$/d; /mysql.help_keyword$/d; /mysql.help_relation$/d; /mysql.help_topic$/d; /mysql.ndb_binlog_index$/d; /mysql.global_grants$/d\' | ' .
'awk \'{print $2 " " $3 " " $4 " " $7 " " $9}\'', 'awk \'{print $2 " " $3 " " $4 " " $7 " " $9}\'',
keep_ouput => 1,
), ),
"Default checksum" "Default checksum"
); ) or diag($test_diff);
# On fast machines, the chunk size will probably be be auto-adjusted so # On fast machines, the chunk size will probably be be auto-adjusted so
# large that all tables will be done in a single chunk without an index. # large that all tables will be done in a single chunk without an index.

View File

@@ -48,7 +48,7 @@ else {
# worse. This is a random stab in the dark. There is a problem either way.) # worse. This is a random stab in the dark. There is a problem either way.)
my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox'; my $master_dsn = 'h=127.1,P=12345,u=msandbox,p=msandbox';
my @args = ($master_dsn, qw(--set-vars innodb_lock_wait_timeout=3), my @args = ($master_dsn, qw(--set-vars innodb_lock_wait_timeout=3),
'--chunk-size', '200'); '--chunk-size', '50');
my $output; my $output;
my $row; my $row;
my $scripts = "$trunk/t/pt-table-checksum/scripts/"; my $scripts = "$trunk/t/pt-table-checksum/scripts/";
@@ -83,7 +83,7 @@ like(
$output, $output,
qr/Replica h=127.0.0.1,P=12347 is stopped/, qr/Replica h=127.0.0.1,P=12347 is stopped/,
"--progress for slave lag" "--progress for slave lag"
); ) or diag($output);
like( like(
$output, $output,