summaryrefslogtreecommitdiff
path: root/src/test/perl/PostgresNode.pm
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2025-02-19 09:41:08 -0500
committerAndres Freund <andres@anarazel.de>2025-02-19 10:11:35 -0500
commit6af51bf05a6afd8e10ef53c1c87de3906e2532a9 (patch)
tree1e16476a30410320ea0892974d31ea620e848038 /src/test/perl/PostgresNode.pm
parent3c562b58c20ee3301f87a61a92096c42469e63a3 (diff)
backport: Extend background_psql() to be able to start asynchronously
This is a backport of ba08edb0654. Originally it was only applied to master, but I (Andres) am planning to fix a few bugs in BackgroundPsql, which would be somewhat harder with the behavioural differences across branches. It's also generally good for test infrastructure to behave similarly across branches, to avoid pain during backpatching. Discussion: https://postgr.es/m/ilcctzb5ju2gulvnadjmhgatnkxsdpac652byb2u3d3wqziyvx@fbuqcglker46 Michael's original commit message: This commit extends the constructor routine of BackgroundPsql.pm with a new "wait" parameter. If set to 0, the routine returns without waiting for psql to start, ready to consume input. background_psql() in Cluster.pm gains the same "wait" parameter. The default behavior is still to wait for psql to start. It becomes now possible to not wait, giving to TAP scripts the possibility to perform actions between a BackgroundPsql startup and its wait_connect() call. Author: Jacob Champion Discussion: https://postgr.es/m/CAOYmi+=60deN20WDyCoHCiecgivJxr=98s7s7-C8SkXwrCfHXg@mail.gmail.com
Diffstat (limited to 'src/test/perl/PostgresNode.pm')
-rw-r--r--src/test/perl/PostgresNode.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index a7abfed589a..5ba26782ceb 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -1714,6 +1714,12 @@ connection.
If given, it must be an array reference containing additional parameters to B<psql>.
+=item wait => 1
+
+By default, this method will not return until connection has completed (or
+failed). Set B<wait> to 0 to return immediately instead. (Clients can call the
+session's C<wait_connect> method manually when needed.)
+
=back
=cut
@@ -1738,13 +1744,15 @@ sub background_psql
'-');
$params{on_error_stop} = 1 unless defined $params{on_error_stop};
+ $params{wait} = 1 unless defined $params{wait};
$timeout = $params{timeout} if defined $params{timeout};
push @psql_params, '-v', 'ON_ERROR_STOP=1' if $params{on_error_stop};
push @psql_params, @{ $params{extra_params} }
if defined $params{extra_params};
- return PostgreSQL::Test::BackgroundPsql->new(0, \@psql_params, $timeout);
+ return PostgreSQL::Test::BackgroundPsql->new(0, \@psql_params, $timeout,
+ $params{wait});
}
=pod