8000 Cleanup some code related to pgbench log checks in TAP tests · postgrespro/postgres@c4c9c77 · GitHub
[go: up one dir, main page]

Skip to content

Commit c4c9c77

Browse files
committed
Cleanup some code related to pgbench log checks in TAP tests
This fixes a couple of problems within the so-said code of this commit subject: - Replace the use of open() with slurp_file(), fixing an issue reported by buildfarm member fairywren whose perl installation keep around CRLF characters, causing the matching patterns for the logs to fail. - Remove the eval block, which is not really necessary. This set of issues has come into light after fixing a different issue with c13585f, and this is wrong since this code has been introduced. Reported-by: Andrew Dunstan, and buildfarm member fairywren Author: Michael Paquier Reviewed-by: Andrew Dunstan Discussion: https://postgr.es/m/0f49303e-7784-b3ee-200b-cbf67be2eb9e@dunslane.net Backpatch-through: 11
1 parent 6ada4fd commit c4c9c77

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/bin/pgbench/t/001_pgbench_with_server.pl

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -834,18 +834,27 @@ sub check_pgbench_logs
834834
my $log_number = 0;
835835
for my $log (sort @logs)
836836
{
837-
eval {
838-
open my $fh, '<', $log or die "$@";
839-
my @contents = <$fh>;
840-
my $clen = @contents;
841-
ok( $min <= $clen && $clen <= $max,
842-
"transaction count for $log ($clen)");
843-
ok( grep(/$re/, @contents) == $clen,
844-
"transaction format for $prefix");
845-
close $fh or die "$@";
846-
};
837+
# Check the contents of each log file.
838+
my $contents_raw = slurp_file($log);
839+
840+
my @contents = split(/\n/, $contents_raw);
841+
my $clen = @contents;
842+
ok( $min <= $clen 8000 && $clen <= $max,
843+
"transaction count for $log ($clen)");
844+
my $clen_match = grep(/$re/, @contents);
845+
ok($clen_match == $clen, "transaction format for $prefix");
846+
847+
# Show more information if some logs don't match
848+
# to help with debugging.
849+
if ($clen_match != $clen)
850+
{
851+
foreach my $log (@contents)
852+
{
853+
print "# Log entry not matching: $log\n"
854+
unless $log =~ /$re/;
855+
}
856+
}
847857
}
848-
ok(unlink(@logs), "remove log files");
849858
return;
850859
}
851860

0 commit comments

Comments
 (0)
0