aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-07-19 14:38:52 +0900
committerMichael Paquier <michael@paquier.xyz>2025-07-19 14:38:52 +0900
commitd4c9195eff419dcad47d5c2137e31f790c32adde (patch)
tree63897e59746a428c6d9940a477994040c42a5b46 /src
parent3683af617044d271ab7486d43d06f9689ed4961d (diff)
downloadpostgresql-d4c9195eff419dcad47d5c2137e31f790c32adde.tar.gz
postgresql-d4c9195eff419dcad47d5c2137e31f790c32adde.zip
Add PostgreSQL::Test::Cluster::is_alive()
This new routine acts as a wrapper of pg_isready, that can be run on a node to check its connection status. This will be used in a recovery test in a follow-up commit. Suggested-by: Andres Freund <andres@anarazel.de> Author: Nazir Bilal Yavuz <byavuz81@gmail.com> Discussion: https://postgr.es/m/CAN55FZ1D6KXvjSs7YGsDeadqCxNF3UUhjRAfforzzP0k-cE=bA@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 301766d2ed9..61f68e0cc2e 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -290,6 +290,32 @@ sub connstr
=pod
+=item $node->is_alive()
+
+Check if the node is alive, using pg_isready.
+Returns 1 if successful, 0 on failure.
+
+=cut
+
+sub is_alive
+{
+ my ($self) = @_;
+ local %ENV = $self->_get_env();
+
+ my $ret = PostgreSQL::Test::Utils::system_log(
+ 'pg_isready',
+ '--host' => $self->host,
+ '--port' => $self->port);
+
+ if ($ret != 0)
+ {
+ return 0;
+ }
+ return 1;
+}
+
+=pod
+
=item $node->raw_connect()
Open a raw TCP or Unix domain socket connection to the server. This is