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

Commit5c8b14a

Browse files
committed
Backpatch addition of wait_for_log(), pump_until().
These were originally introduced ina2ab9c0 anda2ab9c0, as they areneeded by a about-to-be-backpatched test.Discussion:https://postgr.es/m/20220413002626.udl7lll7f3o7nre7@alap3.anarazel.deBackpatch: 10-14
1 parent09b6846 commit5c8b14a

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

‎src/test/perl/PostgreSQL/Test/Utils.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ our @EXPORT = qw(
2626
system_log
2727
run_log
2828
run_command
29+
pump_until
2930
3031
command_ok
3132
command_fails

‎src/test/perl/PostgresNode.pm

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,41 @@ sub wait_for_slot_catchup
20752075

20762076
=pod
20772077
2078+
=item$node->wait_for_log(regexp, offset)
2079+
2080+
Waits for the contents of the server log file, starting at the given offset, to
2081+
match the supplied regular expression. Checks the entire log if no offset is
2082+
given. Times out after $TestLib::timeout_default seconds.
2083+
2084+
If successful, returns the length of the entire log file, in bytes.
2085+
2086+
=cut
2087+
2088+
subwait_for_log
2089+
{
2090+
my ($self,$regexp,$offset) =@_;
2091+
$offset = 0unlessdefined$offset;
2092+
2093+
my$max_attempts = 10 *$TestLib::timeout_default;
2094+
my$attempts = 0;
2095+
2096+
while ($attempts <$max_attempts)
2097+
{
2098+
my$log = TestLib::slurp_file($self->logfile,$offset);
2099+
2100+
return$offset+length($log)if ($log =~m/$regexp/);
2101+
2102+
# Wait 0.1 second before retrying.
2103+
usleep(100_000);
2104+
2105+
$attempts++;
2106+
}
2107+
2108+
croak"timed out waiting for match:$regexp";
2109+
}
2110+
2111+
=pod
2112+
20782113
=item$node->query_hash($dbname, $query, @columns)
20792114
20802115
Execute $query on $dbname, replacing any appearance of the string __COLUMNS__

‎src/test/perl/TestLib.pm

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ our @EXPORT = qw(
3737
system_log
3838
run_log
3939
run_command
40+
pump_until
4041
4142
command_ok
4243
command_fails
@@ -251,6 +252,36 @@ sub run_command
251252
return ($stdout,$stderr);
252253
}
253254

255+
=pod
256+
257+
=itempump_until(proc, timeout, stream, until)
258+
259+
Pump until string is matched on the specified stream, or timeout occurs.
260+
261+
=cut
262+
263+
subpump_until
264+
{
265+
my ($proc,$timeout,$stream,$until) =@_;
266+
$proc->pump_nb();
267+
while (1)
268+
{
269+
lastif$$stream =~/$until/;
270+
if ($timeout->is_expired)
271+
{
272+
diag("pump_until: timeout expired when searching for\"$until\" with stream:\"$$stream\"");
273+
return 0;
274+
}
275+
if (not$proc->pumpable())
276+
{
277+
diag("pump_until: process terminated unexpectedly when searching for\"$until\" with stream:\"$$stream\"");
278+
return 0;
279+
}
280+
$proc->pump();
281+
}
282+
return 1;
283+
}
284+
254285
# Generate a string made of the given range of ASCII characters
255286
subgenerate_ascii_string
256287
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp