aboutsummaryrefslogtreecommitdiff
path: root/src/test/perl/PostgreSQL/Test/Cluster.pm
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2022-03-04 18:53:13 -0800
committerNoah Misch <noah@leadboat.com>2022-03-04 18:53:13 -0800
commitf2698ea02ca8a56f38935d2b300ac54936712558 (patch)
treefa031ce71f9acf7327c3898e708682838fe210a4 /src/test/perl/PostgreSQL/Test/Cluster.pm
parent9240589798e02705dbe3e86549d064988c0f47d2 (diff)
downloadpostgresql-f2698ea02ca8a56f38935d2b300ac54936712558.tar.gz
postgresql-f2698ea02ca8a56f38935d2b300ac54936712558.zip
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
Diffstat (limited to 'src/test/perl/PostgreSQL/Test/Cluster.pm')
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index be05845248a..4db52bc9367 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -36,7 +36,8 @@ PostgreSQL::Test::Cluster - 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 => $PostgreSQL::Test::Utils::timeout_default,
+ timed_out => \$timed_out,
extra_params => ['--single-transaction'],
on_error_die => 1)
print "Sleep timed out" if $timed_out;
@@ -1723,7 +1724,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 => $PostgreSQL::Test::Utils::timeout_default,
+ timed_out => \$timed_out,
extra_params => ['--single-transaction'])
will set $cmdret to undef and $timed_out to a true value.
@@ -1897,7 +1899,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
+$PostgreSQL::Test::Utils::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>
@@ -1985,9 +1988,10 @@ The process's stdin is sourced from the $stdin scalar reference,
and its stdout and stderr go to the $stdout scalar reference.
ptys are used so that psql thinks it's being called interactively.
-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 each command if the timeout is per-command.
+The specified timer object is attached to the harness, as well. It's caller's
+responsibility to set the timeout length (usually
+$PostgreSQL::Test::Utils::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>
disabled. That may be overridden by passing extra psql parameters.
@@ -2303,7 +2307,7 @@ sub connect_fails
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 $PostgreSQL::Test::Utils::timeout_default seconds.
Returns 1 if successful, 0 if timed out.
=cut
@@ -2321,7 +2325,7 @@ sub poll_query_until
'-d', $self->connstr($dbname)
];
my ($stdout, $stderr);
- my $max_attempts = 180 * 10;
+ my $max_attempts = 10 * $PostgreSQL::Test::Utils::timeout_default;
my $attempts = 0;
while ($attempts < $max_attempts)
@@ -2343,8 +2347,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:
@@ -2657,7 +2661,7 @@ sub wait_for_slot_catchup
Waits for the contents of the server log file, starting at the given offset, to
match the supplied regular expression. Checks the entire log if no offset is
-given. Times out after 180 seconds.
+given. Times out after $PostgreSQL::Test::Utils::timeout_default seconds.
If successful, returns the length of the entire log file, in bytes.
@@ -2668,7 +2672,7 @@ sub wait_for_log
my ($self, $regexp, $offset) = @_;
$offset = 0 unless defined $offset;
- my $max_attempts = 180 * 10;
+ my $max_attempts = 10 * $PostgreSQL::Test::Utils::timeout_default;
my $attempts = 0;
while ($attempts < $max_attempts)
@@ -2683,7 +2687,6 @@ sub wait_for_log
$attempts++;
}
- # The logs didn't match within 180 seconds. Give up.
croak "timed out waiting for match: $regexp";
}