'--no-sync',
"--file=$tempdir/only_dump_test_table.sql",
'--table=dump_test.test_table',
- '--lock-wait-timeout=1000000',
+ '--lock-wait-timeout='
+ . (1000 * $TestLib::timeout_default),
'postgres', ], },
role => {
dump_cmd => [
#
$node = get_new_node('CIC_test');
$node->init;
-$node->append_conf('postgresql.conf', 'lock_timeout = 180000');
+$node->append_conf('postgresql.conf',
+ 'lock_timeout = ' . (1000 * $TestLib::timeout_default));
$node->start;
$node->safe_psql('postgres', q(CREATE TABLE tbl(i int)));
$node->safe_psql('postgres', q(CREATE INDEX idx ON tbl(i)));
# Run background pgbench with CIC. We cannot mix-in this script into single
# pgbench: CIC will deadlock with itself occasionally.
my $pgbench_out = '';
-my $pgbench_timer = IPC::Run::timeout(180);
+my $pgbench_timer = IPC::Run::timeout($TestLib::timeout_default);
my $pgbench_h = $node->background_pgbench(
'--no-vacuum --client=1 --transactions=200',
{
$node = get_new_node('CIC_2PC_test');
$node->init;
$node->append_conf('postgresql.conf', 'max_prepared_transactions = 10');
-$node->append_conf('postgresql.conf', 'lock_timeout = 180000');
+$node->append_conf('postgresql.conf',
+ 'lock_timeout = ' . (1000 * $TestLib::timeout_default));
$node->start;
$node->safe_psql('postgres', q(CREATE TABLE tbl(i int)));
$node->safe_psql(
my $main_in = '';
my $main_out = '';
-my $main_timer = IPC::Run::timeout(180);
+my $main_timer = IPC::Run::timeout($TestLib::timeout_default);
my $main_h =
$node->background_psql('postgres', \$main_in, \$main_out,
my $cic_in = '';
my $cic_out = '';
-my $cic_timer = IPC::Run::timeout(180);
+my $cic_timer = IPC::Run::timeout($TestLib::timeout_default);
my $cic_h =
$node->background_psql('postgres', \$cic_in, \$cic_out,
$cic_timer, on_error_stop => 1);
));
$node->restart;
-my $reindex_in = '';
-my $reindex_out = '';
-my $reindex_timer = IPC::Run::timeout(180);
+my $reindex_in = '';
+my $reindex_out = '';
+my $reindex_timer =
+ IPC::Run::timeout($TestLib::timeout_default);
my $reindex_h =
$node->background_psql('postgres', \$reindex_in, \$reindex_out,
$reindex_timer, on_error_stop => 1);
# Run background pgbench with CIC. We cannot mix-in this script into single
# pgbench: CIC will deadlock with itself occasionally.
my $pgbench_out = '';
-my $pgbench_timer = IPC::Run::timeout(180);
+my $pgbench_timer = IPC::Run::timeout($TestLib::timeout_default);
my $pgbench_h = $node->background_pgbench(
'--no-vacuum --client=1 --transactions=100',
{
$node->init;
$node->start;
-# use a long timeout for the benefit of very slow buildfarm machines
-$node->command_ok([qw(pg_isready --timeout=60)], 'succeeds with server running');
+$node->command_ok(
+ [ 'pg_isready', "--timeout=$TestLib::timeout_default" ],
+ 'succeeds with server running');
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;
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.
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>
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
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)
$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:
$windows_os
);
-our ($windows_os, $tmp_check, $log_path, $test_logfile);
+our ($windows_os, $timeout_default, $tmp_check, $log_path, $test_logfile);
BEGIN
{
require Win32API::File;
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
}
+
+ $timeout_default = $ENV{PG_TEST_TIMEOUT_DEFAULT};
+ $timeout_default = 180
+ if not defined $timeout_default or $timeout_default eq '';
}
INIT
);
my $stdout_recv = $node_master->pg_recvlogical_upto(
- 'postgres', 'test_slot', $endpos, 180,
+ 'postgres', 'test_slot', $endpos, $TestLib::timeout_default,
'include-xids' => '0',
'skip-empty-xacts' => '1');
chomp($stdout_recv);
or die "slot never became inactive";
$stdout_recv = $node_master->pg_recvlogical_upto(
- 'postgres', 'test_slot', $endpos, 180,
+ 'postgres', 'test_slot', $endpos, $TestLib::timeout_default,
'include-xids' => '0',
'skip-empty-xacts' => '1');
chomp($stdout_recv);
($ret, $stdout, $stderr) = $node_replica->psql(
'postgres',
"SELECT data FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');",
- timeout => 180);
+ timeout => $TestLib::timeout_default);
is($ret, 0, 'replay from slot before_basebackup succeeds');
my $final_expected_output_bb = q(BEGIN
$stdout = $node_replica->pg_recvlogical_upto(
'postgres', 'before_basebackup',
- $endpos, 180,
+ $endpos, $TestLib::timeout_default,
'include-xids' => '0',
'skip-empty-xacts' => '1');
\$stdout,
'2>',
\$stderr,
- IPC::Run::timeout(900)); # five times the poll_query_until timeout
+ IPC::Run::timeout(5 * $TestLib::timeout_default));
ok( $gnat->poll_query_until(
'postgres',
"SELECT 1 FROM pg_stat_activity WHERE query = '$slow_query'", '1'),
unlink($gnat->data_dir . '/postmaster.pid');
$gnat->rotate_logfile;
log_ipcs();
-# Reject ordinary startup. Retry for the same reasons poll_start() does.
+# Reject ordinary startup. Retry for the same reasons poll_start() does,
+# every 0.1s for at least $TestLib::timeout_default seconds.
my $pre_existing_msg = qr/pre-existing shared memory block/;
{
- my $max_attempts = 180 * 10; # Retry every 0.1s for at least 180s.
+ my $max_attempts = 10 * $TestLib::timeout_default;
my $attempts = 0;
while ($attempts < $max_attempts)
{
{
my ($node) = @_;
- my $max_attempts = 180 * 10;
+ my $max_attempts = 10 * $TestLib::timeout_default;
my $attempts = 0;
while ($attempts < $max_attempts)
$attempts++;
}
- # No success within 180 seconds. Try one last time without fail_ok, which
- # will BAIL_OUT unless it succeeds.
+ # Try one last time without fail_ok, which will BAIL_OUT unless it
+ # succeeds.
$node->start && return 1;
return 0;
}