mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-10 23:27:30 +02:00
* IMPORTANT NOTE: This flag day release breaks compatibility with older versions of PgBackRest. The manifest format, on-disk structure, and the binary names have all changed. You must create a new repository to hold backups for this version of PgBackRest and keep your older repository for a time in case you need to do a restore. The `pg_backrest.conf` file has not changed but you'll need to change any references to `pg_backrest.pl` in cron (or elsewhere) to `pg_backrest` (without the `.pl` extension). * Add info command. * More efficient file ordering for backup. Files are copied in descending size order so a single thread does not end up copying a large file at the end. This had already been implemented for restore. * Logging now uses unbuffered output. This should make log files that are being written by multiple threads less chaotic. Suggested by Michael Renner. * Experimental support for PostgreSQL 9.5. This may break when the control version or WAL magic changes but will be updated in each release.
131 lines
4.5 KiB
Perl
Executable File
131 lines
4.5 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
####################################################################################################################################
|
|
# UtilityTest.pl - Unit Tests for BackRest::Utility
|
|
####################################################################################################################################
|
|
package BackRestTest::UtilityTest;
|
|
|
|
####################################################################################################################################
|
|
# Perl includes
|
|
####################################################################################################################################
|
|
use strict;
|
|
use warnings FATAL => qw(all);
|
|
use Carp qw(confess);
|
|
|
|
use Exporter qw(import);
|
|
use File::Basename qw(dirname);
|
|
|
|
use lib dirname($0) . '/../lib';
|
|
use BackRest::Config;
|
|
use BackRest::File;
|
|
use BackRest::Ini;
|
|
use BackRest::Utility;
|
|
|
|
use BackRestTest::CommonTest;
|
|
|
|
####################################################################################################################################
|
|
# BackRestTestUtility_Test
|
|
####################################################################################################################################
|
|
our @EXPORT = qw(BackRestTestUtility_Test);
|
|
|
|
sub BackRestTestUtility_Test
|
|
{
|
|
my $strTest = shift;
|
|
|
|
# Setup test variables
|
|
my $iRun;
|
|
my $bCreate;
|
|
my $strTestPath = BackRestTestCommon_TestPathGet();
|
|
|
|
# Print test banner
|
|
&log(INFO, 'UTILITY MODULE ******************************************************************');
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
# Create remote
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
my $oLocal = new BackRest::Remote
|
|
(
|
|
undef, # Host
|
|
undef, # User
|
|
undef, # Command
|
|
undef, # Stanza
|
|
undef, # Repo Path
|
|
OPTION_DEFAULT_BUFFER_SIZE, # Buffer size
|
|
OPTION_DEFAULT_COMPRESS_LEVEL, # Compress level
|
|
OPTION_DEFAULT_COMPRESS_LEVEL_NETWORK, # Compress network level
|
|
);
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
# Test config
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
if ($strTest eq 'all' || $strTest eq 'config')
|
|
{
|
|
$iRun = 0;
|
|
$bCreate = true;
|
|
|
|
my $oFile = new BackRest::File
|
|
(
|
|
undef,
|
|
undef,
|
|
undef,
|
|
$oLocal
|
|
);
|
|
|
|
&log(INFO, "Test config\n");
|
|
|
|
# Increment the run, log, and decide whether this unit test should be run
|
|
if (BackRestTestCommon_Run(++$iRun, 'base'))
|
|
{
|
|
# Create the test directory
|
|
if ($bCreate)
|
|
{
|
|
BackRestTestCommon_Drop();
|
|
BackRestTestCommon_Create();
|
|
|
|
$bCreate = false;
|
|
}
|
|
|
|
# Generate a test config
|
|
my %oConfig;
|
|
|
|
$oConfig{test1}{key1} = 'value';
|
|
$oConfig{test1}{key2} = 'value';
|
|
|
|
$oConfig{test2}{key1} = 'value';
|
|
|
|
$oConfig{test3}{key1} = 'value';
|
|
$oConfig{test3}{key2}{sub1} = 'value';
|
|
$oConfig{test3}{key2}{sub2} = 'value';
|
|
|
|
# Save the test config
|
|
my $strFile = "${strTestPath}/config.cfg";
|
|
iniSave($strFile, \%oConfig);
|
|
|
|
my $strConfigHash = $oFile->hash(PATH_ABSOLUTE, $strFile);
|
|
|
|
# Reload the test config
|
|
my %oConfigTest;
|
|
|
|
iniLoad($strFile, \%oConfigTest);
|
|
|
|
# Resave the test config and compare hashes
|
|
my $strFileTest = "${strTestPath}/config-test.cfg";
|
|
iniSave($strFileTest, \%oConfigTest);
|
|
|
|
my $strConfigTestHash = $oFile->hash(PATH_ABSOLUTE, $strFileTest);
|
|
|
|
if ($strConfigHash ne $strConfigTestHash)
|
|
{
|
|
confess "config hash ${strConfigHash} != ${strConfigTestHash}";
|
|
}
|
|
|
|
if (BackRestTestCommon_Cleanup())
|
|
{
|
|
&log(INFO, 'cleanup');
|
|
BackRestTestCommon_Drop();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
1;
|