1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +03:00

Move Perl test modules to a better namespace

The five modules in our TAP test framework all had names in the top
level namespace. This is unwise because, even though we're not
exporting them to CPAN, the names can leak, for example if they are
exported by the RPM build process. We therefore move the modules to the
PostgreSQL::Test namespace. In the process PostgresNode is renamed to
Cluster, and TestLib is renamed to Utils. PostgresVersion becomes simply
PostgreSQL::Version, to avoid possible confusion about what it's the
version of.

Discussion: https://postgr.es/m/aede93a4-7d92-ef26-398f-5094944c2504@dunslane.net

Reviewed by Erik Rijkers and Michael Paquier
This commit is contained in:
Andrew Dunstan
2021-10-24 10:28:19 -04:00
parent 3cd9c3b921
commit b3b4d8e68a
144 changed files with 656 additions and 656 deletions

View File

@@ -7,12 +7,12 @@ use warnings;
use Config;
use Fcntl ':mode';
use File::stat qw{lstat};
use PostgresNode;
use TestLib;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 24;
my $tempdir = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
my $tempdir_short = PostgreSQL::Test::Utils::tempdir_short;
program_help_ok('pg_ctl');
program_version_ok('pg_ctl');
@@ -25,11 +25,11 @@ command_ok([ 'pg_ctl', 'initdb', '-D', "$tempdir/data", '-o', '-N' ],
'pg_ctl initdb');
command_ok([ $ENV{PG_REGRESS}, '--config-auth', "$tempdir/data" ],
'configure authentication');
my $node_port = PostgresNode::get_free_port();
my $node_port = PostgreSQL::Test::Cluster::get_free_port();
open my $conf, '>>', "$tempdir/data/postgresql.conf";
print $conf "fsync = off\n";
print $conf "port = $node_port\n";
print $conf TestLib::slurp_file($ENV{TEMP_CONFIG})
print $conf PostgreSQL::Test::Utils::slurp_file($ENV{TEMP_CONFIG})
if defined $ENV{TEMP_CONFIG};
if ($use_unix_sockets)
@@ -44,7 +44,7 @@ else
close $conf;
my $ctlcmd = [
'pg_ctl', 'start', '-D', "$tempdir/data", '-l',
"$TestLib::log_path/001_start_stop_server.log"
"$PostgreSQL::Test::Utils::log_path/001_start_stop_server.log"
];
if ($Config{osname} ne 'msys')
{

View File

@@ -4,16 +4,16 @@
use strict;
use warnings;
use PostgresNode;
use TestLib;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
my $tempdir = TestLib::tempdir;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
command_exit_is([ 'pg_ctl', 'status', '-D', "$tempdir/nonexistent" ],
4, 'pg_ctl status with nonexistent directory');
my $node = PostgresNode->new('main');
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
command_exit_is([ 'pg_ctl', 'status', '-D', $node->data_dir ],

View File

@@ -4,18 +4,18 @@
use strict;
use warnings;
use PostgresNode;
use TestLib;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 12;
my $tempdir = TestLib::tempdir;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
command_fails_like(
[ 'pg_ctl', '-D', "$tempdir/nonexistent", 'promote' ],
qr/directory .* does not exist/,
'pg_ctl promote with nonexistent directory');
my $node_primary = PostgresNode->new('primary');
my $node_primary = PostgreSQL::Test::Cluster->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 = PostgresNode->new('standby');
my $node_standby = PostgreSQL::Test::Cluster->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 = PostgresNode->new('standby2');
$node_standby = PostgreSQL::Test::Cluster->new('standby2');
$node_standby->init_from_backup($node_primary, 'my_backup',
has_streaming => 1);
$node_standby->start;

View File

@@ -4,8 +4,8 @@
use strict;
use warnings;
use PostgresNode;
use TestLib;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 10;
use Time::HiRes qw(usleep);
@@ -60,7 +60,7 @@ sub check_log_pattern
}
# Set up node with logging collector
my $node = PostgresNode->new('primary');
my $node = PostgreSQL::Test::Cluster->new('primary');
$node->init();
$node->append_conf(
'postgresql.conf', qq(