Skip to content

Commit 7524c78

Browse files
committed
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
1 parent 927474c commit 7524c78

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

src/bin/pg_rewind/t/001_basic.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use strict;
22
use warnings;
33
use TestLib;
4-
use Test::More tests => 10;
4+
use Test::More tests => 11;
55

66
use FindBin;
77
use lib $FindBin::RealBin;

src/bin/pg_rewind/t/002_databases.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use strict;
22
use warnings;
33
use TestLib;
4-
use Test::More tests => 6;
4+
use Test::More tests => 7;
55

66
use FindBin;
77
use lib $FindBin::RealBin;

src/bin/pg_rewind/t/003_extrafiles.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use strict;
44
use warnings;
55
use TestLib;
6-
use Test::More tests => 4;
6+
use Test::More tests => 5;
77

88
use File::Find;
99

src/bin/pg_rewind/t/004_pg_xlog_symlink.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
else
1616
{
17-
plan tests => 4;
17+
plan tests => 5;
1818
}
1919

2020
use FindBin;

src/bin/pg_rewind/t/RewindTest.pm

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ sub start_master
149149

150150
# Create custom role which is used to run pg_rewind, and adjust its
151151
# permissions to the minimum necessary.
152-
$node_master->psql(
152+
$node_master->safe_psql(
153153
'postgres', "
154154
CREATE ROLE rewind_user LOGIN;
155155
GRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean)
@@ -266,9 +266,19 @@ sub run_pg_rewind
266266
[
267267
'pg_rewind', "--debug",
268268
"--source-server", $standby_connstr,
269-
"--target-pgdata=$master_pgdata", "--no-sync"
269+
"--target-pgdata=$master_pgdata", "-R",
270+
"--no-sync"
270271
],
271272
'pg_rewind remote');
273+
274+
# Check that standby.signal has been created.
275+
ok(-e "$master_pgdata/standby.signal");
276+
277+
# Now, when pg_rewind apparently succeeded with minimal permissions,
278+
# add REPLICATION privilege. So we could test that new standby
279+
# is able to connect to the new master with generated config.
280+
$node_standby->safe_psql('postgres',
281+
"ALTER ROLE rewind_user WITH REPLICATION;");
272282
}
273283
else
274284
{
@@ -289,13 +299,15 @@ sub run_pg_rewind
289299
"unable to set permissions for $master_pgdata/postgresql.conf");
290300

291301
# Plug-in rewound node to the now-promoted standby node
292-
my $port_standby = $node_standby->port;
293-
$node_master->append_conf(
294-
'postgresql.conf', qq(
295-
primary_conninfo='port=$port_standby'
296-
));
302+
if ($test_mode ne "remote")
303+
{
304+
my $port_standby = $node_standby->port;
305+
$node_master->append_conf(
306+
'postgresql.conf', qq(
307+
primary_conninfo='port=$port_standby'));
297308

298-
$node_master->set_standby_mode();
309+
$node_master->set_standby_mode();
310+
}
299311

300312
# Restart the master to check that rewind went correctly
301313
$node_master->start;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy