diff options
author | Noah Misch <noah@leadboat.com> | 2022-03-04 18:53:13 -0800 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2022-03-04 18:53:17 -0800 |
commit | 8700a487359f121562aa03d36f5f5a61bfc34f8f (patch) | |
tree | a5737f86149d218b9c61834e4be6873b244d8ad0 /src/test/perl/PostgresNode.pm | |
parent | 4b0696b36e5ae4fd1224c03011eadfeb4aa508dd (diff) | |
download | postgresql-8700a487359f121562aa03d36f5f5a61bfc34f8f.tar.gz postgresql-8700a487359f121562aa03d36f5f5a61bfc34f8f.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/PostgresNode.pm')
-rw-r--r-- | src/test/perl/PostgresNode.pm | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index a106ba1cb39..ff6931c0bfb 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -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; @@ -1412,7 +1413,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. @@ -1569,7 +1571,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 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: |