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

Commitcaa6c1f

Browse files
committed
TAP tests for target_session_attrs connection parameter.
Michael Paquier
1 parent9d1fb11 commitcaa6c1f

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

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

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use warnings;
44
use PostgresNode;
55
use TestLib;
6-
use Test::Moretests=>24;
6+
use Test::Moretests=>28;
77

88
# Initialize master node
99
my$node_master = get_new_node('master');
@@ -59,6 +59,54 @@
5959
is($node_standby_2->psql('postgres','INSERT INTO tab_int VALUES (1)'),
6060
3,'read-only queries on standby 2');
6161

62+
# Tests for connection parameter target_session_attrs
63+
diag"testing connection parameter\"target_session_attrs\"";
64+
65+
# Routine designed to run tests on the connection parameter
66+
# target_session_attrs with multiple nodes.
67+
subtest_target_session_attrs
68+
{
69+
my$node1 =shift;
70+
my$node2 =shift;
71+
my$target_node =shift;
72+
my$mode =shift;
73+
my$status =shift;
74+
75+
my$node1_host =$node1->host;
76+
my$node1_port =$node1->port;
77+
my$node1_name =$node1->name;
78+
my$node2_host =$node2->host;
79+
my$node2_port =$node2->port;
80+
my$node2_name =$node2->name;
81+
82+
my$target_name =$target_node->name;
83+
84+
# Build connection string for connection attempt.
85+
my$connstr ="host=$node1_host,$node2_host";
86+
$connstr .="port=$node1_port,$node2_port";
87+
$connstr .="target_session_attrs=$mode";
88+
89+
# The client used for the connection does not matter, only the backend
90+
# point does.
91+
my ($ret,$stdout,$stderr) =
92+
$node1->psql('postgres','SHOW port;',extra_params=> ['-d',$connstr]);
93+
is($status ==$ret &&$stdouteq$target_node->port, 1,
94+
"connect to node$target_name if mode\"$mode\" and$node1_name,$node2_name listed");
95+
}
96+
97+
# Connect to master in "read-write" mode with master,standby1 list.
98+
test_target_session_attrs($node_master,$node_standby_1,$node_master,
99+
"read-write", 0);
100+
# Connect to master in "read-write" mode with standby1,master list.
101+
test_target_session_attrs($node_standby_1,$node_master,$node_master,
102+
"read-write", 0);
103+
# Connect to master in "any" mode with master,standby1 list.
104+
test_target_session_attrs($node_master,$node_standby_1,$node_master,
105+
"any", 0);
106+
# Connect to standby1 in "any" mode with standby1,master list.
107+
test_target_session_attrs($node_standby_1,$node_master,$node_standby_1,
108+
"any", 0);
109+
62110
diag"switching to physical replication slot";
63111
# Switch to using a physical replication slot. We can do this without a new
64112
# backup since physical slots can go backwards if needed. Do so on both

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp