mirror of
https://github.com/postgres/postgres.git
synced 2025-06-22 02:52:08 +03:00
Introduce PG_TEST_TIMEOUT_DEFAULT for TAP suite non-elapsing timeouts.
Slow hosts may avoid load-induced, spurious failures by setting environment variable PG_TEST_TIMEOUT_DEFAULT to some number of seconds greater than 180. Developers may see faster failures by setting that environment variable to some lesser number of seconds. In tests, write $PostgreSQL::Test::Utils::timeout_default wherever the convention has been to write 180. This change raises the default for some briefer timeouts. Back-patch to v10 (all supported versions). Discussion: https://postgr.es/m/20220218052842.GA3627003@rfd.leadboat.com
This commit is contained in:
@ -31,7 +31,8 @@ PostgresNode - class representing PostgreSQL server instance
|
||||
my ($stdout, $stderr, $timed_out);
|
||||
my $cmdret = $node->psql('postgres', 'SELECT pg_sleep(600)',
|
||||
stdout => \$stdout, stderr => \$stderr,
|
||||
timeout => 180, timed_out => \$timed_out,
|
||||
timeout => $TestLib::timeout_default,
|
||||
timed_out => \$timed_out,
|
||||
extra_params => ['--single-transaction'],
|
||||
on_error_die => 1)
|
||||
print "Sleep timed out" if $timed_out;
|
||||
@ -1363,7 +1364,8 @@ e.g.
|
||||
my ($stdout, $stderr, $timed_out);
|
||||
my $cmdret = $node->psql('postgres', 'SELECT pg_sleep(600)',
|
||||
stdout => \$stdout, stderr => \$stderr,
|
||||
timeout => 180, timed_out => \$timed_out,
|
||||
timeout => $TestLib::timeout_default,
|
||||
timed_out => \$timed_out,
|
||||
extra_params => ['--single-transaction'])
|
||||
|
||||
will set $cmdret to undef and $timed_out to a true value.
|
||||
@ -1520,7 +1522,8 @@ scalar reference. This allows the caller to act on other parts of the system
|
||||
while idling this backend.
|
||||
|
||||
The specified timer object is attached to the harness, as well. It's caller's
|
||||
responsibility to select the timeout length, and to restart the timer after
|
||||
responsibility to set the timeout length (usually
|
||||
$TestLib::timeout_default), and to restart the timer after
|
||||
each command if the timeout is per-command.
|
||||
|
||||
psql is invoked in tuples-only unaligned mode with reading of B<.psqlrc>
|
||||
@ -1741,7 +1744,7 @@ sub background_pgbench
|
||||
Run B<$query> repeatedly, until it returns the B<$expected> result
|
||||
('t', or SQL boolean true, by default).
|
||||
Continues polling if B<psql> returns an error result.
|
||||
Times out after 180 seconds.
|
||||
Times out after $TestLib::timeout_default seconds.
|
||||
Returns 1 if successful, 0 if timed out.
|
||||
|
||||
=cut
|
||||
@ -1754,7 +1757,7 @@ sub poll_query_until
|
||||
|
||||
my $cmd = [ 'psql', '-XAt', '-d', $self->connstr($dbname) ];
|
||||
my ($stdout, $stderr);
|
||||
my $max_attempts = 180 * 10;
|
||||
my $max_attempts = 10 * $TestLib::timeout_default;
|
||||
my $attempts = 0;
|
||||
|
||||
while ($attempts < $max_attempts)
|
||||
@ -1776,8 +1779,8 @@ sub poll_query_until
|
||||
$attempts++;
|
||||
}
|
||||
|
||||
# The query result didn't change in 180 seconds. Give up. Print the
|
||||
# output from the last attempt, hopefully that's useful for debugging.
|
||||
# Give up. Print the output from the last attempt, hopefully that's useful
|
||||
# for debugging.
|
||||
diag qq(poll_query_until timed out executing this query:
|
||||
$query
|
||||
expecting this output:
|
||||
|
Reference in New Issue
Block a user