aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_verifybackup/t/002_algorithm.pl
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2020-04-12 11:26:05 -0400
committerRobert Haas <rhaas@postgresql.org>2020-04-12 11:26:05 -0400
commitdbc60c5593f26dc777a3be032bff4fb4eab1ddd1 (patch)
tree7b14954bf9f6ceace6c6f29da6adddba483c4aa6 /src/bin/pg_verifybackup/t/002_algorithm.pl
parent26640c40715c7f2045cf1b7c6753cac40b64d1e8 (diff)
downloadpostgresql-dbc60c5593f26dc777a3be032bff4fb4eab1ddd1.tar.gz
postgresql-dbc60c5593f26dc777a3be032bff4fb4eab1ddd1.zip
Rename pg_validatebackup to pg_verifybackup.
Also, use "verify" rather than "validate" to refer to the process being undertaken here. Per discussion, that is a more appropriate term. Discussion: https://www.postgresql.org/message-id/172c9d9b-1d0a-1b94-1456-376b1e017322@2ndquadrant.com Discussion: http://postgr.es/m/CA+TgmobLgMh6p8FmLbj_rv9Uhd7tPrLnAyLgGd2SoSj=qD-bVg@mail.gmail.com
Diffstat (limited to 'src/bin/pg_verifybackup/t/002_algorithm.pl')
-rw-r--r--src/bin/pg_verifybackup/t/002_algorithm.pl58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/bin/pg_verifybackup/t/002_algorithm.pl b/src/bin/pg_verifybackup/t/002_algorithm.pl
new file mode 100644
index 00000000000..ee82dcee376
--- /dev/null
+++ b/src/bin/pg_verifybackup/t/002_algorithm.pl
@@ -0,0 +1,58 @@
+# Verify that we can take and verify backups with various checksum types.
+
+use strict;
+use warnings;
+use Cwd;
+use Config;
+use File::Path qw(rmtree);
+use PostgresNode;
+use TestLib;
+use Test::More tests => 19;
+
+my $master = get_new_node('master');
+$master->init(allows_streaming => 1);
+$master->start;
+
+for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
+{
+ my $backup_path = $master->backup_dir . '/' . $algorithm;
+ my @backup = ('pg_basebackup', '-D', $backup_path,
+ '--manifest-checksums', $algorithm,
+ '--no-sync');
+ my @verify = ('pg_verifybackup', '-e', $backup_path);
+
+ # A backup with a bogus algorithm should fail.
+ if ($algorithm eq 'bogus')
+ {
+ $master->command_fails(\@backup,
+ "backup fails with algorithm \"$algorithm\"");
+ next;
+ }
+
+ # A backup with a valid algorithm should work.
+ $master->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.
+ $master->command_ok(\@verify,
+ "verify backup with algorithm \"$algorithm\"");
+
+ # Remove backup immediately to save disk space.
+ rmtree($backup_path);
+}