Commit 7524c788 authored by Alvaro Herrera's avatar Alvaro Herrera

pg_rewind: test new --write-recovery-conf functionality

Author: Alexey Kondratov
Reviewed-by: Paul Guo
Discussion: https://postgr.es/m/2f726102-3f1e-bf16-061e-501919473ace@postgrespro.ru
parent 927474ce
use strict; use strict;
use warnings; use warnings;
use TestLib; use TestLib;
use Test::More tests => 10; use Test::More tests => 11;
use FindBin; use FindBin;
use lib $FindBin::RealBin; use lib $FindBin::RealBin;
......
use strict; use strict;
use warnings; use warnings;
use TestLib; use TestLib;
use Test::More tests => 6; use Test::More tests => 7;
use FindBin; use FindBin;
use lib $FindBin::RealBin; use lib $FindBin::RealBin;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
use strict; use strict;
use warnings; use warnings;
use TestLib; use TestLib;
use Test::More tests => 4; use Test::More tests => 5;
use File::Find; use File::Find;
......
...@@ -14,7 +14,7 @@ if ($windows_os) ...@@ -14,7 +14,7 @@ if ($windows_os)
} }
else else
{ {
plan tests => 4; plan tests => 5;
} }
use FindBin; use FindBin;
......
...@@ -149,7 +149,7 @@ sub start_master ...@@ -149,7 +149,7 @@ sub start_master
# Create custom role which is used to run pg_rewind, and adjust its # Create custom role which is used to run pg_rewind, and adjust its
# permissions to the minimum necessary. # permissions to the minimum necessary.
$node_master->psql( $node_master->safe_psql(
'postgres', " 'postgres', "
CREATE ROLE rewind_user LOGIN; CREATE ROLE rewind_user LOGIN;
GRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) GRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean)
...@@ -266,9 +266,19 @@ sub run_pg_rewind ...@@ -266,9 +266,19 @@ sub run_pg_rewind
[ [
'pg_rewind', "--debug", 'pg_rewind', "--debug",
"--source-server", $standby_connstr, "--source-server", $standby_connstr,
"--target-pgdata=$master_pgdata", "--no-sync" "--target-pgdata=$master_pgdata", "-R",
"--no-sync"
], ],
'pg_rewind remote'); 'pg_rewind remote');
# Check that standby.signal has been created.
ok(-e "$master_pgdata/standby.signal");
# Now, when pg_rewind apparently succeeded with minimal permissions,
# add REPLICATION privilege. So we could test that new standby
# is able to connect to the new master with generated config.
$node_standby->safe_psql('postgres',
"ALTER ROLE rewind_user WITH REPLICATION;");
} }
else else
{ {
...@@ -289,13 +299,15 @@ sub run_pg_rewind ...@@ -289,13 +299,15 @@ sub run_pg_rewind
"unable to set permissions for $master_pgdata/postgresql.conf"); "unable to set permissions for $master_pgdata/postgresql.conf");
# Plug-in rewound node to the now-promoted standby node # Plug-in rewound node to the now-promoted standby node
my $port_standby = $node_standby->port; if ($test_mode ne "remote")
$node_master->append_conf( {
'postgresql.conf', qq( my $port_standby = $node_standby->port;
primary_conninfo='port=$port_standby' $node_master->append_conf(
)); 'postgresql.conf', qq(
primary_conninfo='port=$port_standby'));
$node_master->set_standby_mode(); $node_master->set_standby_mode();
}
# Restart the master to check that rewind went correctly # Restart the master to check that rewind went correctly
$node_master->start; $node_master->start;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment