diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2015-04-13 18:06:12 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2015-04-13 18:09:20 +0300 |
commit | 53ba10770a315361770efdc17d2c01f6a30e3e3d (patch) | |
tree | d83ec6d70e8e25f920dc22818833b59d31e9b62f /src/bin/pg_rewind/RewindTest.pm | |
parent | b2a5545bd63fc94a71b1e97ecdd03c605d97a438 (diff) |
Refactor and fix TAP tests of pg_rewind
* Don't pass arguments to prove, since that's not supported on perl 5.8
which is the minimum version supported by the TAP tests. Refactor the
test files themselves to run the tests twice, in both local and remote mode.
* Use eq rather than == for string comparison. This thinko caused the remote
versions of the tests to never run.
* Add "use strict" and "use warnings", and fix warnings that that produced.
* Increase the delay after standby promotion, to make the tests more robust.
* In remote mode, the connection string to the promoted standby was
incorrect, leading to connection errors.
Patch by Michael Paquier, to address Peter Eisentraut's report.
Diffstat (limited to 'src/bin/pg_rewind/RewindTest.pm')
-rw-r--r-- | src/bin/pg_rewind/RewindTest.pm | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/bin/pg_rewind/RewindTest.pm b/src/bin/pg_rewind/RewindTest.pm index 0f8f4ca7ce0..7a20e79be8b 100644 --- a/src/bin/pg_rewind/RewindTest.pm +++ b/src/bin/pg_rewind/RewindTest.pm @@ -29,6 +29,9 @@ package RewindTest; # master and standby servers. The data directories are also available # in paths $test_master_datadir and $test_standby_datadir +use strict; +use warnings; + use TestLib; use Test::More; @@ -58,8 +61,8 @@ our @EXPORT = qw( # Adjust these paths for your environment my $testroot = "./tmp_check"; -$test_master_datadir="$testroot/data_master"; -$test_standby_datadir="$testroot/data_standby"; +our $test_master_datadir="$testroot/data_master"; +our $test_standby_datadir="$testroot/data_standby"; mkdir $testroot; @@ -73,8 +76,8 @@ my $port_standby=$port_master + 1; my $log_path; my $tempdir_short; -$connstr_master="port=$port_master"; -$connstr_standby="port=$port_standby"; +my $connstr_master="port=$port_master"; +my $connstr_standby="port=$port_standby"; $ENV{PGDATABASE} = "postgres"; @@ -127,7 +130,8 @@ sub append_to_file sub init_rewind_test { - ($testname, $test_mode) = @_; + my $testname = shift; + my $test_mode = shift; $log_path="regress_log/pg_rewind_log_${testname}_${test_mode}"; @@ -195,11 +199,13 @@ sub promote_standby # Now promote slave and insert some new data on master, this will put # the master out-of-sync with the standby. system_or_bail("pg_ctl -w -D $test_standby_datadir promote >>$log_path 2>&1"); - sleep 1; + sleep 2; } sub run_pg_rewind { + my $test_mode = shift; + # Stop the master and be ready to perform the rewind system_or_bail("pg_ctl -w -D $test_master_datadir stop -m fast >>$log_path 2>&1"); @@ -212,7 +218,7 @@ sub run_pg_rewind # overwritten during the rewind. copy("$test_master_datadir/postgresql.conf", "$testroot/master-postgresql.conf.tmp"); # Now run pg_rewind - if ($test_mode == "local") + if ($test_mode eq "local") { # Do rewind using a local pgdata as source # Stop the master and be ready to perform the rewind @@ -225,12 +231,12 @@ sub run_pg_rewind '>>', $log_path, '2>&1'); ok ($result, 'pg_rewind local'); } - elsif ($test_mode == "remote") + elsif ($test_mode eq "remote") { # Do rewind using a remote connection as source my $result = run(['./pg_rewind', - "--source-server=\"port=$port_standby dbname=postgres\"", + "--source-server", "port=$port_standby dbname=postgres", "--target-pgdata=$test_master_datadir"], '>>', $log_path, '2>&1'); ok ($result, 'pg_rewind remote'); |