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

Commit12f327b

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 parentb7374f1 commit12f327b

File tree

7 files changed

+399
-244
lines changed

7 files changed

+399
-244
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
@@ -4,7 +4,6 @@
44
use PostgresNode;
55
use TestLib;
66
use Test::More;
7-
use IPC::Runqw(pump finish timer);
87
use Data::Dumper;
98

109
# Do nothing unless Makefile has told us that the build is --with-readline.
@@ -86,14 +85,7 @@
8685
close$FH;
8786

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

9890
# Simple test case: type something and see if psql responds as expected
9991
subcheck_completion
@@ -103,15 +95,12 @@ sub check_completion
10395
# report test failures from caller location
10496
local$Test::Builder::Level =$Test::Builder::Level + 1;
10597

106-
# reset output collector
107-
$out ="";
10898
# restart per-command timer
109-
$timer->start($TestLib::timeout_default);
110-
# send the data to be sent
111-
$in .=$send;
112-
# wait ...
113-
pump$huntil ($out =~$pattern ||$timer->is_expired);
114-
my$okay = ($out =~$pattern && !$timer->is_expired);
99+
$h->{timeout}->start($PostgreSQL::Test::Utils::timeout_default);
100+
101+
# send the data to be sent and wait for its result
102+
my$out =$h->query_until($pattern,$send);
103+
my$okay = ($out =~$pattern && !$h->{timeout}->is_expired);
115104
ok($okay,$annotation);
116105
# for debugging, log actual output if it didn't match
117106
local$Data::Dumper::Terse = 1;
@@ -232,10 +221,7 @@ sub clear_line
232221
clear_line();
233222

234223
# send psql an explicit \q to shut it down, else pty won't close properly
235-
$timer->start($TestLib::timeout_default);
236-
$in .="\\q\n";
237-
finish$hordie"psql returned$?";
238-
$timer->reset;
224+
$h->quitordie"psql returned$?";
239225

240226
# done
241227
$node->stop;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp