v3-0002-Test-plain-format-server-compressed-gzip-backup.patch

text/x-patch

Filename: v3-0002-Test-plain-format-server-compressed-gzip-backup.patch
Type: text/x-patch
Part: 1
Message: Re: refactoring basebackup.c

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v3-0002
Subject: Test plain format server compressed gzip backup
File+
src/bin/pg_verifybackup/t/009_extract.pl 66 0
From 534ae0b539fe981361a50e1b2794ff88f466b5ff Mon Sep 17 00:00:00 2001
From: Dipesh Pandit <dipesh.pandit@enterprisedb.com>
Date: Mon, 24 Jan 2022 18:06:12 +0530
Subject: [PATCH 2/2] Test plain format server compressed gzip backup

---
 src/bin/pg_verifybackup/t/009_extract.pl | 66 ++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100755 src/bin/pg_verifybackup/t/009_extract.pl

diff --git a/src/bin/pg_verifybackup/t/009_extract.pl b/src/bin/pg_verifybackup/t/009_extract.pl
new file mode 100755
index 0000000..0eeab46
--- /dev/null
+++ b/src/bin/pg_verifybackup/t/009_extract.pl
@@ -0,0 +1,66 @@
+
+# Copyright (c) 2021-2022, PostgreSQL Global Development Group
+
+# This test aims to verify server compression for plain format backup.
+
+use strict;
+use warnings;
+use Cwd;
+use Config;
+use File::Path qw(rmtree);
+use PostgreSQL::Test::Cluster;
+use PostgreSQL::Test::Utils;
+use Test::More tests => 7;
+
+my $primary = PostgreSQL::Test::Cluster->new('primary');
+$primary->init(allows_streaming => 1);
+$primary->start;
+
+my @test_configuration = (
+	{
+		'compression_method' => 'none',
+		'backup_flags' => [],
+		'enabled' => 1
+	},
+	{
+		'compression_method' => 'gzip',
+		'backup_flags' => ['--compress', 'server-gzip:5'],
+		'enabled' => check_pg_config("#define HAVE_LIBZ 1")
+	}
+);
+
+for my $tc (@test_configuration)
+{
+	my $backup_path = $primary->backup_dir . '/' . 'extract_backup';
+	my $method = $tc->{'compression_method'};
+
+	SKIP: {
+		skip "$method compression not supported by this build", 3
+			if ! $tc->{'enabled'};
+
+		# Take backup with server compression enabled.
+		my @backup      = (
+			'pg_basebackup', '-D', $backup_path,
+			'-Xfetch', '--no-sync', '-cfast', '-Fp');
+		push @backup, @{$tc->{'backup_flags'}};
+
+		my @verify = ('pg_verifybackup', '-e', $backup_path);
+
+		# A backup with a valid compression method should work.
+		$primary->command_ok(\@backup, "backup ok with compression method \"$method\"");
+
+		# Verify that backup is extracted
+		if ($method ne 'none')
+		{
+			ok (-f "$backup_path/PG_VERSION", "extracted compressed backup, compression method \"$method\"");
+		}
+		ok(-f "$backup_path/backup_manifest", "backup manifest exists, compression method \"$method\"");
+
+		# Make sure that it verifies OK.
+		$primary->command_ok(\@verify,
+			"verify backup with compression method \"$method\"");
+	}
+
+	# Remove backup immediately to save disk space.
+	rmtree($backup_path);
+}
-- 
1.8.3.1