From 201a76183e2056c2217129e12d68c25ec9c559c8 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 29 Jul 2021 05:58:08 -0400 Subject: [PATCH] Unify PostgresNode's new() and get_new_node() methods There is only one constructor now for PostgresNode, with the idiomatic name 'new'. The method is not exported by the class, and must be called as "PostgresNode->new('name',[args])". All the TAP tests that use PostgresNode are modified accordingly. Third party scripts will need adjusting, which is a fairly mechanical process (I just used a sed script). --- contrib/amcheck/t/001_verify_heapam.pl | 2 +- contrib/auto_explain/t/001_auto_explain.pl | 2 +- contrib/bloom/t/001_wal.pl | 4 +- contrib/test_decoding/t/001_repl_stats.pl | 2 +- src/bin/pg_amcheck/t/002_nonesuch.pl | 2 +- src/bin/pg_amcheck/t/003_check.pl | 2 +- src/bin/pg_amcheck/t/004_verify_heapam.pl | 2 +- src/bin/pg_amcheck/t/005_opclass_damage.pl | 2 +- src/bin/pg_basebackup/t/010_pg_basebackup.pl | 4 +- src/bin/pg_basebackup/t/020_pg_receivewal.pl | 2 +- src/bin/pg_basebackup/t/030_pg_recvlogical.pl | 2 +- src/bin/pg_checksums/t/002_actions.pl | 2 +- .../pg_controldata/t/001_pg_controldata.pl | 2 +- src/bin/pg_ctl/t/002_status.pl | 2 +- src/bin/pg_ctl/t/003_promote.pl | 6 +- src/bin/pg_ctl/t/004_logrotate.pl | 2 +- src/bin/pg_dump/t/002_pg_dump.pl | 2 +- src/bin/pg_dump/t/003_pg_dump_with_server.pl | 2 +- src/bin/pg_dump/t/010_dump_connstr.pl | 6 +- src/bin/pg_resetwal/t/001_basic.pl | 2 +- src/bin/pg_resetwal/t/002_corrupted.pl | 2 +- src/bin/pg_rewind/t/007_standby_source.pl | 4 +- src/bin/pg_rewind/t/008_min_recovery_point.pl | 6 +- src/bin/pg_rewind/t/RewindTest.pm | 4 +- src/bin/pg_verifybackup/t/002_algorithm.pl | 2 +- src/bin/pg_verifybackup/t/003_corruption.pl | 2 +- src/bin/pg_verifybackup/t/004_options.pl | 2 +- src/bin/pg_verifybackup/t/006_encoding.pl | 2 +- src/bin/pg_verifybackup/t/007_wal.pl | 2 +- src/bin/pgbench/t/001_pgbench_with_server.pl | 2 +- src/bin/psql/t/010_tab_completion.pl | 2 +- src/bin/scripts/t/010_clusterdb.pl | 2 +- src/bin/scripts/t/011_clusterdb_all.pl | 2 +- src/bin/scripts/t/020_createdb.pl | 2 +- src/bin/scripts/t/040_createuser.pl | 2 +- src/bin/scripts/t/050_dropdb.pl | 2 +- src/bin/scripts/t/070_dropuser.pl | 2 +- src/bin/scripts/t/080_pg_isready.pl | 2 +- src/bin/scripts/t/090_reindexdb.pl | 2 +- src/bin/scripts/t/091_reindexdb_all.pl | 2 +- src/bin/scripts/t/100_vacuumdb.pl | 2 +- src/bin/scripts/t/101_vacuumdb_all.pl | 2 +- src/bin/scripts/t/102_vacuumdb_stages.pl | 2 +- src/bin/scripts/t/200_connstr.pl | 2 +- src/test/authentication/t/001_password.pl | 2 +- src/test/authentication/t/002_saslprep.pl | 2 +- src/test/kerberos/t/001_auth.pl | 2 +- src/test/ldap/t/001_auth.pl | 2 +- src/test/modules/brin/t/01_workitems.pl | 2 +- src/test/modules/commit_ts/t/001_base.pl | 2 +- src/test/modules/commit_ts/t/002_standby.pl | 4 +- src/test/modules/commit_ts/t/003_standby_2.pl | 4 +- src/test/modules/commit_ts/t/004_restart.pl | 2 +- .../libpq_pipeline/t/001_libpq_pipeline.pl | 2 +- .../ssl_passphrase_callback/t/001_testfunc.pl | 2 +- .../test_misc/t/001_constraint_validation.pl | 2 +- src/test/modules/test_pg_dump/t/001_base.pl | 2 +- src/test/perl/PostgresNode.pm | 80 +++++++------------ src/test/perl/README | 2 +- src/test/recovery/t/001_stream_rep.pl | 6 +- src/test/recovery/t/002_archiving.pl | 6 +- src/test/recovery/t/003_recovery_targets.pl | 8 +- src/test/recovery/t/004_timeline_switch.pl | 10 +-- src/test/recovery/t/005_replay_delay.pl | 6 +- src/test/recovery/t/006_logical_decoding.pl | 2 +- src/test/recovery/t/007_sync_rep.pl | 10 +-- src/test/recovery/t/008_fsm_truncation.pl | 4 +- src/test/recovery/t/009_twophase.pl | 4 +- .../t/010_logical_decoding_timelines.pl | 4 +- src/test/recovery/t/011_crash_recovery.pl | 2 +- src/test/recovery/t/012_subtransactions.pl | 4 +- src/test/recovery/t/013_crash_restart.pl | 2 +- src/test/recovery/t/014_unlogged_reinit.pl | 2 +- src/test/recovery/t/015_promotion_pages.pl | 4 +- src/test/recovery/t/016_min_consistency.pl | 4 +- src/test/recovery/t/017_shm.pl | 2 +- src/test/recovery/t/018_wal_optimize.pl | 2 +- src/test/recovery/t/019_replslot_limit.pl | 12 +-- src/test/recovery/t/020_archive_status.pl | 6 +- src/test/recovery/t/021_row_visibility.pl | 4 +- src/test/recovery/t/022_crash_temp_files.pl | 2 +- src/test/recovery/t/023_pitr_prepared_xact.pl | 4 +- src/test/recovery/t/024_archive_recovery.pl | 4 +- .../recovery/t/025_stuck_on_old_timeline.pl | 6 +- src/test/ssl/t/001_ssltests.pl | 2 +- src/test/ssl/t/002_scram.pl | 2 +- src/test/subscription/t/001_rep_changes.pl | 4 +- src/test/subscription/t/002_types.pl | 4 +- src/test/subscription/t/003_constraints.pl | 4 +- src/test/subscription/t/004_sync.pl | 4 +- src/test/subscription/t/005_encoding.pl | 4 +- src/test/subscription/t/006_rewrite.pl | 4 +- src/test/subscription/t/007_ddl.pl | 4 +- src/test/subscription/t/008_diff_schema.pl | 4 +- src/test/subscription/t/009_matviews.pl | 4 +- src/test/subscription/t/010_truncate.pl | 4 +- src/test/subscription/t/011_generated.pl | 4 +- src/test/subscription/t/012_collation.pl | 4 +- src/test/subscription/t/013_partition.pl | 6 +- src/test/subscription/t/014_binary.pl | 4 +- src/test/subscription/t/015_stream.pl | 4 +- src/test/subscription/t/016_stream_subxact.pl | 4 +- src/test/subscription/t/017_stream_ddl.pl | 4 +- .../t/018_stream_subxact_abort.pl | 4 +- .../t/019_stream_subxact_ddl_abort.pl | 4 +- src/test/subscription/t/020_messages.pl | 4 +- src/test/subscription/t/021_twophase.pl | 4 +- .../subscription/t/022_twophase_cascade.pl | 6 +- src/test/subscription/t/100_bugs.pl | 14 ++-- 109 files changed, 212 insertions(+), 238 deletions(-) diff --git a/contrib/amcheck/t/001_verify_heapam.pl b/contrib/amcheck/t/001_verify_heapam.pl index 9bd66c07f4..4f720a7ed0 100644 --- a/contrib/amcheck/t/001_verify_heapam.pl +++ b/contrib/amcheck/t/001_verify_heapam.pl @@ -15,7 +15,7 @@ my ($node, $result); # # Test set-up # -$node = get_new_node('test'); +$node = PostgresNode->new('test'); $node->init; $node->append_conf('postgresql.conf', 'autovacuum=off'); $node->start; diff --git a/contrib/auto_explain/t/001_auto_explain.pl b/contrib/auto_explain/t/001_auto_explain.pl index 9c4f1d0571..1773a37999 100644 --- a/contrib/auto_explain/t/001_auto_explain.pl +++ b/contrib/auto_explain/t/001_auto_explain.pl @@ -8,7 +8,7 @@ use PostgresNode; use TestLib; use Test::More tests => 4; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->append_conf('postgresql.conf', "shared_preload_libraries = 'auto_explain'"); diff --git a/contrib/bloom/t/001_wal.pl b/contrib/bloom/t/001_wal.pl index 9310af5c3d..55ad35926f 100644 --- a/contrib/bloom/t/001_wal.pl +++ b/contrib/bloom/t/001_wal.pl @@ -43,7 +43,7 @@ SELECT * FROM tst WHERE i = 7 AND t = 'e'; } # Initialize primary node -$node_primary = get_new_node('primary'); +$node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); $node_primary->start; my $backup_name = 'my_backup'; @@ -52,7 +52,7 @@ my $backup_name = 'my_backup'; $node_primary->backup($backup_name); # Create streaming standby linking to primary -$node_standby = get_new_node('standby'); +$node_standby = PostgresNode->new('standby'); $node_standby->init_from_backup($node_primary, $backup_name, has_streaming => 1); $node_standby->start; diff --git a/contrib/test_decoding/t/001_repl_stats.pl b/contrib/test_decoding/t/001_repl_stats.pl index 2dc5ef5f07..fdef6cb1ff 100644 --- a/contrib/test_decoding/t/001_repl_stats.pl +++ b/contrib/test_decoding/t/001_repl_stats.pl @@ -11,7 +11,7 @@ use TestLib; use Test::More tests => 2; # Test set-up -my $node = get_new_node('test'); +my $node = PostgresNode->new('test'); $node->init(allows_streaming => 'logical'); $node->append_conf('postgresql.conf', 'synchronous_commit = on'); $node->start; diff --git a/src/bin/pg_amcheck/t/002_nonesuch.pl b/src/bin/pg_amcheck/t/002_nonesuch.pl index 5f712ee32a..5417959553 100644 --- a/src/bin/pg_amcheck/t/002_nonesuch.pl +++ b/src/bin/pg_amcheck/t/002_nonesuch.pl @@ -10,7 +10,7 @@ use Test::More tests => 72; # Test set-up my ($node, $port); -$node = get_new_node('test'); +$node = PostgresNode->new('test'); $node->init; $node->start; $port = $node->port; diff --git a/src/bin/pg_amcheck/t/003_check.pl b/src/bin/pg_amcheck/t/003_check.pl index 817eb4e116..f3eb41ce3a 100644 --- a/src/bin/pg_amcheck/t/003_check.pl +++ b/src/bin/pg_amcheck/t/003_check.pl @@ -120,7 +120,7 @@ sub perform_all_corruptions() } # Test set-up -$node = get_new_node('test'); +$node = PostgresNode->new('test'); $node->init; $node->append_conf('postgresql.conf', 'autovacuum=off'); $node->start; diff --git a/src/bin/pg_amcheck/t/004_verify_heapam.pl b/src/bin/pg_amcheck/t/004_verify_heapam.pl index b3a96e8016..e4c0b83a1c 100644 --- a/src/bin/pg_amcheck/t/004_verify_heapam.pl +++ b/src/bin/pg_amcheck/t/004_verify_heapam.pl @@ -178,7 +178,7 @@ umask(0077); # Set up the node. Once we create and corrupt the table, # autovacuum workers visiting the table could crash the backend. # Disable autovacuum so that won't happen. -my $node = get_new_node('test'); +my $node = PostgresNode->new('test'); $node->init; $node->append_conf('postgresql.conf', 'autovacuum=off'); diff --git a/src/bin/pg_amcheck/t/005_opclass_damage.pl b/src/bin/pg_amcheck/t/005_opclass_damage.pl index b65becae9d..806335375d 100644 --- a/src/bin/pg_amcheck/t/005_opclass_damage.pl +++ b/src/bin/pg_amcheck/t/005_opclass_damage.pl @@ -10,7 +10,7 @@ use PostgresNode; use TestLib; use Test::More tests => 5; -my $node = get_new_node('test'); +my $node = PostgresNode->new('test'); $node->init; $node->start; diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index 74f8c2c739..ecd6a5d374 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -18,7 +18,7 @@ program_options_handling_ok('pg_basebackup'); my $tempdir = TestLib::tempdir; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); # Set umask so test directories and files are created with default permissions umask(0077); @@ -268,7 +268,7 @@ SKIP: skip "no tar program available", 1 if (!defined $tar || $tar eq ''); - my $node2 = get_new_node('replica'); + my $node2 = PostgresNode->new('replica'); # Recover main data directory $node2->init_from_backup($node, 'tarbackup2', tar_program => $tar); diff --git a/src/bin/pg_basebackup/t/020_pg_receivewal.pl b/src/bin/pg_basebackup/t/020_pg_receivewal.pl index 950083d21c..65076d6632 100644 --- a/src/bin/pg_basebackup/t/020_pg_receivewal.pl +++ b/src/bin/pg_basebackup/t/020_pg_receivewal.pl @@ -14,7 +14,7 @@ program_options_handling_ok('pg_receivewal'); # Set umask so test directories and files are created with default permissions umask(0077); -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init(allows_streaming => 1); $primary->start; diff --git a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl index bbbf9e21db..fe7fe76295 100644 --- a/src/bin/pg_basebackup/t/030_pg_recvlogical.pl +++ b/src/bin/pg_basebackup/t/030_pg_recvlogical.pl @@ -11,7 +11,7 @@ program_help_ok('pg_recvlogical'); program_version_ok('pg_recvlogical'); program_options_handling_ok('pg_recvlogical'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); # Initialize node without replication settings $node->init(allows_streaming => 1, has_archiving => 1); diff --git a/src/bin/pg_checksums/t/002_actions.pl b/src/bin/pg_checksums/t/002_actions.pl index af88b94795..a18c104a94 100644 --- a/src/bin/pg_checksums/t/002_actions.pl +++ b/src/bin/pg_checksums/t/002_actions.pl @@ -92,7 +92,7 @@ sub check_relation_corruption } # Initialize node with checksums disabled. -my $node = get_new_node('node_checksum'); +my $node = PostgresNode->new('node_checksum'); $node->init(); my $pgdata = $node->data_dir; diff --git a/src/bin/pg_controldata/t/001_pg_controldata.pl b/src/bin/pg_controldata/t/001_pg_controldata.pl index c3f3aca095..ce31cfbd3b 100644 --- a/src/bin/pg_controldata/t/001_pg_controldata.pl +++ b/src/bin/pg_controldata/t/001_pg_controldata.pl @@ -14,7 +14,7 @@ command_fails(['pg_controldata'], 'pg_controldata without arguments fails'); command_fails([ 'pg_controldata', 'nonexistent' ], 'pg_controldata with nonexistent directory fails'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; command_like([ 'pg_controldata', $node->data_dir ], diff --git a/src/bin/pg_ctl/t/002_status.pl b/src/bin/pg_ctl/t/002_status.pl index e69cb80134..56a06fafa3 100644 --- a/src/bin/pg_ctl/t/002_status.pl +++ b/src/bin/pg_ctl/t/002_status.pl @@ -14,7 +14,7 @@ my $tempdir_short = TestLib::tempdir_short; command_exit_is([ 'pg_ctl', 'status', '-D', "$tempdir/nonexistent" ], 4, 'pg_ctl status with nonexistent directory'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; command_exit_is([ 'pg_ctl', 'status', '-D', $node->data_dir ], diff --git a/src/bin/pg_ctl/t/003_promote.pl b/src/bin/pg_ctl/t/003_promote.pl index 2d7e2fd5f3..547b3d8893 100644 --- a/src/bin/pg_ctl/t/003_promote.pl +++ b/src/bin/pg_ctl/t/003_promote.pl @@ -15,7 +15,7 @@ command_fails_like( qr/directory .* does not exist/, 'pg_ctl promote with nonexistent directory'); -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); command_fails_like( @@ -30,7 +30,7 @@ command_fails_like( qr/not in standby mode/, 'pg_ctl promote of primary instance fails'); -my $node_standby = get_new_node('standby'); +my $node_standby = PostgresNode->new('standby'); $node_primary->backup('my_backup'); $node_standby->init_from_backup($node_primary, 'my_backup', has_streaming => 1); @@ -47,7 +47,7 @@ ok( $node_standby->poll_query_until( 'promoted standby is not in recovery'); # same again with default wait option -$node_standby = get_new_node('standby2'); +$node_standby = PostgresNode->new('standby2'); $node_standby->init_from_backup($node_primary, 'my_backup', has_streaming => 1); $node_standby->start; diff --git a/src/bin/pg_ctl/t/004_logrotate.pl b/src/bin/pg_ctl/t/004_logrotate.pl index 9a0492ae63..fa14b98c7d 100644 --- a/src/bin/pg_ctl/t/004_logrotate.pl +++ b/src/bin/pg_ctl/t/004_logrotate.pl @@ -10,7 +10,7 @@ use Test::More tests => 5; use Time::HiRes qw(usleep); # Set up node with logging collector -my $node = get_new_node('primary'); +my $node = PostgresNode->new('primary'); $node->init(); $node->append_conf( 'postgresql.conf', qq( diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index c5d8915be8..a4ee54d516 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -3562,7 +3562,7 @@ my %tests = ( ######################################### # Create a PG instance to test actually dumping from -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/pg_dump/t/003_pg_dump_with_server.pl b/src/bin/pg_dump/t/003_pg_dump_with_server.pl index f9fea9ddcf..ba994aee82 100644 --- a/src/bin/pg_dump/t/003_pg_dump_with_server.pl +++ b/src/bin/pg_dump/t/003_pg_dump_with_server.pl @@ -11,7 +11,7 @@ use Test::More tests => 3; my $tempdir = TestLib::tempdir; my $tempdir_short = TestLib::tempdir_short; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); my $port = $node->port; $node->init; diff --git a/src/bin/pg_dump/t/010_dump_connstr.pl b/src/bin/pg_dump/t/010_dump_connstr.pl index 6478894160..c4b60c5d2a 100644 --- a/src/bin/pg_dump/t/010_dump_connstr.pl +++ b/src/bin/pg_dump/t/010_dump_connstr.pl @@ -51,7 +51,7 @@ my $dbname4 = 'regression' . generate_ascii_string(203, 255); my $src_bootstrap_super = 'regress_postgres'; my $dst_bootstrap_super = 'boot'; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init(extra => [ '-U', $src_bootstrap_super, '--locale=C', '--encoding=LATIN1' ]); @@ -181,7 +181,7 @@ $restore_super =~ s/"//g # Restore full dump through psql using environment variables for # dbname/user connection parameters -my $envar_node = get_new_node('destination_envar'); +my $envar_node = PostgresNode->new('destination_envar'); $envar_node->init( extra => [ '-U', $dst_bootstrap_super, '--locale=C', '--encoding=LATIN1' ], @@ -208,7 +208,7 @@ is($stderr, '', 'no dump errors'); # dbname/user connection parameters. "\connect dbname=" forgets # user/port from command line. -my $cmdline_node = get_new_node('destination_cmdline'); +my $cmdline_node = PostgresNode->new('destination_cmdline'); $cmdline_node->init( extra => [ '-U', $dst_bootstrap_super, '--locale=C', '--encoding=LATIN1' ], diff --git a/src/bin/pg_resetwal/t/001_basic.pl b/src/bin/pg_resetwal/t/001_basic.pl index 9c08ade79f..f01a4d2d48 100644 --- a/src/bin/pg_resetwal/t/001_basic.pl +++ b/src/bin/pg_resetwal/t/001_basic.pl @@ -12,7 +12,7 @@ program_help_ok('pg_resetwal'); program_version_ok('pg_resetwal'); program_options_handling_ok('pg_resetwal'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; command_like([ 'pg_resetwal', '-n', $node->data_dir ], diff --git a/src/bin/pg_resetwal/t/002_corrupted.pl b/src/bin/pg_resetwal/t/002_corrupted.pl index 954790c28c..ac915ef91f 100644 --- a/src/bin/pg_resetwal/t/002_corrupted.pl +++ b/src/bin/pg_resetwal/t/002_corrupted.pl @@ -10,7 +10,7 @@ use PostgresNode; use TestLib; use Test::More tests => 6; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; my $pg_control = $node->data_dir . '/global/pg_control'; diff --git a/src/bin/pg_rewind/t/007_standby_source.pl b/src/bin/pg_rewind/t/007_standby_source.pl index 44319a8204..2a717f5a2e 100644 --- a/src/bin/pg_rewind/t/007_standby_source.pl +++ b/src/bin/pg_rewind/t/007_standby_source.pl @@ -58,13 +58,13 @@ primary_psql("CHECKPOINT"); # # A (primary) <--- B (standby) <--- C (standby) $node_a->backup('my_backup'); -$node_b = get_new_node('node_b'); +$node_b = PostgresNode->new('node_b'); $node_b->init_from_backup($node_a, 'my_backup', has_streaming => 1); $node_b->set_standby_mode(); $node_b->start; $node_b->backup('my_backup'); -$node_c = get_new_node('node_c'); +$node_c = PostgresNode->new('node_c'); $node_c->init_from_backup($node_b, 'my_backup', has_streaming => 1); $node_c->set_standby_mode(); $node_c->start; diff --git a/src/bin/pg_rewind/t/008_min_recovery_point.pl b/src/bin/pg_rewind/t/008_min_recovery_point.pl index 9ebcbad0d2..7a390f4abd 100644 --- a/src/bin/pg_rewind/t/008_min_recovery_point.pl +++ b/src/bin/pg_rewind/t/008_min_recovery_point.pl @@ -40,7 +40,7 @@ use File::Copy; my $tmp_folder = TestLib::tempdir; -my $node_1 = get_new_node('node_1'); +my $node_1 = PostgresNode->new('node_1'); $node_1->init(allows_streaming => 1); $node_1->append_conf( 'postgresql.conf', qq( @@ -60,11 +60,11 @@ $node_1->safe_psql('postgres', "INSERT INTO public.bar VALUES ('in both')"); my $backup_name = 'my_backup'; $node_1->backup($backup_name); -my $node_2 = get_new_node('node_2'); +my $node_2 = PostgresNode->new('node_2'); $node_2->init_from_backup($node_1, $backup_name, has_streaming => 1); $node_2->start; -my $node_3 = get_new_node('node_3'); +my $node_3 = PostgresNode->new('node_3'); $node_3->init_from_backup($node_1, $backup_name, has_streaming => 1); $node_3->start; diff --git a/src/bin/pg_rewind/t/RewindTest.pm b/src/bin/pg_rewind/t/RewindTest.pm index 938c661afc..367b99a438 100644 --- a/src/bin/pg_rewind/t/RewindTest.pm +++ b/src/bin/pg_rewind/t/RewindTest.pm @@ -128,7 +128,7 @@ sub setup_cluster # Initialize primary, data checksums are mandatory $node_primary = - get_new_node('primary' . ($extra_name ? "_${extra_name}" : '')); + PostgresNode->new('primary' . ($extra_name ? "_${extra_name}" : '')); # Set up pg_hba.conf and pg_ident.conf for the role running # pg_rewind. This role is used for all the tests, and has @@ -176,7 +176,7 @@ sub create_standby my $extra_name = shift; $node_standby = - get_new_node('standby' . ($extra_name ? "_${extra_name}" : '')); + PostgresNode->new('standby' . ($extra_name ? "_${extra_name}" : '')); $node_primary->backup('my_backup'); $node_standby->init_from_backup($node_primary, 'my_backup'); my $connstr_primary = $node_primary->connstr(); diff --git a/src/bin/pg_verifybackup/t/002_algorithm.pl b/src/bin/pg_verifybackup/t/002_algorithm.pl index c2c4c3176a..7dc1af982a 100644 --- a/src/bin/pg_verifybackup/t/002_algorithm.pl +++ b/src/bin/pg_verifybackup/t/002_algorithm.pl @@ -12,7 +12,7 @@ use PostgresNode; use TestLib; use Test::More tests => 19; -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init(allows_streaming => 1); $primary->start; diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl index 682b3b857e..509390f975 100644 --- a/src/bin/pg_verifybackup/t/003_corruption.pl +++ b/src/bin/pg_verifybackup/t/003_corruption.pl @@ -12,7 +12,7 @@ use PostgresNode; use TestLib; use Test::More tests => 44; -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init(allows_streaming => 1); $primary->start; diff --git a/src/bin/pg_verifybackup/t/004_options.pl b/src/bin/pg_verifybackup/t/004_options.pl index 3f6e84c221..d4210fd293 100644 --- a/src/bin/pg_verifybackup/t/004_options.pl +++ b/src/bin/pg_verifybackup/t/004_options.pl @@ -13,7 +13,7 @@ use TestLib; use Test::More tests => 25; # Start up the server and take a backup. -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init(allows_streaming => 1); $primary->start; my $backup_path = $primary->backup_dir . '/test_options'; diff --git a/src/bin/pg_verifybackup/t/006_encoding.pl b/src/bin/pg_verifybackup/t/006_encoding.pl index a821d52a6a..c0667b7f43 100644 --- a/src/bin/pg_verifybackup/t/006_encoding.pl +++ b/src/bin/pg_verifybackup/t/006_encoding.pl @@ -11,7 +11,7 @@ use PostgresNode; use TestLib; use Test::More tests => 5; -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init(allows_streaming => 1); $primary->start; my $backup_path = $primary->backup_dir . '/test_encoding'; diff --git a/src/bin/pg_verifybackup/t/007_wal.pl b/src/bin/pg_verifybackup/t/007_wal.pl index 28837b8503..adf60fb755 100644 --- a/src/bin/pg_verifybackup/t/007_wal.pl +++ b/src/bin/pg_verifybackup/t/007_wal.pl @@ -13,7 +13,7 @@ use TestLib; use Test::More tests => 7; # Start up the server and take a backup. -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init(allows_streaming => 1); $primary->start; my $backup_path = $primary->backup_dir . '/test_wal'; diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index 3aa9d5d753..ef53f6b2d9 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -10,7 +10,7 @@ use Test::More; use Config; # start a pgbench specific server -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl index 3c58d50118..8695d22545 100644 --- a/src/bin/psql/t/010_tab_completion.pl +++ b/src/bin/psql/t/010_tab_completion.pl @@ -34,7 +34,7 @@ if ($@) } # start a new server -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/010_clusterdb.pl b/src/bin/scripts/t/010_clusterdb.pl index 6d483be143..aae5ea985b 100644 --- a/src/bin/scripts/t/010_clusterdb.pl +++ b/src/bin/scripts/t/010_clusterdb.pl @@ -12,7 +12,7 @@ program_help_ok('clusterdb'); program_version_ok('clusterdb'); program_options_handling_ok('clusterdb'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/011_clusterdb_all.pl b/src/bin/scripts/t/011_clusterdb_all.pl index c7e8514fb6..6ba71780de 100644 --- a/src/bin/scripts/t/011_clusterdb_all.pl +++ b/src/bin/scripts/t/011_clusterdb_all.pl @@ -8,7 +8,7 @@ use PostgresNode; use TestLib; use Test::More tests => 2; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/020_createdb.pl b/src/bin/scripts/t/020_createdb.pl index 7261ebb2ef..3db2f13ae2 100644 --- a/src/bin/scripts/t/020_createdb.pl +++ b/src/bin/scripts/t/020_createdb.pl @@ -12,7 +12,7 @@ program_help_ok('createdb'); program_version_ok('createdb'); program_options_handling_ok('createdb'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/040_createuser.pl b/src/bin/scripts/t/040_createuser.pl index 8fdd32d77b..3da8b7ae75 100644 --- a/src/bin/scripts/t/040_createuser.pl +++ b/src/bin/scripts/t/040_createuser.pl @@ -12,7 +12,7 @@ program_help_ok('createuser'); program_version_ok('createuser'); program_options_handling_ok('createuser'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/050_dropdb.pl b/src/bin/scripts/t/050_dropdb.pl index 646cb4e82f..b9f0592bca 100644 --- a/src/bin/scripts/t/050_dropdb.pl +++ b/src/bin/scripts/t/050_dropdb.pl @@ -12,7 +12,7 @@ program_help_ok('dropdb'); program_version_ok('dropdb'); program_options_handling_ok('dropdb'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/070_dropuser.pl b/src/bin/scripts/t/070_dropuser.pl index cbcb09b0ad..26dadaf4a5 100644 --- a/src/bin/scripts/t/070_dropuser.pl +++ b/src/bin/scripts/t/070_dropuser.pl @@ -12,7 +12,7 @@ program_help_ok('dropuser'); program_version_ok('dropuser'); program_options_handling_ok('dropuser'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/080_pg_isready.pl b/src/bin/scripts/t/080_pg_isready.pl index e2e39ea2d4..4f1184953e 100644 --- a/src/bin/scripts/t/080_pg_isready.pl +++ b/src/bin/scripts/t/080_pg_isready.pl @@ -14,7 +14,7 @@ program_options_handling_ok('pg_isready'); command_fails(['pg_isready'], 'fails with no server running'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/090_reindexdb.pl b/src/bin/scripts/t/090_reindexdb.pl index af5bdf352c..541504d8f0 100644 --- a/src/bin/scripts/t/090_reindexdb.pl +++ b/src/bin/scripts/t/090_reindexdb.pl @@ -12,7 +12,7 @@ program_help_ok('reindexdb'); program_version_ok('reindexdb'); program_options_handling_ok('reindexdb'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/091_reindexdb_all.pl b/src/bin/scripts/t/091_reindexdb_all.pl index 299b198d15..34174e4d71 100644 --- a/src/bin/scripts/t/091_reindexdb_all.pl +++ b/src/bin/scripts/t/091_reindexdb_all.pl @@ -7,7 +7,7 @@ use warnings; use PostgresNode; use Test::More tests => 2; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/100_vacuumdb.pl b/src/bin/scripts/t/100_vacuumdb.pl index 0addc97bf8..0f1e5bb278 100644 --- a/src/bin/scripts/t/100_vacuumdb.pl +++ b/src/bin/scripts/t/100_vacuumdb.pl @@ -12,7 +12,7 @@ program_help_ok('vacuumdb'); program_version_ok('vacuumdb'); program_options_handling_ok('vacuumdb'); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/101_vacuumdb_all.pl b/src/bin/scripts/t/101_vacuumdb_all.pl index 504f252748..a60fc79aae 100644 --- a/src/bin/scripts/t/101_vacuumdb_all.pl +++ b/src/bin/scripts/t/101_vacuumdb_all.pl @@ -7,7 +7,7 @@ use warnings; use PostgresNode; use Test::More tests => 2; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/102_vacuumdb_stages.pl b/src/bin/scripts/t/102_vacuumdb_stages.pl index 155c77edd9..c15057a763 100644 --- a/src/bin/scripts/t/102_vacuumdb_stages.pl +++ b/src/bin/scripts/t/102_vacuumdb_stages.pl @@ -7,7 +7,7 @@ use warnings; use PostgresNode; use Test::More tests => 4; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/bin/scripts/t/200_connstr.pl b/src/bin/scripts/t/200_connstr.pl index b1ceab73bb..f702e32f00 100644 --- a/src/bin/scripts/t/200_connstr.pl +++ b/src/bin/scripts/t/200_connstr.pl @@ -23,7 +23,7 @@ my $dbname2 = my $dbname3 = generate_ascii_string(130, 192); my $dbname4 = generate_ascii_string(193, 255); -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init(extra => [ '--locale=C', '--encoding=LATIN1' ]); $node->start; diff --git a/src/test/authentication/t/001_password.pl b/src/test/authentication/t/001_password.pl index 427a360198..9498c18d7d 100644 --- a/src/test/authentication/t/001_password.pl +++ b/src/test/authentication/t/001_password.pl @@ -62,7 +62,7 @@ sub test_role } # Initialize primary node -my $node = get_new_node('primary'); +my $node = PostgresNode->new('primary'); $node->init; $node->append_conf('postgresql.conf', "log_connections = on\n"); $node->start; diff --git a/src/test/authentication/t/002_saslprep.pl b/src/test/authentication/t/002_saslprep.pl index f080a0ccba..4799e927db 100644 --- a/src/test/authentication/t/002_saslprep.pl +++ b/src/test/authentication/t/002_saslprep.pl @@ -62,7 +62,7 @@ sub test_login # Initialize primary node. Force UTF-8 encoding, so that we can use non-ASCII # characters in the passwords below. -my $node = get_new_node('primary'); +my $node = PostgresNode->new('primary'); $node->init(extra => [ '--locale=C', '--encoding=UTF8' ]); $node->start; diff --git a/src/test/kerberos/t/001_auth.pl b/src/test/kerberos/t/001_auth.pl index b5594924ca..d6191498f0 100644 --- a/src/test/kerberos/t/001_auth.pl +++ b/src/test/kerberos/t/001_auth.pl @@ -167,7 +167,7 @@ END note "setting up PostgreSQL instance"; -my $node = get_new_node('node'); +my $node = PostgresNode->new('node'); $node->init; $node->append_conf( 'postgresql.conf', qq{ diff --git a/src/test/ldap/t/001_auth.pl b/src/test/ldap/t/001_auth.pl index 0ae14e4c85..553041baa2 100644 --- a/src/test/ldap/t/001_auth.pl +++ b/src/test/ldap/t/001_auth.pl @@ -153,7 +153,7 @@ system_or_bail 'ldappasswd', '-x', '-y', $ldap_pwfile, '-s', 'secret2', note "setting up PostgreSQL instance"; -my $node = get_new_node('node'); +my $node = PostgresNode->new('node'); $node->init; $node->append_conf('postgresql.conf', "log_connections = on\n"); $node->start; diff --git a/src/test/modules/brin/t/01_workitems.pl b/src/test/modules/brin/t/01_workitems.pl index a4f603a9d5..ea2e2944a1 100644 --- a/src/test/modules/brin/t/01_workitems.pl +++ b/src/test/modules/brin/t/01_workitems.pl @@ -10,7 +10,7 @@ use TestLib; use Test::More tests => 2; use PostgresNode; -my $node = get_new_node('tango'); +my $node = PostgresNode->new('tango'); $node->init; $node->append_conf('postgresql.conf', 'autovacuum_naptime=1s'); $node->start; diff --git a/src/test/modules/commit_ts/t/001_base.pl b/src/test/modules/commit_ts/t/001_base.pl index dd41936658..0c504421d4 100644 --- a/src/test/modules/commit_ts/t/001_base.pl +++ b/src/test/modules/commit_ts/t/001_base.pl @@ -10,7 +10,7 @@ use TestLib; use Test::More tests => 2; use PostgresNode; -my $node = get_new_node('foxtrot'); +my $node = PostgresNode->new('foxtrot'); $node->init; $node->append_conf('postgresql.conf', 'track_commit_timestamp = on'); $node->start; diff --git a/src/test/modules/commit_ts/t/002_standby.pl b/src/test/modules/commit_ts/t/002_standby.pl index 2664b177ec..227eddeda2 100644 --- a/src/test/modules/commit_ts/t/002_standby.pl +++ b/src/test/modules/commit_ts/t/002_standby.pl @@ -11,7 +11,7 @@ use Test::More tests => 4; use PostgresNode; my $bkplabel = 'backup'; -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init(allows_streaming => 1); $primary->append_conf( @@ -22,7 +22,7 @@ $primary->append_conf( $primary->start; $primary->backup($bkplabel); -my $standby = get_new_node('standby'); +my $standby = PostgresNode->new('standby'); $standby->init_from_backup($primary, $bkplabel, has_streaming => 1); $standby->start; 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 57ab9b1d46..27c5bfbfb7 100644 --- a/src/test/modules/commit_ts/t/003_standby_2.pl +++ b/src/test/modules/commit_ts/t/003_standby_2.pl @@ -11,7 +11,7 @@ use Test::More tests => 4; use PostgresNode; my $bkplabel = 'backup'; -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init(allows_streaming => 1); $primary->append_conf( 'postgresql.conf', qq{ @@ -21,7 +21,7 @@ $primary->append_conf( $primary->start; $primary->backup($bkplabel); -my $standby = get_new_node('standby'); +my $standby = PostgresNode->new('standby'); $standby->init_from_backup($primary, $bkplabel, has_streaming => 1); $standby->start; diff --git a/src/test/modules/commit_ts/t/004_restart.pl b/src/test/modules/commit_ts/t/004_restart.pl index bc9931944f..5d92c5a2e6 100644 --- a/src/test/modules/commit_ts/t/004_restart.pl +++ b/src/test/modules/commit_ts/t/004_restart.pl @@ -8,7 +8,7 @@ use PostgresNode; use TestLib; use Test::More tests => 16; -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); $node_primary->append_conf('postgresql.conf', 'track_commit_timestamp = on'); $node_primary->start; diff --git a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl index 4101ef950e..49f211c827 100644 --- a/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl +++ b/src/test/modules/libpq_pipeline/t/001_libpq_pipeline.pl @@ -9,7 +9,7 @@ use PostgresNode; use TestLib; use Test::More; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl b/src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl index 1e2455e82f..0a45fc1b75 100644 --- a/src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl +++ b/src/test/modules/ssl_passphrase_callback/t/001_testfunc.pl @@ -20,7 +20,7 @@ my $rot13pass = "SbbOnE1"; # see the Makefile for how the certificate and key have been generated -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->append_conf('postgresql.conf', "ssl_passphrase.passphrase = '$rot13pass'"); diff --git a/src/test/modules/test_misc/t/001_constraint_validation.pl b/src/test/modules/test_misc/t/001_constraint_validation.pl index 3729906c1a..7c1929f805 100644 --- a/src/test/modules/test_misc/t/001_constraint_validation.pl +++ b/src/test/modules/test_misc/t/001_constraint_validation.pl @@ -10,7 +10,7 @@ use TestLib; use Test::More tests => 42; # Initialize a test cluster -my $node = get_new_node('primary'); +my $node = PostgresNode->new('primary'); $node->init(); # Turn message level up to DEBUG1 so that we get the messages we want to see $node->append_conf('postgresql.conf', 'client_min_messages = DEBUG1'); 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 8511da5169..ea7739d725 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -713,7 +713,7 @@ my %tests = ( ######################################### # Create a PG instance to test actually dumping from -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index 9231945216..45c69a61ba 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -11,7 +11,7 @@ PostgresNode - class representing PostgreSQL server instance use PostgresNode; - my $node = PostgresNode->get_new_node('mynode'); + my $node = PostgresNode->new('mynode'); # Create a data directory with initdb $node->init(); @@ -61,9 +61,9 @@ PostgresNode - class representing PostgreSQL server instance my $ret = $node->backup_fs_cold('testbackup3') # Restore it to create a new independent node (not a replica) - my $replica = get_new_node('replica'); - $replica->init_from_backup($node, 'testbackup'); - $replica->start; + my $other_node = PostgresNode->new('mycopy'); + $other_node->init_from_backup($node, 'testbackup'); + $other_node->start; # Stop the server $node->stop('fast'); @@ -110,7 +110,6 @@ use Time::HiRes qw(usleep); use Scalar::Util qw(blessed); our @EXPORT = qw( - get_new_node get_free_port ); @@ -139,41 +138,6 @@ INIT =over -=item PostgresNode::new($class, $name, $pghost, $pgport) - -Create a new PostgresNode instance. Does not initdb or start it. - -You should generally prefer to use get_new_node() instead since it takes care -of finding port numbers, registering instances for cleanup, etc. - -=cut - -sub new -{ - my ($class, $name, $pghost, $pgport) = @_; - my $testname = basename($0); - $testname =~ s/\.[^.]+$//; - my $self = { - _port => $pgport, - _host => $pghost, - _basedir => "$TestLib::tmp_check/t_${testname}_${name}_data", - _name => $name, - _logfile_generation => 0, - _logfile_base => "$TestLib::log_path/${testname}_${name}", - _logfile => "$TestLib::log_path/${testname}_${name}.log" - }; - - bless $self, $class; - mkdir $self->{_basedir} - or - BAIL_OUT("could not create data directory \"$self->{_basedir}\": $!"); - $self->dump_info; - - return $self; -} - -=pod - =item $node->port() Get the port number assigned to the host. This won't necessarily be a TCP port @@ -1168,15 +1132,13 @@ sub _update_pid =pod -=item PostgresNode->get_new_node(node_name, %params) +=item PostgresNode->new(node_name, %params) Build a new object of class C (or of a subclass, if you have one), assigning a free port number. Remembers the node, to prevent its port number from being reused for another node, and to ensure that it gets shut down when the test script exits. -You should generally use this instead of C. - =over =item port => [1,65535] @@ -1201,15 +1163,11 @@ not provided, Postgres binaries will be found in the caller's PATH. =back -For backwards compatibility, it is also exported as a standalone function, -which can only create objects of class C. - =cut -sub get_new_node +sub new { - my $class = 'PostgresNode'; - $class = shift if scalar(@_) % 2 != 1; + my $class = shift; my ($name, %params) = @_; # Select a port. @@ -1244,14 +1202,30 @@ sub get_new_node } } - # Lock port number found by creating a new node - my $node = $class->new($name, $host, $port); + my $testname = basename($0); + $testname =~ s/\.[^.]+$//; + my $node = { + _port => $port, + _host => $host, + _basedir => "$TestLib::tmp_check/t_${testname}_${name}_data", + _name => $name, + _logfile_generation => 0, + _logfile_base => "$TestLib::log_path/${testname}_${name}", + _logfile => "$TestLib::log_path/${testname}_${name}.log" + }; if ($params{install_path}) { $node->{_install_path} = $params{install_path}; } + bless $node, $class; + mkdir $node->{_basedir} + or + BAIL_OUT("could not create data directory \"$node->{_basedir}\": $!"); + + $node->dump_info; + # Add node to list of nodes push(@all_nodes, $node); @@ -1322,7 +1296,7 @@ sub _set_pg_version # the remainder are# set. Then the PATH and (DY)LD_LIBRARY_PATH are adjusted # if the node's install path is set, and the copy environment is returned. # -# The install path set in get_new_node needs to be a directory containing +# The install path set in new() needs to be a directory containing # bin and lib subdirectories as in a standard PostgreSQL installation, so this # can't be used with installations where the bin and lib directories don't have # a common parent directory. @@ -1407,7 +1381,7 @@ sub installed_command =item get_free_port() Locate an unprivileged (high) TCP port that's not currently bound to -anything. This is used by get_new_node, and is also exported for use +anything. This is used by new(), and is also exported for use by test cases that need to start other, non-Postgres servers. Ports assigned to existing PostgresNode objects are automatically diff --git a/src/test/perl/README b/src/test/perl/README index fd9394957f..f04b2a2ea4 100644 --- a/src/test/perl/README +++ b/src/test/perl/README @@ -48,7 +48,7 @@ Each test script should begin with: then it will generally need to set up one or more nodes, run commands against them and evaluate the results. For example: - my $node = PostgresNode->get_new_node('primary'); + my $node = PostgresNode->new('primary'); $node->init; $node->start; diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl index df6fdc20d1..ac581c1c07 100644 --- a/src/test/recovery/t/001_stream_rep.pl +++ b/src/test/recovery/t/001_stream_rep.pl @@ -9,7 +9,7 @@ use TestLib; use Test::More tests => 49; # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); # A specific role is created to perform some tests related to replication, # and it needs proper authentication configuration. $node_primary->init( @@ -22,7 +22,7 @@ my $backup_name = 'my_backup'; $node_primary->backup($backup_name); # Create streaming standby linking to primary -my $node_standby_1 = get_new_node('standby_1'); +my $node_standby_1 = PostgresNode->new('standby_1'); $node_standby_1->init_from_backup($node_primary, $backup_name, has_streaming => 1); $node_standby_1->start; @@ -37,7 +37,7 @@ $node_standby_1->backup('my_backup_2'); $node_primary->start; # Create second standby node linking to standby 1 -my $node_standby_2 = get_new_node('standby_2'); +my $node_standby_2 = PostgresNode->new('standby_2'); $node_standby_2->init_from_backup($node_standby_1, $backup_name, has_streaming => 1); $node_standby_2->start; diff --git a/src/test/recovery/t/002_archiving.pl b/src/test/recovery/t/002_archiving.pl index c675c0886c..ce60159f03 100644 --- a/src/test/recovery/t/002_archiving.pl +++ b/src/test/recovery/t/002_archiving.pl @@ -10,7 +10,7 @@ use Test::More tests => 3; use File::Copy; # Initialize primary node, doing archives -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init( has_archiving => 1, allows_streaming => 1); @@ -23,7 +23,7 @@ $node_primary->start; $node_primary->backup($backup_name); # Initialize standby node from backup, fetching WAL from archives -my $node_standby = get_new_node('standby'); +my $node_standby = PostgresNode->new('standby'); $node_standby->init_from_backup($node_primary, $backup_name, has_restoring => 1); $node_standby->append_conf('postgresql.conf', @@ -62,7 +62,7 @@ is($result, qq(1000), 'check content from archives'); # promoted. $node_standby->promote; -my $node_standby2 = get_new_node('standby2'); +my $node_standby2 = PostgresNode->new('standby2'); $node_standby2->init_from_backup($node_primary, $backup_name, has_restoring => 1); $node_standby2->start; diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl index 84e977bd6d..7bd500ed95 100644 --- a/src/test/recovery/t/003_recovery_targets.pl +++ b/src/test/recovery/t/003_recovery_targets.pl @@ -21,7 +21,7 @@ sub test_recovery_standby my $num_rows = shift; my $until_lsn = shift; - my $node_standby = get_new_node($node_name); + my $node_standby = PostgresNode->new($node_name); $node_standby->init_from_backup($node_primary, 'my_backup', has_restoring => 1); @@ -50,7 +50,7 @@ sub test_recovery_standby } # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(has_archiving => 1, allows_streaming => 1); # Bump the transaction ID epoch. This is useful to stress the portability @@ -136,7 +136,7 @@ test_recovery_standby('LSN', 'standby_5', $node_primary, \@recovery_params, test_recovery_standby('multiple overriding settings', 'standby_6', $node_primary, \@recovery_params, "3000", $lsn3); -my $node_standby = get_new_node('standby_7'); +my $node_standby = PostgresNode->new('standby_7'); $node_standby->init_from_backup($node_primary, 'my_backup', has_restoring => 1); $node_standby->append_conf( @@ -156,7 +156,7 @@ ok($logfile =~ qr/multiple recovery targets specified/, # Check behavior when recovery ends before target is reached -$node_standby = get_new_node('standby_8'); +$node_standby = PostgresNode->new('standby_8'); $node_standby->init_from_backup( $node_primary, 'my_backup', has_restoring => 1, diff --git a/src/test/recovery/t/004_timeline_switch.pl b/src/test/recovery/t/004_timeline_switch.pl index c101980e9e..07b1527043 100644 --- a/src/test/recovery/t/004_timeline_switch.pl +++ b/src/test/recovery/t/004_timeline_switch.pl @@ -15,7 +15,7 @@ $ENV{PGDATABASE} = 'postgres'; # on a new timeline. # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); $node_primary->start; @@ -24,11 +24,11 @@ my $backup_name = 'my_backup'; $node_primary->backup($backup_name); # Create two standbys linking to it -my $node_standby_1 = get_new_node('standby_1'); +my $node_standby_1 = PostgresNode->new('standby_1'); $node_standby_1->init_from_backup($node_primary, $backup_name, has_streaming => 1); $node_standby_1->start; -my $node_standby_2 = get_new_node('standby_2'); +my $node_standby_2 = PostgresNode->new('standby_2'); $node_standby_2->init_from_backup($node_primary, $backup_name, has_streaming => 1); $node_standby_2->start; @@ -76,7 +76,7 @@ is($result, qq(2000), 'check content of standby 2'); # when WAL archiving is enabled. # Initialize primary node -my $node_primary_2 = get_new_node('primary_2'); +my $node_primary_2 = PostgresNode->new('primary_2'); $node_primary_2->init(allows_streaming => 1, has_archiving => 1); $node_primary_2->append_conf( 'postgresql.conf', qq( @@ -88,7 +88,7 @@ $node_primary_2->start; $node_primary_2->backup($backup_name); # Create standby node -my $node_standby_3 = get_new_node('standby_3'); +my $node_standby_3 = PostgresNode->new('standby_3'); $node_standby_3->init_from_backup($node_primary_2, $backup_name, has_streaming => 1); diff --git a/src/test/recovery/t/005_replay_delay.pl b/src/test/recovery/t/005_replay_delay.pl index bd7ed4e304..0b56380e0a 100644 --- a/src/test/recovery/t/005_replay_delay.pl +++ b/src/test/recovery/t/005_replay_delay.pl @@ -10,7 +10,7 @@ use TestLib; use Test::More tests => 3; # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); $node_primary->start; @@ -23,7 +23,7 @@ my $backup_name = 'my_backup'; $node_primary->backup($backup_name); # Create streaming standby from backup -my $node_standby = get_new_node('standby'); +my $node_standby = PostgresNode->new('standby'); my $delay = 3; $node_standby->init_from_backup($node_primary, $backup_name, has_streaming => 1); @@ -58,7 +58,7 @@ ok(time() - $primary_insert_time >= $delay, # Check that recovery can be paused or resumed expectedly. -my $node_standby2 = get_new_node('standby2'); +my $node_standby2 = PostgresNode->new('standby2'); $node_standby2->init_from_backup($node_primary, $backup_name, has_streaming => 1); $node_standby2->start; diff --git a/src/test/recovery/t/006_logical_decoding.pl b/src/test/recovery/t/006_logical_decoding.pl index 827a7b488e..cc116062c2 100644 --- a/src/test/recovery/t/006_logical_decoding.pl +++ b/src/test/recovery/t/006_logical_decoding.pl @@ -14,7 +14,7 @@ use Test::More tests => 14; use Config; # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); $node_primary->append_conf( 'postgresql.conf', qq( diff --git a/src/test/recovery/t/007_sync_rep.pl b/src/test/recovery/t/007_sync_rep.pl index 81098dcf00..9d00e17f9f 100644 --- a/src/test/recovery/t/007_sync_rep.pl +++ b/src/test/recovery/t/007_sync_rep.pl @@ -49,7 +49,7 @@ sub start_standby_and_wait } # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); $node_primary->start; my $backup_name = 'primary_backup'; @@ -61,19 +61,19 @@ $node_primary->backup($backup_name); # the ordering of each one of them in the WAL sender array of the primary. # Create standby1 linking to primary -my $node_standby_1 = get_new_node('standby1'); +my $node_standby_1 = PostgresNode->new('standby1'); $node_standby_1->init_from_backup($node_primary, $backup_name, has_streaming => 1); start_standby_and_wait($node_primary, $node_standby_1); # Create standby2 linking to primary -my $node_standby_2 = get_new_node('standby2'); +my $node_standby_2 = PostgresNode->new('standby2'); $node_standby_2->init_from_backup($node_primary, $backup_name, has_streaming => 1); start_standby_and_wait($node_primary, $node_standby_2); # Create standby3 linking to primary -my $node_standby_3 = get_new_node('standby3'); +my $node_standby_3 = PostgresNode->new('standby3'); $node_standby_3->init_from_backup($node_primary, $backup_name, has_streaming => 1); start_standby_and_wait($node_primary, $node_standby_3); @@ -123,7 +123,7 @@ standby3|3|sync), start_standby_and_wait($node_primary, $node_standby_1); # Create standby4 linking to primary -my $node_standby_4 = get_new_node('standby4'); +my $node_standby_4 = PostgresNode->new('standby4'); $node_standby_4->init_from_backup($node_primary, $backup_name, has_streaming => 1); $node_standby_4->start; diff --git a/src/test/recovery/t/008_fsm_truncation.pl b/src/test/recovery/t/008_fsm_truncation.pl index 14b4b97e9e..b1082546a8 100644 --- a/src/test/recovery/t/008_fsm_truncation.pl +++ b/src/test/recovery/t/008_fsm_truncation.pl @@ -12,7 +12,7 @@ use PostgresNode; use TestLib; use Test::More tests => 1; -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); $node_primary->append_conf( @@ -28,7 +28,7 @@ autovacuum = off $node_primary->start; $node_primary->backup('primary_backup'); -my $node_standby = get_new_node('standby'); +my $node_standby = PostgresNode->new('standby'); $node_standby->init_from_backup($node_primary, 'primary_backup', has_streaming => 1); $node_standby->start; diff --git a/src/test/recovery/t/009_twophase.pl b/src/test/recovery/t/009_twophase.pl index 3ee012226d..78d4ef5b54 100644 --- a/src/test/recovery/t/009_twophase.pl +++ b/src/test/recovery/t/009_twophase.pl @@ -29,7 +29,7 @@ sub configure_and_reload # Set up two nodes, which will alternately be primary and replication standby. # Setup london node -my $node_london = get_new_node("london"); +my $node_london = PostgresNode->new("london"); $node_london->init(allows_streaming => 1); $node_london->append_conf( 'postgresql.conf', qq( @@ -40,7 +40,7 @@ $node_london->start; $node_london->backup('london_backup'); # Setup paris node -my $node_paris = get_new_node('paris'); +my $node_paris = PostgresNode->new('paris'); $node_paris->init_from_backup($node_london, 'london_backup', has_streaming => 1); $node_paris->start; diff --git a/src/test/recovery/t/010_logical_decoding_timelines.pl b/src/test/recovery/t/010_logical_decoding_timelines.pl index 12edbf760e..2a9cf3b79c 100644 --- a/src/test/recovery/t/010_logical_decoding_timelines.pl +++ b/src/test/recovery/t/010_logical_decoding_timelines.pl @@ -34,7 +34,7 @@ use Scalar::Util qw(blessed); my ($stdout, $stderr, $ret); # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1, has_archiving => 1); $node_primary->append_conf( 'postgresql.conf', q[ @@ -74,7 +74,7 @@ $node_primary->backup_fs_hot($backup_name); $node_primary->safe_psql('postgres', q[SELECT pg_create_physical_replication_slot('phys_slot');]); -my $node_replica = get_new_node('replica'); +my $node_replica = PostgresNode->new('replica'); $node_replica->init_from_backup( $node_primary, $backup_name, has_streaming => 1, diff --git a/src/test/recovery/t/011_crash_recovery.pl b/src/test/recovery/t/011_crash_recovery.pl index a26e99500b..72fc603e6d 100644 --- a/src/test/recovery/t/011_crash_recovery.pl +++ b/src/test/recovery/t/011_crash_recovery.pl @@ -13,7 +13,7 @@ use Config; plan tests => 3; -my $node = get_new_node('primary'); +my $node = PostgresNode->new('primary'); $node->init(allows_streaming => 1); $node->start; diff --git a/src/test/recovery/t/012_subtransactions.pl b/src/test/recovery/t/012_subtransactions.pl index aa84073311..a3655a076b 100644 --- a/src/test/recovery/t/012_subtransactions.pl +++ b/src/test/recovery/t/012_subtransactions.pl @@ -10,7 +10,7 @@ use TestLib; use Test::More tests => 12; # Setup primary node -my $node_primary = get_new_node("primary"); +my $node_primary = PostgresNode->new("primary"); $node_primary->init(allows_streaming => 1); $node_primary->append_conf( 'postgresql.conf', qq( @@ -22,7 +22,7 @@ $node_primary->backup('primary_backup'); $node_primary->psql('postgres', "CREATE TABLE t_012_tbl (id int)"); # Setup standby node -my $node_standby = get_new_node('standby'); +my $node_standby = PostgresNode->new('standby'); $node_standby->init_from_backup($node_primary, 'primary_backup', has_streaming => 1); $node_standby->start; diff --git a/src/test/recovery/t/013_crash_restart.pl b/src/test/recovery/t/013_crash_restart.pl index 868a50b33d..b5e3457753 100644 --- a/src/test/recovery/t/013_crash_restart.pl +++ b/src/test/recovery/t/013_crash_restart.pl @@ -27,7 +27,7 @@ plan tests => 18; # is really wrong. my $psql_timeout = IPC::Run::timer(60); -my $node = get_new_node('primary'); +my $node = PostgresNode->new('primary'); $node->init(allows_streaming => 1); $node->start(); diff --git a/src/test/recovery/t/014_unlogged_reinit.pl b/src/test/recovery/t/014_unlogged_reinit.pl index b629d549dd..4c22663b64 100644 --- a/src/test/recovery/t/014_unlogged_reinit.pl +++ b/src/test/recovery/t/014_unlogged_reinit.pl @@ -12,7 +12,7 @@ use PostgresNode; use TestLib; use Test::More tests => 12; -my $node = get_new_node('main'); +my $node = PostgresNode->new('main'); $node->init; $node->start; diff --git a/src/test/recovery/t/015_promotion_pages.pl b/src/test/recovery/t/015_promotion_pages.pl index 2b72dc2334..562c4cd3e4 100644 --- a/src/test/recovery/t/015_promotion_pages.pl +++ b/src/test/recovery/t/015_promotion_pages.pl @@ -12,7 +12,7 @@ use TestLib; use Test::More tests => 1; # Initialize primary node -my $alpha = get_new_node('alpha'); +my $alpha = PostgresNode->new('alpha'); $alpha->init(allows_streaming => 1); # Setting wal_log_hints to off is important to get invalid page # references. @@ -25,7 +25,7 @@ $alpha->start; # setup/start a standby $alpha->backup('bkp'); -my $bravo = get_new_node('bravo'); +my $bravo = PostgresNode->new('bravo'); $bravo->init_from_backup($alpha, 'bkp', has_streaming => 1); $bravo->append_conf('postgresql.conf', <new('primary'); $primary->init(allows_streaming => 1); # Set shared_buffers to a very low value to enforce discard and flush @@ -61,7 +61,7 @@ $primary->start; # setup/start a standby $primary->backup('bkp'); -my $standby = get_new_node('standby'); +my $standby = PostgresNode->new('standby'); $standby->init_from_backup($primary, 'bkp', has_streaming => 1); $standby->start; diff --git a/src/test/recovery/t/017_shm.pl b/src/test/recovery/t/017_shm.pl index 6fe9b97f6e..5548a1556d 100644 --- a/src/test/recovery/t/017_shm.pl +++ b/src/test/recovery/t/017_shm.pl @@ -43,7 +43,7 @@ sub log_ipcs } # Node setup. -my $gnat = PostgresNode->get_new_node('gnat'); +my $gnat = PostgresNode->new('gnat'); $gnat->init; # Create a shmem segment that will conflict with gnat's first choice diff --git a/src/test/recovery/t/018_wal_optimize.pl b/src/test/recovery/t/018_wal_optimize.pl index 53d9864309..4aa1bf8f54 100644 --- a/src/test/recovery/t/018_wal_optimize.pl +++ b/src/test/recovery/t/018_wal_optimize.pl @@ -43,7 +43,7 @@ sub run_wal_optimize { my $wal_level = shift; - my $node = get_new_node("node_$wal_level"); + my $node = PostgresNode->new("node_$wal_level"); $node->init; $node->append_conf( 'postgresql.conf', qq( diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl index 54ddcef2bb..99e1a83e4b 100644 --- a/src/test/recovery/t/019_replslot_limit.pl +++ b/src/test/recovery/t/019_replslot_limit.pl @@ -17,7 +17,7 @@ use Time::HiRes qw(usleep); $ENV{PGDATABASE} = 'postgres'; # Initialize primary node, setting wal-segsize to 1MB -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1, extra => ['--wal-segsize=1']); $node_primary->append_conf( 'postgresql.conf', qq( @@ -41,7 +41,7 @@ my $backup_name = 'my_backup'; $node_primary->backup($backup_name); # Create a standby linking to it using the replication slot -my $node_standby = get_new_node('standby_1'); +my $node_standby = PostgresNode->new('standby_1'); $node_standby->init_from_backup($node_primary, $backup_name, has_streaming => 1); $node_standby->append_conf('postgresql.conf', "primary_slot_name = 'rep1'"); @@ -250,7 +250,7 @@ ok($failed, 'check that replication has been broken'); $node_primary->stop; $node_standby->stop; -my $node_primary2 = get_new_node('primary2'); +my $node_primary2 = PostgresNode->new('primary2'); $node_primary2->init(allows_streaming => 1); $node_primary2->append_conf( 'postgresql.conf', qq( @@ -271,7 +271,7 @@ max_slot_wal_keep_size = 0 )); $node_primary2->start; -$node_standby = get_new_node('standby_2'); +$node_standby = PostgresNode->new('standby_2'); $node_standby->init_from_backup($node_primary2, $backup_name, has_streaming => 1); $node_standby->append_conf('postgresql.conf', "primary_slot_name = 'rep1'"); @@ -303,7 +303,7 @@ if ($TestLib::windows_os) # Get a slot terminated while the walsender is active # We do this by sending SIGSTOP to the walsender. Skip this on Windows. -my $node_primary3 = get_new_node('primary3'); +my $node_primary3 = PostgresNode->new('primary3'); $node_primary3->init(allows_streaming => 1, extra => ['--wal-segsize=1']); $node_primary3->append_conf( 'postgresql.conf', qq( @@ -319,7 +319,7 @@ $node_primary3->safe_psql('postgres', $backup_name = 'my_backup'; $node_primary3->backup($backup_name); # Create standby -my $node_standby3 = get_new_node('standby_3'); +my $node_standby3 = PostgresNode->new('standby_3'); $node_standby3->init_from_backup($node_primary3, $backup_name, has_streaming => 1); $node_standby3->append_conf('postgresql.conf', "primary_slot_name = 'rep3'"); diff --git a/src/test/recovery/t/020_archive_status.pl b/src/test/recovery/t/020_archive_status.pl index 777bf05274..cea65735a3 100644 --- a/src/test/recovery/t/020_archive_status.pl +++ b/src/test/recovery/t/020_archive_status.pl @@ -11,7 +11,7 @@ use TestLib; use Test::More tests => 16; use Config; -my $primary = get_new_node('primary'); +my $primary = PostgresNode->new('primary'); $primary->init( has_archiving => 1, allows_streaming => 1); @@ -138,7 +138,7 @@ $primary->poll_query_until('postgres', or die "Timed out while waiting for archiving to finish"; # Test standby with archive_mode = on. -my $standby1 = get_new_node('standby'); +my $standby1 = PostgresNode->new('standby'); $standby1->init_from_backup($primary, 'backup', has_restoring => 1); $standby1->append_conf('postgresql.conf', "archive_mode = on"); my $standby1_data = $standby1->data_dir; @@ -174,7 +174,7 @@ ok( -f "$standby1_data/$segment_path_2_done", # command to fail to persist the .ready files. Note that this node # has inherited the archive command of the previous cold backup that # will cause archiving failures. -my $standby2 = get_new_node('standby2'); +my $standby2 = PostgresNode->new('standby2'); $standby2->init_from_backup($primary, 'backup', has_restoring => 1); $standby2->append_conf('postgresql.conf', 'archive_mode = always'); my $standby2_data = $standby2->data_dir; diff --git a/src/test/recovery/t/021_row_visibility.pl b/src/test/recovery/t/021_row_visibility.pl index fcff0a2feb..7f40977976 100644 --- a/src/test/recovery/t/021_row_visibility.pl +++ b/src/test/recovery/t/021_row_visibility.pl @@ -12,7 +12,7 @@ use Test::More tests => 10; use Config; # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(allows_streaming => 1); $node_primary->append_conf('postgresql.conf', 'max_prepared_transactions=10'); $node_primary->start; @@ -26,7 +26,7 @@ my $backup_name = 'my_backup'; $node_primary->backup($backup_name); # Create streaming standby from backup -my $node_standby = get_new_node('standby'); +my $node_standby = PostgresNode->new('standby'); $node_standby->init_from_backup($node_primary, $backup_name, has_streaming => 1); $node_standby->append_conf('postgresql.conf', 'max_prepared_transactions=10'); diff --git a/src/test/recovery/t/022_crash_temp_files.pl b/src/test/recovery/t/022_crash_temp_files.pl index 157ddba8cf..cc8c8664e2 100644 --- a/src/test/recovery/t/022_crash_temp_files.pl +++ b/src/test/recovery/t/022_crash_temp_files.pl @@ -26,7 +26,7 @@ else # is really wrong. my $psql_timeout = IPC::Run::timer(60); -my $node = get_new_node('node_crash'); +my $node = PostgresNode->new('node_crash'); $node->init(); $node->start(); diff --git a/src/test/recovery/t/023_pitr_prepared_xact.pl b/src/test/recovery/t/023_pitr_prepared_xact.pl index 9190a38f93..a1ff97d070 100644 --- a/src/test/recovery/t/023_pitr_prepared_xact.pl +++ b/src/test/recovery/t/023_pitr_prepared_xact.pl @@ -10,7 +10,7 @@ use Test::More tests => 1; use File::Compare; # Initialize and start primary node with WAL archiving -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); $node_primary->init(has_archiving => 1, allows_streaming => 1); $node_primary->append_conf( 'postgresql.conf', qq{ @@ -24,7 +24,7 @@ $node_primary->backup($backup_name); # Initialize node for PITR targeting a very specific restore point, just # after a PREPARE TRANSACTION is issued so as we finish with a promoted # node where this 2PC transaction needs an explicit COMMIT PREPARED. -my $node_pitr = get_new_node('node_pitr'); +my $node_pitr = PostgresNode->new('node_pitr'); $node_pitr->init_from_backup( $node_primary, $backup_name, standby => 0, diff --git a/src/test/recovery/t/024_archive_recovery.pl b/src/test/recovery/t/024_archive_recovery.pl index f06ed8c8a1..32be5c4251 100644 --- a/src/test/recovery/t/024_archive_recovery.pl +++ b/src/test/recovery/t/024_archive_recovery.pl @@ -11,7 +11,7 @@ use Time::HiRes qw(usleep); # Initialize and start node with wal_level = replica and WAL archiving # enabled. -my $node = get_new_node('orig'); +my $node = PostgresNode->new('orig'); $node->init(has_archiving => 1, allows_streaming => 1); my $replica_config = q[ wal_level = replica @@ -66,7 +66,7 @@ sub test_recovery_wal_level_minimal { my ($node_name, $node_text, $standby_setting) = @_; - my $recovery_node = get_new_node($node_name); + my $recovery_node = PostgresNode->new($node_name); $recovery_node->init_from_backup( $node, $backup_name, has_restoring => 1, diff --git a/src/test/recovery/t/025_stuck_on_old_timeline.pl b/src/test/recovery/t/025_stuck_on_old_timeline.pl index fb15f9576b..00ee9fcaed 100644 --- a/src/test/recovery/t/025_stuck_on_old_timeline.pl +++ b/src/test/recovery/t/025_stuck_on_old_timeline.pl @@ -16,7 +16,7 @@ use FindBin; use Test::More tests => 1; # Initialize primary node -my $node_primary = get_new_node('primary'); +my $node_primary = PostgresNode->new('primary'); # Set up an archive command that will copy the history file but not the WAL # files. No real archive command should behave this way; the point is to @@ -47,7 +47,7 @@ my $backup_name = 'my_backup'; $node_primary->backup($backup_name); # Create streaming standby linking to primary -my $node_standby = get_new_node('standby'); +my $node_standby = PostgresNode->new('standby'); $node_standby->init_from_backup( $node_primary, $backup_name, allows_streaming => 1, @@ -60,7 +60,7 @@ $node_standby->backup($backup_name, backup_options => ['-Xnone']); # Create cascading standby but don't start it yet. # Must set up both streaming and archiving. -my $node_cascade = get_new_node('cascade'); +my $node_cascade = PostgresNode->new('cascade'); $node_cascade->init_from_backup($node_standby, $backup_name, has_streaming => 1); $node_cascade->enable_restoring($node_primary); diff --git a/src/test/ssl/t/001_ssltests.pl b/src/test/ssl/t/001_ssltests.pl index 44daefb002..3bc711f4a7 100644 --- a/src/test/ssl/t/001_ssltests.pl +++ b/src/test/ssl/t/001_ssltests.pl @@ -64,7 +64,7 @@ push @keys, 'client_wrongperms'; #### Set up the server. note "setting up data directory"; -my $node = get_new_node('primary'); +my $node = PostgresNode->new('primary'); $node->init; # PGHOST is enforced here to set up the node, subsequent connections diff --git a/src/test/ssl/t/002_scram.pl b/src/test/ssl/t/002_scram.pl index 9143fa515f..1dfa2b91f3 100644 --- a/src/test/ssl/t/002_scram.pl +++ b/src/test/ssl/t/002_scram.pl @@ -38,7 +38,7 @@ my $common_connstr; # Set up the server. note "setting up data directory"; -my $node = get_new_node('primary'); +my $node = PostgresNode->new('primary'); $node->init; # PGHOST is enforced here to set up the node, subsequent connections diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl index dee5f5c30a..0c84d87873 100644 --- a/src/test/subscription/t/001_rep_changes.pl +++ b/src/test/subscription/t/001_rep_changes.pl @@ -9,12 +9,12 @@ use TestLib; use Test::More tests => 32; # Initialize publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/002_types.pl b/src/test/subscription/t/002_types.pl index 96669f869b..420876099a 100644 --- a/src/test/subscription/t/002_types.pl +++ b/src/test/subscription/t/002_types.pl @@ -10,12 +10,12 @@ use TestLib; use Test::More tests => 4; # Initialize publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/003_constraints.pl b/src/test/subscription/t/003_constraints.pl index 1182a1288c..3767d24f92 100644 --- a/src/test/subscription/t/003_constraints.pl +++ b/src/test/subscription/t/003_constraints.pl @@ -9,12 +9,12 @@ use TestLib; use Test::More tests => 6; # Initialize publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/004_sync.pl b/src/test/subscription/t/004_sync.pl index b3c91af21d..f07c306e5b 100644 --- a/src/test/subscription/t/004_sync.pl +++ b/src/test/subscription/t/004_sync.pl @@ -9,12 +9,12 @@ use TestLib; use Test::More tests => 8; # Initialize publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->append_conf('postgresql.conf', "wal_retrieve_retry_interval = 1ms"); diff --git a/src/test/subscription/t/005_encoding.pl b/src/test/subscription/t/005_encoding.pl index a3f56a452f..9df474beb5 100644 --- a/src/test/subscription/t/005_encoding.pl +++ b/src/test/subscription/t/005_encoding.pl @@ -8,13 +8,13 @@ use PostgresNode; use TestLib; use Test::More tests => 1; -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init( allows_streaming => 'logical', extra => [ '--locale=C', '--encoding=UTF8' ]); $node_publisher->start; -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init( allows_streaming => 'logical', extra => [ '--locale=C', '--encoding=LATIN1' ]); diff --git a/src/test/subscription/t/006_rewrite.pl b/src/test/subscription/t/006_rewrite.pl index 37e05a401a..ec4d641230 100644 --- a/src/test/subscription/t/006_rewrite.pl +++ b/src/test/subscription/t/006_rewrite.pl @@ -8,11 +8,11 @@ use PostgresNode; use TestLib; use Test::More tests => 2; -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/007_ddl.pl b/src/test/subscription/t/007_ddl.pl index dd10d5cffa..1a3a1dcf14 100644 --- a/src/test/subscription/t/007_ddl.pl +++ b/src/test/subscription/t/007_ddl.pl @@ -8,11 +8,11 @@ use PostgresNode; use TestLib; use Test::More tests => 1; -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/008_diff_schema.pl b/src/test/subscription/t/008_diff_schema.pl index a04a798a18..3af3d25604 100644 --- a/src/test/subscription/t/008_diff_schema.pl +++ b/src/test/subscription/t/008_diff_schema.pl @@ -9,12 +9,12 @@ use TestLib; use Test::More tests => 5; # Create publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/009_matviews.pl b/src/test/subscription/t/009_matviews.pl index 92c7d18be8..2e7d0d4413 100644 --- a/src/test/subscription/t/009_matviews.pl +++ b/src/test/subscription/t/009_matviews.pl @@ -8,11 +8,11 @@ use PostgresNode; use TestLib; use Test::More tests => 1; -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/010_truncate.pl b/src/test/subscription/t/010_truncate.pl index 5617469a2c..0e6ecf9c2f 100644 --- a/src/test/subscription/t/010_truncate.pl +++ b/src/test/subscription/t/010_truncate.pl @@ -10,11 +10,11 @@ use Test::More tests => 14; # setup -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->append_conf('postgresql.conf', qq(max_logical_replication_workers = 6)); diff --git a/src/test/subscription/t/011_generated.pl b/src/test/subscription/t/011_generated.pl index 29108cbcf2..a8e7fbd9da 100644 --- a/src/test/subscription/t/011_generated.pl +++ b/src/test/subscription/t/011_generated.pl @@ -10,11 +10,11 @@ use Test::More tests => 2; # setup -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/012_collation.pl b/src/test/subscription/t/012_collation.pl index 8137a165ee..0987391188 100644 --- a/src/test/subscription/t/012_collation.pl +++ b/src/test/subscription/t/012_collation.pl @@ -18,13 +18,13 @@ else plan skip_all => 'ICU not supported by this build'; } -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init( allows_streaming => 'logical', extra => [ '--locale=C', '--encoding=UTF8' ]); $node_publisher->start; -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init( allows_streaming => 'logical', extra => [ '--locale=C', '--encoding=UTF8' ]); diff --git a/src/test/subscription/t/013_partition.pl b/src/test/subscription/t/013_partition.pl index 3478e4db8f..c89d495221 100644 --- a/src/test/subscription/t/013_partition.pl +++ b/src/test/subscription/t/013_partition.pl @@ -10,15 +10,15 @@ use Test::More tests => 62; # setup -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; -my $node_subscriber1 = get_new_node('subscriber1'); +my $node_subscriber1 = PostgresNode->new('subscriber1'); $node_subscriber1->init(allows_streaming => 'logical'); $node_subscriber1->start; -my $node_subscriber2 = get_new_node('subscriber2'); +my $node_subscriber2 = PostgresNode->new('subscriber2'); $node_subscriber2->init(allows_streaming => 'logical'); $node_subscriber2->start; diff --git a/src/test/subscription/t/014_binary.pl b/src/test/subscription/t/014_binary.pl index 7260378f5e..4e8aeb2e41 100644 --- a/src/test/subscription/t/014_binary.pl +++ b/src/test/subscription/t/014_binary.pl @@ -10,12 +10,12 @@ use TestLib; use Test::More tests => 5; # Create and initialize a publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; # Create and initialize subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/015_stream.pl b/src/test/subscription/t/015_stream.pl index 6cc8b4a8d2..da6761f81e 100644 --- a/src/test/subscription/t/015_stream.pl +++ b/src/test/subscription/t/015_stream.pl @@ -9,14 +9,14 @@ use TestLib; use Test::More tests => 4; # Create publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/016_stream_subxact.pl b/src/test/subscription/t/016_stream_subxact.pl index 0245b0685b..4aae98a66e 100644 --- a/src/test/subscription/t/016_stream_subxact.pl +++ b/src/test/subscription/t/016_stream_subxact.pl @@ -9,14 +9,14 @@ use TestLib; use Test::More tests => 2; # Create publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/017_stream_ddl.pl b/src/test/subscription/t/017_stream_ddl.pl index 35b146827d..50bd6e3117 100644 --- a/src/test/subscription/t/017_stream_ddl.pl +++ b/src/test/subscription/t/017_stream_ddl.pl @@ -9,14 +9,14 @@ use TestLib; use Test::More tests => 3; # Create publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/018_stream_subxact_abort.pl b/src/test/subscription/t/018_stream_subxact_abort.pl index 7fc60b5bde..63fe248a04 100644 --- a/src/test/subscription/t/018_stream_subxact_abort.pl +++ b/src/test/subscription/t/018_stream_subxact_abort.pl @@ -9,14 +9,14 @@ use TestLib; use Test::More tests => 4; # Create publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl index 81149b86a9..176a702486 100644 --- a/src/test/subscription/t/019_stream_subxact_ddl_abort.pl +++ b/src/test/subscription/t/019_stream_subxact_ddl_abort.pl @@ -10,14 +10,14 @@ use TestLib; use Test::More tests => 2; # Create publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->append_conf('postgresql.conf', 'logical_decoding_work_mem = 64kB'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/020_messages.pl b/src/test/subscription/t/020_messages.pl index 0e218e0048..ecf9b192a3 100644 --- a/src/test/subscription/t/020_messages.pl +++ b/src/test/subscription/t/020_messages.pl @@ -9,13 +9,13 @@ use TestLib; use Test::More tests => 5; # Create publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->append_conf('postgresql.conf', 'autovacuum = off'); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; diff --git a/src/test/subscription/t/021_twophase.pl b/src/test/subscription/t/021_twophase.pl index c6ada92ff0..903a771fe3 100644 --- a/src/test/subscription/t/021_twophase.pl +++ b/src/test/subscription/t/021_twophase.pl @@ -13,14 +13,14 @@ use Test::More tests => 24; ############################### # Initialize publisher node -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->append_conf('postgresql.conf', qq(max_prepared_transactions = 10)); $node_publisher->start; # Create subscriber node -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->append_conf('postgresql.conf', qq(max_prepared_transactions = 10)); diff --git a/src/test/subscription/t/022_twophase_cascade.pl b/src/test/subscription/t/022_twophase_cascade.pl index e61d28a48b..d7cc99959f 100644 --- a/src/test/subscription/t/022_twophase_cascade.pl +++ b/src/test/subscription/t/022_twophase_cascade.pl @@ -15,19 +15,19 @@ use Test::More tests => 27; # Initialize nodes # node_A -my $node_A = get_new_node('node_A'); +my $node_A = PostgresNode->new('node_A'); $node_A->init(allows_streaming => 'logical'); $node_A->append_conf('postgresql.conf', qq(max_prepared_transactions = 10)); $node_A->start; # node_B -my $node_B = get_new_node('node_B'); +my $node_B = PostgresNode->new('node_B'); $node_B->init(allows_streaming => 'logical'); $node_B->append_conf('postgresql.conf', qq(max_prepared_transactions = 10)); $node_B->start; # node_C -my $node_C = get_new_node('node_C'); +my $node_C = PostgresNode->new('node_C'); $node_C->init(allows_streaming => 'logical'); $node_C->append_conf('postgresql.conf', qq(max_prepared_transactions = 10)); diff --git a/src/test/subscription/t/100_bugs.pl b/src/test/subscription/t/100_bugs.pl index 21eabceb2f..baa4a90771 100644 --- a/src/test/subscription/t/100_bugs.pl +++ b/src/test/subscription/t/100_bugs.pl @@ -19,11 +19,11 @@ use Test::More tests => 5; # fix was to avoid the constant expressions simplification in # RelationGetIndexAttrBitmap(), so it's safe to call in more contexts. -my $node_publisher = get_new_node('publisher'); +my $node_publisher = PostgresNode->new('publisher'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; -my $node_subscriber = get_new_node('subscriber'); +my $node_subscriber = PostgresNode->new('subscriber'); $node_subscriber->init(allows_streaming => 'logical'); $node_subscriber->start; @@ -81,7 +81,7 @@ $node_subscriber->stop('fast'); # identity set before accepting updates. If it did not it would cause # an error when an update was attempted. -$node_publisher = get_new_node('publisher2'); +$node_publisher = PostgresNode->new('publisher2'); $node_publisher->init(allows_streaming => 'logical'); $node_publisher->start; @@ -108,7 +108,7 @@ $node_publisher->stop('fast'); # # Initial sync doesn't complete; the protocol was not being followed per # expectations after commit 07082b08cc5d. -my $node_twoways = get_new_node('twoways'); +my $node_twoways = PostgresNode->new('twoways'); $node_twoways->init(allows_streaming => 'logical'); $node_twoways->start; for my $db (qw(d1 d2)) @@ -158,15 +158,15 @@ is($node_twoways->safe_psql('d2', "SELECT count(f) FROM t2"), # Verify table data is synced with cascaded replication setup. This is mainly # to test whether the data written by tablesync worker gets replicated. -my $node_pub = get_new_node('testpublisher1'); +my $node_pub = PostgresNode->new('testpublisher1'); $node_pub->init(allows_streaming => 'logical'); $node_pub->start; -my $node_pub_sub = get_new_node('testpublisher_subscriber'); +my $node_pub_sub = PostgresNode->new('testpublisher_subscriber'); $node_pub_sub->init(allows_streaming => 'logical'); $node_pub_sub->start; -my $node_sub = get_new_node('testsubscriber1'); +my $node_sub = PostgresNode->new('testsubscriber1'); $node_sub->init(allows_streaming => 'logical'); $node_sub->start;