pgsql: Refactor routine to find single log content pattern in TAP tests

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Refactor routine to find single log content pattern in TAP tests
Date: 2023-06-09 02:57:20
Message-ID: E1q7SJU-000rW2-9a@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e25e5f7fc6b74c9d4ce82627e9145ef5537412e2

Modified Files
--------------
src/test/perl/PostgreSQL/Test/Cluster.pm | 15 ++++++++++++++
src/test/recovery/t/019_replslot_limit.pl | 31 ++++++-----------------------
src/test/recovery/t/033_replay_tsp_drops.pl | 14 ++-----------
3 files changed, 23 insertions(+), 37 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2023-06-09 02:57:21 pgsql: Refactor routine to find single log content pattern in TAP tests
Previous Message Masahiko Sawada 2023-06-09 01:44:12 pgsql: Honor run_as_owner option in tablesync worker.