aboutsummaryrefslogtreecommitdiff
path: root/src/test/perl/PostgreSQL/Test/Cluster.pm
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2022-10-19 17:09:51 +0200
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2022-10-19 17:09:51 +0200
commit460c0076e8de6233eee53f4d6c175b04d8d41de9 (patch)
treeed8a632c90e96176ddf374622158a3e547c761d4 /src/test/perl/PostgreSQL/Test/Cluster.pm
parent342bb38bfeb099c5f8aa8f44a7e18f2dc21f1ecd (diff)
downloadpostgresql-460c0076e8de6233eee53f4d6c175b04d8d41de9.tar.gz
postgresql-460c0076e8de6233eee53f4d6c175b04d8d41de9.zip
Better handle interrupting TAP tests
Set up a signal handler for INT/TERM so that we run our END block if we get them. In END, if the exit status indicates a problem, call _update_pid(-1) to improve chances of the stop working in case start() hasn't returned yet. Also, change END's teardown_node() so that it passes fail_ok=>1, so that if a node fails to stop, we still stop the other nodes in the same test. Per complaint from Andres Freund. This doesn't seem important enough to backpatch, at least for now. Discussion: https://postgr.es/m/20220930040734.mbted42oiynhn2t6@awork3.anarazel.de
Diffstat (limited to 'src/test/perl/PostgreSQL/Test/Cluster.pm')
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index d7c13318b0f..d80134b26f3 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -1545,7 +1545,14 @@ END
foreach my $node (@all_nodes)
{
- $node->teardown_node;
+ # During unclean termination (which could be a signal or some
+ # other failure), we're not sure that the status of our nodes
+ # has been correctly set up already, so try and update it to
+ # improve our chances of shutting them down.
+ $node->_update_pid(-1) if $exit_code != 0;
+
+ # If that fails, don't let that foil other nodes' shutdown
+ $node->teardown_node(fail_ok => 1);
# skip clean if we are requested to retain the basedir
next if defined $ENV{'PG_TEST_NOCLEAN'};
@@ -1564,13 +1571,15 @@ END
Do an immediate stop of the node
+Any optional extra parameter is passed to ->stop.
+
=cut
sub teardown_node
{
- my $self = shift;
+ my ($self, %params) = @_;
- $self->stop('immediate');
+ $self->stop('immediate', %params);
return;
}
@@ -2922,6 +2931,13 @@ sub corrupt_page_checksum
return;
}
+#
+# Signal handlers
+#
+$SIG{TERM} = $SIG{INT} = sub {
+ die "death by signal";
+};
+
=pod
=back