Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3846761

Browse files
kvapkelvich
authored andcommitted
Implement cluster killing in tap tests.
1 parentacd3a72 commit3846761

File tree

5 files changed

+52
-7
lines changed

5 files changed

+52
-7
lines changed

‎Cluster.pm

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package Cluster;
33
use strict;
44
use warnings;
55

6+
use Proc::ProcessTable;
67
use PostgresNode;
78
use TestLib;
89
use Test::More;
@@ -135,7 +136,12 @@ sub stopnode
135136
$mode ='fast'unlessdefined$mode;
136137
diag("stopping node$name${mode}ly at$pgdata port$port");
137138
nextunlessdefined$node->{_pid};
138-
my$ret = TestLib::system_log('pg_ctl','-D',$pgdata,'-m','fast','stop');
139+
my$ret = 0;
140+
if ($modeeq'kill') {
141+
killtree($node->{_pid});
142+
}else {
143+
$ret = TestLib::system_log('pg_ctl','-D',$pgdata,'-m','fast','stop');
144+
}
139145
$node->{_pid} =undef;
140146
$node->_update_pid;
141147

@@ -147,6 +153,45 @@ sub stopnode
147153
return 1;
148154
}
149155

156+
subkilltree
157+
{
158+
my$root =shift;
159+
diag("killtree$root\n");
160+
161+
my$t = new Proc::ProcessTable;
162+
163+
my%parent = ();
164+
#my %cmd = ();
165+
foreachmy$p (@{$t->table}) {
166+
$parent{$p->pid} =$p->ppid;
167+
#$cmd{$p->pid} = $p->cmndline;
168+
}
169+
170+
if (!defined$root) {
171+
return;
172+
}
173+
my@queue = ($root);
174+
my@killist = ();
175+
176+
while (scalar@queue) {
177+
my$victim =shift@queue;
178+
while (my ($pid,$ppid) =each%parent) {
179+
if ($ppid ==$victim) {
180+
push@queue,$pid;
181+
}
182+
}
183+
diag("SIGSTOP to$victim");
184+
kill'STOP',$victim;
185+
unshift@killist,$victim;
186+
}
187+
188+
diag("SIGKILL to" .join('',@killist));
189+
kill'KILL',@killist;
190+
#foreach my $victim (@killist) {
191+
#print("kill $victim " . $cmd{$victim} . "\n");
192+
#}
193+
}
194+
150195
substop
151196
{
152197
my ($self,$mode) =@_;
@@ -155,8 +200,8 @@ sub stop
155200

156201
my$ok = 1;
157202
diag("stopping cluster${mode}ly");
158-
foreachmy$node (@$nodes)
159-
{
203+
204+
foreachmy$node (@$nodes){
160205
if (!stopnode($node,$mode)) {
161206
$ok = 0;
162207
if (!stopnode($node,'immediate')) {

‎t/000_deadlock.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ sub query_exec_async
9393

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

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

‎t/001_basic_recovery.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@
108108

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

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

‎t/002_cross.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ sub parse_state
150150

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

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

‎t/003_pgbench.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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-
ok($cluster->stop(),"cluster stops");
113+
ok($cluster->stop('kill'),"cluster stops");
114114
1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp