Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 460c007

Browse files
committed
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
1 parent 342bb38 commit 460c007

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

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

+19-3
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,14 @@ END
15451545

15461546
foreach my $node (@all_nodes)
15471547
{
1548-
$node->teardown_node;
1548+
# During unclean termination (which could be a signal or some
1549+
# other failure), we're not sure that the status of our nodes
1550+
# has been correctly set up already, so try and update it to
1551+
# improve our chances of shutting them down.
1552+
$node->_update_pid(-1) if $exit_code != 0;
1553+
1554+
# If that fails, don't let that foil other nodes' shutdown
1555+
$node->teardown_node(fail_ok => 1);
15491556

15501557
# skip clean if we are requested to retain the basedir
15511558
next if defined $ENV{'PG_TEST_NOCLEAN'};
@@ -1564,13 +1571,15 @@ END
15641571
15651572
Do an immediate stop of the node
15661573
1574+
Any optional extra parameter is passed to ->stop.
1575+
15671576
=cut
15681577

15691578
sub teardown_node
15701579
{
1571-
my $self = shift;
1580+
my ($self, %params) = @_;
15721581

1573-
$self->stop('immediate');
1582+
$self->stop('immediate', %params);
15741583
return;
15751584
}
15761585

@@ -2922,6 +2931,13 @@ sub corrupt_page_checksum
29222931
return;
29232932
}
29242933

2934+
#
2935+
# Signal handlers
2936+
#
2937+
$SIG{TERM} = $SIG{INT} = sub {
2938+
die "death by signal";
2939+
};
2940+
29252941
=pod
29262942
29272943
=back

0 commit comments

Comments
 (0)