Replace Test::More plans with done_testing

Rather than doing manual book keeping to plan the number of tests to run
in each TAP suite, conclude each run with done_testing() summing up the
the number of tests that ran. This removes the need for maintaning and
updating the plan count at the expense of an accurate count of remaining
during the test suite runtime.

This patch has been discussed a number of times, often in the context of
other patches which updates tests, so a larger number of discussions can
be found in the archives.

Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/DD399313-3D56-4666-8079-88949DAC870F@yesql.se
This commit is contained in:
Daniel Gustafsson 2022-02-11 20:54:44 +01:00
parent 751b8d23b7
commit 549ec201d6
139 changed files with 394 additions and 303 deletions

View File

@ -8,7 +8,7 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Fcntl qw(:seek);
use Test::More tests => 272;
use Test::More;
my ($node, $result);
@ -283,3 +283,5 @@ sub check_all_options_uncorrupted
}
}
}
done_testing();

View File

@ -9,7 +9,7 @@ use Config;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
my ($node, $result);

View File

@ -9,7 +9,7 @@ use Config;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 5;
use Test::More;
Test::More->builder->todo_start('filesystem bug')
if PostgreSQL::Test::Utils::has_wal_read_bug;

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 4;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
@ -53,3 +53,5 @@ like(
$log_contents,
qr/"Node Type": "Index Scan"[^}]*"Index Name": "pg_class_relname_nsp_index"/s,
"index scan logged, json mode");
done_testing();

View File

@ -6,7 +6,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 31;
use Test::More;
my $node_primary;
my $node_standby;
@ -80,3 +80,5 @@ for my $i (1 .. 10)
);
test_index_replay("insert $i");
}
done_testing();

View File

@ -5,7 +5,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 8;
use Test::More;
#########################################
# Basic checks
@ -13,3 +13,5 @@ use Test::More tests => 8;
program_help_ok('oid2name');
program_version_ok('oid2name');
program_options_handling_ok('oid2name');
done_testing();

View File

@ -8,7 +8,7 @@ use warnings;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 2;
use Test::More;
# Test set-up
my $node = PostgreSQL::Test::Cluster->new('test');
@ -118,3 +118,5 @@ $node->safe_psql('postgres',
# shutdown
$node->stop;
done_testing();

View File

@ -5,8 +5,10 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 8;
use Test::More;
program_help_ok('vacuumlo');
program_version_ok('vacuumlo');
program_options_handling_ok('vacuumlo');
done_testing();

View File

@ -11,7 +11,7 @@ use Fcntl ':mode';
use File::stat qw{lstat};
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 22;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
my $xlogdir = "$tempdir/pgxlog";
@ -92,3 +92,5 @@ SKIP:
ok(check_mode_recursive($datadir_group, 0750, 0640),
'check PGDATA permissions');
}
done_testing();

View File

@ -5,8 +5,10 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 8;
use Test::More;
program_help_ok('pg_amcheck');
program_version_ok('pg_amcheck');
program_options_handling_ok('pg_amcheck');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 76;
use Test::More;
# Test set-up
my ($node, $port);
@ -268,3 +268,5 @@ $node->command_checks_all(
qr/pg_amcheck: error: no relations to check/
],
'schema exclusion pattern overrides all inclusion patterns');
done_testing();

View File

@ -8,7 +8,7 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Fcntl qw(:seek);
use Test::More tests => 63;
use Test::More;
my ($node, $port, %corrupt_page, %remove_relation);
@ -517,3 +517,5 @@ $node->command_checks_all(
[ @cmd, '-d', 'db1', '-d', 'db2', '-d', 'db3', '-S', 's*' ],
0, [$no_output_re], [$no_output_re],
'pg_amcheck excluding all corrupt schemas');
done_testing();

View File

@ -297,7 +297,6 @@ close($file)
$node->start;
# Ok, Xids and page layout look ok. We can run corruption tests.
plan tests => 19;
# Check that pg_amcheck runs against the uncorrupted table without error.
$node->command_ok(
@ -528,3 +527,5 @@ $node->command_checks_all(
$node->teardown_node;
$node->clean_node;
done_testing();

View File

@ -8,7 +8,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 5;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('test');
$node->init;
@ -57,3 +57,5 @@ $node->command_checks_all(
[],
'pg_amcheck all schemas, tables and indexes reports fickleidx corruption'
);
done_testing();

View File

@ -4,7 +4,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 42;
use Test::More;
program_help_ok('pg_archivecleanup');
program_version_ok('pg_archivecleanup');
@ -101,3 +101,5 @@ sub run_check
run_check('', 'pg_archivecleanup');
run_check('.partial', 'pg_archivecleanup with .partial file');
run_check('.00000020.backup', 'pg_archivecleanup with .backup file');
done_testing();

View File

@ -5,7 +5,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use PostgreSQL::Test::Cluster;
use Test::More tests => 42;
use Test::More;
program_help_ok('pg_receivewal');
program_version_ok('pg_receivewal');
@ -334,3 +334,5 @@ ok(-e "$timeline_dir/$walfile_after_promotion",
"WAL segment $walfile_after_promotion archived after timeline jump");
ok(-e "$timeline_dir/00000002.history",
"timeline history file archived after timeline jump");
done_testing();

View File

@ -5,7 +5,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use PostgreSQL::Test::Cluster;
use Test::More tests => 20;
use Test::More;
program_help_ok('pg_recvlogical');
program_version_ok('pg_recvlogical');
@ -106,3 +106,5 @@ $node->command_ok(
'--start', '--endpos', "$nextlsn", '--no-loop', '-f', '-'
],
'replayed a two-phase transaction');
done_testing();

View File

@ -4,8 +4,10 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 8;
use Test::More;
program_help_ok('pg_checksums');
program_version_ok('pg_checksums');
program_options_handling_ok('pg_checksums');
done_testing();

View File

@ -11,7 +11,7 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Fcntl qw(:seek);
use Test::More tests => 66;
use Test::More;
# Utility routine to create and check a table with corrupted checksums
@ -257,3 +257,5 @@ fail_corrupt($node, "99990_vm");
fail_corrupt($node, "99990_init.123");
fail_corrupt($node, "99990_fsm.123");
fail_corrupt($node, "99990_vm.123");
done_testing();

View File

@ -4,7 +4,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 20;
use Test::More;
program_help_ok('pg_config');
program_version_ok('pg_config');
@ -17,3 +17,5 @@ command_like([ 'pg_config', '--libdir', '--bindir' ],
qr/lib.*\n.*bin/, 'pg_config two options different order');
command_like(['pg_config'], qr/.*\n.*\n.*/,
'pg_config without options prints many lines');
done_testing();

View File

@ -5,7 +5,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 17;
use Test::More;
program_help_ok('pg_controldata');
program_version_ok('pg_controldata');
@ -42,3 +42,5 @@ command_checks_all(
],
[qr/^$/],
'pg_controldata with corrupted pg_control');
done_testing();

View File

@ -9,7 +9,7 @@ use Fcntl ':mode';
use File::stat qw{lstat};
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 24;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
my $tempdir_short = PostgreSQL::Test::Utils::tempdir_short;
@ -111,3 +111,5 @@ command_ok([ 'pg_ctl', 'restart', '-D', "$tempdir/data" ],
'pg_ctl restart with server running');
system_or_bail 'pg_ctl', 'stop', '-D', "$tempdir/data";
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
@ -25,3 +25,5 @@ command_exit_is([ 'pg_ctl', 'status', '-D', $node->data_dir ],
0, 'pg_ctl status with server running');
system_or_bail 'pg_ctl', 'stop', '-D', $node->data_dir;
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 12;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
@ -62,3 +62,5 @@ command_ok([ 'pg_ctl', '-D', $node_standby->data_dir, 'promote' ],
is($node_standby->safe_psql('postgres', 'SELECT pg_is_in_recovery()'),
'f', 'promoted standby is not in recovery');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 14;
use Test::More;
use Time::HiRes qw(usleep);
# Extract the file name of a $format from the contents of
@ -136,3 +136,5 @@ check_log_pattern('csvlog', $new_current_logfiles, 'syntax error', $node);
check_log_pattern('jsonlog', $new_current_logfiles, 'syntax error', $node);
$node->stop();
done_testing();

View File

@ -7,7 +7,7 @@ use warnings;
use Config;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 82;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
@ -188,3 +188,5 @@ command_fails_like(
qr/\Qpg_dumpall: error: option --exclude-database cannot be used together with -g\/--globals-only\E/,
'pg_dumpall: option --exclude-database cannot be used together with -g/--globals-only'
);
done_testing();

View File

@ -3714,82 +3714,6 @@ my $supports_lz4 = check_pg_config("#define HAVE_LIBLZ4 1");
$node->psql('postgres', 'create database regress_pg_dump_test;');
$node->psql('postgres', 'create database regress_public_owner;');
# Start with number of command_fails_like()*2 tests below (each
# command_fails_like is actually 2 tests)
my $num_tests = 12;
foreach my $run (sort keys %pgdump_runs)
{
my $test_key = $run;
my $run_db = 'postgres';
if (defined($pgdump_runs{$run}->{database}))
{
$run_db = $pgdump_runs{$run}->{database};
}
# Each run of pg_dump is a test itself
$num_tests++;
# If there is a restore cmd, that's another test
if ($pgdump_runs{$run}->{restore_cmd})
{
$num_tests++;
}
if ($pgdump_runs{$run}->{test_key})
{
$test_key = $pgdump_runs{$run}->{test_key};
}
# Then count all the tests run against each run
foreach my $test (sort keys %tests)
{
# postgres is the default database, if it isn't overridden
my $test_db = 'postgres';
# Specific tests can override the database to use
if (defined($tests{$test}->{database}))
{
$test_db = $tests{$test}->{database};
}
# The database to test against needs to match the database the run is
# for, so skip combinations where they don't match up.
if ($run_db ne $test_db)
{
next;
}
# Skip any collation-related commands if there is no collation support
if (!$collation_support && defined($tests{$test}->{collation}))
{
next;
}
# Skip tests specific to LZ4 if this build does not support
# this option.
if (!$supports_lz4 && defined($tests{$test}->{lz4}))
{
next;
}
# If there is a like entry, but no unlike entry, then we will test the like case
if ($tests{$test}->{like}->{$test_key}
&& !defined($tests{$test}->{unlike}->{$test_key}))
{
$num_tests++;
}
else
{
# We will test everything that isn't a 'like'
$num_tests++;
}
}
}
plan tests => $num_tests;
#########################################
# Set up schemas, tables, etc, to be dumped.
@ -3975,3 +3899,5 @@ foreach my $run (sort keys %pgdump_runs)
# Stop the database instance, which will be removed at the end of the tests.
$node->stop('fast');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
@ -36,3 +36,5 @@ command_fails_like(
command_ok(
[ "pg_dump", '-p', $port, '-a', '--include-foreign-data=s2', 'postgres' ],
"dump foreign server with no tables");
done_testing();

View File

@ -12,10 +12,6 @@ if ($PostgreSQL::Test::Utils::is_msys2)
{
plan skip_all => 'High bit name tests fail on Msys2';
}
else
{
plan tests => 14;
}
# We're going to use byte sequences that aren't valid UTF-8 strings. Use
# LATIN1, which accepts any byte and has a conversion from each byte to UTF-8.
@ -229,3 +225,5 @@ $cmdline_node->run_log(
ok($result,
'restore full dump with command-line options for connection parameters');
is($stderr, '', 'no dump errors');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 12;
use Test::More;
program_help_ok('pg_resetwal');
program_version_ok('pg_resetwal');
@ -28,3 +28,5 @@ SKIP:
ok(check_mode_recursive($node->data_dir, 0700, 0600),
'check PGDATA permissions');
}
done_testing();

View File

@ -8,7 +8,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 6;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
@ -54,3 +54,5 @@ command_checks_all(
qr/\Qpg_resetwal: warning: pg_control specifies invalid WAL segment size (0 bytes); proceed with caution\E/
],
'processes zero WAL segment size');
done_testing();

View File

@ -4,7 +4,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 23;
use Test::More;
use FindBin;
use lib $FindBin::RealBin;
@ -191,4 +191,4 @@ run_test('local');
run_test('remote');
run_test('archive');
exit(0);
done_testing();

View File

@ -4,7 +4,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 7;
use Test::More;
use FindBin;
use lib $FindBin::RealBin;
@ -74,4 +74,4 @@ template1
run_test('local');
run_test('remote');
exit(0);
done_testing();

View File

@ -6,7 +6,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 5;
use Test::More;
use File::Find;
@ -103,4 +103,4 @@ sub run_test
run_test('local');
run_test('remote');
exit(0);
done_testing();

View File

@ -9,7 +9,7 @@ use warnings;
use File::Copy;
use File::Path qw(rmtree);
use PostgreSQL::Test::Utils;
use Test::More tests => 5;
use Test::More;
use FindBin;
use lib $FindBin::RealBin;
@ -76,4 +76,4 @@ in standby, after promotion
run_test('local');
run_test('remote');
exit(0);
done_testing();

View File

@ -8,7 +8,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 1;
use Test::More;
use FindBin;
use lib $FindBin::RealBin;
@ -20,4 +20,5 @@ RewindTest::start_primary();
RewindTest::create_standby();
RewindTest::run_pg_rewind('local');
RewindTest::clean_rewind_test();
exit(0);
done_testing();

View File

@ -7,7 +7,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 12;
use Test::More;
program_help_ok('pg_rewind');
program_version_ok('pg_rewind');
@ -41,3 +41,5 @@ command_fails(
'--write-recovery-conf'
],
'no local source with --write-recovery-conf');
done_testing();

View File

@ -27,7 +27,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
use FindBin;
use lib $FindBin::RealBin;
@ -176,4 +176,4 @@ $node_a->teardown_node;
$node_b->teardown_node;
$node_c->teardown_node;
exit(0);
done_testing();

View File

@ -34,7 +34,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
use File::Copy;
@ -173,3 +173,5 @@ and this too), 'table foo after rewind');
$result = $node_2->safe_psql('postgres', 'SELECT * FROM public.bar');
is($result, qq(in both), 'table bar after rewind');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use Config;
use PostgreSQL::Test::Utils;
use Test::More tests => 12;
use Test::More;
#########################################
# Basic checks
@ -26,3 +26,5 @@ command_fails_like(
[ 'pg_test_fsync', '--secs-per-test', '0' ],
qr/\Qpg_test_fsync: error: --secs-per-test must be in range 1..4294967295\E/,
'pg_test_fsync: --secs-per-test must be in range');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use Config;
use PostgreSQL::Test::Utils;
use Test::More tests => 12;
use Test::More;
#########################################
# Basic checks
@ -26,3 +26,5 @@ command_fails_like(
[ 'pg_test_timing', '--duration', '0' ],
qr/\Qpg_test_timing: --duration must be in range 1..4294967295\E/,
'pg_test_timing: --duration must be in range');
done_testing();

View File

@ -4,7 +4,7 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 16;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
@ -34,3 +34,5 @@ command_fails_like(
[ 'pg_verifybackup', '-m', "$tempdir/not_the_manifest", $tempdir ],
qr/could not open file.*\/not_the_manifest\"/,
'pg_verifybackup respects -m flag');
done_testing();

View File

@ -10,7 +10,7 @@ use Config;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 19;
use Test::More;
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
@ -59,3 +59,5 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
# Remove backup immediately to save disk space.
rmtree($backup_path);
}
done_testing();

View File

@ -10,7 +10,7 @@ use Config;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 44;
use Test::More;
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
@ -290,3 +290,5 @@ sub cleanup_search_directory_fails
chmod(0700, $pathname) || die "chmod $pathname: $!";
return;
}
done_testing();

View File

@ -10,7 +10,7 @@ use Config;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 25;
use Test::More;
# Start up the server and take a backup.
my $primary = PostgreSQL::Test::Cluster->new('primary');
@ -105,3 +105,5 @@ command_fails_like(
],
qr/could not open directory/,
'nonexistent backup directory');
done_testing();

View File

@ -10,7 +10,7 @@ use Cwd;
use Config;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 58;
use Test::More;
my $tempdir = PostgreSQL::Test::Utils::tempdir;
@ -209,3 +209,5 @@ sub test_bad_manifest
command_fails_like([ 'pg_verifybackup', $tempdir ], $regexp, $test_name);
return;
}
done_testing();

View File

@ -9,7 +9,7 @@ use Cwd;
use Config;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 5;
use Test::More;
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
@ -32,3 +32,5 @@ command_like(
[ 'pg_verifybackup', '-s', $backup_path ],
qr/backup successfully verified/,
'backup with forced encoding verified');
done_testing();

View File

@ -10,7 +10,7 @@ use Config;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 9;
use Test::More;
# Start up the server and take a backup.
my $primary = PostgreSQL::Test::Cluster->new('primary');
@ -76,3 +76,5 @@ $primary->command_ok([ 'pg_basebackup', '-D', $backup_path2, '--no-sync', '-cfas
command_ok(
[ 'pg_verifybackup', $backup_path2 ],
'valid base backup with timeline > 1');
done_testing();

View File

@ -11,7 +11,7 @@ use Config;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 9;
use Test::More;
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
@ -110,3 +110,5 @@ for my $tc (@test_configuration)
rmtree($extract_path);
}
}
done_testing();

View File

@ -11,8 +11,7 @@ use Config;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 6;
use Test::More;
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
$primary->start;
@ -64,3 +63,5 @@ for my $tc (@test_configuration)
# Remove backup immediately to save disk space.
rmtree($backup_path);
}
done_testing();

View File

@ -10,7 +10,7 @@ use Config;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 9;
use Test::More;
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
@ -109,3 +109,5 @@ for my $tc (@test_configuration)
rmtree($backup_path);
}
}
done_testing();

View File

@ -4,8 +4,10 @@
use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 8;
use Test::More;
program_help_ok('pg_waldump');
program_version_ok('pg_waldump');
program_options_handling_ok('pg_waldump');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 25;
use Test::More;
program_help_ok('psql');
program_version_ok('psql');
@ -80,3 +80,5 @@ psql_like(
'handling of unexpected PQresultStatus',
'START_REPLICATION 0/0',
undef, qr/unexpected PQresultStatus: 8$/);
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 2;
use Test::More;
use Time::HiRes qw(usleep);
my $tempdir = PostgreSQL::Test::Utils::tempdir;
@ -64,3 +64,5 @@ SKIP: {
ok(!$result, 'query failed as expected');
like($stderr, qr/canceling statement due to user request/, 'query was canceled');
}
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 14;
use Test::More;
program_help_ok('clusterdb');
program_version_ok('clusterdb');
@ -34,3 +34,5 @@ $node->issues_sql_like(
$node->command_ok([qw(clusterdb --echo --verbose dbname=template1)],
'clusterdb with connection string');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 2;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
@ -20,3 +20,5 @@ $node->issues_sql_like(
[ 'clusterdb', '-a' ],
qr/statement: CLUSTER.*statement: CLUSTER/s,
'cluster all databases');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 25;
use Test::More;
program_help_ok('createdb');
program_version_ok('createdb');
@ -75,3 +75,5 @@ $node->command_checks_all(
qr/^createdb: error: database creation failed: ERROR: invalid locale name|^createdb: error: database creation failed: ERROR: new LC_CTYPE \(foo'; SELECT '1\) is incompatible with the LC_CTYPE of the template database/s
],
'createdb with incorrect --lc-ctype');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 17;
use Test::More;
program_help_ok('createuser');
program_version_ok('createuser');
@ -35,3 +35,5 @@ $node->issues_sql_like(
$node->command_fails([ 'createuser', 'regress_user1' ],
'fails if role already exists');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 13;
use Test::More;
program_help_ok('dropdb');
program_version_ok('dropdb');
@ -30,3 +30,5 @@ $node->issues_sql_like(
$node->command_fails([ 'dropdb', 'nonexistent' ],
'fails with nonexistent database');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 11;
use Test::More;
program_help_ok('dropuser');
program_version_ok('dropuser');
@ -24,3 +24,5 @@ $node->issues_sql_like(
$node->command_fails([ 'dropuser', 'regress_nonexistent' ],
'fails with nonexistent user');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 10;
use Test::More;
program_help_ok('pg_isready');
program_version_ok('pg_isready');
@ -21,3 +21,5 @@ $node->start;
# use a long timeout for the benefit of very slow buildfarm machines
$node->command_ok([qw(pg_isready --timeout=60)],
'succeeds with server running');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 58;
use Test::More;
program_help_ok('reindexdb');
program_version_ok('reindexdb');
@ -199,3 +199,5 @@ $node->command_checks_all(
qr/^reindexdb: warning: cannot reindex system catalogs concurrently, skipping all/s
],
'parallel reindexdb for system with --concurrently skips catalogs');
done_testing();

View File

@ -5,7 +5,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use Test::More tests => 2;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
@ -17,3 +17,5 @@ $node->issues_sql_like(
[ 'reindexdb', '-a' ],
qr/statement: REINDEX.*statement: REINDEX/s,
'reindex all databases');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 58;
use Test::More;
program_help_ok('vacuumdb');
program_version_ok('vacuumdb');
@ -146,3 +146,5 @@ $node->issues_sql_like(
[ 'vacuumdb', '--min-xid-age', '2147483001', 'postgres' ],
qr/GREATEST.*relfrozenxid.*2147483001/,
'vacuumdb --table --min-xid-age');
done_testing();

View File

@ -5,7 +5,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use Test::More tests => 2;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
@ -15,3 +15,5 @@ $node->issues_sql_like(
[ 'vacuumdb', '-a' ],
qr/statement: VACUUM.*statement: VACUUM/s,
'vacuum all databases');
done_testing();

View File

@ -5,7 +5,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use Test::More tests => 4;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
@ -36,3 +36,5 @@ $node->issues_sql_like(
.*statement:\ RESET\ default_statistics_target;
.*statement:\ ANALYZE/sx,
'analyze more than one database in stages');
done_testing();

View File

@ -6,7 +6,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
# Tests to check connection string handling in utilities
@ -40,3 +40,5 @@ $node->command_ok([qw(reindexdb --all --echo)],
$node->command_ok(
[qw(clusterdb --all --echo --verbose)],
'clusterdb --all with unusual database names');
done_testing();

View File

@ -18,11 +18,6 @@ if (!$use_unix_sockets)
plan skip_all =>
"authentication tests cannot run without Unix-domain sockets";
}
else
{
plan tests => 23;
}
# Delete pg_hba.conf from the given node, add a new entry to it
# and then execute a reload to refresh it.
@ -160,3 +155,5 @@ append_to_file(
!);
test_role($node, 'md5_role', 'password from pgpass', 0);
done_testing();

View File

@ -15,10 +15,6 @@ if (!$use_unix_sockets)
plan skip_all =>
"authentication tests cannot run without Unix-domain sockets";
}
else
{
plan tests => 12;
}
# Delete pg_hba.conf from the given node, add a new entry to it
# and then execute a reload to refresh it.
@ -117,3 +113,5 @@ test_login($node, 'saslpreptest6_role', "foobar", 2);
test_login($node, 'saslpreptest7_role', "foo\xd8\xa71bar", 0);
test_login($node, 'saslpreptest7_role', "foo1\xd8\xa7bar", 2);
test_login($node, 'saslpreptest7_role', "foobar", 2);
done_testing();

View File

@ -21,11 +21,7 @@ use PostgreSQL::Test::Cluster;
use Test::More;
use Time::HiRes qw(usleep);
if ($ENV{with_gssapi} eq 'yes')
{
plan tests => 44;
}
else
if ($ENV{with_gssapi} ne 'yes')
{
plan skip_all => 'GSSAPI/Kerberos not supported by this build';
}
@ -399,3 +395,5 @@ test_access(
'',
'fails with wrong krb_realm, but still authenticates',
"connection authenticated: identity=\"test1\@$realm\" method=gss");
done_testing();

View File

@ -7,11 +7,7 @@ use PostgreSQL::Test::Utils;
use PostgreSQL::Test::Cluster;
use Test::More;
if ($ENV{with_ldap} eq 'yes')
{
plan tests => 28;
}
else
if ($ENV{with_ldap} ne 'yes')
{
plan skip_all => 'LDAP not supported by this build';
}
@ -367,3 +363,5 @@ $node->restart;
$ENV{"PGPASSWORD"} = 'secret1';
test_access($node, 'test1', 2, 'bad combination of LDAPS and StartTLS');
done_testing();

View File

@ -7,7 +7,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 2;
use Test::More;
use PostgreSQL::Test::Cluster;
my $node = PostgreSQL::Test::Cluster->new('tango');
@ -42,3 +42,5 @@ $count = $node->safe_psql('postgres',
);
is($count, 't', "index got summarized");
$node->stop;
done_testing();

View File

@ -7,7 +7,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 2;
use Test::More;
use PostgreSQL::Test::Cluster;
my $node = PostgreSQL::Test::Cluster->new('foxtrot');
@ -34,3 +34,5 @@ my $recovered_ts = $node->safe_psql('postgres',
'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\''
);
is($recovered_ts, $ts, 'commit TS remains after crash recovery');
done_testing();

View File

@ -7,7 +7,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 4;
use Test::More;
use PostgreSQL::Test::Cluster;
my $bkplabel = 'backup';
@ -64,3 +64,5 @@ like(
$standby_ts_stderr,
qr/could not get commit timestamp data/,
'expected error when primary turned feature off');
done_testing();

View File

@ -7,7 +7,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Utils;
use Test::More tests => 4;
use Test::More;
use PostgreSQL::Test::Cluster;
my $bkplabel = 'backup';
@ -65,3 +65,5 @@ my $standby_ts = $standby->safe_psql('postgres',
);
isnt($standby_ts, '',
"standby gives valid value ($standby_ts) after promotion");
done_testing();

View File

@ -6,7 +6,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 16;
use Test::More;
my $node_primary = PostgreSQL::Test::Cluster->new('primary');
$node_primary->init(allows_streaming => 1);
@ -150,3 +150,5 @@ is($after_enable_disabled_ts, '',
'timestamp of disabled tx null after re-enable');
$node_primary->stop;
done_testing();

View File

@ -7,7 +7,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 42;
use Test::More;
# Initialize a test cluster
my $node = PostgreSQL::Test::Cluster->new('primary');
@ -311,3 +311,5 @@ ok( $output =~
run_sql_command('DROP TABLE quuux;');
$node->stop('fast');
done_testing();

View File

@ -6,7 +6,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 20;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
@ -97,3 +97,5 @@ $result = $node->psql('postgres', "DROP TABLESPACE regress_ts4");
ok($result == 0, 'drop tablespace 4');
$node->stop;
done_testing();

View File

@ -5,7 +5,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
@ -106,3 +106,5 @@ foreach my $param (@sample_intersect)
"found GUC $param in postgresql.conf.sample, marked as NOT_IN_SAMPLE\n"
);
}
done_testing();

