diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl index fa7427af8c58..c391c3b3be5b 100644 --- a/src/bin/psql/t/010_tab_completion.pl +++ b/src/bin/psql/t/010_tab_completion.pl @@ -77,8 +77,10 @@ # for possible debugging purposes. my $historyfile = "${PostgreSQL::Test::Utils::log_path}/010_psql_history.txt"; -# fire up an interactive psql session +# fire up an interactive psql session and configure it such that each query +# restarts the timer my $h = $node->interactive_psql('postgres', history_file => $historyfile); +$h->set_query_timer_restart(); # Simple test case: type something and see if psql responds as expected sub check_completion @@ -88,9 +90,6 @@ sub check_completion # report test failures from caller location local $Test::Builder::Level = $Test::Builder::Level + 1; - # restart per-command timer - $h->{timeout}->start($PostgreSQL::Test::Utils::timeout_default); - # send the data to be sent and wait for its result my $out = $h->query_until($pattern, $send); my $okay = ($out =~ $pattern && !$h->{timeout}->is_expired); diff --git a/src/test/modules/test_misc/t/005_timeouts.pl b/src/test/modules/test_misc/t/005_timeouts.pl index cdce2afd9356..5478d3394d1b 100644 --- a/src/test/modules/test_misc/t/005_timeouts.pl +++ b/src/test/modules/test_misc/t/005_timeouts.pl @@ -118,11 +118,7 @@ # We just initialize the GUC and wait. No transaction is required. $psql_session = $node->background_psql('postgres'); -$psql_session->query_until( - qr/starting_bg_psql/, q( - \echo starting_bg_psql - SET idle_session_timeout to '10ms'; -)); +$psql_session->query(q(SET idle_session_timeout to '10ms';)); # Wait until the backend enters the timeout injection point. $node->wait_for_event('client backend', 'idle-session-timeout'); diff --git a/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm b/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm index 60bbd5dd445b..af7d0892c10a 100644 --- a/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm +++ b/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm @@ -100,7 +100,7 @@ sub new "Forbidden caller of constructor: package: $package, file: $file:$line" unless $package->isa('PostgreSQL::Test::Cluster'); - $psql->{timeout} = IPC::Run::timeout( + $psql->{timeout} = IPC::Run::timer( defined($timeout) ? $timeout : $PostgreSQL::Test::Utils::timeout_default); @@ -179,8 +179,10 @@ sub wait_connect =item $session->quit -Close the session and clean up resources. Each test run must be closed with -C. +Close the psql session and clean up resources. Each psql session must be +closed with C before the end of the test. Returns TRUE if psql exited +successfully (i.e. with zero exit code), otherwise returns FALSE and reports +a test failure. =cut @@ -190,7 +192,9 @@ sub quit $self->{stdin} .= "\\q\n"; - return $self->{run}->finish; + my $ret = $self->{run}->finish; + ok($ret, 'Terminating interactive psql session'); + return $ret; } =pod @@ -274,7 +278,8 @@ sub query $self->{run}, $self->{timeout}, \$self->{stderr}, qr/$banner_match/); - die "psql query timed out" if $self->{timeout}->is_expired; + ok(!$self->{timeout}->is_expired, 'psql query timed out') || return; + $output = $self->{stdout}; note "results query $query_cnt:\n", explain { @@ -342,7 +347,8 @@ sub query_until pump_until($self->{run}, $self->{timeout}, \$self->{stdout}, $until); - die "psql query timed out" if $self->{timeout}->is_expired; + ok(!$self->{timeout}->is_expired, 'psql query_until did not time out') + || return; $ret = $self->{stdout}; diff --git a/src/test/recovery/t/031_recovery_conflict.pl b/src/test/recovery/t/031_recovery_conflict.pl index 028b0b5f0e15..965537d1f975 100644 --- a/src/test/recovery/t/031_recovery_conflict.pl +++ b/src/test/recovery/t/031_recovery_conflict.pl @@ -253,7 +253,7 @@ -- wait for lock held by prepared transaction SELECT * FROM $table2; ]); -ok(1, +isnt($res, undef, "$sect: cursor holding conflicting pin, also waiting for lock, established" );