1
+
1
2
=pod
2
3
3
4
=head1 NAME
@@ -106,18 +107,15 @@ of finding port numbers, registering instances for cleanup, etc.
106
107
107
108
sub new
108
109
{
109
- my $class = shift ;
110
- my $name = shift ;
111
- my $pghost = shift ;
112
- my $pgport = shift ;
110
+ my ($class , $name , $pghost , $pgport ) = @_ ;
113
111
my $testname = basename($0 );
114
112
$testname =~ s /\. [^.]+$// ;
115
- my $self = {
116
- _port => $pgport ,
117
- _host => $pghost ,
118
- _basedir => TestLib::tempdir(" data_" . $name ),
119
- _name => $name ,
120
- _logfile => " $TestLib::log_path /${testname} _${name} .log" };
113
+ my $self = {
114
+ _port => $pgport ,
115
+ _host => $pghost ,
116
+ _basedir => TestLib::tempdir(" data_" . $name ),
117
+ _name => $name ,
118
+ _logfile => " $TestLib::log_path /${testname} _${name} .log" };
121
119
122
120
bless $self , $class ;
123
121
$self -> dump_info;
@@ -367,7 +365,7 @@ sub init
367
365
$params {hba_permit_replication } = 1
368
366
unless defined $params {hba_permit_replication };
369
367
$params {allows_streaming } = 0 unless defined $params {allows_streaming };
370
- $params {has_archiving } = 0 unless defined $params {has_archiving };
368
+ $params {has_archiving } = 0 unless defined $params {has_archiving };
371
369
372
370
mkdir $self -> backup_dir;
373
371
mkdir $self -> archive_dir;
@@ -405,7 +403,7 @@ sub init
405
403
close $conf ;
406
404
407
405
$self -> set_replication_conf if $params {hba_permit_replication };
408
- $self -> enable_archiving if $params {has_archiving };
406
+ $self -> enable_archiving if $params {has_archiving };
409
407
}
410
408
411
409
=pod
@@ -492,7 +490,7 @@ sub init_from_backup
492
490
493
491
$params {has_streaming } = 0 unless defined $params {has_streaming };
494
492
$params {hba_permit_replication } = 1
495
- unless defined $params {hba_permit_replication };
493
+ unless defined $params {hba_permit_replication };
496
494
$params {has_restoring } = 0 unless defined $params {has_restoring };
497
495
498
496
print
@@ -514,7 +512,7 @@ sub init_from_backup
514
512
qq(
515
513
port = $port
516
514
) );
517
- $self -> set_replication_conf if $params {hba_permit_replication };
515
+ $self -> set_replication_conf if $params {hba_permit_replication };
518
516
$self -> enable_streaming($root_node ) if $params {has_streaming };
519
517
$self -> enable_restoring($root_node ) if $params {has_restoring };
520
518
}
@@ -607,19 +605,19 @@ sub promote
607
605
my $logfile = $self -> logfile;
608
606
my $name = $self -> name;
609
607
print " ### Promoting node \" $name \"\n " ;
610
- TestLib::system_log(' pg_ctl' , ' -D' , $pgdata , ' -l' , $logfile ,
611
- ' promote' );
608
+ TestLib::system_log(' pg_ctl' , ' -D' , $pgdata , ' -l' , $logfile , ' promote' );
612
609
}
613
610
614
611
# Internal routine to enable streaming replication on a standby node.
615
612
sub enable_streaming
616
613
{
617
- my ($self , $root_node ) = @_ ;
614
+ my ($self , $root_node ) = @_ ;
618
615
my $root_connstr = $root_node -> connstr;
619
- my $name = $self -> name;
616
+ my $name = $self -> name;
620
617
621
618
print " ### Enabling streaming replication for node \" $name \"\n " ;
622
- $self -> append_conf(' recovery.conf' , qq(
619
+ $self -> append_conf(
620
+ ' recovery.conf' , qq(
623
621
primary_conninfo='$root_connstr application_name=$name '
624
622
standby_mode=on
625
623
) );
@@ -628,7 +626,7 @@ standby_mode=on
628
626
# Internal routine to enable archive recovery command on a standby node
629
627
sub enable_restoring
630
628
{
631
- my ($self , $root_node ) = @_ ;
629
+ my ($self , $root_node ) = @_ ;
632
630
my $path = $root_node -> archive_dir;
633
631
my $name = $self -> name;
634
632
@@ -641,11 +639,13 @@ sub enable_restoring
641
639
# first. Paths also need to be double-quoted to prevent failures where
642
640
# the path contains spaces.
643
641
$path =~ s {\\ } { \\\\ } g if ($TestLib::windows_os );
644
- my $copy_command = $TestLib::windows_os ?
645
- qq{ copy "$path \\\\ %f " "%p "} :
646
- qq{ cp $path /%f %p } ;
642
+ my $copy_command =
643
+ $TestLib::windows_os
644
+ ? qq{ copy "$path \\\\ %f " "%p "}
645
+ : qq{ cp $path /%f %p } ;
647
646
648
- $self -> append_conf(' recovery.conf' , qq(
647
+ $self -> append_conf(
648
+ ' recovery.conf' , qq(
649
649
restore_command = '$copy_command '
650
650
standby_mode = on
651
651
) );
@@ -667,12 +667,14 @@ sub enable_archiving
667
667
# first. Paths also need to be double-quoted to prevent failures where
668
668
# the path contains spaces.
669
669
$path =~ s {\\ } { \\\\ } g if ($TestLib::windows_os );
670
- my $copy_command = $TestLib::windows_os ?
671
- qq{ copy "%p " "$path \\\\ %f "} :
672
- qq{ cp %p $path /%f } ;
670
+ my $copy_command =
671
+ $TestLib::windows_os
672
+ ? qq{ copy "%p " "$path \\\\ %f "}
673
+ : qq{ cp %p $path /%f } ;
673
674
674
675
# Enable archive_mode and archive_command on node
675
- $self -> append_conf(' postgresql.conf' , qq(
676
+ $self -> append_conf(
677
+ ' postgresql.conf' , qq(
676
678
archive_mode = on
677
679
archive_command = '$copy_command '
678
680
) );
0 commit comments