diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/recovery/t/001_stream_rep.pl | 82 |
1 files changed, 74 insertions, 8 deletions
diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl index 9e31a53de7..07a9912ce2 100644 --- a/src/test/recovery/t/001_stream_rep.pl +++ b/src/test/recovery/t/001_stream_rep.pl @@ -3,7 +3,7 @@ use strict; use warnings; use PostgresNode; use TestLib; -use Test::More tests => 36; +use Test::More tests => 49; # Initialize primary node my $node_primary = get_new_node('primary'); @@ -85,7 +85,7 @@ sub test_target_session_attrs my $node2_port = $node2->port; my $node2_name = $node2->name; - my $target_name = $target_node->name; + my $target_name = $target_node->name if (defined $target_node); # Build connection string for connection attempt. my $connstr = "host=$node1_host,$node2_host "; @@ -97,10 +97,25 @@ sub test_target_session_attrs my ($ret, $stdout, $stderr) = $node1->psql('postgres', 'SHOW port;', extra_params => [ '-d', $connstr ]); - is( $status == $ret && $stdout eq $target_node->port, - 1, - "connect to node $target_name if mode \"$mode\" and $node1_name,$node2_name listed" - ); + if ($status == 0) + { + is( $status == $ret && $stdout eq $target_node->port, + 1, + "connect to node $target_name if mode \"$mode\" and $node1_name,$node2_name listed" + ); + } + else + { + print "status = $status\n"; + print "ret = $ret\n"; + print "stdout = $stdout\n"; + print "stderr = $stderr\n"; + + is( $status == $ret, + 1, + "fail to connect to any nodes if mode \"$mode\" and $node1_name,$node2_name listed" + ); + } return; } @@ -114,13 +129,64 @@ test_target_session_attrs($node_standby_1, $node_primary, $node_primary, "read-write", 0); # Connect to primary in "any" mode with primary,standby1 list. -test_target_session_attrs($node_primary, $node_standby_1, $node_primary, "any", - 0); +test_target_session_attrs($node_primary, $node_standby_1, $node_primary, + "any", 0); # Connect to standby1 in "any" mode with standby1,primary list. test_target_session_attrs($node_standby_1, $node_primary, $node_standby_1, "any", 0); +# Connect to primary in "primary" mode with primary,standby1 list. +test_target_session_attrs($node_primary, $node_standby_1, $node_primary, + "primary", 0); + +# Connect to primary in "primary" mode with standby1,primary list. +test_target_session_attrs($node_standby_1, $node_primary, $node_primary, + "primary", 0); + +# Connect to standby1 in "read-only" mode with primary,standby1 list. +test_target_session_attrs($node_primary, $node_standby_1, $node_standby_1, + "read-only", 0); + +# Connect to standby1 in "read-only" mode with standby1,primary list. +test_target_session_attrs($node_standby_1, $node_primary, $node_standby_1, + "read-only", 0); + +# Connect to primary in "prefer-standby" mode with primary,primary list. +test_target_session_attrs($node_primary, $node_primary, $node_primary, + "prefer-standby", 0); + +# Connect to standby1 in "prefer-standby" mode with primary,standby1 list. +test_target_session_attrs($node_primary, $node_standby_1, $node_standby_1, + "prefer-standby", 0); + +# Connect to standby1 in "prefer-standby" mode with standby1,primary list. +test_target_session_attrs($node_standby_1, $node_primary, $node_standby_1, + "prefer-standby", 0); + +# Connect to standby1 in "standby" mode with primary,standby1 list. +test_target_session_attrs($node_primary, $node_standby_1, $node_standby_1, + "standby", 0); + +# Connect to standby1 in "standby" mode with standby1,primary list. +test_target_session_attrs($node_standby_1, $node_primary, $node_standby_1, + "standby", 0); + +# Fail to connect in "read-write" mode with standby1,standby2 list. +test_target_session_attrs($node_standby_1, $node_standby_2, undef, + "read-write", 2); + +# Fail to connect in "primary" mode with standby1,standby2 list. +test_target_session_attrs($node_standby_1, $node_standby_2, undef, + "primary", 2); + +# Fail to connect in "read-only" mode with primary,primary list. +test_target_session_attrs($node_primary, $node_primary, undef, + "read-only", 2); + +# Fail to connect in "standby" mode with primary,primary list. +test_target_session_attrs($node_primary, $node_primary, undef, "standby", 2); + # Test for SHOW commands using a WAL sender connection with a replication # role. note "testing SHOW commands for replication connection"; |
