aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_rewind/t/002_databases.pl
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-04-13 18:06:12 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-04-13 18:09:20 +0300
commit53ba10770a315361770efdc17d2c01f6a30e3e3d (patch)
treed83ec6d70e8e25f920dc22818833b59d31e9b62f /src/bin/pg_rewind/t/002_databases.pl
parentb2a5545bd63fc94a71b1e97ecdd03c605d97a438 (diff)
downloadpostgresql-53ba10770a315361770efdc17d2c01f6a30e3e3d.tar.gz
postgresql-53ba10770a315361770efdc17d2c01f6a30e3e3d.zip
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/t/002_databases.pl')
-rw-r--r--src/bin/pg_rewind/t/002_databases.pl46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/bin/pg_rewind/t/002_databases.pl b/src/bin/pg_rewind/t/002_databases.pl
index 709c81e2650..1cf9a3a65d3 100644
--- a/src/bin/pg_rewind/t/002_databases.pl
+++ b/src/bin/pg_rewind/t/002_databases.pl
@@ -1,41 +1,49 @@
use strict;
use warnings;
use TestLib;
-use Test::More tests => 2;
+use Test::More tests => 4;
use RewindTest;
-my $testmode = shift;
+sub run_test
+{
+ my $test_mode = shift;
-RewindTest::init_rewind_test('databases', $testmode);
-RewindTest::setup_cluster();
+ RewindTest::init_rewind_test('databases', $test_mode);
+ RewindTest::setup_cluster();
-# Create a database in master.
-master_psql('CREATE DATABASE inmaster');
+ # Create a database in master.
+ master_psql('CREATE DATABASE inmaster');
-RewindTest::create_standby();
+ RewindTest::create_standby();
-# Create another database, the creation is replicated to the standby
-master_psql('CREATE DATABASE beforepromotion');
+ # Create another database, the creation is replicated to the standby
+ master_psql('CREATE DATABASE beforepromotion');
-RewindTest::promote_standby();
+ RewindTest::promote_standby();
-# Create databases in the old master and the new promoted standby.
-master_psql('CREATE DATABASE master_afterpromotion');
-standby_psql('CREATE DATABASE standby_afterpromotion');
-# The clusters are now diverged.
+ # Create databases in the old master and the new promoted standby.
+ master_psql('CREATE DATABASE master_afterpromotion');
+ standby_psql('CREATE DATABASE standby_afterpromotion');
+ # The clusters are now diverged.
-RewindTest::run_pg_rewind();
+ RewindTest::run_pg_rewind($test_mode);
-# Check that the correct databases are present after pg_rewind.
-check_query('SELECT datname FROM pg_database',
- qq(template1
+ # Check that the correct databases are present after pg_rewind.
+ check_query('SELECT datname FROM pg_database',
+ qq(template1
template0
postgres
inmaster
beforepromotion
standby_afterpromotion
),
- 'database names');
+ 'database names');
+
+}
+
+# Run the test in both modes.
+run_test('local');
+run_test('remote');
exit(0);