From 36d4ab9bff668efcbbbf3393d80bd53f0be09a67 Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 10 Mar 2020 15:12:44 -0400 Subject: [PATCH] Move Perl modules out of lib directory. This directory was once the home of the production Perl code but since f0ef73db this is no longer true. Move the modules to test in most cases, except where the module is expected to be useful for the doc engine beyond the expected lifetime of the Perl test code (about a year if all goes well). The exception is pgBackRest::Version which requires more work to migrate since it is used to track pgBackRest versions. --- build/lib/pgBackRestBuild/Build.pm | 8 +- build/lib/pgBackRestBuild/Build/Common.pm | 4 +- build/lib/pgBackRestBuild/Config/Build.pm | 5 +- .../lib/pgBackRestBuild/Config/BuildDefine.pm | 4 +- .../lib/pgBackRestBuild/Config/BuildParse.pm | 5 +- build/lib/pgBackRestBuild/Config/Data.pm | 11 +- build/lib/pgBackRestBuild/Error/Build.pm | 4 +- doc/doc.pl | 6 +- doc/lib/BackRestDoc/Common/Doc.pm | 4 +- doc/lib/BackRestDoc/Common/DocConfig.pm | 8 +- doc/lib/BackRestDoc/Common/DocExecute.pm | 15 +- doc/lib/BackRestDoc/Common/DocManifest.pm | 4 +- doc/lib/BackRestDoc/Common/DocRender.pm | 5 +- .../lib/BackRestDoc}/Common/Exception.pm | 16 +- .../lib/BackRestDoc}/Common/Ini.pm | 9 +- .../lib/BackRestDoc}/Common/Log.pm | 8 +- doc/lib/BackRestDoc/Common/String.pm | 121 +++++++++ .../BackRestDoc/Custom/DocCustomRelease.pm | 4 +- doc/lib/BackRestDoc/Html/DocHtmlBuilder.pm | 5 +- doc/lib/BackRestDoc/Html/DocHtmlElement.pm | 2 +- doc/lib/BackRestDoc/Html/DocHtmlPage.pm | 5 +- doc/lib/BackRestDoc/Html/DocHtmlSite.pm | 6 +- doc/lib/BackRestDoc/Latex/DocLatex.pm | 7 +- doc/lib/BackRestDoc/Latex/DocLatexSection.pm | 5 +- doc/lib/BackRestDoc/Markdown/DocMarkdown.pm | 4 +- .../BackRestDoc/Markdown/DocMarkdownRender.pm | 5 +- doc/release.pl | 6 +- lib/pgBackRest/Archive/Common.pm | 44 --- lib/pgBackRest/Backup/Common.pm | 256 ------------------ lib/pgBackRest/Common/String.pm | 224 --------------- lib/pgBackRest/Storage/Helper.pm | 109 -------- test/lib/pgBackRestTest/Common/BuildTest.pm | 4 +- .../pgBackRestTest/Common/CodeCountTest.pm | 2 +- .../pgBackRestTest/Common/ContainerTest.pm | 5 +- .../lib/pgBackRestTest/Common/CoverageTest.pm | 4 +- .../lib/pgBackRestTest/Common}/DbVersion.pm | 10 +- test/lib/pgBackRestTest/Common/DefineTest.pm | 4 +- test/lib/pgBackRestTest/Common/ExecuteTest.pm | 15 +- test/lib/pgBackRestTest/Common/FileTest.pm | 12 +- .../pgBackRestTest/Common/HostGroupTest.pm | 4 +- test/lib/pgBackRestTest/Common/HostTest.pm | 4 +- .../lib/pgBackRestTest}/Common/Io/Base.pm | 4 +- .../lib/pgBackRestTest}/Common/Io/Buffered.pm | 15 +- .../lib/pgBackRestTest}/Common/Io/Filter.pm | 4 +- .../lib/pgBackRestTest}/Common/Io/Handle.pm | 8 +- .../lib/pgBackRestTest}/Common/Io/Process.pm | 17 +- test/lib/pgBackRestTest/Common/JobTest.pm | 9 +- test/lib/pgBackRestTest/Common/ListTest.pm | 4 +- test/lib/pgBackRestTest/Common/LogTest.pm | 3 +- test/lib/pgBackRestTest/Common/RunTest.pm | 9 +- test/lib/pgBackRestTest/Common/Storage.pm | 11 +- .../lib/pgBackRestTest/Common/StorageBase.pm | 9 +- .../lib/pgBackRestTest/Common/StoragePosix.pm | 7 +- .../pgBackRestTest/Common/StoragePosixRead.pm | 6 +- .../Common/StoragePosixWrite.pm | 10 +- .../lib/pgBackRestTest/Common/StorageRepo.pm | 106 +++++++- test/lib/pgBackRestTest/Common/VmTest.pm | 7 +- .../lib/pgBackRestTest}/Common/Wait.pm | 4 +- .../lib/pgBackRestTest/Env/ArchiveInfo.pm | 36 ++- .../lib/pgBackRestTest/Env/BackupInfo.pm | 32 ++- test/lib/pgBackRestTest/Env/ExpireEnvTest.pm | 39 +-- .../pgBackRestTest/Env/Host/HostBackupTest.pm | 132 +++++++-- .../pgBackRestTest/Env/Host/HostBaseTest.pm | 5 +- .../Env/Host/HostDbCommonTest.pm | 21 +- .../Env/Host/HostDbSyntheticTest.pm | 21 +- .../lib/pgBackRestTest/Env/Host/HostDbTest.pm | 19 +- .../lib/pgBackRestTest/Env/Host/HostS3Test.pm | 16 +- test/lib/pgBackRestTest/Env/HostEnvTest.pm | 18 +- .../lib/pgBackRestTest/Env}/InfoCommon.pm | 2 +- .../lib/pgBackRestTest/Env}/Manifest.pm | 17 +- .../pgBackRestTest/Module/Mock/MockAllTest.pm | 168 +++++++++++- .../Module/Mock/MockArchiveStopTest.pm | 18 +- .../Module/Mock/MockArchiveTest.pm | 18 +- .../Module/Mock/MockExpireTest.pm | 24 +- .../Module/Mock/MockStanzaTest.pm | 26 +- .../Performance/PerformanceArchivePerlTest.pm | 2 +- .../pgBackRestTest/Module/Real/RealAllTest.pm | 40 +-- test/test.pl | 9 +- test/travis.pl | 5 +- 79 files changed, 860 insertions(+), 1024 deletions(-) rename {lib/pgBackRest => doc/lib/BackRestDoc}/Common/Exception.pm (94%) rename {lib/pgBackRest => doc/lib/BackRestDoc}/Common/Ini.pm (99%) rename {lib/pgBackRest => doc/lib/BackRestDoc}/Common/Log.pm (99%) create mode 100644 doc/lib/BackRestDoc/Common/String.pm delete mode 100644 lib/pgBackRest/Archive/Common.pm delete mode 100644 lib/pgBackRest/Backup/Common.pm delete mode 100644 lib/pgBackRest/Common/String.pm delete mode 100644 lib/pgBackRest/Storage/Helper.pm rename {lib/pgBackRest => test/lib/pgBackRestTest/Common}/DbVersion.pm (88%) rename {lib/pgBackRest => test/lib/pgBackRestTest}/Common/Io/Base.pm (98%) rename {lib/pgBackRest => test/lib/pgBackRestTest}/Common/Io/Buffered.pm (97%) rename {lib/pgBackRest => test/lib/pgBackRestTest}/Common/Io/Filter.pm (97%) rename {lib/pgBackRest => test/lib/pgBackRestTest}/Common/Io/Handle.pm (97%) rename {lib/pgBackRest => test/lib/pgBackRestTest}/Common/Io/Process.pm (93%) rename lib/pgBackRest/Storage/Base.pm => test/lib/pgBackRestTest/Common/StorageBase.pm (97%) rename lib/pgBackRest/Storage/Storage.pm => test/lib/pgBackRestTest/Common/StorageRepo.pm (81%) rename {lib/pgBackRest => test/lib/pgBackRestTest}/Common/Wait.pm (98%) rename lib/pgBackRest/Archive/Info.pm => test/lib/pgBackRestTest/Env/ArchiveInfo.pm (92%) rename lib/pgBackRest/Backup/Info.pm => test/lib/pgBackRestTest/Env/BackupInfo.pm (96%) rename {lib/pgBackRest => test/lib/pgBackRestTest/Env}/InfoCommon.pm (97%) rename {lib/pgBackRest => test/lib/pgBackRestTest/Env}/Manifest.pm (99%) diff --git a/build/lib/pgBackRestBuild/Build.pm b/build/lib/pgBackRestBuild/Build.pm index dd6a54232..9d8cb2dd3 100644 --- a/build/lib/pgBackRestBuild/Build.pm +++ b/build/lib/pgBackRestBuild/Build.pm @@ -13,14 +13,14 @@ use Exporter qw(import); use File::Basename qw(basename); use Storable qw(dclone); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; - -use pgBackRestBuild::Build::Common; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRestTest::Common::Storage; use pgBackRestTest::Common::StoragePosix; +use pgBackRestBuild::Build::Common; + #################################################################################################################################### # Define generator used for auto generated warning messages #################################################################################################################################### diff --git a/build/lib/pgBackRestBuild/Build/Common.pm b/build/lib/pgBackRestBuild/Build/Common.pm index 9691938e6..70f57c60d 100644 --- a/build/lib/pgBackRestBuild/Build/Common.pm +++ b/build/lib/pgBackRestBuild/Build/Common.pm @@ -13,8 +13,8 @@ use Exporter qw(import); our @EXPORT = qw(); use Storable qw(dclone); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # Constants diff --git a/build/lib/pgBackRestBuild/Config/Build.pm b/build/lib/pgBackRestBuild/Config/Build.pm index cdf9c92dc..bc22e1aa4 100644 --- a/build/lib/pgBackRestBuild/Config/Build.pm +++ b/build/lib/pgBackRestBuild/Config/Build.pm @@ -14,10 +14,11 @@ use Exporter qw(import); use File::Basename qw(dirname); use Storable qw(dclone); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + use pgBackRestBuild::Build::Common; use pgBackRestBuild::Config::BuildDefine; use pgBackRestBuild::Config::Data; diff --git a/build/lib/pgBackRestBuild/Config/BuildDefine.pm b/build/lib/pgBackRestBuild/Config/BuildDefine.pm index 78c6b225d..485f98925 100644 --- a/build/lib/pgBackRestBuild/Config/BuildDefine.pm +++ b/build/lib/pgBackRestBuild/Config/BuildDefine.pm @@ -14,12 +14,12 @@ use Exporter qw(import); use File::Basename qw(dirname); use Storable qw(dclone); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; use BackRestDoc::Common::DocConfig; use BackRestDoc::Common::DocRender; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRestBuild::Build::Common; use pgBackRestBuild::Config::Data; diff --git a/build/lib/pgBackRestBuild/Config/BuildParse.pm b/build/lib/pgBackRestBuild/Config/BuildParse.pm index 95dfef2bb..14571cd6e 100644 --- a/build/lib/pgBackRestBuild/Config/BuildParse.pm +++ b/build/lib/pgBackRestBuild/Config/BuildParse.pm @@ -14,10 +14,11 @@ use Exporter qw(import); use File::Basename qw(dirname); use Storable qw(dclone); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + use pgBackRestBuild::Build::Common; use pgBackRestBuild::Config::Build; use pgBackRestBuild::Config::Data; diff --git a/build/lib/pgBackRestBuild/Config/Data.pm b/build/lib/pgBackRestBuild/Config/Data.pm index 99c3c9b1d..44f78117b 100644 --- a/build/lib/pgBackRestBuild/Config/Data.pm +++ b/build/lib/pgBackRestBuild/Config/Data.pm @@ -66,12 +66,13 @@ use File::Basename qw(dirname basename); use Getopt::Long qw(GetOptions); use Storable qw(dclone); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Io::Base; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::Wait; + #################################################################################################################################### # Command constants - commands that are allowed in the exe #################################################################################################################################### @@ -1202,7 +1203,7 @@ my %hConfigDefine = { &CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL, &CFGDEF_TYPE => CFGDEF_TYPE_SIZE, - &CFGDEF_DEFAULT => COMMON_IO_BUFFER_MAX, + &CFGDEF_DEFAULT => 4194304, &CFGDEF_ALLOW_LIST => [ &CFGDEF_DEFAULT_BUFFER_SIZE_MIN, diff --git a/build/lib/pgBackRestBuild/Error/Build.pm b/build/lib/pgBackRestBuild/Error/Build.pm index 3a2622676..85b058559 100644 --- a/build/lib/pgBackRestBuild/Error/Build.pm +++ b/build/lib/pgBackRestBuild/Error/Build.pm @@ -11,11 +11,11 @@ use English '-no_match_vars'; use Exporter qw(import); our @EXPORT = qw(); +use BackRestDoc::Common::Log; + use pgBackRestBuild::Build::Common; use pgBackRestBuild::Error::Data; -use pgBackRest::Common::Log; - #################################################################################################################################### # Constants #################################################################################################################################### diff --git a/doc/doc.pl b/doc/doc.pl index db24edf33..a61738f3e 100755 --- a/doc/doc.pl +++ b/doc/doc.pl @@ -32,9 +32,9 @@ use BackRestDoc::Html::DocHtmlSite; use BackRestDoc::Latex::DocLatex; use BackRestDoc::Markdown::DocMarkdown; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRest::Version; use pgBackRestTest::Common::ExecuteTest; diff --git a/doc/lib/BackRestDoc/Common/Doc.pm b/doc/lib/BackRestDoc/Common/Doc.pm index a5b6d1b24..2afe1fd66 100644 --- a/doc/lib/BackRestDoc/Common/Doc.pm +++ b/doc/lib/BackRestDoc/Common/Doc.pm @@ -13,8 +13,8 @@ use File::Basename qw(dirname); use Scalar::Util qw(blessed); use XML::Checker::Parser; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # CONSTRUCTOR diff --git a/doc/lib/BackRestDoc/Common/DocConfig.pm b/doc/lib/BackRestDoc/Common/DocConfig.pm index faeaae53f..1986378b6 100644 --- a/doc/lib/BackRestDoc/Common/DocConfig.pm +++ b/doc/lib/BackRestDoc/Common/DocConfig.pm @@ -11,11 +11,13 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(dirname); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRestBuild::Config::Data; use pgBackRest::Version; +use pgBackRestBuild::Config::Data; + +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + #################################################################################################################################### # Help types #################################################################################################################################### diff --git a/doc/lib/BackRestDoc/Common/DocExecute.pm b/doc/lib/BackRestDoc/Common/DocExecute.pm index e30eb947f..59758ae1d 100644 --- a/doc/lib/BackRestDoc/Common/DocExecute.pm +++ b/doc/lib/BackRestDoc/Common/DocExecute.pm @@ -15,19 +15,20 @@ use Exporter qw(import); use File::Basename qw(dirname); use Storable qw(dclone); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; use pgBackRestBuild::Config::Data; -use BackRestDoc::Common::DocManifest; - use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::HostTest; use pgBackRestTest::Common::HostGroupTest; +use BackRestDoc::Common::DocManifest; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + #################################################################################################################################### # User that's building the docs #################################################################################################################################### @@ -526,10 +527,6 @@ sub backrestConfig if ($self->{bExe} && $self->isRequired($oSection)) { - # Load module dynamically - require pgBackRest::Common::Ini; - pgBackRest::Common::Ini->import(); - my ($bCacheHit, $strCacheType, $hCacheKey, $hCacheValue) = $self->cachePop('cfg-' . PROJECT_EXE, $hCacheKey); if ($bCacheHit) diff --git a/doc/lib/BackRestDoc/Common/DocManifest.pm b/doc/lib/BackRestDoc/Common/DocManifest.pm index 87ec4e62b..9e8222a1f 100644 --- a/doc/lib/BackRestDoc/Common/DocManifest.pm +++ b/doc/lib/BackRestDoc/Common/DocManifest.pm @@ -13,8 +13,8 @@ use Exporter qw(import); use File::Basename qw(dirname); use JSON::PP; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # File constants diff --git a/doc/lib/BackRestDoc/Common/DocRender.pm b/doc/lib/BackRestDoc/Common/DocRender.pm index f97af3424..b52c7c31c 100644 --- a/doc/lib/BackRestDoc/Common/DocRender.pm +++ b/doc/lib/BackRestDoc/Common/DocRender.pm @@ -12,10 +12,9 @@ use Exporter qw(import); use JSON::PP; use Storable qw(dclone); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; - use BackRestDoc::Common::DocManifest; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # XML tag/param constants diff --git a/lib/pgBackRest/Common/Exception.pm b/doc/lib/BackRestDoc/Common/Exception.pm similarity index 94% rename from lib/pgBackRest/Common/Exception.pm rename to doc/lib/BackRestDoc/Common/Exception.pm index f4e16093f..258886c57 100644 --- a/lib/pgBackRest/Common/Exception.pm +++ b/doc/lib/BackRestDoc/Common/Exception.pm @@ -1,7 +1,7 @@ #################################################################################################################################### # COMMON EXCEPTION MODULE #################################################################################################################################### -package pgBackRest::Common::Exception; +package BackRestDoc::Common::Exception; use strict; use warnings FATAL => qw(all); @@ -158,16 +158,6 @@ sub code return $self->{iCode}; } -#################################################################################################################################### -# Is this a C error? -#################################################################################################################################### -sub errorC -{ - my $self = shift; - - return $self->{bErrorC}; -} - #################################################################################################################################### # extra #################################################################################################################################### @@ -211,7 +201,7 @@ sub isException # If a standard Exception if (blessed($$roException)) { - return $$roException->isa('pgBackRest::Common::Exception') ? 1 : 0; + return $$roException->isa('BackRestDoc::Common::Exception') ? 1 : 0; } # Else if a specially formatted string from the C library elsif ($$roException =~ /^PGBRCLIB\:[0-9]+\:/) @@ -226,7 +216,7 @@ sub isException my $strMessage = join(':', @stryException); # Create exception - $$roException = new pgBackRest::Common::Exception("ERROR", $iCode, $strMessage, $strTrace, undef, 1); + $$roException = new BackRestDoc::Common::Exception("ERROR", $iCode, $strMessage, $strTrace, undef, 1); return 1; } diff --git a/lib/pgBackRest/Common/Ini.pm b/doc/lib/BackRestDoc/Common/Ini.pm similarity index 99% rename from lib/pgBackRest/Common/Ini.pm rename to doc/lib/BackRestDoc/Common/Ini.pm index 2562ee064..f48865527 100644 --- a/lib/pgBackRest/Common/Ini.pm +++ b/doc/lib/BackRestDoc/Common/Ini.pm @@ -1,7 +1,7 @@ #################################################################################################################################### # COMMON INI MODULE #################################################################################################################################### -package pgBackRest::Common::Ini; +package BackRestDoc::Common::Ini; use strict; use warnings FATAL => qw(all); @@ -15,11 +15,12 @@ use File::Basename qw(dirname); use JSON::PP; use Storable qw(dclone); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + #################################################################################################################################### # Boolean constants #################################################################################################################################### diff --git a/lib/pgBackRest/Common/Log.pm b/doc/lib/BackRestDoc/Common/Log.pm similarity index 99% rename from lib/pgBackRest/Common/Log.pm rename to doc/lib/BackRestDoc/Common/Log.pm index ec3aaa354..d3f52a07b 100644 --- a/lib/pgBackRest/Common/Log.pm +++ b/doc/lib/BackRestDoc/Common/Log.pm @@ -1,7 +1,7 @@ #################################################################################################################################### # COMMON LOG MODULE #################################################################################################################################### -package pgBackRest::Common::Log; +package BackRestDoc::Common::Log; use strict; use warnings FATAL => qw(all); @@ -15,8 +15,8 @@ use File::Basename qw(dirname); use Scalar::Util qw(blessed reftype); use Time::HiRes qw(gettimeofday usleep); -use pgBackRest::Common::Exception; -use pgBackRest::Common::String; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::String; #################################################################################################################################### # Boolean constants @@ -751,7 +751,7 @@ sub log # Return a typed exception if code is defined if (defined($iCode)) { - $oErrorLast = new pgBackRest::Common::Exception($strLevel, $iCode, $strMessage, longmess(), $rExtra); + $oErrorLast = new BackRestDoc::Common::Exception($strLevel, $iCode, $strMessage, longmess(), $rExtra); return $oErrorLast; } diff --git a/doc/lib/BackRestDoc/Common/String.pm b/doc/lib/BackRestDoc/Common/String.pm new file mode 100644 index 000000000..6fb30edc6 --- /dev/null +++ b/doc/lib/BackRestDoc/Common/String.pm @@ -0,0 +1,121 @@ +#################################################################################################################################### +# COMMON STRING MODULE +#################################################################################################################################### +package BackRestDoc::Common::String; + +use strict; +use warnings FATAL => qw(all); +use Carp qw(confess longmess); + +use Exporter qw(import); + our @EXPORT = qw(); +use File::Basename qw(dirname); + +#################################################################################################################################### +# trim +# +# Trim whitespace. +#################################################################################################################################### +sub trim +{ + my $strBuffer = shift; + + if (!defined($strBuffer)) + { + return; + } + + $strBuffer =~ s/^\s+|\s+$//g; + + return $strBuffer; +} + +push @EXPORT, qw(trim); + +#################################################################################################################################### +# coalesce - return first defined parameter +#################################################################################################################################### +sub coalesce +{ + foreach my $strParam (@_) + { + if (defined($strParam)) + { + return $strParam; + } + } + + return; +} + +push @EXPORT, qw(coalesce); + +#################################################################################################################################### +# timestampFormat +# +# Get standard timestamp format (or formatted as specified). +#################################################################################################################################### +sub timestampFormat +{ + my $strFormat = shift; + my $lTime = shift; + + if (!defined($strFormat)) + { + $strFormat = '%4d-%02d-%02d %02d:%02d:%02d'; + } + + if (!defined($lTime)) + { + $lTime = time(); + } + + my ($iSecond, $iMinute, $iHour, $iMonthDay, $iMonth, $iYear, $iWeekDay, $iYearDay, $bIsDst) = localtime($lTime); + + if ($strFormat eq "%4d") + { + return sprintf($strFormat, $iYear + 1900) + } + else + { + return sprintf($strFormat, $iYear + 1900, $iMonth + 1, $iMonthDay, $iHour, $iMinute, $iSecond); + } +} + +push @EXPORT, qw(timestampFormat); + +#################################################################################################################################### +# stringSplit +#################################################################################################################################### +sub stringSplit +{ + my $strString = shift; + my $strChar = shift; + my $iLength = shift; + + if (length($strString) <= $iLength) + { + return $strString, undef; + } + + my $iPos = index($strString, $strChar); + + if ($iPos == -1) + { + return $strString, undef; + } + + my $iNewPos = $iPos; + + while ($iNewPos != -1 && $iNewPos + 1 < $iLength) + { + $iPos = $iNewPos; + $iNewPos = index($strString, $strChar, $iPos + 1); + } + + return substr($strString, 0, $iPos + 1), substr($strString, $iPos + 1); +} + +push @EXPORT, qw(stringSplit); + +1; diff --git a/doc/lib/BackRestDoc/Custom/DocCustomRelease.pm b/doc/lib/BackRestDoc/Custom/DocCustomRelease.pm index 75e4f8f4f..0e5db6327 100644 --- a/doc/lib/BackRestDoc/Custom/DocCustomRelease.pm +++ b/doc/lib/BackRestDoc/Custom/DocCustomRelease.pm @@ -12,13 +12,13 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(dirname); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; use pgBackRestBuild::Config::Data; use BackRestDoc::Common::DocRender; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # XML node constants diff --git a/doc/lib/BackRestDoc/Html/DocHtmlBuilder.pm b/doc/lib/BackRestDoc/Html/DocHtmlBuilder.pm index 790df8772..77dcccae0 100644 --- a/doc/lib/BackRestDoc/Html/DocHtmlBuilder.pm +++ b/doc/lib/BackRestDoc/Html/DocHtmlBuilder.pm @@ -10,9 +10,8 @@ use Carp qw(confess); use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; - +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use BackRestDoc::Html::DocHtmlElement; #################################################################################################################################### diff --git a/doc/lib/BackRestDoc/Html/DocHtmlElement.pm b/doc/lib/BackRestDoc/Html/DocHtmlElement.pm index a5d7cf88b..d6ae588d7 100644 --- a/doc/lib/BackRestDoc/Html/DocHtmlElement.pm +++ b/doc/lib/BackRestDoc/Html/DocHtmlElement.pm @@ -11,7 +11,7 @@ use Exporter qw(import); our @EXPORT = qw(); use Scalar::Util qw(blessed); -use pgBackRest::Common::Log; +use BackRestDoc::Common::Log; #################################################################################################################################### # Html Element Types diff --git a/doc/lib/BackRestDoc/Html/DocHtmlPage.pm b/doc/lib/BackRestDoc/Html/DocHtmlPage.pm index f83f5f2cc..fc27d6763 100644 --- a/doc/lib/BackRestDoc/Html/DocHtmlPage.pm +++ b/doc/lib/BackRestDoc/Html/DocHtmlPage.pm @@ -12,14 +12,13 @@ use Data::Dumper; use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; - use BackRestDoc::Common::DocConfig; use BackRestDoc::Common::DocManifest; use BackRestDoc::Common::DocRender; use BackRestDoc::Html::DocHtmlBuilder; use BackRestDoc::Html::DocHtmlElement; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # CONSTRUCTOR diff --git a/doc/lib/BackRestDoc/Html/DocHtmlSite.pm b/doc/lib/BackRestDoc/Html/DocHtmlSite.pm index 322a81b88..e202e0f6a 100644 --- a/doc/lib/BackRestDoc/Html/DocHtmlSite.pm +++ b/doc/lib/BackRestDoc/Html/DocHtmlSite.pm @@ -16,15 +16,15 @@ use File::Copy; use POSIX qw(strftime); use Storable qw(dclone); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; use pgBackRestTest::Common::ExecuteTest; use BackRestDoc::Common::DocConfig; use BackRestDoc::Common::DocManifest; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use BackRestDoc::Html::DocHtmlPage; #################################################################################################################################### diff --git a/doc/lib/BackRestDoc/Latex/DocLatex.pm b/doc/lib/BackRestDoc/Latex/DocLatex.pm index c952f14ce..9bbf6838c 100644 --- a/doc/lib/BackRestDoc/Latex/DocLatex.pm +++ b/doc/lib/BackRestDoc/Latex/DocLatex.pm @@ -17,11 +17,12 @@ use File::Copy; use POSIX qw(strftime); use Storable qw(dclone); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + use pgBackRestTest::Common::ExecuteTest; use BackRestDoc::Common::DocConfig; diff --git a/doc/lib/BackRestDoc/Latex/DocLatexSection.pm b/doc/lib/BackRestDoc/Latex/DocLatexSection.pm index e71788149..ef745c6c6 100644 --- a/doc/lib/BackRestDoc/Latex/DocLatexSection.pm +++ b/doc/lib/BackRestDoc/Latex/DocLatexSection.pm @@ -11,11 +11,10 @@ use Carp qw(confess); use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; - use BackRestDoc::Common::DocConfig; use BackRestDoc::Common::DocManifest; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # CONSTRUCTOR diff --git a/doc/lib/BackRestDoc/Markdown/DocMarkdown.pm b/doc/lib/BackRestDoc/Markdown/DocMarkdown.pm index 3eca7398b..a6d756c80 100644 --- a/doc/lib/BackRestDoc/Markdown/DocMarkdown.pm +++ b/doc/lib/BackRestDoc/Markdown/DocMarkdown.pm @@ -15,14 +15,14 @@ use File::Copy; use POSIX qw(strftime); use Storable qw(dclone); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; use pgBackRestTest::Common::ExecuteTest; use BackRestDoc::Common::DocConfig; use BackRestDoc::Common::DocManifest; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use BackRestDoc::Markdown::DocMarkdownRender; #################################################################################################################################### diff --git a/doc/lib/BackRestDoc/Markdown/DocMarkdownRender.pm b/doc/lib/BackRestDoc/Markdown/DocMarkdownRender.pm index 467de4365..4be6e90a4 100644 --- a/doc/lib/BackRestDoc/Markdown/DocMarkdownRender.pm +++ b/doc/lib/BackRestDoc/Markdown/DocMarkdownRender.pm @@ -15,11 +15,10 @@ use File::Basename qw(dirname); use File::Copy; use Storable qw(dclone); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; - use BackRestDoc::Common::DocConfig; use BackRestDoc::Common::DocManifest; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # CONSTRUCTOR diff --git a/doc/release.pl b/doc/release.pl index 8f9aa2768..0aa8bab35 100755 --- a/doc/release.pl +++ b/doc/release.pl @@ -32,9 +32,9 @@ use BackRestDoc::Html::DocHtmlSite; use BackRestDoc::Latex::DocLatex; use BackRestDoc::Markdown::DocMarkdown; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRest::Version; use pgBackRestTest::Common::ExecuteTest; diff --git a/lib/pgBackRest/Archive/Common.pm b/lib/pgBackRest/Archive/Common.pm deleted file mode 100644 index b66b9c6ab..000000000 --- a/lib/pgBackRest/Archive/Common.pm +++ /dev/null @@ -1,44 +0,0 @@ -#################################################################################################################################### -# ARCHIVE COMMON MODULE -#################################################################################################################################### -package pgBackRest::Archive::Common; - -use strict; -use warnings FATAL => qw(all); -use Carp qw(confess); - -use Config; -use Exporter qw(import); - our @EXPORT = qw(); -use Fcntl qw(SEEK_CUR O_RDONLY); -use File::Basename qw(dirname); - -use pgBackRest::DbVersion; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::Storage::Helper; - -#################################################################################################################################### -# RegEx constants -#################################################################################################################################### -use constant REGEX_ARCHIVE_DIR_DB_VERSION => '^[0-9]+(\.[0-9]+)*-[0-9]+$'; - push @EXPORT, qw(REGEX_ARCHIVE_DIR_DB_VERSION); -use constant REGEX_ARCHIVE_DIR_WAL => '^[0-F]{16}$'; - push @EXPORT, qw(REGEX_ARCHIVE_DIR_WAL); - -#################################################################################################################################### -# PostgreSQL WAL system id offset -#################################################################################################################################### -use constant PG_WAL_SYSTEM_ID_OFFSET_GTE_93 => 12 + $Config{ptrsize}; - push @EXPORT, qw(PG_WAL_SYSTEM_ID_OFFSET_GTE_93); -use constant PG_WAL_SYSTEM_ID_OFFSET_LT_93 => 12; - push @EXPORT, qw(PG_WAL_SYSTEM_ID_OFFSET_LT_93); - -#################################################################################################################################### -# WAL segment size -#################################################################################################################################### -use constant PG_WAL_SEGMENT_SIZE => 16777216; - push @EXPORT, qw(PG_WAL_SEGMENT_SIZE); - -1; diff --git a/lib/pgBackRest/Backup/Common.pm b/lib/pgBackRest/Backup/Common.pm deleted file mode 100644 index 6dc6dfe28..000000000 --- a/lib/pgBackRest/Backup/Common.pm +++ /dev/null @@ -1,256 +0,0 @@ -#################################################################################################################################### -# BACKUP COMMON MODULE -#################################################################################################################################### -package pgBackRest::Backup::Common; - -use strict; -use warnings FATAL => qw(all); -use Carp qw(confess); - -use Exporter qw(import); - our @EXPORT = qw(); -use File::Basename; - -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRest::Common::Wait; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; - -#################################################################################################################################### -# Latest backup link constant -#################################################################################################################################### -use constant LINK_LATEST => 'latest'; - push @EXPORT, qw(LINK_LATEST); - -use constant CFGOPTVAL_BACKUP_TYPE_FULL => 'full'; - push @EXPORT, qw(CFGOPTVAL_BACKUP_TYPE_FULL); -use constant CFGOPTVAL_BACKUP_TYPE_DIFF => 'diff'; - push @EXPORT, qw(CFGOPTVAL_BACKUP_TYPE_DIFF); -use constant CFGOPTVAL_BACKUP_TYPE_INCR => 'incr'; - push @EXPORT, qw(CFGOPTVAL_BACKUP_TYPE_INCR); - -#################################################################################################################################### -# backupRegExpGet -# -# Generate a regexp depending on the backups that need to be found. -#################################################################################################################################### -sub backupRegExpGet -{ - # Assign function parameters, defaults, and log debug info - my - ( - $strOperation, - $bFull, - $bDifferential, - $bIncremental, - $bAnchor - ) = - logDebugParam - ( - __PACKAGE__ . '::backupRegExpGet', \@_, - {name => 'bFull', default => false}, - {name => 'bDifferential', default => false}, - {name => 'bIncremental', default => false}, - {name => 'bAnchor', default => true} - ); - - # One of the types must be selected - if (!($bFull || $bDifferential || $bIncremental)) - { - confess &log(ASSERT, 'at least one backup type must be selected'); - } - - # Standard regexp to match date and time formatting - my $strDateTimeRegExp = "[0-9]{8}\\-[0-9]{6}"; - # Start the expression with the anchor if requested, date/time regexp and full backup indicator - my $strRegExp = ($bAnchor ? '^' : '') . $strDateTimeRegExp . 'F'; - - # Add the diff and/or incr expressions if requested - if ($bDifferential || $bIncremental) - { - # If full requested then diff/incr is optional - if ($bFull) - { - $strRegExp .= "(\\_"; - } - # Else diff/incr is required - else - { - $strRegExp .= "\\_"; - } - - # Append date/time regexp for diff/incr - $strRegExp .= $strDateTimeRegExp; - - # Filter on both diff/incr - if ($bDifferential && $bIncremental) - { - $strRegExp .= '(D|I)'; - } - # Else just diff - elsif ($bDifferential) - { - $strRegExp .= 'D'; - } - # Else just incr - else - { - $strRegExp .= 'I'; - } - - # If full requested then diff/incr is optional - if ($bFull) - { - $strRegExp .= '){0,1}'; - } - } - - # Append the end anchor if requested - $strRegExp .= $bAnchor ? "\$" : ''; - - # Return from function and log return values if any - return logDebugReturn - ( - $strOperation, - {name => 'strRegExp', value => $strRegExp} - ); -} - -push @EXPORT, qw(backupRegExpGet); - -#################################################################################################################################### -# backupLabelFormat -# -# Format the label for a backup. -#################################################################################################################################### -sub backupLabelFormat -{ - # Assign function parameters, defaults, and log debug info - my - ( - $strOperation, - $strType, - $strBackupLabelLast, - $lTimestampStart - ) = - logDebugParam - ( - __PACKAGE__ . '::backupLabelFormat', \@_, - {name => 'strType', trace => true}, - {name => 'strBackupLabelLast', required => false, trace => true}, - {name => 'lTimestampTart', trace => true} - ); - - # Full backup label - my $strBackupLabel; - - if ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL) - { - # Last backup label must not be defined - if (defined($strBackupLabelLast)) - { - confess &log(ASSERT, "strBackupLabelLast must not be defined when strType = '${strType}'"); - } - - # Format the timestamp and add the full indicator - $strBackupLabel = timestampFileFormat(undef, $lTimestampStart) . 'F'; - } - # Else diff or incr label - else - { - # Last backup label must be defined - if (!defined($strBackupLabelLast)) - { - confess &log(ASSERT, "strBackupLabelLast must be defined when strType = '${strType}'"); - } - - # Get the full backup portion of the last backup label - $strBackupLabel = substr($strBackupLabelLast, 0, 16); - - # Format the timestamp - $strBackupLabel .= '_' . timestampFileFormat(undef, $lTimestampStart); - - # Add the diff indicator - if ($strType eq CFGOPTVAL_BACKUP_TYPE_DIFF) - { - $strBackupLabel .= 'D'; - } - # Else incr indicator - else - { - $strBackupLabel .= 'I'; - } - } - - # Return from function and log return values if any - return logDebugReturn - ( - $strOperation, - {name => 'strBackupLabel', value => $strBackupLabel, trace => true} - ); -} - -push @EXPORT, qw(backupLabelFormat); - -#################################################################################################################################### -# backupLabel -# -# Get unique backup label. -#################################################################################################################################### -sub backupLabel -{ - # Assign function parameters, defaults, and log debug info - my - ( - $strOperation, - $oStorageRepo, - $strRepoBackupPath, - $strType, - $strBackupLabelLast, - $lTimestampStart - ) = - logDebugParam - ( - __PACKAGE__ . '::backupLabelFormat', \@_, - {name => 'oStorageRepo', trace => true}, - {name => 'strRepoBackupPath', trace => true}, - {name => 'strType', trace => true}, - {name => 'strBackupLabelLast', required => false, trace => true}, - {name => 'lTimestampStart', trace => true} - ); - - # Create backup label - my $strBackupLabel = backupLabelFormat($strType, $strBackupLabelLast, $lTimestampStart); - - # Make sure that the timestamp has not already been used by a prior backup. This is unlikely for online backups since there is - # already a wait after the manifest is built but it's still possible if the remote and local systems don't have synchronized - # clocks. In practice this is most useful for making offline testing faster since it allows the wait after manifest build to - # be skipped by dealing with any backup label collisions here. - if ($oStorageRepo->list( - $strRepoBackupPath, - {strExpression => - ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL ? '^' : '_') . timestampFileFormat(undef, $lTimestampStart) . - ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL ? 'F' : '(D|I)$')}) || - $oStorageRepo->list( - "${strRepoBackupPath}/" . PATH_BACKUP_HISTORY . '/' . timestampFormat('%4d', $lTimestampStart), - {strExpression => - ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL ? '^' : '_') . timestampFileFormat(undef, $lTimestampStart) . - ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL ? 'F' : '(D|I)\.manifest\.gz$'), - bIgnoreMissing => true})) - { - waitRemainder(); - $strBackupLabel = backupLabelFormat($strType, $strBackupLabelLast, time()); - } - - # Return from function and log return values if any - return logDebugReturn - ( - $strOperation, - {name => 'strBackupLabel', value => $strBackupLabel, trace => true} - ); -} - -push @EXPORT, qw(backupLabel); - -1; diff --git a/lib/pgBackRest/Common/String.pm b/lib/pgBackRest/Common/String.pm deleted file mode 100644 index ca8f8f548..000000000 --- a/lib/pgBackRest/Common/String.pm +++ /dev/null @@ -1,224 +0,0 @@ -#################################################################################################################################### -# COMMON STRING MODULE -#################################################################################################################################### -package pgBackRest::Common::String; - -use strict; -use warnings FATAL => qw(all); -use Carp qw(confess longmess); - -use Exporter qw(import); - our @EXPORT = qw(); -use File::Basename qw(dirname); - -#################################################################################################################################### -# trim -# -# Trim whitespace. -#################################################################################################################################### -sub trim -{ - my $strBuffer = shift; - - if (!defined($strBuffer)) - { - return; - } - - $strBuffer =~ s/^\s+|\s+$//g; - - return $strBuffer; -} - -push @EXPORT, qw(trim); - -#################################################################################################################################### -# coalesce - return first defined parameter -#################################################################################################################################### -sub coalesce -{ - foreach my $strParam (@_) - { - if (defined($strParam)) - { - return $strParam; - } - } - - return; -} - -push @EXPORT, qw(coalesce); - -#################################################################################################################################### -# commonPrefix -# -# Determine how much of two strings is the same from the beginning. -#################################################################################################################################### -sub commonPrefix -{ - my $strString1 = shift; - my $strString2 = shift; - - my $iCommonLen = 0; - my $iCompareLen = length($strString1) < length($strString2) ? length($strString1) : length($strString2); - - for (my $iIndex = 0; $iIndex < $iCompareLen; $iIndex++) - { - if (substr($strString1, $iIndex, 1) ne substr($strString2, $iIndex, 1)) - { - last; - } - - $iCommonLen++; - } - - return $iCommonLen; -} - -push @EXPORT, qw(commonPrefix); - -#################################################################################################################################### -# boolFormat -# -# Output boolean as true or false. -#################################################################################################################################### -sub boolFormat -{ - return shift() ? 'true' : 'false'; -} - -push @EXPORT, qw(boolFormat); - -#################################################################################################################################### -# fileSizeFormat -# -# Format file sizes in human-readable form. -#################################################################################################################################### -sub fileSizeFormat -{ - my $lFileSize = shift; - - if ($lFileSize < 1024) - { - return $lFileSize . 'B'; - } - - if ($lFileSize < (1024 * 1024)) - { - return (int($lFileSize / 102.4) / 10) . 'KB'; - } - - if ($lFileSize < (1024 * 1024 * 1024)) - { - return (int($lFileSize / 1024 / 102.4) / 10) . 'MB'; - } - - return (int($lFileSize / 1024 / 1024 / 102.4) / 10) . 'GB'; -} - -push @EXPORT, qw(fileSizeFormat); - -#################################################################################################################################### -# timestampFormat -# -# Get standard timestamp format (or formatted as specified). -#################################################################################################################################### -sub timestampFormat -{ - my $strFormat = shift; - my $lTime = shift; - - if (!defined($strFormat)) - { - $strFormat = '%4d-%02d-%02d %02d:%02d:%02d'; - } - - if (!defined($lTime)) - { - $lTime = time(); - } - - my ($iSecond, $iMinute, $iHour, $iMonthDay, $iMonth, $iYear, $iWeekDay, $iYearDay, $bIsDst) = localtime($lTime); - - if ($strFormat eq "%4d") - { - return sprintf($strFormat, $iYear + 1900) - } - else - { - return sprintf($strFormat, $iYear + 1900, $iMonth + 1, $iMonthDay, $iHour, $iMinute, $iSecond); - } -} - -push @EXPORT, qw(timestampFormat); - -#################################################################################################################################### -# timestampFileFormat -#################################################################################################################################### -sub timestampFileFormat -{ - my $strFormat = shift; - my $lTime = shift; - - return timestampFormat(defined($strFormat) ? $strFormat : '%4d%02d%02d-%02d%02d%02d', $lTime); -} - -push @EXPORT, qw(timestampFileFormat); - -#################################################################################################################################### -# stringSplit -#################################################################################################################################### -sub stringSplit -{ - my $strString = shift; - my $strChar = shift; - my $iLength = shift; - - if (length($strString) <= $iLength) - { - return $strString, undef; - } - - my $iPos = index($strString, $strChar); - - if ($iPos == -1) - { - return $strString, undef; - } - - my $iNewPos = $iPos; - - while ($iNewPos != -1 && $iNewPos + 1 < $iLength) - { - $iPos = $iNewPos; - $iNewPos = index($strString, $strChar, $iPos + 1); - } - - return substr($strString, 0, $iPos + 1), substr($strString, $iPos + 1); -} - -push @EXPORT, qw(stringSplit); - -#################################################################################################################################### -# regexPrefix - return the constant first part of the regex if it has a beginning anchor -# -# This works by scanning the string until the first special regex character is found so escaped characters will not be included. -#################################################################################################################################### -sub regexPrefix -{ - my $strExpression = shift; - my $strPrefix; - - # Only generate prefix if expression is defined and has a beginning anchor - if (defined($strExpression) && $strExpression =~ /^\^/) - { - ($strPrefix) = substr($strExpression, 1) =~ /^[^\.\^\$\*\+\-\?\(\)\[\]\{\}\\\|\ ]+/g; - } - - return $strPrefix; -} - -push @EXPORT, qw(regexPrefix); - -1; diff --git a/lib/pgBackRest/Storage/Helper.pm b/lib/pgBackRest/Storage/Helper.pm deleted file mode 100644 index ae1c192df..000000000 --- a/lib/pgBackRest/Storage/Helper.pm +++ /dev/null @@ -1,109 +0,0 @@ -#################################################################################################################################### -# Repository Storage Helper -#################################################################################################################################### -package pgBackRest::Storage::Helper; - -use strict; -use warnings FATAL => qw(all); -use Carp qw(confess); - -use Exporter qw(import); - our @EXPORT = qw(); -use File::Basename qw(basename); - -use pgBackRest::Common::Log; -use pgBackRest::Storage::Storage; -use pgBackRest::Version; - -#################################################################################################################################### -# Temp file extension -#################################################################################################################################### -use constant STORAGE_TEMP_EXT => PROJECT_EXE . '.tmp'; - push @EXPORT, qw(STORAGE_TEMP_EXT); - -#################################################################################################################################### -# Cache storage so it can be retrieved quickly -#################################################################################################################################### -my $oRepoStorage; - -#################################################################################################################################### -# storageRepoCommandSet -#################################################################################################################################### -my $strStorageRepoCommand; -my $strStorageRepoType; - -sub storageRepoCommandSet -{ - # Assign function parameters, defaults, and log debug info - my - ( - $strOperation, - $strCommand, - $strStorageType, - ) = - logDebugParam - ( - __PACKAGE__ . '::storageRepoCommandSet', \@_, - {name => 'strCommand'}, - {name => 'strStorageType'}, - ); - - $strStorageRepoCommand = $strCommand; - $strStorageRepoType = $strStorageType; - - # Return from function and log return values if any - return logDebugReturn($strOperation); -} - -push @EXPORT, qw(storageRepoCommandSet); - -#################################################################################################################################### -# storageRepo - get repository storage -#################################################################################################################################### -sub storageRepo -{ - # Assign function parameters, defaults, and log debug info - my - ( - $strOperation, - $strStanza, - ) = - logDebugParam - ( - __PACKAGE__ . '::storageRepo', \@_, - {name => 'strStanza', optional => true, trace => true}, - ); - - # Create storage if not defined - if (!defined($oRepoStorage)) - { - $oRepoStorage = new pgBackRest::Storage::Storage($strStorageRepoCommand, $strStorageRepoType, 64 * 1024, 60); - } - - # Return from function and log return values if any - return logDebugReturn - ( - $strOperation, - {name => 'oStorageRepo', value => $oRepoStorage, trace => true}, - ); -} - -push @EXPORT, qw(storageRepo); - -#################################################################################################################################### -# Clear the repo storage cache - FOR TESTING ONLY! -#################################################################################################################################### -sub storageRepoCacheClear -{ - # Assign function parameters, defaults, and log debug info - my ($strOperation) = logDebugParam(__PACKAGE__ . '::storageRepoCacheClear'); - - undef($oRepoStorage); - - # Return from function and log return values if any - return logDebugReturn($strOperation); -} - -push @EXPORT, qw(storageRepoCacheClear); - -1; diff --git a/test/lib/pgBackRestTest/Common/BuildTest.pm b/test/lib/pgBackRestTest/Common/BuildTest.pm index d5ebbd728..46283f8a2 100644 --- a/test/lib/pgBackRestTest/Common/BuildTest.pm +++ b/test/lib/pgBackRestTest/Common/BuildTest.pm @@ -15,8 +15,8 @@ use English '-no_match_vars'; use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; #################################################################################################################################### # VM hash keywords diff --git a/test/lib/pgBackRestTest/Common/CodeCountTest.pm b/test/lib/pgBackRestTest/Common/CodeCountTest.pm index e4959d1ed..49b6c35ee 100644 --- a/test/lib/pgBackRestTest/Common/CodeCountTest.pm +++ b/test/lib/pgBackRestTest/Common/CodeCountTest.pm @@ -14,7 +14,7 @@ use English '-no_match_vars'; use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; +use BackRestDoc::Common::Log; use pgBackRestTest::Common::ExecuteTest; diff --git a/test/lib/pgBackRestTest/Common/ContainerTest.pm b/test/lib/pgBackRestTest/Common/ContainerTest.pm index fd4f6eb3d..b70897771 100755 --- a/test/lib/pgBackRestTest/Common/ContainerTest.pm +++ b/test/lib/pgBackRestTest/Common/ContainerTest.pm @@ -18,10 +18,11 @@ use Exporter qw(import); use File::Basename qw(dirname); use Getopt::Long qw(GetOptions); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::VmTest; diff --git a/test/lib/pgBackRestTest/Common/CoverageTest.pm b/test/lib/pgBackRestTest/Common/CoverageTest.pm index d5d829cad..439746012 100644 --- a/test/lib/pgBackRestTest/Common/CoverageTest.pm +++ b/test/lib/pgBackRestTest/Common/CoverageTest.pm @@ -15,10 +15,10 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(dirname); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use BackRestDoc::Html::DocHtmlBuilder; use BackRestDoc::Html::DocHtmlElement; diff --git a/lib/pgBackRest/DbVersion.pm b/test/lib/pgBackRestTest/Common/DbVersion.pm similarity index 88% rename from lib/pgBackRest/DbVersion.pm rename to test/lib/pgBackRestTest/Common/DbVersion.pm index b765ec193..cff6cb537 100644 --- a/lib/pgBackRest/DbVersion.pm +++ b/test/lib/pgBackRestTest/Common/DbVersion.pm @@ -1,7 +1,7 @@ #################################################################################################################################### # DB VERSION MODULE #################################################################################################################################### -package pgBackRest::DbVersion; +package pgBackRestTest::Common::DbVersion; use strict; use warnings FATAL => qw(all); @@ -10,13 +10,7 @@ use Carp qw(confess); use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; - -#################################################################################################################################### -# Supported page size -#################################################################################################################################### -use constant PG_PAGE_SIZE => 8192; - push @EXPORT, qw(PG_PAGE_SIZE); +use BackRestDoc::Common::Log; #################################################################################################################################### # PostgreSQL version numbers diff --git a/test/lib/pgBackRestTest/Common/DefineTest.pm b/test/lib/pgBackRestTest/Common/DefineTest.pm index f5db56dd4..3a616ab27 100644 --- a/test/lib/pgBackRestTest/Common/DefineTest.pm +++ b/test/lib/pgBackRestTest/Common/DefineTest.pm @@ -13,8 +13,8 @@ use Carp qw(confess); use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRestTest::Common::VmTest; diff --git a/test/lib/pgBackRestTest/Common/ExecuteTest.pm b/test/lib/pgBackRestTest/Common/ExecuteTest.pm index fe00af772..4db083a19 100644 --- a/test/lib/pgBackRestTest/Common/ExecuteTest.pm +++ b/test/lib/pgBackRestTest/Common/ExecuteTest.pm @@ -17,10 +17,11 @@ use IPC::Open3; use POSIX ':sys_wait_h'; use Symbol 'gensym'; -use pgBackRest::Common::Io::Handle; -use pgBackRest::Common::Io::Buffered; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::Io::Handle; +use pgBackRestTest::Common::Io::Buffered; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # new @@ -101,11 +102,11 @@ sub begin $self->{pId} = open3(undef, $self->{hOut}, $self->{hError}, $self->{strCommand}); # Create buffered read object - $self->{oIo} = new pgBackRest::Common::Io::Buffered(new pgBackRest::Common::Io::Handle('exec test', $self->{hOut}), 0, 65536); + $self->{oIo} = new pgBackRestTest::Common::Io::Buffered(new pgBackRestTest::Common::Io::Handle('exec test', $self->{hOut}), 0, 65536); # Create buffered error object - $self->{oIoError} = new pgBackRest::Common::Io::Buffered( - new pgBackRest::Common::Io::Handle('exec test', $self->{hError}), 0, 65536); + $self->{oIoError} = new pgBackRestTest::Common::Io::Buffered( + new pgBackRestTest::Common::Io::Handle('exec test', $self->{hError}), 0, 65536); # Record start time and set process timeout $self->{iProcessTimeout} = 300; diff --git a/test/lib/pgBackRestTest/Common/FileTest.pm b/test/lib/pgBackRestTest/Common/FileTest.pm index c621d4950..59d09ba29 100644 --- a/test/lib/pgBackRestTest/Common/FileTest.pm +++ b/test/lib/pgBackRestTest/Common/FileTest.pm @@ -21,23 +21,23 @@ use IPC::Open3; use POSIX ':sys_wait_h'; use Symbol 'gensym'; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRest::Common::Wait; -use pgBackRest::Manifest; -use pgBackRest::Storage::Base; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::HostGroupTest; use pgBackRestTest::Common::LogTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageBase; use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Wait; use pgBackRestTest::Env::Host::HostBaseTest; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::Host::HostDbCommonTest; use pgBackRestTest::Env::Host::HostDbTest; use pgBackRestTest::Env::Host::HostS3Test; +use pgBackRestTest::Env::Manifest; #################################################################################################################################### # testLinkCreate diff --git a/test/lib/pgBackRestTest/Common/HostGroupTest.pm b/test/lib/pgBackRestTest/Common/HostGroupTest.pm index 9243be45a..b9b8a6f16 100644 --- a/test/lib/pgBackRestTest/Common/HostGroupTest.pm +++ b/test/lib/pgBackRestTest/Common/HostGroupTest.pm @@ -14,8 +14,8 @@ use Cwd qw(abs_path); use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRestTest::Common::ExecuteTest; diff --git a/test/lib/pgBackRestTest/Common/HostTest.pm b/test/lib/pgBackRestTest/Common/HostTest.pm index 9a1e23e1e..ccd8493d3 100644 --- a/test/lib/pgBackRestTest/Common/HostTest.pm +++ b/test/lib/pgBackRestTest/Common/HostTest.pm @@ -14,8 +14,8 @@ use Cwd qw(abs_path); use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRestTest::Common::ExecuteTest; diff --git a/lib/pgBackRest/Common/Io/Base.pm b/test/lib/pgBackRestTest/Common/Io/Base.pm similarity index 98% rename from lib/pgBackRest/Common/Io/Base.pm rename to test/lib/pgBackRestTest/Common/Io/Base.pm index b5f6475f2..590429272 100644 --- a/lib/pgBackRest/Common/Io/Base.pm +++ b/test/lib/pgBackRestTest/Common/Io/Base.pm @@ -1,7 +1,7 @@ #################################################################################################################################### # Base IO Module #################################################################################################################################### -package pgBackRest::Common::Io::Base; +package pgBackRestTest::Common::Io::Base; use strict; use warnings FATAL => qw(all); @@ -12,7 +12,7 @@ use Exporter qw(import); our @EXPORT = qw(); use Scalar::Util qw(blessed); -use pgBackRest::Common::Log; +use BackRestDoc::Common::Log; #################################################################################################################################### # Package name constant diff --git a/lib/pgBackRest/Common/Io/Buffered.pm b/test/lib/pgBackRestTest/Common/Io/Buffered.pm similarity index 97% rename from lib/pgBackRest/Common/Io/Buffered.pm rename to test/lib/pgBackRestTest/Common/Io/Buffered.pm index 29441e4f6..68415c5fb 100644 --- a/lib/pgBackRest/Common/Io/Buffered.pm +++ b/test/lib/pgBackRestTest/Common/Io/Buffered.pm @@ -1,8 +1,8 @@ #################################################################################################################################### # Buffered Handle IO #################################################################################################################################### -package pgBackRest::Common::Io::Buffered; -use parent 'pgBackRest::Common::Io::Filter'; +package pgBackRestTest::Common::Io::Buffered; +use parent 'pgBackRestTest::Common::Io::Filter'; use strict; use warnings FATAL => qw(all); @@ -14,11 +14,12 @@ use Exporter qw(import); use IO::Select; use Time::HiRes qw(gettimeofday); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Io::Base; -use pgBackRest::Common::Io::Handle; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::Io::Base; +use pgBackRestTest::Common::Io::Handle; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # Package name constant diff --git a/lib/pgBackRest/Common/Io/Filter.pm b/test/lib/pgBackRestTest/Common/Io/Filter.pm similarity index 97% rename from lib/pgBackRest/Common/Io/Filter.pm rename to test/lib/pgBackRestTest/Common/Io/Filter.pm index 57c0596e7..d0b099e03 100644 --- a/lib/pgBackRest/Common/Io/Filter.pm +++ b/test/lib/pgBackRestTest/Common/Io/Filter.pm @@ -1,7 +1,7 @@ #################################################################################################################################### # Base Filter Module #################################################################################################################################### -package pgBackRest::Common::Io::Filter; +package pgBackRestTest::Common::Io::Filter; use strict; use warnings FATAL => qw(all); @@ -12,7 +12,7 @@ use Exporter qw(import); our @EXPORT = qw(); use Scalar::Util qw(blessed); -use pgBackRest::Common::Log; +use BackRestDoc::Common::Log; #################################################################################################################################### # new diff --git a/lib/pgBackRest/Common/Io/Handle.pm b/test/lib/pgBackRestTest/Common/Io/Handle.pm similarity index 97% rename from lib/pgBackRest/Common/Io/Handle.pm rename to test/lib/pgBackRestTest/Common/Io/Handle.pm index 8f70fee24..7e20c5845 100644 --- a/lib/pgBackRest/Common/Io/Handle.pm +++ b/test/lib/pgBackRestTest/Common/Io/Handle.pm @@ -1,8 +1,8 @@ #################################################################################################################################### # Basic Handle IO #################################################################################################################################### -package pgBackRest::Common::Io::Handle; -use parent 'pgBackRest::Common::Io::Base'; +package pgBackRestTest::Common::Io::Handle; +use parent 'pgBackRestTest::Common::Io::Base'; use strict; use warnings FATAL => qw(all); @@ -12,8 +12,8 @@ use English '-no_match_vars'; use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; #################################################################################################################################### # Package name constant diff --git a/lib/pgBackRest/Common/Io/Process.pm b/test/lib/pgBackRestTest/Common/Io/Process.pm similarity index 93% rename from lib/pgBackRest/Common/Io/Process.pm rename to test/lib/pgBackRestTest/Common/Io/Process.pm index 528fdb6cb..4ee5d767c 100644 --- a/lib/pgBackRest/Common/Io/Process.pm +++ b/test/lib/pgBackRestTest/Common/Io/Process.pm @@ -1,8 +1,8 @@ #################################################################################################################################### # Process Execution, Management, and IO #################################################################################################################################### -package pgBackRest::Common::Io::Process; -use parent 'pgBackRest::Common::Io::Filter'; +package pgBackRestTest::Common::Io::Process; +use parent 'pgBackRestTest::Common::Io::Filter'; use strict; use warnings FATAL => qw(all); @@ -15,10 +15,11 @@ use IPC::Open3 qw(open3); use POSIX qw(:sys_wait_h); use Symbol 'gensym'; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Io::Buffered; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::Io::Buffered; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # Amount of time to attempt to retrieve errors when a process terminates unexpectedly @@ -100,8 +101,8 @@ sub error # Drain the stderr stream my $strError; - my $oIoError = new pgBackRest::Common::Io::Buffered( - new pgBackRest::Common::Io::Handle($self->id(), $self->{fhReadError}), 5, $self->bufferMax()); + my $oIoError = new pgBackRestTest::Common::Io::Buffered( + new pgBackRestTest::Common::Io::Handle($self->id(), $self->{fhReadError}), 5, $self->bufferMax()); while (defined(my $strLine = $oIoError->readLine(true, false))) { diff --git a/test/lib/pgBackRestTest/Common/JobTest.pm b/test/lib/pgBackRestTest/Common/JobTest.pm index 6b7b6c698..81da346b3 100644 --- a/test/lib/pgBackRestTest/Common/JobTest.pm +++ b/test/lib/pgBackRestTest/Common/JobTest.pm @@ -18,15 +18,16 @@ use File::Basename qw(dirname basename); use POSIX qw(ceil); use Time::HiRes qw(gettimeofday); -use pgBackRest::DbVersion; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + use pgBackRestTest::Common::BuildTest; use pgBackRestTest::Common::ContainerTest; use pgBackRestTest::Common::CoverageTest; +use pgBackRestTest::Common::DbVersion; use pgBackRestTest::Common::DefineTest; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::ListTest; diff --git a/test/lib/pgBackRestTest/Common/ListTest.pm b/test/lib/pgBackRestTest/Common/ListTest.pm index 13c1c56ae..e4d93ebf6 100644 --- a/test/lib/pgBackRestTest/Common/ListTest.pm +++ b/test/lib/pgBackRestTest/Common/ListTest.pm @@ -13,8 +13,8 @@ use Carp qw(confess); use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Log; -use pgBackRest::Common::String; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; use pgBackRestTest::Common::DefineTest; use pgBackRestTest::Common::VmTest; diff --git a/test/lib/pgBackRestTest/Common/LogTest.pm b/test/lib/pgBackRestTest/Common/LogTest.pm index 19ea2bc49..a5698277f 100644 --- a/test/lib/pgBackRestTest/Common/LogTest.pm +++ b/test/lib/pgBackRestTest/Common/LogTest.pm @@ -15,9 +15,10 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(dirname); -use pgBackRest::Common::Log; use pgBackRest::Version; +use BackRestDoc::Common::Log; + use pgBackRestTest::Common::ContainerTest; use pgBackRestTest::Common::ExecuteTest; diff --git a/test/lib/pgBackRestTest/Common/RunTest.pm b/test/lib/pgBackRestTest/Common/RunTest.pm index 3cc09ca5a..b90889945 100644 --- a/test/lib/pgBackRestTest/Common/RunTest.pm +++ b/test/lib/pgBackRestTest/Common/RunTest.pm @@ -15,12 +15,12 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(dirname); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRest::Common::Wait; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + use pgBackRestTest::Common::BuildTest; use pgBackRestTest::Common::DefineTest; use pgBackRestTest::Common::ExecuteTest; @@ -28,6 +28,7 @@ use pgBackRestTest::Common::LogTest; use pgBackRestTest::Common::Storage; use pgBackRestTest::Common::StoragePosix; use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # Constant to use when bogus data is required diff --git a/test/lib/pgBackRestTest/Common/Storage.pm b/test/lib/pgBackRestTest/Common/Storage.pm index c95aee6f0..01b5b619c 100644 --- a/test/lib/pgBackRestTest/Common/Storage.pm +++ b/test/lib/pgBackRestTest/Common/Storage.pm @@ -2,7 +2,7 @@ # Implements storage functionality using drivers. #################################################################################################################################### package pgBackRestTest::Common::Storage; -use parent 'pgBackRest::Storage::Base'; +use parent 'pgBackRestTest::Common::StorageBase'; use strict; use warnings FATAL => qw(all); @@ -11,10 +11,11 @@ use English '-no_match_vars'; use File::Basename qw(dirname); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRest::Storage::Base; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + +use pgBackRestTest::Common::StorageBase; #################################################################################################################################### # new diff --git a/lib/pgBackRest/Storage/Base.pm b/test/lib/pgBackRestTest/Common/StorageBase.pm similarity index 97% rename from lib/pgBackRest/Storage/Base.pm rename to test/lib/pgBackRestTest/Common/StorageBase.pm index 0da8f61cd..daef8a69c 100644 --- a/lib/pgBackRest/Storage/Base.pm +++ b/test/lib/pgBackRestTest/Common/StorageBase.pm @@ -1,7 +1,7 @@ #################################################################################################################################### # Base Storage Module #################################################################################################################################### -package pgBackRest::Storage::Base; +package pgBackRestTest::Common::StorageBase; use strict; use warnings FATAL => qw(all); @@ -13,9 +13,10 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(dirname); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Io::Base; -use pgBackRest::Common::Log; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::Io::Base; #################################################################################################################################### # Storage constants diff --git a/test/lib/pgBackRestTest/Common/StoragePosix.pm b/test/lib/pgBackRestTest/Common/StoragePosix.pm index 913c619f7..d02d0449b 100644 --- a/test/lib/pgBackRestTest/Common/StoragePosix.pm +++ b/test/lib/pgBackRestTest/Common/StoragePosix.pm @@ -16,9 +16,10 @@ use File::Basename qw(basename dirname); use Fcntl qw(:mode); use File::stat qw{lstat}; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Storage::Base; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::StorageBase; use pgBackRestTest::Common::StoragePosixRead; use pgBackRestTest::Common::StoragePosixWrite; diff --git a/test/lib/pgBackRestTest/Common/StoragePosixRead.pm b/test/lib/pgBackRestTest/Common/StoragePosixRead.pm index 208b9e7bf..6e3886308 100644 --- a/test/lib/pgBackRestTest/Common/StoragePosixRead.pm +++ b/test/lib/pgBackRestTest/Common/StoragePosixRead.pm @@ -2,7 +2,7 @@ # Posix File Read #################################################################################################################################### package pgBackRestTest::Common::StoragePosixRead; -use parent 'pgBackRest::Common::Io::Handle'; +use parent 'pgBackRestTest::Common::Io::Handle'; use strict; use warnings FATAL => qw(all); @@ -11,8 +11,8 @@ use English '-no_match_vars'; use Fcntl qw(O_RDONLY); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; #################################################################################################################################### # CONSTRUCTOR diff --git a/test/lib/pgBackRestTest/Common/StoragePosixWrite.pm b/test/lib/pgBackRestTest/Common/StoragePosixWrite.pm index 8b3fbbf30..616abe9d6 100644 --- a/test/lib/pgBackRestTest/Common/StoragePosixWrite.pm +++ b/test/lib/pgBackRestTest/Common/StoragePosixWrite.pm @@ -2,7 +2,7 @@ # Posix File Write #################################################################################################################################### package pgBackRestTest::Common::StoragePosixWrite; -use parent 'pgBackRest::Common::Io::Handle'; +use parent 'pgBackRestTest::Common::Io::Handle'; use strict; use warnings FATAL => qw(all); @@ -12,11 +12,11 @@ use English '-no_match_vars'; use Fcntl qw(O_RDONLY O_WRONLY O_CREAT O_TRUNC); use File::Basename qw(dirname); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; -use pgBackRest::Common::Io::Handle; -use pgBackRest::Storage::Base; +use pgBackRestTest::Common::Io::Handle; +use pgBackRestTest::Common::StorageBase; #################################################################################################################################### # CONSTRUCTOR diff --git a/lib/pgBackRest/Storage/Storage.pm b/test/lib/pgBackRestTest/Common/StorageRepo.pm similarity index 81% rename from lib/pgBackRest/Storage/Storage.pm rename to test/lib/pgBackRestTest/Common/StorageRepo.pm index 91de58a7d..ce04dffbb 100644 --- a/lib/pgBackRest/Storage/Storage.pm +++ b/test/lib/pgBackRestTest/Common/StorageRepo.pm @@ -1,8 +1,8 @@ #################################################################################################################################### # C Storage Interface #################################################################################################################################### -package pgBackRest::Storage::Storage; -use parent 'pgBackRest::Storage::Base'; +package pgBackRestTest::Common::StorageRepo; +use parent 'pgBackRestTest::Common::StorageBase'; use strict; use warnings FATAL => qw(all); @@ -10,16 +10,27 @@ use Carp qw(confess); use English '-no_match_vars'; use Digest::SHA qw(sha1_hex); +use Exporter qw(import); + our @EXPORT = qw(); use File::Basename qw(dirname); use Fcntl qw(:mode); use File::stat qw{lstat}; use JSON::PP; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Io::Handle; -use pgBackRest::Common::Io::Process; -use pgBackRest::Common::Log; -use pgBackRest::Storage::Base; +use pgBackRest::Version; + +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::Io::Handle; +use pgBackRestTest::Common::Io::Process; +use pgBackRestTest::Common::StorageBase; + +#################################################################################################################################### +# Temp file extension +#################################################################################################################################### +use constant STORAGE_TEMP_EXT => PROJECT_EXE . '.tmp'; + push @EXPORT, qw(STORAGE_TEMP_EXT); #################################################################################################################################### # new @@ -123,9 +134,9 @@ sub exec ); $strCommand = "$self->{strCommand} ${strCommand}"; - my $oBuffer = new pgBackRest::Common::Io::Buffered( - new pgBackRest::Common::Io::Handle($strCommand), $self->{iTimeoutIo}, $self->{lBufferMax}); - my $oProcess = new pgBackRest::Common::Io::Process($oBuffer, $strCommand); + my $oBuffer = new pgBackRestTest::Common::Io::Buffered( + new pgBackRestTest::Common::Io::Handle($strCommand), $self->{iTimeoutIo}, $self->{lBufferMax}); + my $oProcess = new pgBackRestTest::Common::Io::Process($oBuffer, $strCommand); my $tResult; @@ -479,9 +490,9 @@ sub put "$self->{strCommand}" . (defined($strCipherPass) ? ' --cipher-pass=' . $self->escape($strCipherPass) : '') . ($bRaw ? ' --raw' : '') . ' repo-put ' . $self->escape($strFile); - my $oBuffer = new pgBackRest::Common::Io::Buffered( - new pgBackRest::Common::Io::Handle($strCommand), $self->{iTimeoutIo}, $self->{lBufferMax}); - my $oProcess = new pgBackRest::Common::Io::Process($oBuffer, $strCommand); + my $oBuffer = new pgBackRestTest::Common::Io::Buffered( + new pgBackRestTest::Common::Io::Handle($strCommand), $self->{iTimeoutIo}, $self->{lBufferMax}); + my $oProcess = new pgBackRestTest::Common::Io::Process($oBuffer, $strCommand); if (defined($tContent)) { @@ -529,6 +540,75 @@ sub remove return logDebugReturn($strOperation); } +#################################################################################################################################### +# Cache storage so it can be retrieved quickly +#################################################################################################################################### +my $oRepoStorage; + +#################################################################################################################################### +# storageRepoCommandSet +#################################################################################################################################### +my $strStorageRepoCommand; +my $strStorageRepoType; + +sub storageRepoCommandSet +{ + # Assign function parameters, defaults, and log debug info + my + ( + $strOperation, + $strCommand, + $strStorageType, + ) = + logDebugParam + ( + __PACKAGE__ . '::storageRepoCommandSet', \@_, + {name => 'strCommand'}, + {name => 'strStorageType'}, + ); + + $strStorageRepoCommand = $strCommand; + $strStorageRepoType = $strStorageType; + + # Return from function and log return values if any + return logDebugReturn($strOperation); +} + +push @EXPORT, qw(storageRepoCommandSet); + +#################################################################################################################################### +# storageRepo - get repository storage +#################################################################################################################################### +sub storageRepo +{ + # Assign function parameters, defaults, and log debug info + my + ( + $strOperation, + $strStanza, + ) = + logDebugParam + ( + __PACKAGE__ . '::storageRepo', \@_, + {name => 'strStanza', optional => true, trace => true}, + ); + + # Create storage if not defined + if (!defined($oRepoStorage)) + { + $oRepoStorage = new pgBackRestTest::Common::StorageRepo($strStorageRepoCommand, $strStorageRepoType, 64 * 1024, 60); + } + + # Return from function and log return values if any + return logDebugReturn + ( + $strOperation, + {name => 'oStorageRepo', value => $oRepoStorage, trace => true}, + ); +} + +push @EXPORT, qw(storageRepo); + #################################################################################################################################### # Getters #################################################################################################################################### diff --git a/test/lib/pgBackRestTest/Common/VmTest.pm b/test/lib/pgBackRestTest/Common/VmTest.pm index 84b29ca0c..2db0a743d 100644 --- a/test/lib/pgBackRestTest/Common/VmTest.pm +++ b/test/lib/pgBackRestTest/Common/VmTest.pm @@ -13,9 +13,10 @@ use Carp qw(confess); use Exporter qw(import); our @EXPORT = qw(); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::DbVersion; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::DbVersion; #################################################################################################################################### # VM hash keywords diff --git a/lib/pgBackRest/Common/Wait.pm b/test/lib/pgBackRestTest/Common/Wait.pm similarity index 98% rename from lib/pgBackRest/Common/Wait.pm rename to test/lib/pgBackRestTest/Common/Wait.pm index 246695333..b3898ebb9 100644 --- a/lib/pgBackRest/Common/Wait.pm +++ b/test/lib/pgBackRestTest/Common/Wait.pm @@ -1,7 +1,7 @@ #################################################################################################################################### # COMMON WAIT MODULE #################################################################################################################################### -package pgBackRest::Common::Wait; +package pgBackRestTest::Common::Wait; use strict; use warnings FATAL => qw(all); @@ -13,7 +13,7 @@ use File::Basename qw(dirname); use POSIX qw(ceil); use Time::HiRes qw(gettimeofday usleep); -use pgBackRest::Common::Log; +use BackRestDoc::Common::Log; #################################################################################################################################### # Wait constants diff --git a/lib/pgBackRest/Archive/Info.pm b/test/lib/pgBackRestTest/Env/ArchiveInfo.pm similarity index 92% rename from lib/pgBackRest/Archive/Info.pm rename to test/lib/pgBackRestTest/Env/ArchiveInfo.pm index c73e4a6e6..a1117ba68 100644 --- a/lib/pgBackRest/Archive/Info.pm +++ b/test/lib/pgBackRestTest/Env/ArchiveInfo.pm @@ -5,8 +5,8 @@ # regarding the stanza database version, database WAL segment system id and other information to ensure that archiving is being # performed on the proper database. #################################################################################################################################### -package pgBackRest::Archive::Info; -use parent 'pgBackRest::Common::Ini'; +package pgBackRestTest::Env::ArchiveInfo; +use parent 'BackRestDoc::Common::Ini'; use strict; use warnings FATAL => qw(all); @@ -17,15 +17,15 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(dirname basename); -use pgBackRest::Archive::Common; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::DbVersion; -use pgBackRest::InfoCommon; -use pgBackRest::Manifest; -use pgBackRest::Storage::Base; -use pgBackRest::Storage::Helper; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::DbVersion; +use pgBackRestTest::Common::StorageBase; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Env::InfoCommon; +use pgBackRestTest::Env::Manifest; #################################################################################################################################### # File/path constants @@ -33,6 +33,20 @@ use pgBackRest::Storage::Helper; use constant ARCHIVE_INFO_FILE => 'archive.info'; push @EXPORT, qw(ARCHIVE_INFO_FILE); +#################################################################################################################################### +# RegEx constants +#################################################################################################################################### +use constant REGEX_ARCHIVE_DIR_DB_VERSION => '^[0-9]+(\.[0-9]+)*-[0-9]+$'; + push @EXPORT, qw(REGEX_ARCHIVE_DIR_DB_VERSION); +use constant REGEX_ARCHIVE_DIR_WAL => '^[0-F]{16}$'; + push @EXPORT, qw(REGEX_ARCHIVE_DIR_WAL); + +#################################################################################################################################### +# WAL segment size +#################################################################################################################################### +use constant PG_WAL_SEGMENT_SIZE => 16777216; + push @EXPORT, qw(PG_WAL_SEGMENT_SIZE); + #################################################################################################################################### # Archive info constants #################################################################################################################################### diff --git a/lib/pgBackRest/Backup/Info.pm b/test/lib/pgBackRestTest/Env/BackupInfo.pm similarity index 96% rename from lib/pgBackRest/Backup/Info.pm rename to test/lib/pgBackRestTest/Env/BackupInfo.pm index 80bf83ae3..7b8e105fa 100644 --- a/lib/pgBackRest/Backup/Info.pm +++ b/test/lib/pgBackRestTest/Env/BackupInfo.pm @@ -1,8 +1,8 @@ #################################################################################################################################### # BACKUP INFO MODULE #################################################################################################################################### -package pgBackRest::Backup::Info; -use parent 'pgBackRest::Common::Ini'; +package pgBackRestTest::Env::BackupInfo; +use parent 'BackRestDoc::Common::Ini'; use strict; use warnings FATAL => qw(all); @@ -14,14 +14,24 @@ use Exporter qw(import); use File::Basename qw(dirname basename); use File::stat; -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Common; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::InfoCommon; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::InfoCommon; +use pgBackRestTest::Env::Manifest; + +#################################################################################################################################### +# Backup type constants +#################################################################################################################################### +use constant CFGOPTVAL_BACKUP_TYPE_FULL => 'full'; + push @EXPORT, qw(CFGOPTVAL_BACKUP_TYPE_FULL); +use constant CFGOPTVAL_BACKUP_TYPE_DIFF => 'diff'; + push @EXPORT, qw(CFGOPTVAL_BACKUP_TYPE_DIFF); +use constant CFGOPTVAL_BACKUP_TYPE_INCR => 'incr'; + push @EXPORT, qw(CFGOPTVAL_BACKUP_TYPE_INCR); #################################################################################################################################### # File/path constants @@ -479,7 +489,7 @@ sub backupArchiveDbHistoryId my @stryArchiveBackup; # Build the db list from the history in the backup info and archive info file - my $oArchiveInfo = new pgBackRest::Archive::Info($strPathBackupArchive, true); + my $oArchiveInfo = new pgBackRestTest::Env::ArchiveInfo($strPathBackupArchive, true); my $hDbListArchive = $oArchiveInfo->dbHistoryList(); my $hDbListBackup = $self->dbHistoryList(); my $iDbHistoryId = undef; diff --git a/test/lib/pgBackRestTest/Env/ExpireEnvTest.pm b/test/lib/pgBackRestTest/Env/ExpireEnvTest.pm index 9d4312dd2..52bc0c034 100644 --- a/test/lib/pgBackRestTest/Env/ExpireEnvTest.pm +++ b/test/lib/pgBackRestTest/Env/ExpireEnvTest.pm @@ -14,22 +14,23 @@ use Carp qw(confess); use Fcntl qw(O_RDONLY); use File::Basename qw(basename); -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Common; -use pgBackRest::Backup::Info; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::DbVersion; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; use pgBackRest::Version; -use pgBackRestTest::Env::HostEnvTest; -use pgBackRestTest::Env::Host::HostBaseTest; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::DbVersion; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::FileTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::BackupInfo; +use pgBackRestTest::Env::HostEnvTest; +use pgBackRestTest::Env::Host::HostBackupTest; +use pgBackRestTest::Env::Host::HostBaseTest; +use pgBackRestTest::Env::Manifest; #################################################################################################################################### # new @@ -216,20 +217,20 @@ sub stanzaSet if (!$bStanzaUpgrade) { $oArchiveInfo = - new pgBackRest::Archive::Info($self->{oHostBackup}->repoArchivePath(), false, + new pgBackRestTest::Env::ArchiveInfo($self->{oHostBackup}->repoArchivePath(), false, {bIgnoreMissing => true, strCipherPassSub => $self->{oHostBackup}->repoEncrypt() ? ENCRYPTION_KEY_ARCHIVE : undef}); $oBackupInfo = - new pgBackRest::Backup::Info($self->{oHostBackup}->repoBackupPath(), false, + new pgBackRestTest::Env::BackupInfo($self->{oHostBackup}->repoBackupPath(), false, {bIgnoreMissing => true, strCipherPassSub => $self->{oHostBackup}->repoEncrypt() ? ENCRYPTION_KEY_MANIFEST : undef}); } # Else get the info data from disk else { $oArchiveInfo = - new pgBackRest::Archive::Info($self->{oHostBackup}->repoArchivePath(), + new pgBackRestTest::Env::ArchiveInfo($self->{oHostBackup}->repoArchivePath(), {strCipherPassSub => $self->{oHostBackup}->repoEncrypt() ? ENCRYPTION_KEY_ARCHIVE : undef}); $oBackupInfo = - new pgBackRest::Backup::Info($self->{oHostBackup}->repoBackupPath(), + new pgBackRestTest::Env::BackupInfo($self->{oHostBackup}->repoBackupPath(), {strCipherPassSub => $self->{oHostBackup}->repoEncrypt() ? ENCRYPTION_KEY_MANIFEST : undef}); } @@ -384,7 +385,7 @@ sub backupCreate # Get passphrase (returns undefined if repo not encrypted) to access the manifest my $strCipherPassManifest = - (new pgBackRest::Backup::Info($self->{oHostBackup}->repoBackupPath()))->cipherPassSub(); + (new pgBackRestTest::Env::BackupInfo($self->{oHostBackup}->repoBackupPath()))->cipherPassSub(); my $strCipherPassBackupSet; # If repo is encrypted then get passphrase for accessing the backup files from the last manifest if it exists provide one @@ -396,7 +397,7 @@ sub backupCreate my $strManifestFile = "$$oStanza{strBackupClusterPath}/${strBackupLabel}/" . FILE_MANIFEST; - my $oManifest = new pgBackRest::Manifest($strManifestFile, {bLoad => false, strDbVersion => PG_VERSION_93, + my $oManifest = new pgBackRestTest::Env::Manifest($strManifestFile, {bLoad => false, strDbVersion => PG_VERSION_93, iDbCatalogVersion => $self->dbCatalogVersion(PG_VERSION_93), strCipherPass => $strCipherPassManifest, strCipherPassSub => $strCipherPassBackupSet}); @@ -433,7 +434,7 @@ sub backupCreate $$oStanza{oManifest} = $oManifest; # Add the backup to info - my $oBackupInfo = new pgBackRest::Backup::Info($$oStanza{strBackupClusterPath}, false); + my $oBackupInfo = new pgBackRestTest::Env::BackupInfo($$oStanza{strBackupClusterPath}, false); $oBackupInfo->check($$oStanza{strDbVersion}, $$oStanza{iControlVersion}, $$oStanza{iCatalogVersion}, $$oStanza{ullDbSysId}); $oBackupInfo->add($oManifest); @@ -531,7 +532,7 @@ sub archiveCreate # Get passphrase (returns undefined if repo not encrypted) to access the archive files my $strCipherPass = - (new pgBackRest::Archive::Info($self->{oHostBackup}->repoArchivePath()))->cipherPassSub(); + (new pgBackRestTest::Env::ArchiveInfo($self->{oHostBackup}->repoArchivePath()))->cipherPassSub(); push(my @stryArchive, $strArchive); diff --git a/test/lib/pgBackRestTest/Env/Host/HostBackupTest.pm b/test/lib/pgBackRestTest/Env/Host/HostBackupTest.pm index b03b18f46..f7319a1f1 100644 --- a/test/lib/pgBackRestTest/Env/Host/HostBackupTest.pm +++ b/test/lib/pgBackRestTest/Env/Host/HostBackupTest.pm @@ -18,25 +18,32 @@ use File::Basename qw(dirname); use File::stat qw{lstat}; use Storable qw(dclone); -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Common; -use pgBackRest::Backup::Info; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::DbVersion; -use pgBackRest::Manifest; -use pgBackRest::Storage::Base; -use pgBackRest::Storage::Helper; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + +use pgBackRestTest::Common::DbVersion; +use pgBackRestTest::Common::StorageBase; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::BackupInfo; use pgBackRestTest::Env::Host::HostBaseTest; use pgBackRestTest::Env::Host::HostS3Test; +use pgBackRestTest::Env::Manifest; use pgBackRestTest::Common::ContainerTest; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::HostGroupTest; use pgBackRestTest::Common::RunTest; +#################################################################################################################################### +# Latest backup link constant +#################################################################################################################################### +use constant LINK_LATEST => 'latest'; + push @EXPORT, qw(LINK_LATEST); + #################################################################################################################################### # Host defaults #################################################################################################################################### @@ -183,6 +190,93 @@ sub new ); } +#################################################################################################################################### +# timestampFileFormat +#################################################################################################################################### +sub timestampFileFormat +{ + my $strFormat = shift; + my $lTime = shift; + + return timestampFormat(defined($strFormat) ? $strFormat : '%4d%02d%02d-%02d%02d%02d', $lTime); +} + +push @EXPORT, qw(timestampFileFormat); + +#################################################################################################################################### +# backupLabelFormat +# +# Format the label for a backup. +#################################################################################################################################### +sub backupLabelFormat +{ + # Assign function parameters, defaults, and log debug info + my + ( + $strOperation, + $strType, + $strBackupLabelLast, + $lTimestampStart + ) = + logDebugParam + ( + __PACKAGE__ . '::backupLabelFormat', \@_, + {name => 'strType', trace => true}, + {name => 'strBackupLabelLast', required => false, trace => true}, + {name => 'lTimestampTart', trace => true} + ); + + # Full backup label + my $strBackupLabel; + + if ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL) + { + # Last backup label must not be defined + if (defined($strBackupLabelLast)) + { + confess &log(ASSERT, "strBackupLabelLast must not be defined when strType = '${strType}'"); + } + + # Format the timestamp and add the full indicator + $strBackupLabel = timestampFileFormat(undef, $lTimestampStart) . 'F'; + } + # Else diff or incr label + else + { + # Last backup label must be defined + if (!defined($strBackupLabelLast)) + { + confess &log(ASSERT, "strBackupLabelLast must be defined when strType = '${strType}'"); + } + + # Get the full backup portion of the last backup label + $strBackupLabel = substr($strBackupLabelLast, 0, 16); + + # Format the timestamp + $strBackupLabel .= '_' . timestampFileFormat(undef, $lTimestampStart); + + # Add the diff indicator + if ($strType eq CFGOPTVAL_BACKUP_TYPE_DIFF) + { + $strBackupLabel .= 'D'; + } + # Else incr indicator + else + { + $strBackupLabel .= 'I'; + } + } + + # Return from function and log return values if any + return logDebugReturn + ( + $strOperation, + {name => 'strBackupLabel', value => $strBackupLabel, trace => true} + ); +} + +push @EXPORT, qw(backupLabelFormat); + #################################################################################################################################### # backupBegin #################################################################################################################################### @@ -485,7 +579,7 @@ sub backupCompare ${$oExpectedManifest}{&MANIFEST_SECTION_BACKUP}{&MANIFEST_KEY_LABEL} = $strBackup; - my $oActualManifest = new pgBackRest::Manifest( + my $oActualManifest = new pgBackRestTest::Env::Manifest( $self->repoBackupPath("${strBackup}/" . FILE_MANIFEST), {strCipherPass => $self->cipherPassManifest()}); ${$oExpectedManifest}{&MANIFEST_SECTION_BACKUP}{&MANIFEST_KEY_TIMESTAMP_START} = @@ -823,7 +917,7 @@ sub stanzaCreate } # Get the passphrase for accessing the manifest file - $self->{strCipherPassManifest} = (new pgBackRest::Backup::Info($self->repoBackupPath()))->cipherPassSub(); + $self->{strCipherPassManifest} = (new pgBackRestTest::Env::BackupInfo($self->repoBackupPath()))->cipherPassSub(); } if (storageRepo()->exists('archive/' . $self->stanza() . qw{/} . ARCHIVE_INFO_FILE)) @@ -837,7 +931,7 @@ sub stanzaCreate # Get the passphrase for accessing the archived files $self->{strCipherPassArchive} = - (new pgBackRest::Archive::Info($self->repoArchivePath()))->cipherPassSub(); + (new pgBackRestTest::Env::ArchiveInfo($self->repoArchivePath()))->cipherPassSub(); } # Return from function and log return values if any @@ -1332,13 +1426,13 @@ sub infoMunge # If the original file content does not exist then load it if (!defined($self->{hInfoFile}{$strFileName})) { - $self->{hInfoFile}{$strFileName} = new pgBackRest::Common::Ini( + $self->{hInfoFile}{$strFileName} = new BackRestDoc::Common::Ini( storageRepo(), $strFileName, {strCipherPass => !$bManifest ? undef : $self->cipherPassManifest()}); } # Make a copy of the original file contents - my $oMungeIni = new pgBackRest::Common::Ini( + my $oMungeIni = new BackRestDoc::Common::Ini( storageRepo(), $strFileName, {bLoad => false, strContent => iniRender($self->{hInfoFile}{$strFileName}->{oContent}), strCipherPass => !$bManifest ? undef : $self->cipherPassManifest()}); @@ -1632,7 +1726,7 @@ sub restore if (!defined($rhExpectedManifest)) { # Load the manifest from the backup expected to be chosen/processed by restore - my $oExpectedManifest = new pgBackRest::Manifest( + my $oExpectedManifest = new pgBackRestTest::Env::Manifest( $self->repoBackupPath($strBackupExpected . qw{/} . FILE_MANIFEST), {strCipherPass => $oHostBackup->cipherPassManifest()}); @@ -1742,7 +1836,7 @@ sub restoreCompare if (defined(${$oExpectedManifestRef}{&MANIFEST_SECTION_BACKUP}{&MANIFEST_KEY_PRIOR})) { my $oExpectedManifest = - new pgBackRest::Manifest( + new pgBackRestTest::Env::Manifest( $self->repoBackupPath( ($strBackup eq 'latest' ? $oHostBackup->backupLast() : $strBackup) . '/' . FILE_MANIFEST), {strCipherPass => $oHostBackup->cipherPassManifest()}); @@ -1752,7 +1846,7 @@ sub restoreCompare $oExpectedManifest->get(MANIFEST_SECTION_BACKUP_OPTION, &MANIFEST_KEY_DELTA); $oLastManifest = - new pgBackRest::Manifest( + new pgBackRestTest::Env::Manifest( $self->repoBackupPath( ${$oExpectedManifestRef}{&MANIFEST_SECTION_BACKUP}{&MANIFEST_KEY_PRIOR} . qw{/} . FILE_MANIFEST), {strCipherPass => $oHostBackup->cipherPassManifest()}); @@ -1807,7 +1901,7 @@ sub restoreCompare } } - my $oActualManifest = new pgBackRest::Manifest( + my $oActualManifest = new pgBackRestTest::Env::Manifest( "${strTestPath}/" . FILE_MANIFEST, {bLoad => false, strDbVersion => $oExpectedManifestRef->{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_DB_VERSION}, iDbCatalogVersion => $oExpectedManifestRef->{&MANIFEST_SECTION_BACKUP_DB}{&MANIFEST_KEY_CATALOG}, diff --git a/test/lib/pgBackRestTest/Env/Host/HostBaseTest.pm b/test/lib/pgBackRestTest/Env/Host/HostBaseTest.pm index 640b41a45..7b8c40fd9 100644 --- a/test/lib/pgBackRestTest/Env/Host/HostBaseTest.pm +++ b/test/lib/pgBackRestTest/Env/Host/HostBaseTest.pm @@ -16,14 +16,15 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(dirname); -use pgBackRest::Common::Log; -use pgBackRest::Storage::Helper; use pgBackRest::Version; +use BackRestDoc::Common::Log; + use pgBackRestTest::Common::ContainerTest; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::JobTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; use pgBackRestTest::Common::VmTest; #################################################################################################################################### diff --git a/test/lib/pgBackRestTest/Env/Host/HostDbCommonTest.pm b/test/lib/pgBackRestTest/Env/Host/HostDbCommonTest.pm index 9e2315080..c7dc6e6bf 100644 --- a/test/lib/pgBackRestTest/Env/Host/HostDbCommonTest.pm +++ b/test/lib/pgBackRestTest/Env/Host/HostDbCommonTest.pm @@ -16,21 +16,22 @@ use Exporter qw(import); use File::Basename qw(dirname); use Storable qw(dclone); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRest::Common::Wait; -use pgBackRest::DbVersion; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; use pgBackRest::Version; -use pgBackRestTest::Env::Host::HostBackupTest; -use pgBackRestTest::Env::Host::HostBaseTest; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + +use pgBackRestTest::Common::DbVersion; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::HostGroupTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Common::Wait; +use pgBackRestTest::Env::Host::HostBackupTest; +use pgBackRestTest::Env::Host::HostBaseTest; +use pgBackRestTest::Env::Manifest; #################################################################################################################################### # Test WAL size diff --git a/test/lib/pgBackRestTest/Env/Host/HostDbSyntheticTest.pm b/test/lib/pgBackRestTest/Env/Host/HostDbSyntheticTest.pm index 329e2a96f..81377c707 100644 --- a/test/lib/pgBackRestTest/Env/Host/HostDbSyntheticTest.pm +++ b/test/lib/pgBackRestTest/Env/Host/HostDbSyntheticTest.pm @@ -17,21 +17,22 @@ use Fcntl ':mode'; use File::Basename qw(basename dirname); use File::stat; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRest::Common::Wait; -use pgBackRest::DbVersion; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + +use pgBackRestTest::Common::ContainerTest; +use pgBackRestTest::Common::DbVersion; +use pgBackRestTest::Common::FileTest; +use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Common::Wait; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::Host::HostBaseTest; use pgBackRestTest::Env::Host::HostDbCommonTest; -use pgBackRestTest::Common::ContainerTest; -use pgBackRestTest::Common::FileTest; -use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Env::Manifest; #################################################################################################################################### # new diff --git a/test/lib/pgBackRestTest/Env/Host/HostDbTest.pm b/test/lib/pgBackRestTest/Env/Host/HostDbTest.pm index 38439ed51..94990fd47 100644 --- a/test/lib/pgBackRestTest/Env/Host/HostDbTest.pm +++ b/test/lib/pgBackRestTest/Env/Host/HostDbTest.pm @@ -16,20 +16,21 @@ use Exporter qw(import); our @EXPORT = qw(); use File::Basename qw(basename); -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRest::Common::Wait; -use pgBackRest::DbVersion; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + +use pgBackRestTest::Common::ContainerTest; +use pgBackRestTest::Common::DbVersion; +use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Common::Wait; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::Host::HostBaseTest; use pgBackRestTest::Env::Host::HostDbCommonTest; -use pgBackRestTest::Common::ContainerTest; -use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Env::Manifest; #################################################################################################################################### # Db defaults diff --git a/test/lib/pgBackRestTest/Env/Host/HostS3Test.pm b/test/lib/pgBackRestTest/Env/Host/HostS3Test.pm index f6a8b4bf6..c5de9ed6a 100644 --- a/test/lib/pgBackRestTest/Env/Host/HostS3Test.pm +++ b/test/lib/pgBackRestTest/Env/Host/HostS3Test.pm @@ -17,20 +17,20 @@ use Exporter qw(import); use File::Basename qw(dirname); use Storable qw(dclone); -use pgBackRest::Backup::Common; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; use pgBackRest::Version; -use pgBackRestTest::Env::Host::HostBaseTest; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; + use pgBackRestTest::Common::ContainerTest; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::HostGroupTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Common::Wait; +use pgBackRestTest::Env::Host::HostBaseTest; +use pgBackRestTest::Env::Manifest; #################################################################################################################################### # S3 defaults diff --git a/test/lib/pgBackRestTest/Env/HostEnvTest.pm b/test/lib/pgBackRestTest/Env/HostEnvTest.pm index fe4826ced..9541887f7 100644 --- a/test/lib/pgBackRestTest/Env/HostEnvTest.pm +++ b/test/lib/pgBackRestTest/Env/HostEnvTest.pm @@ -16,22 +16,22 @@ use Exporter qw(import); our @EXPORT = qw(); use Storable qw(dclone); -use pgBackRest::Archive::Common; -use pgBackRest::Common::Log; -use pgBackRest::DbVersion; -use pgBackRest::Storage::Base; -use pgBackRest::Storage::Helper; +use BackRestDoc::Common::Log; +use pgBackRestTest::Common::ContainerTest; +use pgBackRestTest::Common::DbVersion; +use pgBackRestTest::Common::ExecuteTest; +use pgBackRestTest::Common::HostGroupTest; +use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageBase; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Env::ArchiveInfo; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::Host::HostBaseTest; use pgBackRestTest::Env::Host::HostDbCommonTest; use pgBackRestTest::Env::Host::HostDbTest; use pgBackRestTest::Env::Host::HostDbSyntheticTest; use pgBackRestTest::Env::Host::HostS3Test; -use pgBackRestTest::Common::ContainerTest; -use pgBackRestTest::Common::ExecuteTest; -use pgBackRestTest::Common::HostGroupTest; -use pgBackRestTest::Common::RunTest; #################################################################################################################################### # Constants diff --git a/lib/pgBackRest/InfoCommon.pm b/test/lib/pgBackRestTest/Env/InfoCommon.pm similarity index 97% rename from lib/pgBackRest/InfoCommon.pm rename to test/lib/pgBackRestTest/Env/InfoCommon.pm index 663dd5cb0..22990a81e 100644 --- a/lib/pgBackRest/InfoCommon.pm +++ b/test/lib/pgBackRestTest/Env/InfoCommon.pm @@ -2,7 +2,7 @@ # INFO MODULE # Constants, variables and functions common to the info files #################################################################################################################################### -package pgBackRest::InfoCommon; +package pgBackRestTest::Env::InfoCommon; use strict; use warnings FATAL => qw(all); diff --git a/lib/pgBackRest/Manifest.pm b/test/lib/pgBackRestTest/Env/Manifest.pm similarity index 99% rename from lib/pgBackRest/Manifest.pm rename to test/lib/pgBackRestTest/Env/Manifest.pm index 4199f1052..3da3a8700 100644 --- a/lib/pgBackRest/Manifest.pm +++ b/test/lib/pgBackRestTest/Env/Manifest.pm @@ -1,8 +1,8 @@ #################################################################################################################################### # MANIFEST MODULE #################################################################################################################################### -package pgBackRest::Manifest; -use parent 'pgBackRest::Common::Ini'; +package pgBackRestTest::Env::Manifest; +use parent 'BackRestDoc::Common::Ini'; use strict; use warnings FATAL => qw(all); @@ -13,12 +13,13 @@ use Exporter qw(import); use File::Basename qw(dirname basename); use Time::Local qw(timelocal); -use pgBackRest::DbVersion; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::Storage::Helper; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; + +use pgBackRestTest::Common::DbVersion; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # File/path constants diff --git a/test/lib/pgBackRestTest/Module/Mock/MockAllTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockAllTest.pm index a306609fe..f8c14a171 100644 --- a/test/lib/pgBackRestTest/Module/Mock/MockAllTest.pm +++ b/test/lib/pgBackRestTest/Module/Mock/MockAllTest.pm @@ -13,27 +13,173 @@ use Carp qw(confess); use File::Basename qw(basename dirname); -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Common; -use pgBackRest::Backup::Info; -use pgBackRest::DbVersion; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::InfoCommon; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + use pgBackRestTest::Common::ContainerTest; +use pgBackRestTest::Common::DbVersion; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::FileTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Wait; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::BackupInfo; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::Host::HostS3Test; use pgBackRestTest::Env::HostEnvTest; +use pgBackRestTest::Env::InfoCommon; +use pgBackRestTest::Env::Manifest; + +#################################################################################################################################### +# backupRegExpGet +# +# Generate a regexp depending on the backups that need to be found. +#################################################################################################################################### +sub backupRegExpGet +{ + # Assign function parameters, defaults, and log debug info + my + ( + $strOperation, + $bFull, + $bDifferential, + $bIncremental, + $bAnchor + ) = + logDebugParam + ( + __PACKAGE__ . '::backupRegExpGet', \@_, + {name => 'bFull', default => false}, + {name => 'bDifferential', default => false}, + {name => 'bIncremental', default => false}, + {name => 'bAnchor', default => true} + ); + + # One of the types must be selected + if (!($bFull || $bDifferential || $bIncremental)) + { + confess &log(ASSERT, 'at least one backup type must be selected'); + } + + # Standard regexp to match date and time formatting + my $strDateTimeRegExp = "[0-9]{8}\\-[0-9]{6}"; + # Start the expression with the anchor if requested, date/time regexp and full backup indicator + my $strRegExp = ($bAnchor ? '^' : '') . $strDateTimeRegExp . 'F'; + + # Add the diff and/or incr expressions if requested + if ($bDifferential || $bIncremental) + { + # If full requested then diff/incr is optional + if ($bFull) + { + $strRegExp .= "(\\_"; + } + # Else diff/incr is required + else + { + $strRegExp .= "\\_"; + } + + # Append date/time regexp for diff/incr + $strRegExp .= $strDateTimeRegExp; + + # Filter on both diff/incr + if ($bDifferential && $bIncremental) + { + $strRegExp .= '(D|I)'; + } + # Else just diff + elsif ($bDifferential) + { + $strRegExp .= 'D'; + } + # Else just incr + else + { + $strRegExp .= 'I'; + } + + # If full requested then diff/incr is optional + if ($bFull) + { + $strRegExp .= '){0,1}'; + } + } + + # Append the end anchor if requested + $strRegExp .= $bAnchor ? "\$" : ''; + + # Return from function and log return values if any + return logDebugReturn + ( + $strOperation, + {name => 'strRegExp', value => $strRegExp} + ); +} + +#################################################################################################################################### +# backupLabel +# +# Get unique backup label. +#################################################################################################################################### +sub backupLabel +{ + # Assign function parameters, defaults, and log debug info + my + ( + $strOperation, + $oStorageRepo, + $strRepoBackupPath, + $strType, + $strBackupLabelLast, + $lTimestampStart + ) = + logDebugParam + ( + __PACKAGE__ . '::backupLabelFormat', \@_, + {name => 'oStorageRepo', trace => true}, + {name => 'strRepoBackupPath', trace => true}, + {name => 'strType', trace => true}, + {name => 'strBackupLabelLast', required => false, trace => true}, + {name => 'lTimestampStart', trace => true} + ); + + # Create backup label + my $strBackupLabel = backupLabelFormat($strType, $strBackupLabelLast, $lTimestampStart); + + # Make sure that the timestamp has not already been used by a prior backup. This is unlikely for online backups since there is + # already a wait after the manifest is built but it's still possible if the remote and local systems don't have synchronized + # clocks. In practice this is most useful for making offline testing faster since it allows the wait after manifest build to + # be skipped by dealing with any backup label collisions here. + if ($oStorageRepo->list( + $strRepoBackupPath, + {strExpression => + ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL ? '^' : '_') . timestampFileFormat(undef, $lTimestampStart) . + ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL ? 'F' : '(D|I)$')}) || + $oStorageRepo->list( + "${strRepoBackupPath}/" . PATH_BACKUP_HISTORY . '/' . timestampFormat('%4d', $lTimestampStart), + {strExpression => + ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL ? '^' : '_') . timestampFileFormat(undef, $lTimestampStart) . + ($strType eq CFGOPTVAL_BACKUP_TYPE_FULL ? 'F' : '(D|I)\.manifest\.gz$'), + bIgnoreMissing => true})) + { + waitRemainder(); + $strBackupLabel = backupLabelFormat($strType, $strBackupLabelLast, time()); + } + + # Return from function and log return values if any + return logDebugReturn + ( + $strOperation, + {name => 'strBackupLabel', value => $strBackupLabel, trace => true} + ); +} #################################################################################################################################### # Build PostgreSQL pages for testing diff --git a/test/lib/pgBackRestTest/Module/Mock/MockArchiveStopTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockArchiveStopTest.pm index 39f0a21c2..1bb163322 100644 --- a/test/lib/pgBackRestTest/Module/Mock/MockArchiveStopTest.pm +++ b/test/lib/pgBackRestTest/Module/Mock/MockArchiveStopTest.pm @@ -13,21 +13,21 @@ use Carp qw(confess); use File::Basename qw(dirname); -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Info; -use pgBackRest::DbVersion; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::BackupInfo; use pgBackRestTest::Env::HostEnvTest; use pgBackRestTest::Env::Host::HostBackupTest; +use pgBackRestTest::Env::Manifest; +use pgBackRestTest::Common::DbVersion; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # run diff --git a/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm index 2ecf8a164..7812b7f6b 100644 --- a/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm +++ b/test/lib/pgBackRestTest/Module/Mock/MockArchiveTest.pm @@ -13,21 +13,21 @@ use Carp qw(confess); use File::Basename qw(dirname); -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Info; -use pgBackRest::DbVersion; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::BackupInfo; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::HostEnvTest; +use pgBackRestTest::Env::Manifest; +use pgBackRestTest::Common::DbVersion; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # archiveCheck diff --git a/test/lib/pgBackRestTest/Module/Mock/MockExpireTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockExpireTest.pm index ec7d2bf3c..1e93af4e9 100644 --- a/test/lib/pgBackRestTest/Module/Mock/MockExpireTest.pm +++ b/test/lib/pgBackRestTest/Module/Mock/MockExpireTest.pm @@ -14,23 +14,23 @@ use Carp qw(confess); use File::Basename qw(dirname); use Storable qw(dclone); -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Info; -use pgBackRest::DbVersion; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; -use pgBackRestTest::Common::ExecuteTest; -use pgBackRestTest::Common::RunTest; -use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::BackupInfo; use pgBackRestTest::Env::ExpireEnvTest; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::Host::HostS3Test; use pgBackRestTest::Env::HostEnvTest; +use pgBackRestTest::Env::Manifest; +use pgBackRestTest::Common::DbVersion; +use pgBackRestTest::Common::ExecuteTest; +use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # run diff --git a/test/lib/pgBackRestTest/Module/Mock/MockStanzaTest.pm b/test/lib/pgBackRestTest/Module/Mock/MockStanzaTest.pm index bace447f5..b1c5ce67c 100644 --- a/test/lib/pgBackRestTest/Module/Mock/MockStanzaTest.pm +++ b/test/lib/pgBackRestTest/Module/Mock/MockStanzaTest.pm @@ -13,24 +13,24 @@ use Carp qw(confess); use File::Basename qw(dirname); -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Info; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::DbVersion; -use pgBackRest::InfoCommon; -use pgBackRest::Manifest; -use pgBackRest::Storage::Base; -use pgBackRest::Storage::Helper; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::BackupInfo; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::HostEnvTest; +use pgBackRestTest::Env::InfoCommon; +use pgBackRestTest::Env::Manifest; +use pgBackRestTest::Common::DbVersion; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::FileTest; use pgBackRestTest::Common::RunTest; +use pgBackRestTest::Common::StorageBase; +use pgBackRestTest::Common::StorageRepo; use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # run @@ -214,8 +214,8 @@ sub run forceStorageMove(storageRepo(), $strArchiveInfoCopyOldFile, $strArchiveInfoFile, {bRecurse => false}); # Confirm versions - my $oArchiveInfo = new pgBackRest::Archive::Info($oHostBackup->repoArchivePath()); - my $oBackupInfo = new pgBackRest::Backup::Info($oHostBackup->repoBackupPath()); + my $oArchiveInfo = new pgBackRestTest::Env::ArchiveInfo($oHostBackup->repoArchivePath()); + my $oBackupInfo = new pgBackRestTest::Env::BackupInfo($oHostBackup->repoBackupPath()); $self->testResult(sub {$oArchiveInfo->test(INFO_ARCHIVE_SECTION_DB, INFO_ARCHIVE_KEY_DB_VERSION, undef, PG_VERSION_93)}, true, 'archive at old pg version'); $self->testResult(sub {$oBackupInfo->test(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_DB_VERSION, undef, diff --git a/test/lib/pgBackRestTest/Module/Performance/PerformanceArchivePerlTest.pm b/test/lib/pgBackRestTest/Module/Performance/PerformanceArchivePerlTest.pm index 5fc759114..7ec14c15b 100644 --- a/test/lib/pgBackRestTest/Module/Performance/PerformanceArchivePerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Performance/PerformanceArchivePerlTest.pm @@ -15,7 +15,7 @@ use English '-no_match_vars'; use Storable qw(dclone); use Time::HiRes qw(gettimeofday); -use pgBackRest::Common::Log; +use BackRestDoc::Common::Log; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::RunTest; diff --git a/test/lib/pgBackRestTest/Module/Real/RealAllTest.pm b/test/lib/pgBackRestTest/Module/Real/RealAllTest.pm index ac7fdafd0..718917d1c 100644 --- a/test/lib/pgBackRestTest/Module/Real/RealAllTest.pm +++ b/test/lib/pgBackRestTest/Module/Real/RealAllTest.pm @@ -13,29 +13,31 @@ use Carp qw(confess); use File::Basename qw(dirname); -use pgBackRest::Archive::Info; -use pgBackRest::Backup::Info; -use pgBackRest::DbVersion; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Ini; -use pgBackRest::Common::Log; -use pgBackRest::Common::Wait; -use pgBackRest::InfoCommon; -use pgBackRest::Manifest; -use pgBackRest::Storage::Helper; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Ini; +use BackRestDoc::Common::Log; + use pgBackRestTest::Common::ContainerTest; +use pgBackRestTest::Common::DbVersion; use pgBackRestTest::Common::ExecuteTest; use pgBackRestTest::Common::FileTest; use pgBackRestTest::Common::RunTest; use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Storage; +use pgBackRestTest::Common::StoragePosix; +use pgBackRestTest::Common::StorageRepo; +use pgBackRestTest::Common::Wait; +use pgBackRestTest::Env::ArchiveInfo; +use pgBackRestTest::Env::BackupInfo; +use pgBackRestTest::Env::InfoCommon; use pgBackRestTest::Env::Host::HostBaseTest; use pgBackRestTest::Env::Host::HostBackupTest; use pgBackRestTest::Env::Host::HostDbTest; +use pgBackRestTest::Env::Host::HostDbTest; use pgBackRestTest::Env::HostEnvTest; -use pgBackRestTest::Common::Storage; -use pgBackRestTest::Common::StoragePosix; +use pgBackRestTest::Env::Manifest; #################################################################################################################################### # Backup advisory lock @@ -129,10 +131,10 @@ sub run # Get passphrase to access the Manifest file from backup.info - returns undefined if repo not encrypted my $strCipherPass = - (new pgBackRest::Backup::Info($oHostBackup->repoBackupPath()))->cipherPassSub(); + (new pgBackRestTest::Env::BackupInfo($oHostBackup->repoBackupPath()))->cipherPassSub(); # Create a manifest with the pg version to get version-specific paths - my $oManifest = new pgBackRest::Manifest(BOGUS, {bLoad => false, strDbVersion => $self->pgVersion(), + my $oManifest = new pgBackRestTest::Env::Manifest(BOGUS, {bLoad => false, strDbVersion => $self->pgVersion(), iDbCatalogVersion => $self->dbCatalogVersion($self->pgVersion()), strCipherPass => $strCipherPass, strCipherPassSub => $bRepoEncrypt ? ENCRYPTION_KEY_BACKUPSET : undef}); @@ -351,8 +353,8 @@ sub run # Run stanza-create offline to create files needing to be upgraded (using new pg-path) $oHostBackup->stanzaCreate('successfully create stanza files to be upgraded', {strOptionalParam => ' --pg1-path=' . $oHostDbMaster->dbPath() . '/testbase/ --no-online --force'}); - my $oArchiveInfo = new pgBackRest::Archive::Info($oHostBackup->repoArchivePath()); - my $oBackupInfo = new pgBackRest::Backup::Info($oHostBackup->repoBackupPath()); + my $oArchiveInfo = new pgBackRestTest::Env::ArchiveInfo($oHostBackup->repoArchivePath()); + my $oBackupInfo = new pgBackRestTest::Env::BackupInfo($oHostBackup->repoBackupPath()); # Read info files to confirm the files were created with a different database version if ($self->pgVersion() eq PG_VERSION_94) @@ -374,8 +376,8 @@ sub run $oHostBackup->stanzaUpgrade('upgrade stanza files online'); # Reread the info files and confirm the result - $oArchiveInfo = new pgBackRest::Archive::Info($oHostBackup->repoArchivePath()); - $oBackupInfo = new pgBackRest::Backup::Info($oHostBackup->repoBackupPath()); + $oArchiveInfo = new pgBackRestTest::Env::ArchiveInfo($oHostBackup->repoArchivePath()); + $oBackupInfo = new pgBackRestTest::Env::BackupInfo($oHostBackup->repoBackupPath()); $self->testResult(sub {$oArchiveInfo->test(INFO_ARCHIVE_SECTION_DB, INFO_ARCHIVE_KEY_DB_VERSION, undef, $self->pgVersion())}, true, 'archive upgrade online corrects db'); $self->testResult(sub {$oBackupInfo->test(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_DB_VERSION, undef, @@ -777,7 +779,7 @@ sub run else { # Backup info will have the catalog number - my $oBackupInfo = new pgBackRest::Common::Ini( + my $oBackupInfo = new BackRestDoc::Common::Ini( storageRepo(), $oHostBackup->repoBackupPath(FILE_BACKUP_INFO), {bLoad => false, strContent => ${storageRepo()->get($oHostBackup->repoBackupPath(FILE_BACKUP_INFO))}}); diff --git a/test/test.pl b/test/test.pl index 1e274fe49..c1d73ffa6 100755 --- a/test/test.pl +++ b/test/test.pl @@ -27,12 +27,12 @@ use lib dirname(dirname($0)) . '/lib'; use lib dirname(dirname($0)) . '/build/lib'; use lib dirname(dirname($0)) . '/doc/lib'; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; -use pgBackRest::Common::String; -use pgBackRest::Common::Wait; use pgBackRest::Version; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; +use BackRestDoc::Common::String; + use pgBackRestBuild::Build; use pgBackRestBuild::Build::Common; use pgBackRestBuild::Config::Build; @@ -54,6 +54,7 @@ use pgBackRestTest::Common::RunTest; use pgBackRestTest::Common::Storage; use pgBackRestTest::Common::StoragePosix; use pgBackRestTest::Common::VmTest; +use pgBackRestTest::Common::Wait; #################################################################################################################################### # Usage diff --git a/test/travis.pl b/test/travis.pl index 23c0ae9fb..3355f6690 100755 --- a/test/travis.pl +++ b/test/travis.pl @@ -21,9 +21,10 @@ use Pod::Usage qw(pod2usage); use lib dirname($0) . '/lib'; use lib dirname(dirname($0)) . '/lib'; +use lib dirname(dirname($0)) . '/doc/lib'; -use pgBackRest::Common::Exception; -use pgBackRest::Common::Log; +use BackRestDoc::Common::Exception; +use BackRestDoc::Common::Log; use pgBackRestTest::Common::ContainerTest; use pgBackRestTest::Common::ExecuteTest;