mirror of
https://github.com/postgres/postgres.git
synced 2026-03-09 01:31:22 -04:00
There are a lot of Perl scripts in the tree, mostly code generation
and TAP tests. Occasionally, these scripts produce warnings. These
are probably always mistakes on the developer side (true positives).
Typical examples are warnings from genbki.pl or related when you make
a mess in the catalog files during development, or warnings from tests
when they massage a config file that looks different on different
hosts, or mistakes during merges (e.g., duplicate subroutine
definitions), or just mistakes that weren't noticed because there is a
lot of output in a verbose build.
This changes all warnings into fatal errors, by replacing
use warnings;
by
use warnings FATAL => 'all';
in all Perl files.
Discussion: https://www.postgresql.org/message-id/flat/06f899fd-1826-05ab-42d6-adeb1fd5e200%40eisentraut.org
61 lines
1.8 KiB
Perl
61 lines
1.8 KiB
Perl
|
|
# Copyright (c) 2021-2023, PostgreSQL Global Development Group
|
|
|
|
# Verify that we can take and verify backups with various checksum types.
|
|
|
|
use strict;
|
|
use warnings FATAL => 'all';
|
|
use File::Path qw(rmtree);
|
|
use PostgreSQL::Test::Cluster;
|
|
use PostgreSQL::Test::Utils;
|
|
use Test::More;
|
|
|
|
my $primary = PostgreSQL::Test::Cluster->new('primary');
|
|
$primary->init(allows_streaming => 1);
|
|
$primary->start;
|
|
|
|
for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
|
|
{
|
|
my $backup_path = $primary->backup_dir . '/' . $algorithm;
|
|
my @backup = (
|
|
'pg_basebackup', '-D', $backup_path,
|
|
'--manifest-checksums', $algorithm, '--no-sync', '-cfast');
|
|
my @verify = ('pg_verifybackup', '-e', $backup_path);
|
|
|
|
# A backup with a bogus algorithm should fail.
|
|
if ($algorithm eq 'bogus')
|
|
{
|
|
$primary->command_fails(\@backup,
|
|
"backup fails with algorithm \"$algorithm\"");
|
|
next;
|
|
}
|
|
|
|
# A backup with a valid algorithm should work.
|
|
$primary->command_ok(\@backup, "backup ok with algorithm \"$algorithm\"");
|
|
|
|
# We expect each real checksum algorithm to be mentioned on every line of
|
|
# the backup manifest file except the first and last; for simplicity, we
|
|
# just check that it shows up lots of times. When the checksum algorithm
|
|
# is none, we just check that the manifest exists.
|
|
if ($algorithm eq 'none')
|
|
{
|
|
ok(-f "$backup_path/backup_manifest", "backup manifest exists");
|
|
}
|
|
else
|
|
{
|
|
my $manifest = slurp_file("$backup_path/backup_manifest");
|
|
my $count_of_algorithm_in_manifest =
|
|
(() = $manifest =~ /$algorithm/mig);
|
|
cmp_ok($count_of_algorithm_in_manifest,
|
|
'>', 100, "$algorithm is mentioned many times in the manifest");
|
|
}
|
|
|
|
# Make sure that it verifies OK.
|
|
$primary->command_ok(\@verify,
|
|
"verify backup with algorithm \"$algorithm\"");
|
|
|
|
# Remove backup immediately to save disk space.
|
|
rmtree($backup_path);
|
|
}
|
|
|
|
done_testing();
|