You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-11-06 08:49:29 +02:00
Implemented issue #26: Info command.
* Includes updating the manifest to format 4. It turns out the manifest and .info files were not very good for providing information. A format update was required anyway so worked through the backlog of changes that would require a format change. * Multiple database versions are now supported in the archive. Does't actually work yet but the structure should be good. * Tests use more constants now that test logs can catch name regressions.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -11,23 +11,24 @@ use strict;
|
||||
use warnings FATAL => qw(all);
|
||||
use Carp qw(confess);
|
||||
|
||||
use File::Basename;
|
||||
use File::Path qw(remove_tree);
|
||||
use Cwd 'abs_path';
|
||||
use Exporter qw(import);
|
||||
use File::Basename;
|
||||
use File::Copy qw(move);
|
||||
use File::Path qw(remove_tree);
|
||||
use IO::Select;
|
||||
use IPC::Open3;
|
||||
use POSIX ':sys_wait_h';
|
||||
use IO::Select;
|
||||
use File::Copy qw(move);
|
||||
|
||||
use lib dirname($0) . '/../lib';
|
||||
use BackRest::Utility;
|
||||
use BackRest::Config;
|
||||
use BackRest::Remote;
|
||||
use BackRest::File;
|
||||
use BackRest::Manifest;
|
||||
use BackRest::Db;
|
||||
use BackRest::File;
|
||||
use BackRest::Ini;
|
||||
use BackRest::Manifest;
|
||||
use BackRest::Remote;
|
||||
use BackRest::Utility;
|
||||
|
||||
use Exporter qw(import);
|
||||
our @EXPORT = qw(BackRestTestCommon_Create BackRestTestCommon_Drop BackRestTestCommon_Setup BackRestTestCommon_ExecuteBegin
|
||||
BackRestTestCommon_ExecuteEnd BackRestTestCommon_Execute BackRestTestCommon_ExecuteBackRest
|
||||
BackRestTestCommon_PathCreate BackRestTestCommon_PathMode BackRestTestCommon_PathRemove
|
||||
@@ -41,7 +42,8 @@ our @EXPORT = qw(BackRestTestCommon_Create BackRestTestCommon_Drop BackRestTestC
|
||||
BackRestTestCommon_DbCommonPathGet BackRestTestCommon_ClusterStop BackRestTestCommon_DbTablespacePathGet
|
||||
BackRestTestCommon_DbPortGet BackRestTestCommon_iniLoad BackRestTestCommon_iniSave BackRestTestCommon_DbVersion
|
||||
BackRestTestCommon_CommandPsqlGet BackRestTestCommon_DropRepo BackRestTestCommon_CreateRepo
|
||||
BackRestTestCommon_manifestLoad BackRestTestCommon_manifestSave BackRestTestCommon_CommandMainAbsGet);
|
||||
BackRestTestCommon_manifestLoad BackRestTestCommon_manifestSave BackRestTestCommon_CommandMainAbsGet
|
||||
BackRestTestCommon_TestLogAppendFile);
|
||||
|
||||
my $strPgSqlBin;
|
||||
my $strCommonStanza;
|
||||
@@ -68,6 +70,7 @@ my $bNoCleanup;
|
||||
my $bLogForce;
|
||||
|
||||
# Execution globals
|
||||
my $bExecuteRemote;
|
||||
my $strErrorLog;
|
||||
my $hError;
|
||||
my $strOutLog;
|
||||
@@ -83,6 +86,7 @@ my $strTestLog;
|
||||
my $strModule;
|
||||
my $strModuleTest;
|
||||
my $iModuleTestRun;
|
||||
my $bValidWalChecksum;
|
||||
|
||||
####################################################################################################################################
|
||||
# BackRestTestCommon_ClusterStop
|
||||
@@ -172,6 +176,7 @@ sub BackRestTestCommon_Run
|
||||
my $strLog = shift;
|
||||
my $strModuleParam = shift;
|
||||
my $strModuleTestParam = shift;
|
||||
my $bValidWalChecksumParam = shift;
|
||||
|
||||
# &log(INFO, "module " . (defined($strModule) ? $strModule : ''));
|
||||
BackRestTestCommon_TestLog();
|
||||
@@ -196,6 +201,7 @@ sub BackRestTestCommon_Run
|
||||
$strModule = $strModuleParam;
|
||||
$strModuleTest = $strModuleTestParam;
|
||||
$iModuleTestRun = $iRun;
|
||||
$bValidWalChecksum = defined($bValidWalChecksumParam) ? $bValidWalChecksumParam : true;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -210,6 +216,45 @@ sub BackRestTestCommon_Cleanup
|
||||
return !$bNoCleanup && !$bDryRun;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# BackRestTestCommon_TestLogAppendFile
|
||||
####################################################################################################################################
|
||||
sub BackRestTestCommon_TestLogAppendFile
|
||||
{
|
||||
my $strFileName = shift;
|
||||
my $bRemote = shift;
|
||||
|
||||
if (defined($strModule))
|
||||
{
|
||||
my $hFile;
|
||||
|
||||
if ($bRemote)
|
||||
{
|
||||
BackRestTestCommon_Execute("chmod g+x " . BackRestTestCommon_RepoPathGet(), $bRemote);
|
||||
}
|
||||
|
||||
open($hFile, '<', $strFileName)
|
||||
or confess &log(ERROR, "unable to open ${strFileName} for appending to test log");
|
||||
|
||||
my $strHeader = "+ supplemental file: " . BackRestTestCommon_ExecuteRegAll($strFileName);
|
||||
|
||||
$strFullLog .= "\n${strHeader}\n" . ('-' x length($strHeader)) . "\n";
|
||||
|
||||
while (my $strLine = readline($hFile))
|
||||
{
|
||||
$strLine = BackRestTestCommon_ExecuteRegAll($strLine);
|
||||
$strFullLog .= $strLine;
|
||||
}
|
||||
|
||||
close($hFile);
|
||||
|
||||
if ($bRemote)
|
||||
{
|
||||
BackRestTestCommon_Execute("chmod g-x " . BackRestTestCommon_RepoPathGet(), $bRemote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# BackRestTestCommon_TestLog
|
||||
####################################################################################################################################
|
||||
@@ -259,9 +304,9 @@ sub BackRestTestCommon_ExecuteBegin
|
||||
my $strComment = shift;
|
||||
|
||||
# Set defaults
|
||||
$bRemote = defined($bRemote) ? $bRemote : false;
|
||||
$bExecuteRemote = defined($bRemote) ? $bRemote : false;
|
||||
|
||||
if ($bRemote)
|
||||
if ($bExecuteRemote)
|
||||
{
|
||||
$strCommand = "ssh ${strCommonUserBackRest}\@${strCommonHost} '${strCommandParam}'";
|
||||
}
|
||||
@@ -314,12 +359,29 @@ sub BackRestTestCommon_ExecuteRegExp
|
||||
{
|
||||
my $iIndex;
|
||||
my $strTypeReplacement;
|
||||
my $strReplacement;
|
||||
|
||||
if (!defined($bIndex) || $bIndex)
|
||||
{
|
||||
if (defined($$oReplaceHash{$strType}{$strReplace}))
|
||||
if (defined($strToken))
|
||||
{
|
||||
$iIndex = $$oReplaceHash{$strType}{$strReplace}{index};
|
||||
my @stryReplacement = ($strReplace =~ /$strToken/g);
|
||||
|
||||
if (@stryReplacement != 1)
|
||||
{
|
||||
confess &log(ASSERT, "'${strToken}' is not a sub-regexp of '${strExpression}' or matches multiple times on '${strReplace}'");
|
||||
}
|
||||
|
||||
$strReplacement = $stryReplacement[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
$strReplacement = $strReplace;
|
||||
}
|
||||
|
||||
if (defined($$oReplaceHash{$strType}{$strReplacement}))
|
||||
{
|
||||
$iIndex = $$oReplaceHash{$strType}{$strReplacement}{index};
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -329,14 +391,12 @@ sub BackRestTestCommon_ExecuteRegExp
|
||||
}
|
||||
|
||||
$iIndex = $$oReplaceHash{$strType}{index}++;
|
||||
$$oReplaceHash{$strType}{$strReplace}{index} = $iIndex;
|
||||
$$oReplaceHash{$strType}{$strReplacement}{index} = $iIndex;
|
||||
}
|
||||
}
|
||||
|
||||
$strTypeReplacement = "[${strType}" . (defined($iIndex) ? "-${iIndex}" : '') . ']';
|
||||
|
||||
my $strReplacement;
|
||||
|
||||
if (defined($strToken))
|
||||
{
|
||||
$strReplacement = $strReplace;
|
||||
@@ -363,6 +423,7 @@ sub BackRestTestCommon_ExecuteRegAll
|
||||
my $strBinPath = dirname(dirname(abs_path($0))) . '/bin';
|
||||
|
||||
$strLine =~ s/$strBinPath/[BACKREST_BIN_PATH]/g;
|
||||
$strLine =~ s/$strPgSqlBin/[PGSQL_BIN_PATH]/g;
|
||||
|
||||
my $strTestPath = BackRestTestCommon_TestPathGet();
|
||||
|
||||
@@ -372,27 +433,45 @@ sub BackRestTestCommon_ExecuteRegAll
|
||||
}
|
||||
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'MODIFICATION-TIME', 'modification_time = [0-9]+', '[0-9]+$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'TIMESTAMP', 'timestamp"[ ]{0,1}:[ ]{0,1}[0-9]+','[0-9]+$');
|
||||
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'BACKUP-INCR', '[0-9]{8}\-[0-9]{6}F\_[0-9]{8}\-[0-9]{6}I');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'BACKUP-DIFF', '[0-9]{8}\-[0-9]{6}F\_[0-9]{8}\-[0-9]{6}D');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'BACKUP-FULL', '[0-9]{8}\-[0-9]{6}F');
|
||||
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'GROUP', 'group = [^ \n,\[\]]+', '[^ \n,\[\]]+$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'GROUP', 'group"[ ]{0,1}:[ ]{0,1}"[^"]+', '[^"]+$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'USER', 'user = [^ \n,\[\]]+', '[^ \n,\[\]]+$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'USER', 'user"[ ]{0,1}:[ ]{0,1}"[^"]+', '[^"]+$');
|
||||
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'VERSION', 'version = ' . version_get(), version_get . '$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'VERSION', '"version" : ' . version_get(), version_get . '$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'VERSION', 'version[ ]{0,1}=[ ]{0,1}\"' . version_get(), version_get . '$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'VERSION', '"version"[ ]{0,1}:[ ]{0,1}\"' . version_get(), version_get . '$');
|
||||
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'FORMAT', '"format" : ' . FORMAT, FORMAT . '$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'FORMAT', 'format=' . FORMAT, FORMAT . '$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'FORMAT', '"format"[ ]{0,1}:[ ]{0,1}' . FORMAT, FORMAT . '$');
|
||||
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'PORT', '--port=[0-9]+', '[0-9]+$');
|
||||
|
||||
my $strTimestampRegExp = "[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-6][0-9]:[0-6][0-9]";
|
||||
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'TIMESTAMP', "\"timestamp-copy-start\" : \"$strTimestampRegExp\"",
|
||||
$strTimestampRegExp, false);
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'TIMESTAMP', "\"timestamp-start\" : \"$strTimestampRegExp\"",
|
||||
$strTimestampRegExp, false);
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'TIMESTAMP', "\"timestamp-stop\" : \"$strTimestampRegExp\"",
|
||||
$strTimestampRegExp, false);
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'TIMESTAMP',
|
||||
"timestamp-[a-z-]+[\"]{0,1}[ ]{0,1}[\:\=)]{1}[ ]{0,1}[\"]{0,1}[0-9]+", '[0-9]+$', false);
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'TIMESTAMP',
|
||||
"start\" : [0-9]{10}", '[0-9]{10}$', false);
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'TIMESTAMP',
|
||||
"stop\" : [0-9]{10}", '[0-9]{10}$', false);
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'TIMESTAMP-STR', "est backup timestamp: $strTimestampRegExp",
|
||||
"${strTimestampRegExp}\$", false);
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'CHECKSUM', 'checksum=[\"]{0,1}[0-f]{40}', '[0-f]{40}$', false);
|
||||
|
||||
if (!$bValidWalChecksum)
|
||||
{
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'CHECKSUM', '[0-F]{24}-[0-f]{40}', '[0-f]{40}$', false);
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'DB-SYSTEM-ID',
|
||||
"db-system-id[\"]{0,1}[ ]{0,1}[\:\=)]{1}[ ]{0,1}[0-9]+", '[0-9]+$');
|
||||
$strLine = BackRestTestCommon_ExecuteRegExp($strLine, 'BACKUP-INFO',
|
||||
"backup-info-[a-z-]+[\"]{0,1}[ ]{0,1}[\:\=)]{1}[ ]{0,1}[0-9]+", '[0-9]+$', false);
|
||||
}
|
||||
|
||||
return $strLine;
|
||||
}
|
||||
@@ -446,7 +525,7 @@ sub BackRestTestCommon_ExecuteEnd
|
||||
{
|
||||
$strLine =~ s/^[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-6][0-9]:[0-6][0-9]\.[0-9]{3} T[0-9]{2} //;
|
||||
|
||||
if ($strLine !~ /^ TEST/ && $strLine =~ /^ /)
|
||||
if ($strLine !~ /^ TEST/ && $strLine !~ /\r$/)
|
||||
{
|
||||
$strLine =~ s/^ //;
|
||||
$strLine =~ s/^ //;
|
||||
@@ -462,7 +541,7 @@ sub BackRestTestCommon_ExecuteEnd
|
||||
# Check the exit status and output an error if needed
|
||||
my $iExitStatus = ${^CHILD_ERROR_NATIVE} >> 8;
|
||||
|
||||
if (defined($iExpectedExitStatus) && $iExitStatus == $iExpectedExitStatus)
|
||||
if (defined($iExpectedExitStatus) && ($iExitStatus == $iExpectedExitStatus || $bExecuteRemote && $iExitStatus != 0))
|
||||
{
|
||||
return $iExitStatus;
|
||||
}
|
||||
@@ -789,7 +868,7 @@ sub BackRestTestCommon_iniLoad
|
||||
BackRestTestCommon_Execute("chmod g+x " . BackRestTestCommon_RepoPathGet(), $bRemote);
|
||||
}
|
||||
|
||||
ini_load($strFileName, $oIniRef);
|
||||
iniLoad($strFileName, $oIniRef);
|
||||
|
||||
if ($bRemote)
|
||||
{
|
||||
@@ -805,6 +884,7 @@ sub BackRestTestCommon_iniSave
|
||||
my $strFileName = shift;
|
||||
my $oIniRef = shift;
|
||||
my $bRemote = shift;
|
||||
my $bChecksum = shift;
|
||||
|
||||
# Defaults
|
||||
$bRemote = defined($bRemote) ? $bRemote : false;
|
||||
@@ -815,7 +895,19 @@ sub BackRestTestCommon_iniSave
|
||||
BackRestTestCommon_Execute("chmod g+w " . $strFileName, $bRemote);
|
||||
}
|
||||
|
||||
ini_save($strFileName, $oIniRef);
|
||||
# Calculate a new checksum if requested
|
||||
if (defined($bChecksum) && $bChecksum)
|
||||
{
|
||||
delete($$oIniRef{&INI_SECTION_BACKREST}{&INI_KEY_CHECKSUM});
|
||||
|
||||
my $oSHA = Digest::SHA->new('sha1');
|
||||
my $oJSON = JSON::PP->new()->canonical()->allow_nonref();
|
||||
$oSHA->add($oJSON->encode($oIniRef));
|
||||
|
||||
$$oIniRef{&INI_SECTION_BACKREST}{&INI_KEY_CHECKSUM} = $oSHA->hexdigest();
|
||||
}
|
||||
|
||||
iniSave($strFileName, $oIniRef);
|
||||
|
||||
if ($bRemote)
|
||||
{
|
||||
@@ -839,7 +931,7 @@ sub BackRestTestCommon_ConfigRemap
|
||||
|
||||
# Load Config file
|
||||
my %oConfig;
|
||||
ini_load($strConfigFile, \%oConfig);
|
||||
iniLoad($strConfigFile, \%oConfig, true);
|
||||
|
||||
# Load remote config file
|
||||
my %oRemoteConfig;
|
||||
@@ -848,7 +940,7 @@ sub BackRestTestCommon_ConfigRemap
|
||||
if ($bRemote)
|
||||
{
|
||||
BackRestTestCommon_Execute("mv " . BackRestTestCommon_RepoPathGet() . "/pg_backrest.conf ${strRemoteConfigFile}", true);
|
||||
ini_load($strRemoteConfigFile, \%oRemoteConfig);
|
||||
iniLoad($strRemoteConfigFile, \%oRemoteConfig, true);
|
||||
}
|
||||
|
||||
# Rewrite remap section
|
||||
@@ -861,7 +953,7 @@ sub BackRestTestCommon_ConfigRemap
|
||||
if ($strRemap eq 'base')
|
||||
{
|
||||
$oConfig{$strStanza}{'db-path'} = $strRemapPath;
|
||||
${$oManifestRef}{'backup:path'}{base} = $strRemapPath;
|
||||
${$oManifestRef}{'backup:path'}{base}{&MANIFEST_SUBKEY_PATH} = $strRemapPath;
|
||||
|
||||
if ($bRemote)
|
||||
{
|
||||
@@ -872,19 +964,18 @@ sub BackRestTestCommon_ConfigRemap
|
||||
{
|
||||
$oConfig{"${strStanza}:restore:tablespace-map"}{$strRemap} = $strRemapPath;
|
||||
|
||||
${$oManifestRef}{'backup:path'}{"tablespace:${strRemap}"} = $strRemapPath;
|
||||
${$oManifestRef}{'backup:tablespace'}{$strRemap}{'path'} = $strRemapPath;
|
||||
${$oManifestRef}{'base:link'}{"pg_tblspc/${strRemap}"}{'link_destination'} = $strRemapPath;
|
||||
${$oManifestRef}{'backup:path'}{"tablespace/${strRemap}"}{&MANIFEST_SUBKEY_PATH} = $strRemapPath;
|
||||
${$oManifestRef}{'base:link'}{"pg_tblspc/${strRemap}"}{destination} = $strRemapPath;
|
||||
}
|
||||
}
|
||||
|
||||
# Resave the config file
|
||||
ini_save($strConfigFile, \%oConfig);
|
||||
iniSave($strConfigFile, \%oConfig, true);
|
||||
|
||||
# Load remote config file
|
||||
if ($bRemote)
|
||||
{
|
||||
ini_save($strRemoteConfigFile, \%oRemoteConfig);
|
||||
iniSave($strRemoteConfigFile, \%oRemoteConfig, true);
|
||||
BackRestTestCommon_Execute("mv ${strRemoteConfigFile} " . BackRestTestCommon_RepoPathGet() . '/pg_backrest.conf', true);
|
||||
}
|
||||
}
|
||||
@@ -903,7 +994,7 @@ sub BackRestTestCommon_ConfigRecovery
|
||||
|
||||
# Load Config file
|
||||
my %oConfig;
|
||||
ini_load($strConfigFile, \%oConfig);
|
||||
iniLoad($strConfigFile, \%oConfig, true);
|
||||
|
||||
# Load remote config file
|
||||
my %oRemoteConfig;
|
||||
@@ -912,7 +1003,7 @@ sub BackRestTestCommon_ConfigRecovery
|
||||
if ($bRemote)
|
||||
{
|
||||
BackRestTestCommon_Execute("mv " . BackRestTestCommon_RepoPathGet() . "/pg_backrest.conf ${strRemoteConfigFile}", true);
|
||||
ini_load($strRemoteConfigFile, \%oRemoteConfig);
|
||||
iniLoad($strRemoteConfigFile, \%oRemoteConfig, true);
|
||||
}
|
||||
|
||||
# Rewrite remap section
|
||||
@@ -924,12 +1015,12 @@ sub BackRestTestCommon_ConfigRecovery
|
||||
}
|
||||
|
||||
# Resave the config file
|
||||
ini_save($strConfigFile, \%oConfig);
|
||||
iniSave($strConfigFile, \%oConfig, true);
|
||||
|
||||
# Load remote config file
|
||||
if ($bRemote)
|
||||
{
|
||||
ini_save($strRemoteConfigFile, \%oRemoteConfig);
|
||||
iniSave($strRemoteConfigFile, \%oRemoteConfig, true);
|
||||
BackRestTestCommon_Execute("mv ${strRemoteConfigFile} " . BackRestTestCommon_RepoPathGet() . '/pg_backrest.conf', true);
|
||||
}
|
||||
}
|
||||
@@ -1039,7 +1130,7 @@ sub BackRestTestCommon_ConfigCreate
|
||||
|
||||
# Write out the configuration file
|
||||
my $strFile = BackRestTestCommon_TestPathGet() . '/pg_backrest.conf';
|
||||
ini_save($strFile, \%oParamHash);
|
||||
iniSave($strFile, \%oParamHash, true);
|
||||
|
||||
# Move the configuration file based on local
|
||||
if ($strLocal eq 'db')
|
||||
|
||||
@@ -11,15 +11,16 @@ use strict;
|
||||
use warnings FATAL => qw(all);
|
||||
use Carp qw(confess);
|
||||
|
||||
use File::Basename qw(dirname);
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
use File::stat;
|
||||
use Exporter qw(import);
|
||||
use File::Basename qw(dirname);
|
||||
use File::stat;
|
||||
use Time::HiRes qw(gettimeofday);
|
||||
|
||||
use lib dirname($0) . '/../lib';
|
||||
use BackRest::Utility;
|
||||
use BackRestTest::CommonTest;
|
||||
|
||||
use BackRestTest::BackupTest;
|
||||
use BackRestTest::CommonTest;
|
||||
|
||||
####################################################################################################################################
|
||||
# Exports
|
||||
|
||||
@@ -11,8 +11,9 @@ use strict;
|
||||
use warnings FATAL => qw(all);
|
||||
use Carp qw(confess);
|
||||
|
||||
use File::Basename qw(dirname);
|
||||
use Cwd qw(abs_path);
|
||||
use Exporter qw(import);
|
||||
use File::Basename qw(dirname);
|
||||
use Scalar::Util 'blessed';
|
||||
#use Data::Dumper qw(Dumper);
|
||||
#use Scalar::Util qw(blessed);
|
||||
@@ -20,15 +21,13 @@ use Scalar::Util 'blessed';
|
||||
# use Test::Deep;
|
||||
|
||||
use lib dirname($0) . '/../lib';
|
||||
use BackRest::Exception;
|
||||
use BackRest::Utility;
|
||||
use BackRest::Config;
|
||||
use BackRest::Exception;
|
||||
use BackRest::Ini;
|
||||
use BackRest::Utility;
|
||||
|
||||
use BackRestTest::CommonTest;
|
||||
|
||||
use Exporter qw(import);
|
||||
our @EXPORT = qw(BackRestTestConfig_Test);
|
||||
|
||||
sub optionSetTest
|
||||
{
|
||||
my $oOption = shift;
|
||||
@@ -240,6 +239,8 @@ sub optionTestExpect
|
||||
####################################################################################################################################
|
||||
# BackRestTestConfig_Test
|
||||
####################################################################################################################################
|
||||
our @EXPORT = qw(BackRestTestConfig_Test);
|
||||
|
||||
sub BackRestTestConfig_Test
|
||||
{
|
||||
my $strTest = shift;
|
||||
@@ -608,8 +609,8 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, 'load from config stanza section - option ' . OPTION_THREAD_MAX))
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{"$strStanza:" . &OP_BACKUP}{&OPTION_THREAD_MAX} = 2;
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
$$oConfig{"${strStanza}:" . &OP_BACKUP}{&OPTION_THREAD_MAX} = 2;
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -623,7 +624,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{"$strStanza:" . &CONFIG_SECTION_GENERAL}{&OPTION_THREAD_MAX} = 3;
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -638,7 +639,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &OP_BACKUP}{&OPTION_THREAD_MAX} = 2;
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -652,7 +653,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_GENERAL}{&OPTION_THREAD_MAX} = 5;
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -665,7 +666,7 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, 'default - option ' . OPTION_THREAD_MAX))
|
||||
{
|
||||
$oConfig = {};
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -679,7 +680,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_GENERAL}{&OPTION_THREAD_MAX} = 9;
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -694,7 +695,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &OP_BACKUP}{&OPTION_HARDLINK} = 'Y';
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -707,7 +708,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_LOG}{&OPTION_LOG_LEVEL_CONSOLE} = BOGUS;
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -720,7 +721,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_LOG}{&OPTION_LOG_LEVEL_CONSOLE} = lc(INFO);
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
@@ -740,7 +741,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_EXPIRE}{&OPTION_RETENTION_FULL} = 2;
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
@@ -753,7 +754,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_BACKUP}{&OPTION_COMPRESS} = 'n';
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -767,7 +768,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_RESTORE_RECOVERY_SETTING}{'archive-command'} = '/path/to/pg_backrest.pl';
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
@@ -780,7 +781,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{$strStanza . ':' . &CONFIG_SECTION_RESTORE_RECOVERY_SETTING}{'standby-mode'} = 'on';
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
@@ -792,7 +793,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{$strStanza}{&OPTION_DB_PATH} = '/path/to/db';
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
@@ -805,7 +806,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{$strStanza}{&OPTION_DB_PATH} = '/path/to/db';
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
@@ -818,7 +819,7 @@ sub BackRestTestConfig_Test
|
||||
{
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_GENERAL}{&OPTION_REPO_PATH} = '/repo';
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
@@ -833,7 +834,7 @@ sub BackRestTestConfig_Test
|
||||
$oConfig = {};
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_COMMAND}{&OPTION_COMMAND_PSQL} = '/psql -X %option%';
|
||||
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_COMMAND}{&OPTION_COMMAND_PSQL_OPTION} = '--port=5432';
|
||||
ini_save($strConfigFile, $oConfig);
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
|
||||
@@ -11,25 +11,23 @@ use strict;
|
||||
use warnings FATAL => qw(all);
|
||||
use Carp qw(confess);
|
||||
|
||||
use File::Basename;
|
||||
use Cwd 'abs_path';
|
||||
use File::stat;
|
||||
use Exporter qw(import);
|
||||
use Fcntl ':mode';
|
||||
use File::Basename;
|
||||
use File::stat;
|
||||
use POSIX qw(ceil);
|
||||
use Scalar::Util 'blessed';
|
||||
use Time::HiRes qw(gettimeofday usleep);
|
||||
use POSIX qw(ceil);
|
||||
|
||||
use lib dirname($0) . '/../lib';
|
||||
use BackRest::Utility;
|
||||
use BackRest::Config;
|
||||
use BackRest::File;
|
||||
use BackRest::Remote;
|
||||
use BackRest::Utility;
|
||||
|
||||
use BackRestTest::CommonTest;
|
||||
|
||||
use Exporter qw(import);
|
||||
our @EXPORT = qw(BackRestTestFile_Test);
|
||||
|
||||
my $strTestPath;
|
||||
my $strHost;
|
||||
my $strUserBackRest;
|
||||
@@ -67,6 +65,8 @@ sub BackRestTestFile_Setup
|
||||
####################################################################################################################################
|
||||
# BackRestTestFile_Test
|
||||
####################################################################################################################################
|
||||
our @EXPORT = qw(BackRestTestFile_Test);
|
||||
|
||||
sub BackRestTestFile_Test
|
||||
{
|
||||
my $strTest = shift;
|
||||
|
||||
@@ -11,21 +11,22 @@ use strict;
|
||||
use warnings FATAL => qw(all);
|
||||
use Carp qw(confess);
|
||||
|
||||
use File::Basename;
|
||||
use Exporter qw(import);
|
||||
use File::Basename qw(dirname);
|
||||
|
||||
use lib dirname($0) . '/../lib';
|
||||
use BackRest::Utility;
|
||||
use BackRest::Config;
|
||||
use BackRest::File;
|
||||
use BackRest::Ini;
|
||||
use BackRest::Utility;
|
||||
|
||||
use BackRestTest::CommonTest;
|
||||
|
||||
use Exporter qw(import);
|
||||
our @EXPORT = qw(BackRestTestUtility_Test);
|
||||
|
||||
####################################################################################################################################
|
||||
# BackRestTestUtility_Test
|
||||
####################################################################################################################################
|
||||
our @EXPORT = qw(BackRestTestUtility_Test);
|
||||
|
||||
sub BackRestTestUtility_Test
|
||||
{
|
||||
my $strTest = shift;
|
||||
@@ -97,18 +98,18 @@ sub BackRestTestUtility_Test
|
||||
|
||||
# Save the test config
|
||||
my $strFile = "${strTestPath}/config.cfg";
|
||||
ini_save($strFile, \%oConfig);
|
||||
iniSave($strFile, \%oConfig);
|
||||
|
||||
my $strConfigHash = $oFile->hash(PATH_ABSOLUTE, $strFile);
|
||||
|
||||
# Reload the test config
|
||||
my %oConfigTest;
|
||||
|
||||
ini_load($strFile, \%oConfigTest);
|
||||
iniLoad($strFile, \%oConfigTest);
|
||||
|
||||
# Resave the test config and compare hashes
|
||||
my $strFileTest = "${strTestPath}/config-test.cfg";
|
||||
ini_save($strFileTest, \%oConfigTest);
|
||||
iniSave($strFileTest, \%oConfigTest);
|
||||
|
||||
my $strConfigTestHash = $oFile->hash(PATH_ABSOLUTE, $strFileTest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user