View File

@ -718,44 +718,6 @@ $node->start;
my $port = $node->port;
my $num_tests = 0;
foreach my $run (sort keys %pgdump_runs)
{
my $test_key = $run;
# Each run of pg_dump is a test itself
$num_tests++;
# If there is a restore cmd, that's another test
if ($pgdump_runs{$run}->{restore_cmd})
{
$num_tests++;
}
if ($pgdump_runs{$run}->{test_key})
{
$test_key = $pgdump_runs{$run}->{test_key};
}
# Then count all the tests run against each run
foreach my $test (sort keys %tests)
{
# If there is a like entry, but no unlike entry, then we will test the like case
if ($tests{$test}->{like}->{$test_key}
&& !defined($tests{$test}->{unlike}->{$test_key}))
{
$num_tests++;
}
else
{
# We will test everything that isn't a 'like'
$num_tests++;
}
}
}
plan tests => $num_tests;
#########################################
# Set up schemas, tables, etc, to be dumped.
@ -847,3 +809,5 @@ foreach my $run (sort keys %pgdump_runs)
# Stop the database instance, which will be removed at the end of the tests.
$node->stop('fast');
done_testing();

View File

@ -54,8 +54,7 @@ Each test script should begin with:
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
# Replace with the number of tests to execute:
use Test::More tests => 1;
use Test::More;
then it will generally need to set up one or more nodes, run commands
against them and evaluate the results. For example:
@ -69,6 +68,10 @@ against them and evaluate the results. For example:
$node->stop('fast');
Each test script should end with:
done_testing();
Test::More::like entails use of the qr// operator. Avoid Perl 5.8.8 bug
#39185 by not using the "$" regular expression metacharacter in qr// when also
using the "/m" modifier. Instead of "$", use "\n" or "(?=\n|\z)".

