On 27.09.2019 6:27, Paul Guo wrote:
Secondarily, I see no reason to test connstr_source rather than just "conn" in the other patch; doing it the other way is more natural, since it's that thing that's tested as an argument. pg_rewind.c: Please put the new #include line keeping the alphabetical order. Agreed to the above suggestions. I attached the v9.
I went through the remaining two patches and they seem to be very clear and concise. However, there are two points I could complain about:
1) Maybe I've missed it somewhere in the thread above, but currently pg_rewind allows to run itself with -R and --source-pgdata. In that case -R option is just swallowed and neither standby.signal, nor postgresql.auto.conf is written, which is reasonable though. Should it be stated somehow in the docs that -R option always has to go altogether with --source-server? Or should pg_rewind notify user that options are incompatible and no recovery configuration will be written?
2) Are you going to leave -R option completely without tap-tests? Attached is a small patch, which tests -R option along with the existing 'remote' case. If needed it may be split into two separate cases. First, it tests that pg_rewind is able to succeed with minimal permissions according to the Michael's patch d9f543e [1]. Next, it checks presence of standby.signal and adds REPLICATION permission to rewind_user to test that new standby is able to start with generated recovery configuration.
[1] https://github.com/postgres/postgres/commit/d9f543e9e9be15f92abdeaf870e57ef289020191
Regards -- Alexey Kondratov Postgres Professional https://www.postgrespro.com Russian Postgres Company
>From 8c607794f259cd4dec0fa6172b69d62e6468bee3 Mon Sep 17 00:00:00 2001 From: Alexey Kondratov <kondratov.alek...@gmail.com> Date: Fri, 27 Sep 2019 14:30:57 +0300 Subject: [PATCH v9 3/3] Test new standby start with generated config during pg_rewind remote --- src/bin/pg_rewind/t/001_basic.pl | 2 +- src/bin/pg_rewind/t/002_databases.pl | 2 +- src/bin/pg_rewind/t/003_extrafiles.pl | 2 +- src/bin/pg_rewind/t/004_pg_xlog_symlink.pl | 2 +- src/bin/pg_rewind/t/RewindTest.pm | 11 ++++++++++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_rewind/t/001_basic.pl b/src/bin/pg_rewind/t/001_basic.pl index 115192170e..c3293e93df 100644 --- a/src/bin/pg_rewind/t/001_basic.pl +++ b/src/bin/pg_rewind/t/001_basic.pl @@ -1,7 +1,7 @@ use strict; use warnings; use TestLib; -use Test::More tests => 10; +use Test::More tests => 11; use FindBin; use lib $FindBin::RealBin; diff --git a/src/bin/pg_rewind/t/002_databases.pl b/src/bin/pg_rewind/t/002_databases.pl index f1eb4fe1d2..1db534c0dc 100644 --- a/src/bin/pg_rewind/t/002_databases.pl +++ b/src/bin/pg_rewind/t/002_databases.pl @@ -1,7 +1,7 @@ use strict; use warnings; use TestLib; -use Test::More tests => 6; +use Test::More tests => 7; use FindBin; use lib $FindBin::RealBin; diff --git a/src/bin/pg_rewind/t/003_extrafiles.pl b/src/bin/pg_rewind/t/003_extrafiles.pl index c4040bd562..f4710440fc 100644 --- a/src/bin/pg_rewind/t/003_extrafiles.pl +++ b/src/bin/pg_rewind/t/003_extrafiles.pl @@ -3,7 +3,7 @@ use strict; use warnings; use TestLib; -use Test::More tests => 4; +use Test::More tests => 5; use File::Find; diff --git a/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl b/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl index ed1ddb6b60..639eeb9c91 100644 --- a/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl +++ b/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl @@ -14,7 +14,7 @@ if ($windows_os) } else { - plan tests => 4; + plan tests => 5; } use FindBin; diff --git a/src/bin/pg_rewind/t/RewindTest.pm b/src/bin/pg_rewind/t/RewindTest.pm index 68b6004e94..fcc48cb1d9 100644 --- a/src/bin/pg_rewind/t/RewindTest.pm +++ b/src/bin/pg_rewind/t/RewindTest.pm @@ -266,9 +266,18 @@ sub run_pg_rewind [ 'pg_rewind', "--debug", "--source-server", $standby_connstr, - "--target-pgdata=$master_pgdata", "--no-sync" + "--target-pgdata=$master_pgdata", "-R", "--no-sync" ], '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->psql( + 'postgres', "ALTER ROLE rewind_user WITH REPLICATION;"); } else { -- 2.17.1