1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

Refactor routine to find single log content pattern in TAP tests

The same routine to check if a specific pattern can be found in the
server logs was copied over four different test scripts.  This refactors
the whole to use a single routine located in PostgreSQL::Test::Cluster,
named log_contains, to grab the contents of the server logs and check
for a specific pattern.

On HEAD, the code previously used assumed that slurp_file() could not
handle an undefined offset, setting it to zero, but slurp_file() does
do an extra fseek() before retrieving the log contents only if an offset
is defined.  In two places, the test was retrieving the full log
contents with slurp_file() after calling substr() to apply an offset,
ignoring that slurp_file() would be able to handle that.

Backpatch all the way down to ease the introduction of new tests that
could rely on the new routine.

Author: Vignesh C
Reviewed-by: Andrew Dunstan, Dagfinn Ilmari Mannsåker, Michael Paquier
Discussion: https://postgr.es/m/CALDaNm0YSiLpjCmajwLfidQrFOrLNKPQir7s__PeVvh9U3uoTQ@mail.gmail.com
Backpatch-through: 11
This commit is contained in:
Michael Paquier
2023-06-09 11:56:27 +09:00
parent a83edeaf68
commit 392ea0c78f
5 changed files with 32 additions and 75 deletions

View File

@@ -2547,6 +2547,22 @@ sub log_check
=pod
=item log_contains(pattern, offset)
Find pattern in logfile of node after offset byte.
=cut
sub log_contains
{
my ($self, $pattern, $offset) = @_;
return PostgreSQL::Test::Utils::slurp_file($self->logfile, $offset) =~
m/$pattern/;
}
=pod
=item $node->run_log(...)
Runs a shell command like PostgreSQL::Test::Utils::run_log, but with connection parameters set