Skip to content

Commit d4c9195

Browse files
committed
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
1 parent 3683af6 commit d4c9195

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/perl/PostgreSQL/Test/Cluster.pm

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,32 @@ sub connstr
290290

291291
=pod
292292
293+
=item $node->is_alive()
294+
295+
Check if the node is alive, using pg_isready.
296+
Returns 1 if successful, 0 on failure.
297+
298+
=cut
299+
300+
sub is_alive
301+
{
302+
my ($self) = @_;
303+
local %ENV = $self->_get_env();
304+
305+
my $ret = PostgreSQL::Test::Utils::system_log(
306+
'pg_isready',
307+
'--host' => $self->host,
308+
'--port' => $self->port);
309+
310+
if ($ret != 0)
311+
{
312+
return 0;
313+
}
314+
return 1;
315+
}
316+
317+
=pod
318+
293319
=item $node->raw_connect()
294320
295321
Open a raw TCP or Unix domain socket connection to the server. This is

0 commit comments

Comments
 (0)