v5-0001-Have-find_in_log-sub-routine-as-a-common-routine_PG12.patch
text/x-patch
Filename: v5-0001-Have-find_in_log-sub-routine-as-a-common-routine_PG12.patch
Type: text/x-patch
Part: 1
Patch
Format: format-patch
Series: patch v5-0001
Subject: Have find_in_log sub routine as a common routine available for all tap tests.
| File | + | − |
|---|---|---|
| src/test/perl/PostgresNode.pm | 15 | 0 |
| src/test/recovery/t/033_replay_tsp_drops.pl | 2 | 12 |
From 7570e55a9f0121a9e2e0a12f4e8718cc531811c9 Mon Sep 17 00:00:00 2001
From: Vignesh C <vignesh21@gmail.com>
Date: Tue, 6 Jun 2023 17:20:34 +0530
Subject: [PATCH v5] Have find_in_log sub routine as a common routine available
for all tap tests.
Have find_in_log sub routine as a common routine available for all tap
tests.
---
src/test/perl/PostgresNode.pm | 15 +++++++++++++++
src/test/recovery/t/033_replay_tsp_drops.pl | 14 ++------------
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 6506308ff1..8fae4eb1bb 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -1972,6 +1972,21 @@ sub issues_sql_like
=pod
+=item $node->log_contains(pattern, offset)
+
+Find pattern in logfile of node after offset byte.
+
+=cut
+
+sub log_contains
+{
+ my ($self, $pattern, $offset) = @_;
+
+ return TestLib::slurp_file($self->logfile, $offset) =~ m/$pattern/;
+}
+
+=pod
+
=item $node->run_log(...)
Runs a shell command like TestLib::run_log, but with connection parameters set
diff --git a/src/test/recovery/t/033_replay_tsp_drops.pl b/src/test/recovery/t/033_replay_tsp_drops.pl
index 140d94db31..4c8f4e7970 100644
--- a/src/test/recovery/t/033_replay_tsp_drops.pl
+++ b/src/test/recovery/t/033_replay_tsp_drops.pl
@@ -132,21 +132,11 @@ while ($max_attempts-- >= 0)
{
last
if (
- find_in_log(
- $node_standby, qr!WARNING: ( [A-Z0-9]+:)? creating missing directory: pg_tblspc/!,
+ $node_standby->log_contains(
+ qr!WARNING: ( [A-Z0-9]+:)? creating missing directory: pg_tblspc/!,
$logstart));
usleep(100_000);
}
ok($max_attempts > 0, "invalid directory creation is detected");
done_testing();
-
-# find $pat in logfile of $node after $off-th byte
-sub find_in_log
-{
- my ($node, $pat, $off) = @_;
-
- my $log = PostgreSQL::Test::Utils::slurp_file($node->logfile, $off);
-
- return $log =~ m/$pat/;
-}
--
2.34.1