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

Commit3769e11

Browse files
committed
Make test_target_session_attrs more robust against connection failure.
Feed the desired command to psql via "-c" not stdin, else Perlmay complain that it can't push stdin to an already-failed psqlprocess, as seen in intermittent buildfarm failures.Make some minor cosmetic improvements while at it.Before commitee28cac we had no tests here that expected failureto connect, so there seems no need for a back-patch.Discussion:https://postgr.es/m/CALDaNm2mo8YED=M2ZJKGf1U3F3mw6SaQuLXWCK8rZP6sECYcrA@mail.gmail.com
1 parentf06b1c5 commit3769e11

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

‎src/test/recovery/t/001_stream_rep.pl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
# Tests for connection parameter target_session_attrs
6969
note"testing connection parameter\"target_session_attrs\"";
7070

71-
#Routine designedtorun tests on the connection parameter
72-
#target_session_attrswithmultiple nodes.
71+
#Attempttoconnect to $node1, then $node2, using target_session_attrs=$mode.
72+
#Expect to connect to $target_node (undef for failure)withgiven $status.
7373
subtest_target_session_attrs
7474
{
7575
my$node1 =shift;
@@ -84,7 +84,8 @@ sub test_target_session_attrs
8484
my$node2_host =$node2->host;
8585
my$node2_port =$node2->port;
8686
my$node2_name =$node2->name;
87-
87+
my$target_port =undef;
88+
$target_port =$target_node->portif (defined$target_node);
8889
my$target_name =undef;
8990
$target_name =$target_node->nameif (defined$target_node);
9091

@@ -93,16 +94,18 @@ sub test_target_session_attrs
9394
$connstr .="port=$node1_port,$node2_port";
9495
$connstr .="target_session_attrs=$mode";
9596

96-
# The client used for the connection does not matter, only the backend
97-
# point does.
97+
# Attempt to connect, and if successful, get the server port number
98+
# we connected to. Note we must pass the SQL command via the command
99+
# line not stdin, else Perl may spit up trying to write to stdin of
100+
# an already-failed psql process.
98101
my ($ret,$stdout,$stderr) =
99-
$node1->psql('postgres','SHOW port;',
100-
extra_params=> ['-d',$connstr ]);
102+
$node1->psql('postgres',undef,
103+
extra_params=> ['-d',$connstr,'-c','SHOW port;' ]);
101104
if ($status == 0)
102105
{
103-
is($status ==$ret &&$stdouteq$target_node->port,
106+
is($status ==$ret &&$stdouteq$target_port,
104107
1,
105-
"connect to node$target_nameif mode\"$mode\" and$node1_name,$node2_name listed"
108+
"connect to node$target_namewith mode\"$mode\" and$node1_name,$node2_name listed"
106109
);
107110
}
108111
else
@@ -112,9 +115,9 @@ sub test_target_session_attrs
112115
print"stdout =$stdout\n";
113116
print"stderr =$stderr\n";
114117

115-
is($status ==$ret,
118+
is($status ==$ret && !defined$target_node,
116119
1,
117-
"fail to connectto any nodes if mode\"$mode\" and$node1_name,$node2_name listed"
120+
"fail to connectwith mode\"$mode\" and$node1_name,$node2_name listed"
118121
);
119122
}
120123

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp