Skip to content

Commit b3b4d8e

Browse files
committed
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
1 parent 3cd9c3b commit b3b4d8e

File tree

144 files changed

+656
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+656
-656
lines changed

contrib/amcheck/t/001_verify_heapam.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use strict;
55
use warnings;
66

7-
use PostgresNode;
8-
use TestLib;
7+
use PostgreSQL::Test::Cluster;
8+
use PostgreSQL::Test::Utils;
99

1010
use Fcntl qw(:seek);
1111
use Test::More tests => 272;
@@ -15,7 +15,7 @@
1515
#
1616
# Test set-up
1717
#
18-
$node = PostgresNode->new('test');
18+
$node = PostgreSQL::Test::Cluster->new('test');
1919
$node->init;
2020
$node->append_conf('postgresql.conf', 'autovacuum=off');
2121
$node->start;

contrib/amcheck/t/002_cic.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use warnings;
77

88
use Config;
9-
use PostgresNode;
10-
use TestLib;
9+
use PostgreSQL::Test::Cluster;
10+
use PostgreSQL::Test::Utils;
1111

1212
use Test::More tests => 4;
1313

@@ -16,7 +16,7 @@
1616
#
1717
# Test set-up
1818
#
19-
$node = PostgresNode->new('CIC_test');
19+
$node = PostgreSQL::Test::Cluster->new('CIC_test');
2020
$node->init;
2121
$node->append_conf('postgresql.conf', 'lock_timeout = 180000');
2222
$node->start;

contrib/amcheck/t/003_cic_2pc.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use warnings;
77

88
use Config;
9-
use PostgresNode;
10-
use TestLib;
9+
use PostgreSQL::Test::Cluster;
10+
use PostgreSQL::Test::Utils;
1111

1212
use Test::More tests => 6;
1313

@@ -16,7 +16,7 @@
1616
#
1717
# Test set-up
1818
#
19-
$node = PostgresNode->new('CIC_2PC_test');
19+
$node = PostgreSQL::Test::Cluster->new('CIC_2PC_test');
2020
$node->init;
2121
$node->append_conf('postgresql.conf', 'max_prepared_transactions = 10');
2222
$node->append_conf('postgresql.conf', 'lock_timeout = 180000');

contrib/auto_explain/t/001_auto_explain.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
use strict;
55
use warnings;
66

7-
use PostgresNode;
8-
use TestLib;
7+
use PostgreSQL::Test::Cluster;
8+
use PostgreSQL::Test::Utils;
99
use Test::More tests => 4;
1010

11-
my $node = PostgresNode->new('main');
11+
my $node = PostgreSQL::Test::Cluster->new('main');
1212
$node->init;
1313
$node->append_conf('postgresql.conf',
1414
"shared_preload_libraries = 'auto_explain'");

contrib/bloom/t/001_wal.pl

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Test generic xlog record work for bloom index replication.
55
use strict;
66
use warnings;
7-
use PostgresNode;
8-
use TestLib;
7+
use PostgreSQL::Test::Cluster;
8+
use PostgreSQL::Test::Utils;
99
use Test::More tests => 31;
1010

1111
my $node_primary;
@@ -41,7 +41,7 @@ sub test_index_replay
4141
}
4242

4343
# Initialize primary node
44-
$node_primary = PostgresNode->new('primary');
44+
$node_primary = PostgreSQL::Test::Cluster->new('primary');
4545
$node_primary->init(allows_streaming => 1);
4646
$node_primary->start;
4747
my $backup_name = 'my_backup';
@@ -50,7 +50,7 @@ sub test_index_replay
5050
$node_primary->backup($backup_name);
5151

5252
# Create streaming standby linking to primary
53-
$node_standby = PostgresNode->new('standby');
53+
$node_standby = PostgreSQL::Test::Cluster->new('standby');
5454
$node_standby->init_from_backup($node_primary, $backup_name,
5555
has_streaming => 1);
5656
$node_standby->start;

contrib/oid2name/t/001_basic.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use strict;
55
use warnings;
66

7-
use TestLib;
7+
use PostgreSQL::Test::Utils;
88
use Test::More tests => 8;
99

1010
#########################################

contrib/test_decoding/t/001_repl_stats.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
use strict;
77
use warnings;
88
use File::Path qw(rmtree);
9-
use PostgresNode;
10-
use TestLib;
9+
use PostgreSQL::Test::Cluster;
10+
use PostgreSQL::Test::Utils;
1111
use Test::More tests => 2;
1212

1313
# Test set-up
14-
my $node = PostgresNode->new('test');
14+
my $node = PostgreSQL::Test::Cluster->new('test');
1515
$node->init(allows_streaming => 'logical');
1616
$node->append_conf('postgresql.conf', 'synchronous_commit = on');
1717
$node->start;

contrib/vacuumlo/t/001_basic.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use strict;
55
use warnings;
66

7-
use TestLib;
7+
use PostgreSQL::Test::Utils;
88
use Test::More tests => 8;
99

1010
program_help_ok('vacuumlo');

src/bin/initdb/t/001_initdb.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
use warnings;
1010
use Fcntl ':mode';
1111
use File::stat qw{lstat};
12-
use PostgresNode;
13-
use TestLib;
12+
use PostgreSQL::Test::Cluster;
13+
use PostgreSQL::Test::Utils;
1414
use Test::More tests => 22;
1515

16-
my $tempdir = TestLib::tempdir;
16+
my $tempdir = PostgreSQL::Test::Utils::tempdir;
1717
my $xlogdir = "$tempdir/pgxlog";
1818
my $datadir = "$tempdir/data";
1919

src/bin/pg_amcheck/t/001_basic.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use strict;
55
use warnings;
66

7-
use TestLib;
7+
use PostgreSQL::Test::Utils;
88
use Test::More tests => 8;
99

1010
program_help_ok('pg_amcheck');

src/bin/pg_amcheck/t/002_nonesuch.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
use strict;
55
use warnings;
66

7-
use PostgresNode;
8-
use TestLib;
7+
use PostgreSQL::Test::Cluster;
8+
use PostgreSQL::Test::Utils;
99
use Test::More tests => 76;
1010

1111
# Test set-up
1212
my ($node, $port);
13-
$node = PostgresNode->new('test');
13+
$node = PostgreSQL::Test::Cluster->new('test');
1414
$node->init;
1515
$node->start;
1616
$port = $node->port;

src/bin/pg_amcheck/t/003_check.pl

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use strict;
55
use warnings;
66

7-
use PostgresNode;
8-
use TestLib;
7+
use PostgreSQL::Test::Cluster;
8+
use PostgreSQL::Test::Utils;
99

1010
use Fcntl qw(:seek);
1111
use Test::More tests => 63;
@@ -120,7 +120,7 @@ ()
120120
}
121121

122122
# Test set-up
123-
$node = PostgresNode->new('test');
123+
$node = PostgreSQL::Test::Cluster->new('test');
124124
$node->init;
125125
$node->append_conf('postgresql.conf', 'autovacuum=off');
126126
$node->start;
@@ -316,7 +316,7 @@ ()
316316
# Leave 'db3' uncorrupted
317317
#
318318

319-
# Standard first arguments to TestLib functions
319+
# Standard first arguments to PostgreSQL::Test::Utils functions
320320
my @cmd = ('pg_amcheck', '-p', $port);
321321

322322
# Regular expressions to match various expected output

src/bin/pg_amcheck/t/004_verify_heapam.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use strict;
55
use warnings;
66

7-
use PostgresNode;
8-
use TestLib;
7+
use PostgreSQL::Test::Cluster;
8+
use PostgreSQL::Test::Utils;
99

1010
use Fcntl qw(:seek);
1111
use Test::More;
@@ -178,7 +178,7 @@ sub write_tuple
178178
# Set up the node. Once we create and corrupt the table,
179179
# autovacuum workers visiting the table could crash the backend.
180180
# Disable autovacuum so that won't happen.
181-
my $node = PostgresNode->new('test');
181+
my $node = PostgreSQL::Test::Cluster->new('test');
182182
$node->init;
183183
$node->append_conf('postgresql.conf', 'autovacuum=off');
184184

src/bin/pg_amcheck/t/005_opclass_damage.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#
77
use strict;
88
use warnings;
9-
use PostgresNode;
10-
use TestLib;
9+
use PostgreSQL::Test::Cluster;
10+
use PostgreSQL::Test::Utils;
1111
use Test::More tests => 5;
1212

13-
my $node = PostgresNode->new('test');
13+
my $node = PostgreSQL::Test::Cluster->new('test');
1414
$node->init;
1515
$node->start;
1616

src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
use strict;
55
use warnings;
6-
use TestLib;
6+
use PostgreSQL::Test::Utils;
77
use Test::More tests => 42;
88

99
program_help_ok('pg_archivecleanup');
1010
program_version_ok('pg_archivecleanup');
1111
program_options_handling_ok('pg_archivecleanup');
1212

13-
my $tempdir = TestLib::tempdir;
13+
my $tempdir = PostgreSQL::Test::Utils::tempdir;
1414

1515
my @walfiles = (
1616
'00000001000000370000000C.gz', '00000001000000370000000D',

src/bin/pg_basebackup/t/010_pg_basebackup.pl

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
use File::Basename qw(basename dirname);
99
use File::Path qw(rmtree);
1010
use Fcntl qw(:seek);
11-
use PostgresNode;
12-
use TestLib;
11+
use PostgreSQL::Test::Cluster;
12+
use PostgreSQL::Test::Utils;
1313
use Test::More tests => 110;
1414

1515
program_help_ok('pg_basebackup');
1616
program_version_ok('pg_basebackup');
1717
program_options_handling_ok('pg_basebackup');
1818

19-
my $tempdir = TestLib::tempdir;
19+
my $tempdir = PostgreSQL::Test::Utils::tempdir;
2020

21-
my $node = PostgresNode->new('main');
21+
my $node = PostgreSQL::Test::Cluster->new('main');
2222

2323
# Set umask so test directories and files are created with default permissions
2424
umask(0077);
@@ -238,14 +238,14 @@
238238
# to our physical temp location. That way we can use shorter names
239239
# for the tablespace directories, which hopefully won't run afoul of
240240
# the 99 character length limit.
241-
my $sys_tempdir = TestLib::tempdir_short;
242-
my $real_sys_tempdir = TestLib::perl2host($sys_tempdir) . "/tempdir";
241+
my $sys_tempdir = PostgreSQL::Test::Utils::tempdir_short;
242+
my $real_sys_tempdir = PostgreSQL::Test::Utils::perl2host($sys_tempdir) . "/tempdir";
243243
my $shorter_tempdir = $sys_tempdir . "/tempdir";
244244
dir_symlink "$tempdir", $shorter_tempdir;
245245

246246
mkdir "$tempdir/tblspc1";
247247
my $realTsDir = "$real_sys_tempdir/tblspc1";
248-
my $real_tempdir = TestLib::perl2host($tempdir);
248+
my $real_tempdir = PostgreSQL::Test::Utils::perl2host($tempdir);
249249
$node->safe_psql('postgres',
250250
"CREATE TABLESPACE tblspc1 LOCATION '$realTsDir';");
251251
$node->safe_psql('postgres',
@@ -270,7 +270,7 @@
270270
skip "no tar program available", 1
271271
if (!defined $tar || $tar eq '');
272272

273-
my $node2 = PostgresNode->new('replica');
273+
my $node2 = PostgreSQL::Test::Cluster->new('replica');
274274

275275
# Recover main data directory
276276
$node2->init_from_backup($node, 'tarbackup2', tar_program => $tar);
@@ -279,7 +279,7 @@
279279
my $repTsDir = "$tempdir/tblspc1replica";
280280
my $realRepTsDir = "$real_sys_tempdir/tblspc1replica";
281281
mkdir $repTsDir;
282-
TestLib::system_or_bail($tar, 'xf', $tblspc_tars[0], '-C', $repTsDir);
282+
PostgreSQL::Test::Utils::system_or_bail($tar, 'xf', $tblspc_tars[0], '-C', $repTsDir);
283283

284284
# Update tablespace map to point to new directory.
285285
# XXX Ideally pg_basebackup would handle this.

src/bin/pg_basebackup/t/020_pg_receivewal.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
use strict;
55
use warnings;
6-
use TestLib;
7-
use PostgresNode;
6+
use PostgreSQL::Test::Utils;
7+
use PostgreSQL::Test::Cluster;
88
use Test::More tests => 27;
99

1010
program_help_ok('pg_receivewal');
@@ -14,7 +14,7 @@
1414
# Set umask so test directories and files are created with default permissions
1515
umask(0077);
1616

17-
my $primary = PostgresNode->new('primary');
17+
my $primary = PostgreSQL::Test::Cluster->new('primary');
1818
$primary->init(allows_streaming => 1);
1919
$primary->start;
2020

src/bin/pg_basebackup/t/030_pg_recvlogical.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
use strict;
55
use warnings;
6-
use TestLib;
7-
use PostgresNode;
6+
use PostgreSQL::Test::Utils;
7+
use PostgreSQL::Test::Cluster;
88
use Test::More tests => 20;
99

1010
program_help_ok('pg_recvlogical');
1111
program_version_ok('pg_recvlogical');
1212
program_options_handling_ok('pg_recvlogical');
1313

14-
my $node = PostgresNode->new('main');
14+
my $node = PostgreSQL::Test::Cluster->new('main');
1515

1616
# Initialize node without replication settings
1717
$node->init(allows_streaming => 1, has_archiving => 1);

src/bin/pg_checksums/t/001_basic.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use strict;
55
use warnings;
6-
use TestLib;
6+
use PostgreSQL::Test::Utils;
77
use Test::More tests => 8;
88

99
program_help_ok('pg_checksums');

src/bin/pg_checksums/t/002_actions.pl

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use strict;
88
use warnings;
99
use Config;
10-
use PostgresNode;
11-
use TestLib;
10+
use PostgreSQL::Test::Cluster;
11+
use PostgreSQL::Test::Utils;
1212

1313
use Fcntl qw(:seek);
1414
use Test::More tests => 66;
@@ -93,7 +93,7 @@ sub check_relation_corruption
9393
}
9494

9595
# Initialize node with checksums disabled.
96-
my $node = PostgresNode->new('node_checksum');
96+
my $node = PostgreSQL::Test::Cluster->new('node_checksum');
9797
$node->init();
9898
my $pgdata = $node->data_dir;
9999

@@ -207,7 +207,7 @@ sub check_relation_corruption
207207
my $basedir = $node->basedir;
208208
my $tablespace_dir = "$basedir/ts_corrupt_dir";
209209
mkdir($tablespace_dir);
210-
$tablespace_dir = TestLib::perl2host($tablespace_dir);
210+
$tablespace_dir = PostgreSQL::Test::Utils::perl2host($tablespace_dir);
211211
$node->safe_psql('postgres',
212212
"CREATE TABLESPACE ts_corrupt LOCATION '$tablespace_dir';");
213213
check_relation_corruption($node, 'corrupt2', 'ts_corrupt');

0 commit comments

Comments
 (0)