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

Commit aaa5ee8

Browse files
kvapkelvich
authored andcommitted
Add a check that the cluster stops gracefully, to the tap tests.
1 parent 39bcefa commit aaa5ee8

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

Cluster.pm

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,46 @@ sub start
126126
}
127127
}
128128

129+
sub stopnode
130+
{
131+
my ($node, $mode) = @_;
132+
my $port = $node->port;
133+
my $pgdata = $node->data_dir;
134+
my $name = $node->name;
135+
$mode = 'fast' unless defined $mode;
136+
diag("stopping node $name ${mode}ly at $pgdata port $port");
137+
next unless defined $node->{_pid};
138+
my $ret = TestLib::system_log('pg_ctl', '-D', $pgdata, '-m', 'fast', 'stop');
139+
$node->{_pid} = undef;
140+
$node->_update_pid;
141+
142+
if ($ret != 0) {
143+
diag("$name failed to stop ${mode}ly");
144+
return 0;
145+
}
146+
147+
return 1;
148+
}
149+
129150
sub stop
130151
{
131-
my ($self) = @_;
152+
my ($self, $mode) = @_;
132153
my $nodes = $self->{nodes};
154+
$mode = 'fast' unless defined $mode;
133155

156+
my $ok = 1;
157+
diag("stopping cluster ${mode}ly");
134158
foreach my $node (@$nodes)
135159
{
136-
$node->stop('fast');
160+
if (!stopnode($node, $mode)) {
161+
$ok = 0;
162+
if (!stopnode($node, 'immediate')) {
163+
BAIL_OUT("failed to stop $node immediately");
164+
}
165+
}
137166
}
167+
168+
return $ok;
138169
}
139170

140171
sub teardown

t/000_deadlock.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use Cluster;
55
use TestLib;
6-
use Test::More tests => 1;
6+
use Test::More tests => 2;
77

88
use DBI;
99
use DBD::Pg ':async';
@@ -93,5 +93,5 @@ sub query_exec_async
9393

9494
query_row($conns[0], "select * from t where k = 1");
9595

96-
$cluster->stop();
96+
ok($cluster->stop(), "cluster stops");
9797
1;

t/001_basic_recovery.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use warnings;
33
use Cluster;
44
use TestLib;
5-
use Test::More tests => 7;
5+
use Test::More tests => 8;
66

77
my $cluster = new Cluster(3);
88
$cluster->init();
@@ -108,5 +108,5 @@
108108

109109
is($psql_out, '90', "Check replication after failed node recovery.");
110110

111-
$cluster->stop();
111+
ok($cluster->stop(), "cluster stops");
112112
1;

t/002_cross.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use Cluster;
55
use TestLib;
6-
use Test::More tests => 1;
6+
use Test::More tests => 2;
77
use IPC::Run qw(start finish);
88
use Cwd;
99

@@ -150,5 +150,5 @@ sub parse_state
150150

151151
is($anomalies, 0, "no cross anomalies after $selects selects");
152152

153-
$cluster->stop();
153+
ok($cluster->stop(), "cluster stops");
154154
1;

t/003_pgbench.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use Cluster;
55
use TestLib;
6-
use Test::More tests => 2;
6+
use Test::More tests => 3;
77
use IPC::Run qw(start finish);
88
use Cwd;
99

@@ -110,5 +110,5 @@ sub writer
110110
($rc, $out, $err) = $cluster->psql(0, 'postgres', "select count(*) from reader_log where v = 0;");
111111
isnt($out, 0, "there are some zeros in reader_log");
112112

113-
$cluster->stop();
113+
ok($cluster->stop(), "cluster stops");
114114
1;

0 commit comments

Comments
 (0)