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

Commit31877cd

Browse files
committed
Backport BackgroundPsql perl test module
Backport the new BackgroundPsql modules and the constructor functions,background_psql() and interactive_psql, to all supportedbranches. That makes it easier to backpatch tests that use it.BackgroundPsql was introduced in version 16. On version 16, thiscommit backports just the new timeout argument from master (commit334f512). On older branches, the whole facility. This includes thechange to `use warnings FATAL => 'all'`, which we haven't otherwisebackported, but it seems good to keep the file identical acrossbranches.Discussion:https://www.postgresql.org/message-id/b7c64f20-ea01-4f15-9088-0cd6832af149@iki.fi
1 parent4c8e00a commit31877cd

File tree

8 files changed

+405
-258
lines changed

8 files changed

+405
-258
lines changed

‎contrib/amcheck/t/003_cic_2pc.pl‎

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,63 +37,46 @@
3737
# statements.
3838
#
3939

40-
my$main_in ='';
41-
my$main_out ='';
42-
my$main_timer = IPC::Run::timeout($TestLib::timeout_default);
43-
44-
my$main_h =
45-
$node->background_psql('postgres', \$main_in, \$main_out,
46-
$main_timer,on_error_stop=> 1);
47-
$main_in .=q(
40+
my$main_h =$node->background_psql('postgres');
41+
42+
$main_h->query_safe(q(
4843
BEGIN;
4944
INSERT INTO tbl VALUES(0);
50-
\echo syncpoint1
51-
);
52-
pump$main_huntil$main_out =~/syncpoint1/ ||$main_timer->is_expired;
53-
54-
my$cic_in ='';
55-
my$cic_out ='';
56-
my$cic_timer = IPC::Run::timeout($TestLib::timeout_default);
57-
my$cic_h =
58-
$node->background_psql('postgres', \$cic_in, \$cic_out,
59-
$cic_timer,on_error_stop=> 1);
60-
$cic_in .=q(
45+
));
46+
47+
my$cic_h =$node->background_psql('postgres');
48+
49+
$cic_h->query_until(qr/start/,q(
6150
\echo start
6251
CREATE INDEX CONCURRENTLY idx ON tbl(i);
63-
);
64-
pump$cic_huntil$cic_out =~/start/ ||$cic_timer->is_expired;
52+
));
6553

66-
$main_in .=q(
54+
$main_h->query_safe(q(
6755
PREPARE TRANSACTION 'a';
68-
);
56+
));
6957

70-
$main_in .=q(
58+
$main_h->query_safe(q(
7159
BEGIN;
7260
INSERT INTO tbl VALUES(0);
73-
\echo syncpoint2
74-
);
75-
pump$main_huntil$main_out =~/syncpoint2/ ||$main_timer->is_expired;
61+
));
7662

7763
$node->safe_psql('postgres',q(COMMIT PREPARED 'a';));
7864

79-
$main_in .=q(
65+
$main_h->query_safe(q(
8066
PREPARE TRANSACTION 'b';
8167
BEGIN;
8268
INSERT INTO tbl VALUES(0);
83-
\echo syncpoint3
84-
);
85-
pump$main_huntil$main_out =~/syncpoint3/ ||$main_timer->is_expired;
69+
));
8670

8771
$node->safe_psql('postgres',q(COMMIT PREPARED 'b';));
8872

89-
$main_in .=q(
73+
$main_h->query_safe(q(
9074
PREPARE TRANSACTION 'c';
9175
COMMIT PREPARED 'c';
92-
);
93-
$main_h->pump_nb;
76+
));
9477

95-
$main_h->finish;
96-
$cic_h->finish;
78+
$main_h->quit;
79+
$cic_h->quit;
9780

9881
$result =$node->psql('postgres',q(SELECT bt_index_check('idx',true)));
9982
is($result,'0','bt_index_check after overlapping 2PC');
@@ -114,22 +97,15 @@
11497
));
11598
$node->restart;
11699

117-
my$reindex_in ='';
118-
my$reindex_out ='';
119-
my$reindex_timer =
120-
IPC::Run::timeout($TestLib::timeout_default);
121-
my$reindex_h =
122-
$node->background_psql('postgres', \$reindex_in, \$reindex_out,
123-
$reindex_timer,on_error_stop=> 1);
124-
$reindex_in .=q(
100+
my$reindex_h =$node->background_psql('postgres');
101+
$reindex_h->query_until(qr/start/,q(
125102
\echo start
126103
DROP INDEX CONCURRENTLY idx;
127104
CREATE INDEX CONCURRENTLY idx ON tbl(i);
128-
);
129-
pump$reindex_huntil$reindex_out =~/start/ ||$reindex_timer->is_expired;
105+
));
130106

131107
$node->safe_psql('postgres',"COMMIT PREPARED 'spans_restart'");
132-
$reindex_h->finish;
108+
$reindex_h->quit;
133109
$result =$node->psql('postgres',q(SELECT bt_index_check('idx',true)));
134110
is($result,'0','bt_index_check after 2PC and restart');
135111

‎src/bin/psql/t/010_tab_completion.pl‎

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PostgresNode;
88
use TestLib;
99
use Test::More;
10-
use IPC::Runqw(pump finish timer);
1110
use Data::Dumper;
1211

1312
# Do nothing unless Makefile has told us that the build is --with-readline.
@@ -89,14 +88,7 @@
8988
close$FH;
9089

9190
# fire up an interactive psql session
92-
my$in ='';
93-
my$out ='';
94-
95-
my$timer = timer($TestLib::timeout_default);
96-
97-
my$h =$node->interactive_psql('postgres', \$in, \$out,$timer);
98-
99-
like($out,qr/psql/,"print startup banner");
91+
my$h =$node->interactive_psql('postgres');
10092

10193
# Simple test case: type something and see if psql responds as expected
10294
subcheck_completion
@@ -106,15 +98,12 @@ sub check_completion
10698
# report test failures from caller location
10799
local$Test::Builder::Level =$Test::Builder::Level + 1;
108100

109-
# reset output collector
110-
$out ="";
111101
# restart per-command timer
112-
$timer->start($TestLib::timeout_default);
113-
# send the data to be sent
114-
$in .=$send;
115-
# wait ...
116-
pump$huntil ($out =~$pattern ||$timer->is_expired);
117-
my$okay = ($out =~$pattern && !$timer->is_expired);
102+
$h->{timeout}->start($PostgreSQL::Test::Utils::timeout_default);
103+
104+
# send the data to be sent and wait for its result
105+
my$out =$h->query_until($pattern,$send);
106+
my$okay = ($out =~$pattern && !$h->{timeout}->is_expired);
118107
ok($okay,$annotation);
119108
# for debugging, log actual output if it didn't match
120109
local$Data::Dumper::Terse = 1;
@@ -235,10 +224,7 @@ sub clear_line
235224
clear_line();
236225

237226
# send psql an explicit \q to shut it down, else pty won't close properly
238-
$timer->start($TestLib::timeout_default);
239-
$in .="\\q\n";
240-
finish$hordie"psql returned$?";
241-
$timer->reset;
227+
$h->quitordie"psql returned$?";
242228

243229
# done
244230
$node->stop;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp