aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/modules/commit_ts/t/001_base.pl12
-rw-r--r--src/test/modules/commit_ts/t/002_standby.pl34
-rw-r--r--src/test/modules/commit_ts/t/003_standby_2.pl28
-rw-r--r--src/test/modules/test_pg_dump/t/001_base.pl458
-rw-r--r--src/test/perl/PostgresNode.pm11
-rw-r--r--src/test/perl/RecursiveCopy.pm5
-rw-r--r--src/test/perl/TestLib.pm1
-rw-r--r--src/test/recovery/t/001_stream_rep.pl9
-rw-r--r--src/test/recovery/t/002_archiving.pl3
-rw-r--r--src/test/recovery/t/003_recovery_targets.pl3
-rw-r--r--src/test/recovery/t/004_timeline_switch.pl4
-rw-r--r--src/test/recovery/t/005_replay_delay.pl14
-rw-r--r--src/test/recovery/t/007_sync_rep.pl33
13 files changed, 293 insertions, 322 deletions
diff --git a/src/test/modules/commit_ts/t/001_base.pl b/src/test/modules/commit_ts/t/001_base.pl
index f076a2739d4..427092cfc50 100644
--- a/src/test/modules/commit_ts/t/001_base.pl
+++ b/src/test/modules/commit_ts/t/001_base.pl
@@ -13,17 +13,21 @@ $node->append_conf('postgresql.conf', 'track_commit_timestamp = on');
$node->start;
# Create a table, compare "now()" to the commit TS of its xmin
-$node->safe_psql('postgres', 'create table t as select now from (select now(), pg_sleep(1)) f');
+$node->safe_psql('postgres',
+ 'create table t as select now from (select now(), pg_sleep(1)) f');
my $true = $node->safe_psql('postgres',
- 'select t.now - ts.* < \'1s\' from t, pg_class c, pg_xact_commit_timestamp(c.xmin) ts where relname = \'t\'');
+'select t.now - ts.* < \'1s\' from t, pg_class c, pg_xact_commit_timestamp(c.xmin) ts where relname = \'t\''
+);
is($true, 't', 'commit TS is set');
my $ts = $node->safe_psql('postgres',
- 'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\'');
+'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\''
+);
# Verify that we read the same TS after crash recovery
$node->stop('immediate');
$node->start;
my $recovered_ts = $node->safe_psql('postgres',
- 'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\'');
+'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\''
+);
is($recovered_ts, $ts, 'commit TS remains after crash recovery');
diff --git a/src/test/modules/commit_ts/t/002_standby.pl b/src/test/modules/commit_ts/t/002_standby.pl
index 9410c9c3d25..4dbde2978e4 100644
--- a/src/test/modules/commit_ts/t/002_standby.pl
+++ b/src/test/modules/commit_ts/t/002_standby.pl
@@ -8,10 +8,11 @@ use Test::More tests => 4;
use PostgresNode;
my $bkplabel = 'backup';
-my $master = get_new_node('master');
+my $master = get_new_node('master');
$master->init(allows_streaming => 1);
-$master->append_conf('postgresql.conf', qq{
+$master->append_conf(
+ 'postgresql.conf', qq{
track_commit_timestamp = on
max_wal_senders = 5
wal_level = hot_standby
@@ -28,30 +29,37 @@ for my $i (1 .. 10)
$master->safe_psql('postgres', "create table t$i()");
}
my $master_ts = $master->safe_psql('postgres',
- qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'});
-my $master_lsn = $master->safe_psql('postgres',
- 'select pg_current_xlog_location()');
+qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
+);
+my $master_lsn =
+ $master->safe_psql('postgres', 'select pg_current_xlog_location()');
$standby->poll_query_until('postgres',
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_xlog_replay_location()})
- or die "slave never caught up";
+ or die "slave never caught up";
my $standby_ts = $standby->safe_psql('postgres',
- qq{select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = 't10'});
+qq{select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = 't10'}
+);
is($master_ts, $standby_ts, "standby gives same value as master");
$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
$master->restart;
$master->safe_psql('postgres', 'checkpoint');
-$master_lsn = $master->safe_psql('postgres',
- 'select pg_current_xlog_location()');
+$master_lsn =
+ $master->safe_psql('postgres', 'select pg_current_xlog_location()');
$standby->poll_query_until('postgres',
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_xlog_replay_location()})
- or die "slave never caught up";
+ or die "slave never caught up";
$standby->safe_psql('postgres', 'checkpoint');
# This one should raise an error now
my ($ret, $standby_ts_stdout, $standby_ts_stderr) = $standby->psql('postgres',
- 'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t10\'');
+'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t10\''
+);
is($ret, 3, 'standby errors when master turned feature off');
-is($standby_ts_stdout, '', "standby gives no value when master turned feature off");
-like($standby_ts_stderr, qr/could not get commit timestamp data/, 'expected error when master turned feature off');
+is($standby_ts_stdout, '',
+ "standby gives no value when master turned feature off");
+like(
+ $standby_ts_stderr,
+ qr/could not get commit timestamp data/,
+ 'expected error when master turned feature off');
diff --git a/src/test/modules/commit_ts/t/003_standby_2.pl b/src/test/modules/commit_ts/t/003_standby_2.pl
index 138cc43dc2b..d37ff182c4c 100644
--- a/src/test/modules/commit_ts/t/003_standby_2.pl
+++ b/src/test/modules/commit_ts/t/003_standby_2.pl
@@ -8,9 +8,10 @@ use Test::More tests => 4;
use PostgresNode;
my $bkplabel = 'backup';
-my $master = get_new_node('master');
+my $master = get_new_node('master');
$master->init(allows_streaming => 1);
-$master->append_conf('postgresql.conf', qq{
+$master->append_conf(
+ 'postgresql.conf', qq{
track_commit_timestamp = on
max_wal_senders = 5
wal_level = hot_standby
@@ -29,20 +30,25 @@ for my $i (1 .. 10)
$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
$master->restart;
$master->safe_psql('postgres', 'checkpoint');
-my $master_lsn = $master->safe_psql('postgres',
- 'select pg_current_xlog_location()');
+my $master_lsn =
+ $master->safe_psql('postgres', 'select pg_current_xlog_location()');
$standby->poll_query_until('postgres',
qq{SELECT '$master_lsn'::pg_lsn <= pg_last_xlog_replay_location()})
- or die "slave never caught up";
+ or die "slave never caught up";
$standby->safe_psql('postgres', 'checkpoint');
$standby->restart;
-my ($psql_ret, $standby_ts_stdout, $standby_ts_stderr) = $standby->psql('postgres',
- qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'});
+my ($psql_ret, $standby_ts_stdout, $standby_ts_stderr) = $standby->psql(
+ 'postgres',
+qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'}
+);
is($psql_ret, 3, 'expect error when getting commit timestamp after restart');
is($standby_ts_stdout, '', "standby does not return a value after restart");
-like($standby_ts_stderr, qr/could not get commit timestamp data/, 'expected err msg after restart');
+like(
+ $standby_ts_stderr,
+ qr/could not get commit timestamp data/,
+ 'expected err msg after restart');
$master->append_conf('postgresql.conf', 'track_commit_timestamp = on');
$master->restart;
@@ -54,5 +60,7 @@ $standby->poll_query_until('postgres', "SELECT pg_is_in_recovery() <> true");
$standby->safe_psql('postgres', "create table t11()");
my $standby_ts = $standby->safe_psql('postgres',
- qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't11'});
-isnt($standby_ts, '', "standby gives valid value ($standby_ts) after promotion");
+qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't11'}
+);
+isnt($standby_ts, '',
+ "standby gives valid value ($standby_ts) after promotion");
diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl
index 626eb4b758f..fd00e4bd321 100644
--- a/src/test/modules/test_pg_dump/t/001_base.pl
+++ b/src/test/modules/test_pg_dump/t/001_base.pl
@@ -45,175 +45,110 @@ my %pgdump_runs = (
'-f', "$tempdir/binary_upgrade.sql",
'--schema-only',
'--binary-upgrade',
- '-d', 'postgres', # alternative way to specify database
- ],
- },
+ '-d', 'postgres', # alternative way to specify database
+ ], },
clean => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/clean.sql",
'-c',
- '-d', 'postgres', # alternative way to specify database
- ],
- },
+ '-d', 'postgres', # alternative way to specify database
+ ], },
clean_if_exists => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/clean_if_exists.sql",
'-c',
'--if-exists',
- '-E', 'UTF8', # no-op, just tests that option is accepted
- 'postgres',
- ],
- },
+ '-E', 'UTF8', # no-op, just tests that option is accepted
+ 'postgres', ], },
column_inserts => {
dump_cmd => [
- 'pg_dump',
- '-f', "$tempdir/column_inserts.sql",
- '-a',
- '--column-inserts',
- 'postgres',
- ],
- },
+ 'pg_dump', '-f',
+ "$tempdir/column_inserts.sql", '-a',
+ '--column-inserts', 'postgres', ], },
createdb => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/createdb.sql",
'-C',
- '-R', # no-op, just for testing
- 'postgres',
- ],
- },
+ '-R', # no-op, just for testing
+ 'postgres', ], },
data_only => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/data_only.sql",
'-a',
- '-v', # no-op, just make sure it works
- 'postgres',
- ],
- },
+ '-v', # no-op, just make sure it works
+ 'postgres', ], },
defaults => {
- dump_cmd => [
- 'pg_dump',
- '-f', "$tempdir/defaults.sql",
- 'postgres',
- ],
+ dump_cmd => [ 'pg_dump', '-f', "$tempdir/defaults.sql", 'postgres', ],
},
defaults_custom_format => {
test_key => 'defaults',
dump_cmd => [
- 'pg_dump',
- '-Fc',
- '-Z6',
- '-f', "$tempdir/defaults_custom_format.dump",
- 'postgres',
- ],
+ 'pg_dump', '-Fc', '-Z6', '-f',
+ "$tempdir/defaults_custom_format.dump", 'postgres', ],
restore_cmd => [
'pg_restore',
- '-f', "$tempdir/defaults_custom_format.sql",
- "$tempdir/defaults_custom_format.dump",
- ],
- },
+ '-f',
+ "$tempdir/defaults_custom_format.sql",
+ "$tempdir/defaults_custom_format.dump", ], },
defaults_dir_format => {
test_key => 'defaults',
dump_cmd => [
- 'pg_dump',
- '-Fd',
- '-f', "$tempdir/defaults_dir_format",
- 'postgres',
- ],
+ 'pg_dump', '-Fd', '-f', "$tempdir/defaults_dir_format",
+ 'postgres', ],
restore_cmd => [
'pg_restore',
- '-f', "$tempdir/defaults_dir_format.sql",
- "$tempdir/defaults_dir_format",
- ],
- },
+ '-f',
+ "$tempdir/defaults_dir_format.sql",
+ "$tempdir/defaults_dir_format", ], },
defaults_parallel => {
test_key => 'defaults',
dump_cmd => [
- 'pg_dump',
- '-Fd',
- '-j2',
- '-f', "$tempdir/defaults_parallel",
- 'postgres',
- ],
+ 'pg_dump', '-Fd', '-j2', '-f', "$tempdir/defaults_parallel",
+ 'postgres', ],
restore_cmd => [
- 'pg_restore',
- '-f', "$tempdir/defaults_parallel.sql",
- "$tempdir/defaults_parallel",
- ],
+ 'pg_restore', '-f',
+ "$tempdir/defaults_parallel.sql", "$tempdir/defaults_parallel", ],
},
defaults_tar_format => {
test_key => 'defaults',
dump_cmd => [
- 'pg_dump',
- '-Ft',
- '-f', "$tempdir/defaults_tar_format.tar",
- 'postgres',
- ],
+ 'pg_dump', '-Ft', '-f', "$tempdir/defaults_tar_format.tar",
+ 'postgres', ],
restore_cmd => [
'pg_restore',
- '-f', "$tempdir/defaults_tar_format.sql",
- "$tempdir/defaults_tar_format.tar",
- ],
- },
+ '-f',
+ "$tempdir/defaults_tar_format.sql",
+ "$tempdir/defaults_tar_format.tar", ], },
pg_dumpall_globals => {
- dump_cmd => [
- 'pg_dumpall',
- '-f', "$tempdir/pg_dumpall_globals.sql",
- '-g',
- ],
- },
+ dump_cmd =>
+ [ 'pg_dumpall', '-f', "$tempdir/pg_dumpall_globals.sql", '-g', ], },
no_privs => {
- dump_cmd => [
- 'pg_dump',
- '-f', "$tempdir/no_privs.sql",
- '-x',
- 'postgres',
- ],
- },
+ dump_cmd =>
+ [ 'pg_dump', '-f', "$tempdir/no_privs.sql", '-x', 'postgres', ], },
no_owner => {
- dump_cmd => [
- 'pg_dump',
- '-f', "$tempdir/no_owner.sql",
- '-O',
- 'postgres',
- ],
- },
+ dump_cmd =>
+ [ 'pg_dump', '-f', "$tempdir/no_owner.sql", '-O', 'postgres', ], },
schema_only => {
- dump_cmd => [
- 'pg_dump',
- '-f', "$tempdir/schema_only.sql",
- '-s',
- 'postgres',
- ],
+ dump_cmd =>
+ [ 'pg_dump', '-f', "$tempdir/schema_only.sql", '-s', 'postgres', ],
},
section_pre_data => {
dump_cmd => [
- 'pg_dump',
- '-f', "$tempdir/section_pre_data.sql",
- '--section=pre-data',
- 'postgres',
- ],
- },
+ 'pg_dump', '-f', "$tempdir/section_pre_data.sql",
+ '--section=pre-data', 'postgres', ], },
section_data => {
dump_cmd => [
- 'pg_dump',
- '-f', "$tempdir/section_data.sql",
- '--section=data',
- 'postgres',
- ],
- },
+ 'pg_dump', '-f',
+ "$tempdir/section_data.sql", '--section=data',
+ 'postgres', ], },
section_post_data => {
dump_cmd => [
- 'pg_dump',
- '-f', "$tempdir/section_post_data.sql",
- '--section=post-data',
- 'postgres',
- ],
- },
-);
+ 'pg_dump', '-f', "$tempdir/section_post_data.sql",
+ '--section=post-data', 'postgres', ], },);
###############################################################
# Definition of the tests to run.
@@ -255,200 +190,167 @@ my %pgdump_runs = (
my %tests = (
'CREATE EXTENSION test_pg_dump' => {
create_order => 2,
- create_sql => 'CREATE EXTENSION test_pg_dump;',
- regexp => qr/^
+ create_sql => 'CREATE EXTENSION test_pg_dump;',
+ regexp => qr/^
\QCREATE EXTENSION IF NOT EXISTS test_pg_dump WITH SCHEMA public;\E
$/xm,
like => {
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_privs => 1,
- no_owner => 1,
- schema_only => 1,
- section_pre_data => 1,
- },
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_privs => 1,
+ no_owner => 1,
+ schema_only => 1,
+ section_pre_data => 1, },
unlike => {
- binary_upgrade => 1,
+ binary_upgrade => 1,
pg_dumpall_globals => 1,
- section_post_data => 1,
- },
- },
+ section_post_data => 1, }, },
'CREATE ROLE dump_test' => {
create_order => 1,
- create_sql => 'CREATE ROLE dump_test;',
- regexp => qr/^CREATE ROLE dump_test;$/m,
- like => {
- pg_dumpall_globals => 1,
- },
- unlike => {
- binary_upgrade => 1,
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_privs => 1,
- no_owner => 1,
- schema_only => 1,
- section_pre_data => 1,
- section_post_data => 1,
- },
- },
+ create_sql => 'CREATE ROLE dump_test;',
+ regexp => qr/^CREATE ROLE dump_test;$/m,
+ like => { pg_dumpall_globals => 1, },
+ unlike => {
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_privs => 1,
+ no_owner => 1,
+ schema_only => 1,
+ section_pre_data => 1,
+ section_post_data => 1, }, },
'CREATE TABLE regress_pg_dump_table' => {
regexp => qr/^
\QCREATE TABLE regress_pg_dump_table (\E
\n\s+\Qcol1 integer,\E
\n\s+\Qcol2 integer\E
\n\);$/xm,
- like => {
- binary_upgrade => 1,
- },
+ like => { binary_upgrade => 1, },
unlike => {
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_privs => 1,
- no_owner => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_privs => 1,
+ no_owner => 1,
pg_dumpall_globals => 1,
- schema_only => 1,
- section_pre_data => 1,
- section_post_data => 1,
- },
- },
+ schema_only => 1,
+ section_pre_data => 1,
+ section_post_data => 1, }, },
'CREATE ACCESS METHOD regress_test_am' => {
regexp => qr/^
\QCREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;\E
$/xm,
- like => {
- binary_upgrade => 1,
- },
+ like => { binary_upgrade => 1, },
unlike => {
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_privs => 1,
- no_owner => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_privs => 1,
+ no_owner => 1,
pg_dumpall_globals => 1,
- schema_only => 1,
- section_pre_data => 1,
- section_post_data => 1,
- },
- },
+ schema_only => 1,
+ section_pre_data => 1,
+ section_post_data => 1, }, },
'COMMENT ON EXTENSION test_pg_dump' => {
regexp => qr/^
\QCOMMENT ON EXTENSION test_pg_dump \E
\QIS 'Test pg_dump with an extension';\E
$/xm,
like => {
- binary_upgrade => 1,
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_privs => 1,
- no_owner => 1,
- schema_only => 1,
- section_pre_data => 1,
- },
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_privs => 1,
+ no_owner => 1,
+ schema_only => 1,
+ section_pre_data => 1, },
unlike => {
pg_dumpall_globals => 1,
- section_post_data => 1,
- },
- },
+ section_post_data => 1, }, },
'GRANT SELECT ON TABLE regress_pg_dump_table' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT SELECT ON TABLE regress_pg_dump_table TO dump_test;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
$/xms,
- like => {
- binary_upgrade => 1,
- },
+ like => { binary_upgrade => 1, },
unlike => {
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_owner => 1,
- schema_only => 1,
- section_pre_data => 1,
- no_privs => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_owner => 1,
+ schema_only => 1,
+ section_pre_data => 1,
+ no_privs => 1,
pg_dumpall_globals => 1,
- section_post_data => 1,
- },
- },
+ section_post_data => 1, }, },
'GRANT SELECT(col1) ON regress_pg_dump_table' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT SELECT(col1) ON TABLE regress_pg_dump_table TO PUBLIC;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
$/xms,
- like => {
- binary_upgrade => 1,
- },
+ like => { binary_upgrade => 1, },
unlike => {
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_owner => 1,
- schema_only => 1,
- section_pre_data => 1,
- no_privs => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_owner => 1,
+ schema_only => 1,
+ section_pre_data => 1,
+ no_privs => 1,
pg_dumpall_globals => 1,
- section_post_data => 1,
- },
- },
+ section_post_data => 1, }, },
'GRANT SELECT(col2) ON regress_pg_dump_table TO dump_test' => {
create_order => 4,
- create_sql => 'GRANT SELECT(col2) ON regress_pg_dump_table
+ create_sql => 'GRANT SELECT(col2) ON regress_pg_dump_table
TO dump_test;',
regexp => qr/^
\QGRANT SELECT(col2) ON TABLE regress_pg_dump_table TO dump_test;\E
$/xm,
like => {
- binary_upgrade => 1,
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_owner => 1,
- schema_only => 1,
- section_pre_data => 1,
- },
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_owner => 1,
+ schema_only => 1,
+ section_pre_data => 1, },
unlike => {
- no_privs => 1,
+ no_privs => 1,
pg_dumpall_globals => 1,
- section_post_data => 1,
- },
- },
+ section_post_data => 1, }, },
'REVOKE SELECT(col1) ON regress_pg_dump_table' => {
create_order => 3,
- create_sql => 'REVOKE SELECT(col1) ON regress_pg_dump_table
+ create_sql => 'REVOKE SELECT(col1) ON regress_pg_dump_table
FROM PUBLIC;',
regexp => qr/^
\QREVOKE SELECT(col1) ON TABLE regress_pg_dump_table FROM PUBLIC;\E
$/xm,
like => {
- binary_upgrade => 1,
- clean => 1,
- clean_if_exists => 1,
- createdb => 1,
- defaults => 1,
- no_owner => 1,
- schema_only => 1,
- section_pre_data => 1,
- },
+ binary_upgrade => 1,
+ clean => 1,
+ clean_if_exists => 1,
+ createdb => 1,
+ defaults => 1,
+ no_owner => 1,
+ schema_only => 1,
+ section_pre_data => 1, },
unlike => {
- no_privs => 1,
+ no_privs => 1,
pg_dumpall_globals => 1,
- section_post_data => 1,
- },
- },
-);
+ section_post_data => 1, }, },);
#########################################
# Create a PG instance to test actually dumping from
@@ -461,28 +363,34 @@ my $port = $node->port;
my $num_tests = 0;
-foreach my $run (sort keys %pgdump_runs) {
+foreach my $run (sort keys %pgdump_runs)
+{
my $test_key = $run;
# Each run of pg_dump is a test itself
$num_tests++;
# If there is a restore cmd, that's another test
- if ($pgdump_runs{$run}->{restore_cmd}) {
+ if ($pgdump_runs{$run}->{restore_cmd})
+ {
$num_tests++;
}
- if ($pgdump_runs{$run}->{test_key}) {
+ if ($pgdump_runs{$run}->{test_key})
+ {
$test_key = $pgdump_runs{$run}->{test_key};
}
# Then count all the tests run against each run
- foreach my $test (sort keys %tests) {
- if ($tests{$test}->{like}->{$test_key}) {
+ foreach my $test (sort keys %tests)
+ {
+ if ($tests{$test}->{like}->{$test_key})
+ {
$num_tests++;
}
- if ($tests{$test}->{unlike}->{$test_key}) {
+ if ($tests{$test}->{unlike}->{$test_key})
+ {
$num_tests++;
}
}
@@ -497,17 +405,26 @@ my $create_sql = '';
foreach my $test (
sort {
- if ($tests{$a}->{create_order} and $tests{$b}->{create_order}) {
+ if ($tests{$a}->{create_order} and $tests{$b}->{create_order})
+ {
$tests{$a}->{create_order} <=> $tests{$b}->{create_order};
- } elsif ($tests{$a}->{create_order}) {
+ }
+ elsif ($tests{$a}->{create_order})
+ {
-1;
- } elsif ($tests{$b}->{create_order}) {
+ }
+ elsif ($tests{$b}->{create_order})
+ {
1;
- } else {
+ }
+ else
+ {
0;
}
- } keys %tests) {
- if ($tests{$test}->{create_sql}) {
+ } keys %tests)
+{
+ if ($tests{$test}->{create_sql})
+ {
$create_sql .= $tests{$test}->{create_sql};
}
}
@@ -518,17 +435,22 @@ $node->safe_psql('postgres', $create_sql);
#########################################
# Run all runs
-foreach my $run (sort keys %pgdump_runs) {
+foreach my $run (sort keys %pgdump_runs)
+{
my $test_key = $run;
- $node->command_ok(\@{ $pgdump_runs{$run}->{dump_cmd} }, "$run: pg_dump runs");
+ $node->command_ok(\@{ $pgdump_runs{$run}->{dump_cmd} },
+ "$run: pg_dump runs");
- if ($pgdump_runs{$run}->{restore_cmd}) {
- $node->command_ok(\@{ $pgdump_runs{$run}->{restore_cmd} }, "$run: pg_restore runs");
+ if ($pgdump_runs{$run}->{restore_cmd})
+ {
+ $node->command_ok(\@{ $pgdump_runs{$run}->{restore_cmd} },
+ "$run: pg_restore runs");
}
- if ($pgdump_runs{$run}->{test_key}) {
+ if ($pgdump_runs{$run}->{test_key})
+ {
$test_key = $pgdump_runs{$run}->{test_key};
}
@@ -538,13 +460,19 @@ foreach my $run (sort keys %pgdump_runs) {
# Run all tests where this run is included
# as either a 'like' or 'unlike' test.
- foreach my $test (sort keys %tests) {
- if ($tests{$test}->{like}->{$test_key}) {
+ foreach my $test (sort keys %tests)
+ {
+ if ($tests{$test}->{like}->{$test_key})
+ {
like($output_file, $tests{$test}->{regexp}, "$run: dumps $test");
}
- if ($tests{$test}->{unlike}->{$test_key}) {
- unlike($output_file, $tests{$test}->{regexp}, "$run: does not dump $test");
+ if ($tests{$test}->{unlike}->{$test_key})
+ {
+ unlike(
+ $output_file,
+ $tests{$test}->{regexp},
+ "$run: does not dump $test");
}
}
}
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 4e66006af3b..636dfec5c06 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -103,6 +103,7 @@ our ($test_localhost, $test_pghost, $last_port_assigned, @all_nodes);
INIT
{
+
# PGHOST is set once and for all through a single series of tests when
# this module is loaded.
$test_localhost = "127.0.0.1";
@@ -540,11 +541,12 @@ sub _backup_fs
if ($hot)
{
+
# We ignore pg_stop_backup's return value. We also assume archiving
# is enabled; otherwise the caller will have to copy the remaining
# segments.
- my $stdout = $self->safe_psql('postgres',
- 'SELECT * FROM pg_stop_backup();');
+ my $stdout =
+ $self->safe_psql('postgres', 'SELECT * FROM pg_stop_backup();');
print "# pg_stop_backup: $stdout\n";
}
@@ -842,6 +844,7 @@ sub get_new_node
while ($found == 0)
{
+
# advance $port, wrapping correctly around range end
$port = 49152 if ++$port >= 65536;
print "# Checking port $port\n";
@@ -896,6 +899,7 @@ sub get_new_node
# order, later when the File::Temp objects are destroyed.
END
{
+
# take care not to change the script's exit value
my $exit_code = $?;
@@ -1078,7 +1082,7 @@ sub psql
IPC::Run::timeout($params{timeout}, exception => $timeout_exception)
if (defined($params{timeout}));
- ${$params{timed_out}} = 0 if defined $params{timed_out};
+ ${ $params{timed_out} } = 0 if defined $params{timed_out};
# IPC::Run would otherwise append to existing contents:
$$stdout = "" if ref($stdout);
@@ -1107,6 +1111,7 @@ sub psql
my $exc_save = $@;
if ($exc_save)
{
+
# IPC::Run::run threw an exception. re-throw unless it's a
# timeout, which we'll handle by testing is_expired
die $exc_save
diff --git a/src/test/perl/RecursiveCopy.pm b/src/test/perl/RecursiveCopy.pm
index c4da1bbd837..3e988132868 100644
--- a/src/test/perl/RecursiveCopy.pm
+++ b/src/test/perl/RecursiveCopy.pm
@@ -65,7 +65,7 @@ sub copypath
{
die "if specified, filterfn must be a subroutine reference"
unless defined(ref $params{filterfn})
- and (ref $params{filterfn} eq 'CODE');
+ and (ref $params{filterfn} eq 'CODE');
$filterfn = $params{filterfn};
}
@@ -93,7 +93,8 @@ sub _copypath_recurse
# Can't handle symlinks or other weird things
die "Source path \"$srcpath\" is not a regular file or directory"
- unless -f $srcpath or -d $srcpath;
+ unless -f $srcpath
+ or -d $srcpath;
# Abort if destination path already exists. Should we allow directories
# to exist already?
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index 0057f6dfe9f..649fd821733 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -109,6 +109,7 @@ INIT
END
{
+
# Preserve temporary directory for this test on failure
$File::Temp::KEEP_ALL = 1 unless all_tests_passing();
}
diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl
index 06c3c1f4cda..7b42f215344 100644
--- a/src/test/recovery/t/001_stream_rep.pl
+++ b/src/test/recovery/t/001_stream_rep.pl
@@ -51,10 +51,13 @@ my $result =
print "standby 1: $result\n";
is($result, qq(1002), 'check streamed content on standby 1');
-$result = $node_standby_2->safe_psql('postgres', "SELECT count(*) FROM tab_int");
+$result =
+ $node_standby_2->safe_psql('postgres', "SELECT count(*) FROM tab_int");
print "standby 2: $result\n";
is($result, qq(1002), 'check streamed content on standby 2');
# Check that only READ-only queries can run on standbys
-is($node_standby_1->psql('postgres', 'INSERT INTO tab_int VALUES (1)'), 3, 'Read-only queries on standby 1');
-is($node_standby_2->psql('postgres', 'INSERT INTO tab_int VALUES (1)'), 3, 'Read-only queries on standby 2');
+is($node_standby_1->psql('postgres', 'INSERT INTO tab_int VALUES (1)'),
+ 3, 'Read-only queries on standby 1');
+is($node_standby_2->psql('postgres', 'INSERT INTO tab_int VALUES (1)'),
+ 3, 'Read-only queries on standby 2');
diff --git a/src/test/recovery/t/002_archiving.pl b/src/test/recovery/t/002_archiving.pl
index b0b25380d2d..fc2bf7ee1d6 100644
--- a/src/test/recovery/t/002_archiving.pl
+++ b/src/test/recovery/t/002_archiving.pl
@@ -48,5 +48,6 @@ my $caughtup_query =
$node_standby->poll_query_until('postgres', $caughtup_query)
or die "Timed out while waiting for standby to catch up";
-my $result = $node_standby->safe_psql('postgres', "SELECT count(*) FROM tab_int");
+my $result =
+ $node_standby->safe_psql('postgres', "SELECT count(*) FROM tab_int");
is($result, qq(1000), 'check content from archives');
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index b20116ac8cc..20b878e524a 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -66,7 +66,8 @@ $node_master->backup('my_backup');
# target TXID.
$node_master->safe_psql('postgres',
"INSERT INTO tab_int VALUES (generate_series(1001,2000))");
-my $recovery_txid = $node_master->safe_psql('postgres', "SELECT txid_current()");
+my $recovery_txid =
+ $node_master->safe_psql('postgres', "SELECT txid_current()");
my $lsn2 =
$node_master->safe_psql('postgres', "SELECT pg_current_xlog_location();");
diff --git a/src/test/recovery/t/004_timeline_switch.pl b/src/test/recovery/t/004_timeline_switch.pl
index 6af06c7e594..3ee8df2cdc2 100644
--- a/src/test/recovery/t/004_timeline_switch.pl
+++ b/src/test/recovery/t/004_timeline_switch.pl
@@ -63,8 +63,8 @@ $node_standby_1->poll_query_until('postgres',
"SELECT pg_is_in_recovery() <> true");
$node_standby_1->safe_psql('postgres',
"INSERT INTO tab_int VALUES (generate_series(1001,2000))");
-$until_lsn =
- $node_standby_1->safe_psql('postgres', "SELECT pg_current_xlog_location();");
+$until_lsn = $node_standby_1->safe_psql('postgres',
+ "SELECT pg_current_xlog_location();");
$caughtup_query =
"SELECT '$until_lsn'::pg_lsn <= pg_last_xlog_replay_location()";
$node_standby_2->poll_query_until('postgres', $caughtup_query)
diff --git a/src/test/recovery/t/005_replay_delay.pl b/src/test/recovery/t/005_replay_delay.pl
index e38ab9dfd2f..cfd89292423 100644
--- a/src/test/recovery/t/005_replay_delay.pl
+++ b/src/test/recovery/t/005_replay_delay.pl
@@ -21,7 +21,7 @@ $node_master->backup($backup_name);
# Create streaming standby from backup
my $node_standby = get_new_node('standby');
-my $delay = 3;
+my $delay = 3;
$node_standby->init_from_backup($node_master, $backup_name,
has_streaming => 1);
$node_standby->append_conf(
@@ -47,10 +47,11 @@ my $until_lsn =
my $remaining = 90;
while ($remaining-- > 0)
{
+
# Done waiting?
- my $replay_status =
- $node_standby->safe_psql('postgres',
- "SELECT (pg_last_xlog_replay_location() - '$until_lsn'::pg_lsn) >= 0");
+ my $replay_status = $node_standby->safe_psql('postgres',
+ "SELECT (pg_last_xlog_replay_location() - '$until_lsn'::pg_lsn) >= 0"
+ );
last if $replay_status eq 't';
# No, sleep some more.
@@ -59,9 +60,10 @@ while ($remaining-- > 0)
sleep $sleep;
}
-die "Maximum number of attempts reached ($remaining remain)" if $remaining < 0;
+die "Maximum number of attempts reached ($remaining remain)"
+ if $remaining < 0;
# This test is successful if and only if the LSN has been applied with at least
# the configured apply delay.
ok(time() - $master_insert_time >= $delay,
- "Check that standby applies WAL only after replication delay");
+ "Check that standby applies WAL only after replication delay");
diff --git a/src/test/recovery/t/007_sync_rep.pl b/src/test/recovery/t/007_sync_rep.pl
index d551954bcbb..baf4477e3c6 100644
--- a/src/test/recovery/t/007_sync_rep.pl
+++ b/src/test/recovery/t/007_sync_rep.pl
@@ -6,7 +6,8 @@ use TestLib;
use Test::More tests => 8;
# Query checking sync_priority and sync_state of each standby
-my $check_sql = "SELECT application_name, sync_priority, sync_state FROM pg_stat_replication ORDER BY application_name;";
+my $check_sql =
+"SELECT application_name, sync_priority, sync_state FROM pg_stat_replication ORDER BY application_name;";
# Check that sync_state of each standby is expected.
# If $setting is given, synchronous_standby_names is set to it and
@@ -18,12 +19,12 @@ sub test_sync_state
if (defined($setting))
{
$self->psql('postgres',
- "ALTER SYSTEM SET synchronous_standby_names = '$setting';");
+ "ALTER SYSTEM SET synchronous_standby_names = '$setting';");
$self->reload;
}
my $timeout_max = 30;
- my $timeout = 0;
+ my $timeout = 0;
my $result;
# A reload may take some time to take effect on busy machines,
@@ -71,7 +72,8 @@ $node_standby_3->start;
# Check that sync_state is determined correctly when
# synchronous_standby_names is specified in old syntax.
-test_sync_state($node_master, qq(standby1|1|sync
+test_sync_state(
+ $node_master, qq(standby1|1|sync
standby2|2|potential
standby3|0|async),
'old syntax of synchronous_standby_names',
@@ -82,7 +84,8 @@ standby3|0|async),
# Note that standby1 is chosen as sync standby because
# it's stored in the head of WalSnd array which manages
# all the standbys though they have the same priority.
-test_sync_state($node_master, qq(standby1|1|sync
+test_sync_state(
+ $node_master, qq(standby1|1|sync
standby2|1|potential
standby3|1|potential),
'asterisk in synchronous_standby_names',
@@ -100,7 +103,8 @@ $node_standby_3->start;
# Specify 2 as the number of sync standbys.
# Check that two standbys are in 'sync' state.
-test_sync_state($node_master, qq(standby2|2|sync
+test_sync_state(
+ $node_master, qq(standby2|2|sync
standby3|3|sync),
'2 synchronous standbys',
'2(standby1,standby2,standby3)');
@@ -111,14 +115,15 @@ $node_standby_1->start;
# Create standby4 linking to master
my $node_standby_4 = get_new_node('standby4');
$node_standby_4->init_from_backup($node_master, $backup_name,
- has_streaming => 1);
+ has_streaming => 1);
$node_standby_4->start;
# Check that standby1 and standby2 whose names appear earlier in
# synchronous_standby_names are considered as sync. Also check that
# standby3 appearing later represents potential, and standby4 is
# in 'async' state because it's not in the list.
-test_sync_state($node_master, qq(standby1|1|sync
+test_sync_state(
+ $node_master, qq(standby1|1|sync
standby2|2|sync
standby3|3|potential
standby4|0|async),
@@ -127,7 +132,8 @@ standby4|0|async),
# Check that sync_state of each standby is determined correctly
# when num_sync exceeds the number of names of potential sync standbys
# specified in synchronous_standby_names.
-test_sync_state($node_master, qq(standby1|0|async
+test_sync_state(
+ $node_master, qq(standby1|0|async
standby2|4|sync
standby3|3|sync
standby4|1|sync),
@@ -138,7 +144,8 @@ standby4|1|sync),
# but does not make sense in most cases. Check that sync_state is
# chosen properly even in case of that setting.
# The priority of standby2 should be 2 because it matches * first.
-test_sync_state($node_master, qq(standby1|1|sync
+test_sync_state(
+ $node_master, qq(standby1|1|sync
standby2|2|sync
standby3|2|potential
standby4|2|potential),
@@ -147,7 +154,8 @@ standby4|2|potential),
# Check that the setting of '2(*)' chooses standby2 and standby3 that are stored
# earlier in WalSnd array as sync standbys.
-test_sync_state($node_master, qq(standby1|1|potential
+test_sync_state(
+ $node_master, qq(standby1|1|potential
standby2|1|sync
standby3|1|sync
standby4|1|potential),
@@ -159,7 +167,8 @@ $node_standby_3->stop;
# Check that the state of standby1 stored earlier in WalSnd array than
# standby4 is transited from potential to sync.
-test_sync_state($node_master, qq(standby1|1|sync
+test_sync_state(
+ $node_master, qq(standby1|1|sync
standby2|1|sync
standby4|1|potential),
'potential standby found earlier in array is promoted to sync');