View File

@ -6,7 +6,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 55;
use Test::More;
# Initialize primary node
my $node_primary = PostgreSQL::Test::Cluster->new('primary');
@ -529,3 +529,5 @@ ok( ($phys_restart_lsn_pre cmp $phys_restart_lsn_post) == 0,
my $primary_data = $node_primary->data_dir;
ok(!-f "$primary_data/pg_wal/$segment_removed",
"WAL segment $segment_removed recycled after physical slot advancing");
done_testing();

View File

@ -6,7 +6,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 7;
use Test::More;
use File::Copy;
# Initialize primary node, doing archives
@ -120,3 +120,5 @@ like(
$log_contents,
qr/WARNING:.*recovery_end_command/s,
"recovery_end_command failure detected in logs after promotion");
done_testing();

View File

@ -6,7 +6,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 9;
use Test::More;
use Time::HiRes qw(usleep);
# Create and test a standby from given backup, with a certain recovery target.
@ -182,3 +182,5 @@ $logfile = slurp_file($node_standby->logfile());
ok( $logfile =~
qr/FATAL: .* recovery ended before configured recovery target was reached/,
'recovery end before target reached is a fatal error');
done_testing();

View File

@ -7,7 +7,7 @@ use warnings;
use File::Path qw(rmtree);
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
$ENV{PGDATABASE} = 'postgres';
@ -106,3 +106,5 @@ $node_primary_2->wait_for_catchup($node_standby_3);
my $result_2 =
$node_standby_3->safe_psql('postgres', "SELECT count(*) FROM tab_int");
is($result_2, qq(1), 'check content of standby 3');
done_testing();

View File

@ -7,7 +7,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 3;
use Test::More;
# Initialize primary node
my $node_primary = PostgreSQL::Test::Cluster->new('primary');
@ -110,3 +110,5 @@ $node_standby2->poll_query_until('postgres',
$node_standby2->promote;
$node_standby2->poll_query_until('postgres', "SELECT NOT pg_is_in_recovery()")
or die "Timed out while waiting for promotion to finish";
done_testing();

View File

@ -10,7 +10,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 15;
use Test::More;
use Config;
# Initialize primary node
@ -200,3 +200,5 @@ ok(($logical_restart_lsn_pre cmp $logical_restart_lsn_post) == 0,
# done with the node
$node_primary->stop;
done_testing();

View File

@ -6,7 +6,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 11;
use Test::More;
# Query checking sync_priority and sync_state of each standby
my $check_sql =
@ -217,3 +217,5 @@ standby3|1|quorum
standby4|1|quorum),
'all standbys are considered as candidates for quorum sync standbys',
'ANY 2(*)');
done_testing();

View File

@ -10,7 +10,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 1;
use Test::More;
my $node_primary = PostgreSQL::Test::Cluster->new('primary');
$node_primary->init(allows_streaming => 1);
@ -96,3 +96,5 @@ is( $node_standby->psql(
qq{insert into testtab select generate_series(1,1000), 'foo';}),
0,
'INSERT succeeds with truncated relation FSM');
done_testing();

View File

@ -7,7 +7,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 24;
use Test::More;
my $psql_out = '';
my $psql_rc = '';
@ -480,3 +480,5 @@ $cur_standby->psql(
is( $psql_out,
qq{27|issued to paris},
"Check expected t_009_tbl2 data on standby");
done_testing();

View File

@ -26,7 +26,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 13;
use Test::More;
use File::Copy;
use IPC::Run ();
use Scalar::Util qw(blessed);
@ -196,3 +196,5 @@ is($stdout, $final_expected_output_bb,
'got same output from walsender via pg_recvlogical on before_basebackup');
$node_replica->teardown_node();
done_testing();

View File

@ -11,8 +11,6 @@ use PostgreSQL::Test::Utils;
use Test::More;
use Config;
plan tests => 3;
my $node = PostgreSQL::Test::Cluster->new('primary');
$node->init(allows_streaming => 1);
$node->start;
@ -62,3 +60,5 @@ is($node->safe_psql('postgres', qq[SELECT pg_xact_status('$xid');]),
$stdin .= "\\q\n";
$tx->finish; # wait for psql to quit gracefully
done_testing();

View File

@ -7,7 +7,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 12;
use Test::More;
# Setup primary node
my $node_primary = PostgreSQL::Test::Cluster->new("primary");
@ -214,3 +214,5 @@ $node_primary->psql(
"SELECT coalesce(sum(id),-1) FROM t_012_tbl",
stdout => \$psql_out);
is($psql_out, '-1', "Not visible");
done_testing();

View File

@ -18,9 +18,6 @@ use PostgreSQL::Test::Utils;
use Test::More;
use Config;
plan tests => 18;
# To avoid hanging while expecting some specific input from a psql
# instance being driven by us, add a timeout high enough that it
# should never trigger even on very slow machines, unless something
@ -272,3 +269,5 @@ sub pump_until
return 1;
}
done_testing();

View File

@ -10,7 +10,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 12;
use Test::More;
my $node = PostgreSQL::Test::Cluster->new('main');
@ -82,3 +82,5 @@ ok( !-f "$pgdata/${ts1UnloggedPath}_vm",
'vm fork in tablespace removed at startup');
ok( !-f "$pgdata/${ts1UnloggedPath}_fsm",
'fsm fork in tablespace removed at startup');
done_testing();

View File

@ -9,7 +9,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 1;
use Test::More;
# Initialize primary node
my $alpha = PostgreSQL::Test::Cluster->new('alpha');
@ -85,3 +85,5 @@ $bravo->start;
my $psql_out;
$bravo->psql('postgres', "SELECT count(*) FROM test1", stdout => \$psql_out);
is($psql_out, '1000', "Check that table state is correct");
done_testing();

View File

@ -11,7 +11,7 @@ use strict;
use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 1;
use Test::More;
# Find the largest LSN in the set of pages part of the given relation
# file. This is used for offline checks of page consistency. The LSN
@ -139,3 +139,5 @@ die "No minRecoveryPoint in control file found\n"
# the pages on disk.
ok($offline_recovery_lsn ge $offline_max_lsn,
"Check offline that table data is consistent with minRecoveryPoint");
done_testing();

View File

@ -25,10 +25,6 @@ if ($@ || $windows_os)
{
plan skip_all => 'SysV shared memory not supported by this platform';
}
else
{
plan tests => 4;
}
my $tempdir = PostgreSQL::Test::Utils::tempdir;
@ -218,3 +214,5 @@ sub poll_start
$node->start && return 1;
return 0;
}
done_testing();

View File

@ -14,7 +14,7 @@ use warnings;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More tests => 38;
use Test::More;
sub check_orphan_relfilenodes
{
@ -399,3 +399,5 @@ wal_skip_threshold = 0
# Run same test suite for multiple wal_level values.
run_wal_optimize("minimal");
run_wal_optimize("replica");
done_testing();

View File

@ -11,7 +11,7 @@ use PostgreSQL::Test::Utils;
use PostgreSQL::Test::Cluster;
use File::Path qw(rmtree);
use Test::More tests => $PostgreSQL::Test::Utils::windows_os ? 16 : 20;
use Test::More;
use Time::HiRes qw(usleep);
$ENV{PGDATABASE} = 'postgres';
@ -421,3 +421,5 @@ sub find_in_log
return $log =~ m/$pat/;
}
done_testing();

Some files were not shown because too many files have changed in this diff Show More