2015-10-08 17:43:56 +02:00
|
|
|
####################################################################################################################################
|
2015-10-28 11:10:36 +02:00
|
|
|
# LogTest.pm - Capture the output of commands to compare them with an expected version
|
2015-10-08 17:43:56 +02:00
|
|
|
####################################################################################################################################
|
2016-04-14 15:30:54 +02:00
|
|
|
package pgBackRestTest::Common::LogTest;
|
2015-10-08 17:43:56 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use Cwd qw(abs_path);
|
|
|
|
use Exporter qw(import);
|
|
|
|
our @EXPORT = qw();
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
|
2020-03-10 21:41:56 +02:00
|
|
|
use pgBackRestDoc::Common::Log;
|
2020-03-10 23:57:02 +02:00
|
|
|
use pgBackRestDoc::ProjectInfo;
|
2020-03-10 21:12:44 +02:00
|
|
|
|
2016-12-04 00:34:51 +02:00
|
|
|
use pgBackRestTest::Common::ContainerTest;
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRestTest::Common::ExecuteTest;
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2019-12-17 22:23:07 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Expect log cache for supplemental files so they are only added to expect logs when they have changed
|
|
|
|
####################################################################################################################################
|
|
|
|
my $hyExpectCache = undef;
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# new
|
|
|
|
####################################################################################################################################
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift; # Class name
|
|
|
|
|
|
|
|
# Create the class hash
|
|
|
|
my $self = {};
|
|
|
|
bless $self, $class;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
(
|
|
|
|
my $strOperation,
|
|
|
|
$self->{strModule},
|
|
|
|
$self->{strTest},
|
|
|
|
$self->{iRun},
|
|
|
|
$self->{bForce},
|
|
|
|
$self->{strComment},
|
|
|
|
$self->{strCommandMain},
|
|
|
|
$self->{strPgSqlBin},
|
|
|
|
$self->{strTestPath},
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
2016-08-11 23:32:28 +02:00
|
|
|
__PACKAGE__ . '->new', \@_,
|
2015-10-08 17:43:56 +02:00
|
|
|
{name => 'strModule', trace => true},
|
|
|
|
{name => 'strTest', trace => true},
|
|
|
|
{name => 'iRun', trace => true},
|
|
|
|
{name => 'bForce', trace => true},
|
|
|
|
{name => 'strComment', trace => true},
|
|
|
|
{name => 'strCommandMain', trace => true},
|
2016-06-12 15:00:16 +02:00
|
|
|
{name => 'strPgSqlBin', required => false, trace => true},
|
2015-10-08 17:43:56 +02:00
|
|
|
{name => 'strTestPath', trace => true},
|
|
|
|
);
|
|
|
|
|
|
|
|
# Initialize the test log
|
|
|
|
$self->{strLog} = 'run ' . sprintf('%03d', $self->{iRun}) . ' - ' . $self->{strComment};
|
|
|
|
$self->{strLog} .= "\n" . ('=' x length($self->{strLog})) . "\n";
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Initialize the filename
|
|
|
|
$self->{strFileName} = sprintf("expect/$self->{strModule}-$self->{strTest}-%03d.log", $self->{iRun});
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
# Initialize the replacement hash
|
|
|
|
$self->{oReplaceHash} = {};
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'self', value => $self, trace => true}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# logAdd
|
|
|
|
####################################################################################################################################
|
|
|
|
sub logAdd
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
$strCommand,
|
|
|
|
$strComment,
|
|
|
|
$strLog
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
2016-08-11 23:32:28 +02:00
|
|
|
__PACKAGE__ . '->logAdd', \@_,
|
2015-10-08 17:43:56 +02:00
|
|
|
{name => 'strCommand', trace => true},
|
|
|
|
{name => 'strComment', required => false, trace => true},
|
|
|
|
{name => 'strLog', required => false, trace => true}
|
|
|
|
);
|
|
|
|
|
|
|
|
$self->{strLog} .= "\n";
|
|
|
|
|
|
|
|
if (defined($strComment))
|
|
|
|
{
|
|
|
|
$self->{strLog} .= $self->regExpReplaceAll($strComment) . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->{strLog} .= '> ' . $self->regExpReplaceAll($strCommand) . "\n" . ('-' x '132') . "\n";
|
|
|
|
|
|
|
|
# Make sure there is a log before trying to output it
|
|
|
|
if (defined($strLog))
|
|
|
|
{
|
|
|
|
# Do replacements on each line of the log
|
|
|
|
foreach my $strLine (split("\n", $strLog))
|
|
|
|
{
|
2017-02-05 17:59:49 +02:00
|
|
|
# Remove timestamp from log line
|
2016-09-14 23:30:57 +02:00
|
|
|
$strLine =~ s/^[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-6][0-9]:[0-6][0-9]\.[0-9]{3} //;
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2017-02-05 17:59:49 +02:00
|
|
|
# Don't include test points in the final log
|
2015-10-08 17:43:56 +02:00
|
|
|
if ($strLine !~ /^ TEST/)
|
|
|
|
{
|
2017-02-05 17:59:49 +02:00
|
|
|
# Remove spaces that provided padding for the timetamp
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine =~ s/^ //;
|
2017-02-05 17:59:49 +02:00
|
|
|
|
|
|
|
# Remove any final CRs
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine =~ s/\r$//;
|
|
|
|
|
2017-02-05 17:59:49 +02:00
|
|
|
# Do other replacements
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine = $self->regExpReplaceAll($strLine);
|
|
|
|
|
2017-02-05 17:59:49 +02:00
|
|
|
# Add to the log
|
2015-10-08 17:43:56 +02:00
|
|
|
$self->{strLog} .= "${strLine}\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
logDebugReturn($strOperation);
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# supplementalAdd
|
|
|
|
####################################################################################################################################
|
|
|
|
sub supplementalAdd
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
my $strFileName = shift;
|
|
|
|
my $strComment = shift;
|
2017-06-09 23:51:41 +02:00
|
|
|
my $strContent = shift;
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2019-12-17 22:23:07 +02:00
|
|
|
# Get content if it is not defined
|
2017-06-09 23:51:41 +02:00
|
|
|
if (!defined($strContent))
|
2015-10-08 17:43:56 +02:00
|
|
|
{
|
2017-06-09 23:51:41 +02:00
|
|
|
open(my $hFile, '<', $strFileName)
|
|
|
|
or confess &log(ERROR, "unable to open ${strFileName} for appending to test log");
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
while (my $strLine = readline($hFile))
|
|
|
|
{
|
2019-12-17 22:23:07 +02:00
|
|
|
$strContent .= $strLine;
|
2017-06-09 23:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
close($hFile);
|
|
|
|
}
|
2019-12-17 22:23:07 +02:00
|
|
|
|
2021-04-28 16:58:45 +02:00
|
|
|
# Only output when the content of this file has changed
|
2019-12-17 22:23:07 +02:00
|
|
|
if (!defined($hyExpectCache->{$strFileName}) || $hyExpectCache->{$strFileName} ne $strContent)
|
2017-06-09 23:51:41 +02:00
|
|
|
{
|
2019-12-17 22:23:07 +02:00
|
|
|
# $hyExpectCache->{$strFileName} = $strContent;
|
|
|
|
|
|
|
|
my $strHeader = "+ supplemental file: " . $self->regExpReplaceAll($strFileName);
|
|
|
|
|
|
|
|
if (defined($strComment))
|
|
|
|
{
|
|
|
|
$self->{strLog} .= "\n" . $self->regExpReplaceAll($strComment) . "\n" . ('=' x '132') . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->{strLog} .= "\n${strHeader}\n" . ('-' x length($strHeader)) . "\n";
|
|
|
|
|
|
|
|
if (length($strContent) > 0)
|
2017-06-09 23:51:41 +02:00
|
|
|
{
|
|
|
|
foreach my $strLine (split("\n", $strContent))
|
|
|
|
{
|
|
|
|
$self->{strLog} .= $self->regExpReplaceAll($strLine) . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# logWrite
|
|
|
|
####################################################################################################################################
|
|
|
|
sub logWrite
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
$strBasePath,
|
|
|
|
$strTestPath,
|
|
|
|
$strFileName
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
2016-08-11 23:32:28 +02:00
|
|
|
__PACKAGE__ . '->logWrite', \@_,
|
2015-10-08 17:43:56 +02:00
|
|
|
{name => 'strBasePath', trace => true},
|
|
|
|
{name => 'strTestPath', trace => true},
|
2016-12-23 15:22:59 +02:00
|
|
|
{name => 'strFileName', default => $self->{strFileName}, trace => true}
|
2015-10-08 17:43:56 +02:00
|
|
|
);
|
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
my $strReferenceLogFile = "${strBasePath}/test/${strFileName}";
|
|
|
|
my $strTestLogFile;
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
if ($self->{bForce})
|
|
|
|
{
|
2015-11-22 21:02:14 +02:00
|
|
|
$strTestLogFile = $strReferenceLogFile;
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-06 16:00:11 +02:00
|
|
|
my $strTestLogPath = "${strTestPath}/expect";
|
2015-10-08 17:43:56 +02:00
|
|
|
|
|
|
|
if (!-e $strTestLogPath)
|
|
|
|
{
|
2016-05-11 00:12:37 +02:00
|
|
|
mkdir($strTestLogPath, 0750) or
|
2016-04-06 16:00:11 +02:00
|
|
|
confess "unable to create expect log path ${strTestLogPath}";
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
$strTestLogFile = "${strTestPath}/${strFileName}";
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
open(my $hFile, '>', $strTestLogFile)
|
2016-04-06 16:00:11 +02:00
|
|
|
or confess "unable to open expect log file '${strTestLogFile}': $!";
|
2015-10-08 17:43:56 +02:00
|
|
|
|
|
|
|
syswrite($hFile, $self->{strLog})
|
2016-04-06 16:00:11 +02:00
|
|
|
or confess "unable to write expect log file '${strTestLogFile}': $!";
|
2015-10-08 17:43:56 +02:00
|
|
|
|
|
|
|
close($hFile);
|
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
if (!$self->{bForce})
|
|
|
|
{
|
|
|
|
executeTest("diff ${strReferenceLogFile} ${strTestLogFile}");
|
|
|
|
}
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
# Return from function and log return values if any
|
|
|
|
logDebugReturn($strOperation);
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# regExpReplace
|
|
|
|
####################################################################################################################################
|
|
|
|
sub regExpReplace
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
my $strLine = shift;
|
|
|
|
my $strType = shift;
|
|
|
|
my $strExpression = shift;
|
|
|
|
my $strToken = shift;
|
|
|
|
my $bIndex = shift;
|
|
|
|
|
|
|
|
my @stryReplace = ($strLine =~ /$strExpression/g);
|
|
|
|
|
|
|
|
foreach my $strReplace (@stryReplace)
|
|
|
|
{
|
|
|
|
my $iIndex;
|
|
|
|
my $strTypeReplacement;
|
|
|
|
my $strReplacement;
|
|
|
|
|
|
|
|
if (!defined($bIndex) || $bIndex)
|
|
|
|
{
|
|
|
|
if (defined($strToken))
|
|
|
|
{
|
|
|
|
my @stryReplacement = ($strReplace =~ /$strToken/g);
|
|
|
|
|
|
|
|
if (@stryReplacement != 1)
|
|
|
|
{
|
2016-08-24 18:39:27 +02:00
|
|
|
my $strError = "'${strToken}'";
|
|
|
|
|
|
|
|
if (@stryReplacement == 0)
|
|
|
|
{
|
2016-12-04 00:34:51 +02:00
|
|
|
confess &log(ASSERT, $strError . " is not a sub-regexp of '${strExpression}' or" .
|
2016-08-24 18:39:27 +02:00
|
|
|
" matches " . @stryReplacement . " times on {[${strReplace}]}");
|
|
|
|
}
|
|
|
|
|
|
|
|
confess &log(
|
2016-12-04 00:34:51 +02:00
|
|
|
ASSERT, $strError . " matches '${strExpression}' " . @stryReplacement . " times on '${strReplace}': " .
|
2016-08-24 18:39:27 +02:00
|
|
|
join(',', @stryReplacement));
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$strReplacement = $stryReplacement[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strReplacement = $strReplace;
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
if (defined($strType))
|
2015-10-08 17:43:56 +02:00
|
|
|
{
|
2016-06-24 14:12:58 +02:00
|
|
|
if (defined(${$self->{oReplaceHash}}{$strType}{$strReplacement}))
|
2015-10-08 17:43:56 +02:00
|
|
|
{
|
2016-06-24 14:12:58 +02:00
|
|
|
$iIndex = ${$self->{oReplaceHash}}{$strType}{$strReplacement}{index};
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
2016-06-24 14:12:58 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!defined(${$self->{oReplaceHash}}{$strType}{index}))
|
|
|
|
{
|
|
|
|
${$self->{oReplaceHash}}{$strType}{index} = 1;
|
|
|
|
}
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
$iIndex = ${$self->{oReplaceHash}}{$strType}{index}++;
|
|
|
|
${$self->{oReplaceHash}}{$strType}{$strReplacement}{index} = $iIndex;
|
|
|
|
}
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
$strTypeReplacement = defined($strType) ? "[${strType}" . (defined($iIndex) ? "-${iIndex}" : '') . ']' : '';
|
2015-10-08 17:43:56 +02:00
|
|
|
|
|
|
|
if (defined($strToken))
|
|
|
|
{
|
|
|
|
$strReplacement = $strReplace;
|
|
|
|
$strReplacement =~ s/$strToken/$strTypeReplacement/;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strReplacement = $strTypeReplacement;
|
|
|
|
}
|
|
|
|
|
2017-11-06 19:51:12 +02:00
|
|
|
$strReplace =~ s/\//\\\//g;
|
|
|
|
$strReplace =~ s/\+/\\\+/g;
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine =~ s/$strReplace/$strReplacement/g;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $strLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# regExpReplaceAll
|
2016-05-06 16:25:46 +02:00
|
|
|
#
|
|
|
|
# Replaces dynamic test output so that the expected test output can be verified against actual test output.
|
2015-10-08 17:43:56 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
sub regExpReplaceAll
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
my $strLine = shift;
|
|
|
|
|
|
|
|
my $strBinPath = dirname(dirname(abs_path($0))) . '/bin';
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Replace the exe path/file with sh ' prepended
|
|
|
|
my $strLineBefore = $strLine;
|
2017-02-17 00:18:48 +02:00
|
|
|
$strLine =~ s/bash -l -c '$self->{strCommandMain}/[BACKREST-BIN]/g;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
|
|
|
# Replace the final ' if the previous expression made changes
|
|
|
|
if ($strLine ne $strLineBefore)
|
|
|
|
{
|
|
|
|
$strLine =~ s/'$//g;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Replace the exe path/file with sh ' prepended
|
2016-06-24 14:12:58 +02:00
|
|
|
$strLine =~ s/$self->{strCommandMain}/[BACKREST-BIN]/g;
|
|
|
|
|
2016-06-24 16:54:31 +02:00
|
|
|
# Replace the test path
|
|
|
|
$strLine =~ s/$self->{strTestPath}/[TEST_PATH]/g;
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2016-06-24 16:54:31 +02:00
|
|
|
# Replace the pgsql path (if exists)
|
2016-06-12 15:00:16 +02:00
|
|
|
if (defined($self->{strPgSqlBin}))
|
|
|
|
{
|
|
|
|
$strLine =~ s/$self->{strPgSqlBin}/[PGSQL_BIN_PATH]/g;
|
|
|
|
}
|
|
|
|
|
2018-11-25 02:05:03 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'BACKREST-NAME-VERSION', '^' . PROJECT_NAME . ' ' . PROJECT_VERSION,
|
2015-10-08 17:43:56 +02:00
|
|
|
undef, false);
|
2016-09-17 17:53:28 +02:00
|
|
|
$strLine = $self->regExpReplace(
|
2018-11-25 02:05:03 +02:00
|
|
|
$strLine, 'BACKREST-VERSION', ' begin ' . PROJECT_VERSION . '\:', PROJECT_VERSION, false);
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, undef, '^docker exec -u [a-z]* test-[0-9]+\-', 'test-[0-9]+\-', false);
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'CONTAINER-EXEC', '^docker exec -u [a-z]*', '^docker exec -u [a-z]*', false);
|
|
|
|
|
2016-09-14 23:37:07 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'PROCESS-ID', 'sent term signal to process [0-9]+', '[0-9]+$', false);
|
2017-06-09 23:51:41 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'YEAR', 'backup\.history\/20[0-9]{2}', '20[0-9]{2}$');
|
2015-10-08 17:43:56 +02:00
|
|
|
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'BACKUP-INCR', '[0-9]{8}\-[0-9]{6}F\_[0-9]{8}\-[0-9]{6}I');
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'BACKUP-DIFF', '[0-9]{8}\-[0-9]{6}F\_[0-9]{8}\-[0-9]{6}D');
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'BACKUP-FULL', '[0-9]{8}\-[0-9]{6}F');
|
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
$strLine = $self->regExpReplace(
|
|
|
|
$strLine, 'BACKUP-EXPR', 'strExpression \= \_[0-9]{8}\-[0-9]{6}', '\_[0-9]{8}\-[0-9]{6}$', false);
|
|
|
|
|
2020-08-20 20:04:26 +02:00
|
|
|
if ($strLine =~ /^P00 DETAIL\: statistics\: /)
|
|
|
|
{
|
|
|
|
$strLine = 'P00 DETAIL: statistics: STATISTICS'
|
|
|
|
}
|
2019-06-18 16:13:28 +02:00
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'GROUP', 'strGroup = [^ \n,\[\]]+', '[^ \n,\[\]]+$');
|
2019-09-26 13:52:02 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'GROUP', 'unknown group in backup manifest mapped to \'[^\']+', '[^\']+$');
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'GROUP', 'group"[ ]{0,1}:[ ]{0,1}"[^"]+', '[^"]+$');
|
2017-02-21 15:59:23 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'GROUP', 'group=\"[^"]+', '[^"]+$');
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'GROUP', 'group for .* was not mapped to a name\, set to .+$', '[^ ]+$');
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'GROUP', 'set ownership [^\:]+:[^ ]+', '[^\:]+$');
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'GROUP', TEST_USER . '\, ' . TEST_GROUP, '[^ ]+$');
|
2016-10-01 19:39:44 +02:00
|
|
|
|
2017-11-21 19:57:00 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', 'strRemoteHostUser = [^ \n,\[\]]+', '[^ \n,\[\]]+$');
|
2019-09-26 13:52:02 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', 'unknown user in backup manifest mapped to \'[^\']+', '[^\']+$');
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', 'strUser = [^ \n,\[\]]+', '[^ \n,\[\]]+$');
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', 'user"[ ]{0,1}:[ ]{0,1}"[^"]+', '[^"]+$');
|
2016-10-01 19:39:44 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', 'user=\"[^"]+', '[^"]+$');
|
2018-02-04 01:27:38 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', '^pg-host-user=.+$', '[^=]+$');
|
2017-02-21 15:59:23 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', 'user for .* was not mapped to a name\, set to .+$', '[^ ]+$');
|
2016-10-01 19:39:44 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', 'set ownership [^\:]+', '[^ ]+$');
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', 'cannot be used for restore\, set to .+$', '[^ ]+$');
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', '-user=[a-z0-9_]+', '[^=]+$');
|
2020-06-16 20:06:38 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', '[^ ]+\@db\-primary', '^[^\@]+');
|
2016-12-04 00:34:51 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'USER', '[\( ]{1}' . TEST_USER . '[\,\)]{1}', TEST_USER);
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2020-11-23 19:41:54 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'EXEC-ID', '--exec-id=[^ ]+', '[^=]+$', false);
|
|
|
|
|
2017-11-06 19:51:12 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'CIPHER-PASS', '^cipher\-pass\=.+$', '[^\=]+$');
|
|
|
|
|
2016-12-10 21:05:28 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'PORT', 'db[1-9]{0,1}-port=[0-9]+', '[0-9]+$');
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# Replace year when it falls on a single line when executing ls -1R
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'YEAR', '^20[0-9]{2}$');
|
|
|
|
|
|
|
|
# Replace year when it is the last part of a path when executing ls -1R
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'YEAR', 'history\/20[0-9]{2}\:$', '20[0-9]{2}');
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
my $strTimestampRegExp = "[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-6][0-9]:[0-6][0-9]";
|
|
|
|
|
2016-02-02 21:33:15 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'TS_PATH', "PG\\_[0-9]\\.[0-9]\\_[0-9]{9}");
|
2019-04-19 03:26:02 +02:00
|
|
|
my $strProjectVersion = PROJECT_VERSION;
|
|
|
|
$strProjectVersion =~ s/\./\\./g;
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'VERSION',
|
2019-04-19 03:26:02 +02:00
|
|
|
"version[\"]{0,1}[ ]{0,1}[\:\=)]{1}[ ]{0,1}[\"]{0,1}" . $strProjectVersion, $strProjectVersion . '$');
|
2016-12-04 00:34:51 +02:00
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP', 'timestamp"[ ]{0,1}:[ ]{0,1}[0-9]{10}','[0-9]{10}$');
|
2016-12-04 00:34:51 +02:00
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP',
|
2017-06-09 23:51:41 +02:00
|
|
|
"timestamp-[a-z-]+[\"]{0,1}[ ]{0,1}[\:\=)]{1}[ ]{0,1}[\"]{0,1}[0-9]{10}", '[0-9]{10}$', false);
|
2016-12-04 00:34:51 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP', "start\" : [0-9]{10}", '[0-9]{10}$', false);
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP', "stop\" : [0-9]{10}", '[0-9]{10}$', false);
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP', TEST_GROUP . '\, [0-9]{10}', '[0-9]{10}$', false);
|
2019-10-01 19:20:43 +02:00
|
|
|
$strLine = $self->regExpReplace(
|
|
|
|
$strLine, 'TIMESTAMP', 'generated by pgBackRest restore on .*$',
|
|
|
|
'[0-9]{4}\-[0-9]{2}\-[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}$', false);
|
2016-12-04 00:34:51 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'SIZE', "size\"[ ]{0,1}:[ ]{0,1}[0-9]+", '[0-9]+$', false);
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'DELTA', "delta\"[ ]{0,1}:[ ]{0,1}[0-9]+", '[0-9]+$', false);
|
|
|
|
$strLine = $self->regExpReplace(
|
2017-02-05 17:31:29 +02:00
|
|
|
$strLine, 'TIMESTAMP-STR', "timestamp start\/stop: $strTimestampRegExp / $strTimestampRegExp",
|
2016-12-04 00:34:51 +02:00
|
|
|
"${strTimestampRegExp} / ${strTimestampRegExp}\$", false);
|
2015-10-08 17:43:56 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'CHECKSUM', 'checksum=[\"]{0,1}[0-f]{40}', '[0-f]{40}$', false);
|
|
|
|
|
2019-12-17 22:23:07 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'LOG-LEVEL-FILE', 'log-level-file=[a-z]+', '[a-z]+$', false);
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'LOG-SUBPROCESS', 'log-subprocess=[a-z]+', '[a-z]+$', false);
|
|
|
|
$strLine = $self->regExpReplace($strLine, '', ' --log-subprocess', undef, false);
|
|
|
|
$strLine = $self->regExpReplace($strLine, '', ' --no-log-subprocess', undef, false);
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'BUFFER-SIZE', 'buffer-size=[0-9a-z]+', '[0-9a-z]+$', false);
|
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'REMOTE-PROCESS-TERMINATED-MESSAGE',
|
2016-07-26 22:57:38 +02:00
|
|
|
'remote process terminated.*: (ssh.*|no output from terminated process)$',
|
2015-11-22 21:02:14 +02:00
|
|
|
'(ssh.*|no output from terminated process)$', false);
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
# Full test time-based recovery
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP-TARGET', "\\, target \\'.*UTC", "[^\\']+UTC\$");
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP-TARGET', " \\-\\-target\\=\\\".*UTC", "[^\\\"]+UTC\$");
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP-TARGET', "^recovery_target_time \\= \\'.*UTC", "[^\\']+UTC\$");
|
|
|
|
|
2020-01-30 23:38:05 +02:00
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP-TARGET', "\\, target \\'.*\\+00", "[^\\']+\\+00\$");
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP-TARGET', " \\-\\-target\\=\\\".*\\+00", "[^\\\"]+\\+00\$");
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'TIMESTAMP-TARGET', "^recovery_target_time \\= \\'.*\\+00", "[^\\']+\\+00\$");
|
|
|
|
|
2016-08-24 18:39:27 +02:00
|
|
|
# Full test xid-based recovery (this expressions only work when time-based expressions above have already been applied
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'XID-TARGET', "\\, target \\'[0-9]+", "[0-9]+\$");
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'XID-TARGET', " \\-\\-target\\=\\\"[0-9]+", "[0-9]+\$");
|
|
|
|
$strLine = $self->regExpReplace($strLine, 'XID-TARGET', "^recovery_target_xid \\= \\'[0-9]+", "[0-9]+\$");
|
|
|
|
|
2016-12-04 00:34:51 +02:00
|
|
|
$strLine = $self->regExpReplace(
|
|
|
|
$strLine, 'MODIFICATION-TIME', '(' . (substr(time(), 0, 5) - 1) . '[0-9]{5}|' . substr(time(), 0, 5) . '[0-9]{5})',
|
|
|
|
'^[0-9]{10}$');
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
return $strLine;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|