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

Commit412e755

Browse files
committed
tap tests clean-up: don't use immediate stop, logs on bail_out, clean syntax warnings
1 parentf64864a commit412e755

File tree

4 files changed

+38
-21
lines changed

4 files changed

+38
-21
lines changed

‎Cluster.pm

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,10 @@ sub stopid
164164
return stopnode($self->{nodes}->[$idx]);
165165
}
166166

167-
substop
167+
subdumplogs
168168
{
169-
my ($self,$mode) =@_;
169+
my ($self) =@_;
170170
my$nodes =$self->{nodes};
171-
$mode ='fast'unlessdefined$mode;
172171

173172
diag("Dumping logs:");
174173
foreachmy$node (@$nodes) {
@@ -181,6 +180,15 @@ sub stop
181180
diag($data);
182181
diag("##################################################################\n\n");
183182
}
183+
}
184+
185+
substop
186+
{
187+
my ($self,$mode) =@_;
188+
my$nodes =$self->{nodes};
189+
$mode ='fast'unlessdefined$mode;
190+
191+
# $self->dumplogs();
184192

185193
my$ok = 1;
186194
diag("stopping cluster${mode}ly");
@@ -198,6 +206,13 @@ sub stop
198206
return$ok;
199207
}
200208

209+
subbail_out_with_logs
210+
{
211+
my ($self,$msg) =@_;
212+
$self->dumplogs();
213+
BAIL_OUT($msg);
214+
}
215+
201216
subteardown
202217
{
203218
my ($self) =@_;

‎t/001_basic_recovery.pl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# Wait until nodes are up
1414
###############################################################################
1515

16+
my$ret;
1617
my$psql_out;
1718
# XXX: create extension on start and poll_untill status is Online
1819
sleep(10);
@@ -39,32 +40,29 @@
3940
###############################################################################
4041

4142
diag("stopping node 2");
42-
if ($cluster->stopid(2,'immediate')) {
43-
pass("node 2 stops");
43+
if ($cluster->stopid(2,'fast')) {
44+
pass("node 2 stops in fast mode");
4445
}else {
45-
fail("node 2 stops");
46-
if (!$cluster->stopid(2,'kill')) {
47-
my$name =$cluster->{nodes}->[2]->name;
48-
BAIL_OUT("failed to kill$name");
49-
}
46+
my$name =$cluster->{nodes}->[2]->name;
47+
$cluster->bail_out_with_logs("failed to stop$name in fast mode");
5048
}
5149

5250
sleep(5);# Wait until failure of node will be detected
5351

5452
diag("inserting 2 on node 0");
55-
my$ret =$cluster->psql(0,'postgres',"insert into t values(2, 20);");# this transaciton may fail
53+
$ret =$cluster->psql(0,'postgres',"insert into t values(2, 20);");# this transaciton may fail
5654
diag"tx1 status =$ret";
5755

5856
diag("inserting 3 on node 1");
59-
my$ret =$cluster->psql(1,'postgres',"insert into t values(3, 30);");# this transaciton may fail
57+
$ret =$cluster->psql(1,'postgres',"insert into t values(3, 30);");# this transaciton may fail
6058
diag"tx2 status =$ret";
6159

6260
diag("inserting 4 on node 0 (can fail)");
63-
my$ret =$cluster->psql(0,'postgres',"insert into t values(4, 40);");
61+
$ret =$cluster->psql(0,'postgres',"insert into t values(4, 40);");
6462
diag"tx1 status =$ret";
6563

6664
diag("inserting 5 on node 1 (can fail)");
67-
my$ret =$cluster->psql(1,'postgres',"insert into t values(5, 50);");
65+
$ret =$cluster->psql(1,'postgres',"insert into t values(5, 50);");
6866
diag"tx2 status =$ret";
6967

7068
diag("selecting");

‎t/002_cross.pl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
diag("preparing the tables");
2525
if ($cluster->psql(0,'postgres',"create table t (k int primary key, v int)"))
2626
{
27-
BAIL_OUT('failed to create t');
27+
$cluster->bail_out_with_logs('failed to create t');
2828
}
2929

3030
if ($cluster->psql(0,'postgres',"insert into t (select generate_series(0,$nkeys - 1), 0)"))
3131
{
32-
BAIL_OUT('failed to fill t');
32+
$cluster->bail_out_with_logs('failed to fill t');
3333
}
3434

3535
subappender
@@ -145,7 +145,11 @@ sub parse_state
145145
diag("finishing benches");
146146
foreachmy$appender (@appenders)
147147
{
148-
finish($appender) || BAIL_OUT("pgbench exited with$?");
148+
if (!finish($appender))
149+
{
150+
$cluster->dumplogs();
151+
$cluster->bail_out_with_logs("pgbench exited with$?");
152+
}
149153
}
150154

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

‎t/003_pgbench.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
diag("preparing the tables");
2323
if ($cluster->psql(0,'postgres',"create table t (k int primary key, v int)"))
2424
{
25-
BAIL_OUT('failed to create t');
25+
$cluster->bail_out_with_logs('failed to create t');
2626
}
2727

2828
if ($cluster->psql(0,'postgres',"insert into t (select generate_series(0, 999), 0)"))
2929
{
30-
BAIL_OUT('failed to fill t');
30+
$cluster->bail_out_with_logs('failed to fill t');
3131
}
3232

3333
if ($cluster->psql(0,'postgres',"create table reader_log (v int)"))
3434
{
35-
BAIL_OUT('failed to create reader_log');
35+
$cluster->bail_out_with_logs('failed to create reader_log');
3636
}
3737

3838
subreader
@@ -98,7 +98,7 @@ sub writer
9898
diag("finishing benches");
9999
foreachmy$bench (@benches)
100100
{
101-
finish($bench) ||BAIL_OUT("pgbench exited with$?");
101+
finish($bench) ||$cluster->bail_out_with_logs("pgbench exited with$?");
102102
}
103103
diag($out);
104104

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp