Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3509a06

Browse files
committed
Refactor routine to find single log content pattern in TAP tests
The same routine to check if a specific pattern can be found in theserver logs was copied over four different test scripts. This refactorsthe whole to use a single routine located in PostgreSQL::Test::Cluster,named log_contains, to grab the contents of the server logs and checkfor a specific pattern.On HEAD, the code previously used assumed that slurp_file() could nothandle an undefined offset, setting it to zero, but slurp_file() doesdo an extra fseek() before retrieving the log contents only if an offsetis defined. In two places, the test was retrieving the full logcontents 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 thatcould rely on the new routine.Author: Vignesh CReviewed-by: Andrew Dunstan, Dagfinn Ilmari Mannsåker, Michael PaquierDiscussion:https://postgr.es/m/CALDaNm0YSiLpjCmajwLfidQrFOrLNKPQir7s__PeVvh9U3uoTQ@mail.gmail.comBackpatch-through: 11
1 parent15b7775 commit3509a06

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

‎src/test/perl/PostgresNode.pm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,21 @@ sub issues_sql_like
19721972

19731973
=pod
19741974
1975+
=item$node->log_contains(pattern, offset)
1976+
1977+
Find pattern in logfile of node after offset byte.
1978+
1979+
=cut
1980+
1981+
sublog_contains
1982+
{
1983+
my ($self,$pattern,$offset) =@_;
1984+
1985+
return TestLib::slurp_file($self->logfile,$offset) =~m/$pattern/;
1986+
}
1987+
1988+
=pod
1989+
19751990
=item$node->run_log(...)
19761991
19771992
Runs a shell command like TestLib::run_log, but with connection parameters set

‎src/test/recovery/t/033_replay_tsp_drops.pl

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,21 +132,11 @@ sub test_tablespace
132132
{
133133
last
134134
if (
135-
find_in_log(
136-
$node_standby,qr!WARNING: ( [A-Z0-9]+:)? creating missing directory: pg_tblspc/!,
135+
$node_standby->log_contains(
136+
qr!WARNING: ( [A-Z0-9]+:)? creating missing directory: pg_tblspc/!,
137137
$logstart));
138138
usleep(100_000);
139139
}
140140
ok($max_attempts > 0,"invalid directory creation is detected");
141141

142142
done_testing();
143-
144-
# find $pat in logfile of $node after $off-th byte
145-
subfind_in_log
146-
{
147-
my ($node,$pat,$off) =@_;
148-
149-
my$log = PostgreSQL::Test::Utils::slurp_file($node->logfile,$off);
150-
151-
return$log =~m/$pat/;
152-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp