1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Test log mode is working.

This commit is contained in:
David Steele 2014-08-09 18:35:55 -04:00
parent 83d0db27d1
commit 09e2351ae8
6 changed files with 22 additions and 19 deletions

View File

@ -75,7 +75,7 @@ my $strType; # Type of backup: full, differential (diff), incremental
# Test parameters - not for general use
my $bNoFork = false; # Prevents the archive process from forking when local archiving is enabled
my $bTest = false; # Enters test mode - not harmful in anyway, but adds special logging and pauses for unit testing
my $iTestDelay = 2; # Amount of time to delay after hitting a test point (the default would not be enough for manual tests)
my $iTestDelay = 5; # Amount of time to delay after hitting a test point (the default would not be enough for manual tests)
GetOptions ("config=s" => \$strConfigFile,
"stanza=s" => \$strStanza,

View File

@ -1286,8 +1286,6 @@ sub backup
&log(DEBUG, "cluster path is $strDbClusterPath");
# Create the cluster backup path
# $oFile->path_create(PATH_BACKUP, "backup", undef, true);
# $oFile->path_create(PATH_BACKUP, "temp", undef, true);
$oFile->path_create(PATH_BACKUP_CLUSTER, undef, undef, true);
# Find the previous backup based on the type
@ -1394,7 +1392,7 @@ sub backup
# After the backup has been stopped, need to make a copy of the archive logs need to make the db consistent
&log(DEBUG, "retrieving archive logs ${strArchiveStart}:${strArchiveStop}");
my @stryArchive = archive_list_get($strArchiveStart, $strArchiveStop, $oDb->version_get() < 9.3);
my @stryArchive = archive_list_get($strArchiveStart, $strArchiveStop, $oDb->db_version_get() < 9.3);
foreach my $strArchive (@stryArchive)
{

View File

@ -104,7 +104,7 @@ sub tablespace_map_get
}
####################################################################################################################################
# VERSION_GET
# DB_VERSION_GET
####################################################################################################################################
sub db_version_get
{

View File

@ -72,7 +72,7 @@ use constant
# Test global variables
my $bTest = false;
my $iTestDelay = 2;
my $iTestDelay;
####################################################################################################################################
# VERSION_GET
@ -399,29 +399,31 @@ sub log
my $iCode = shift;
my $strMessageFormat = $strMessage;
my $iLogLevelRank = $oLogLevelRank{"${strLevel}"}{rank};
if ($bTest && $strLevel eq TEST)
if ($strLevel eq TEST)
{
$iLogLevelRank = $oLogLevelRank{TRACE}{rank} + 1;
$strMessageFormat = TEST_ENCLOSE . '-' . $strMessageFormat . '-' . TEST_ENCLOSE;
}
elsif (!defined($oLogLevelRank{"${strLevel}"}{rank}))
elsif (!defined($iLogLevelRank))
{
confess &log(ASSERT, "log level ${strLevel} does not exist");
}
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
if (!defined($strMessageFormat))
{
$strMessageFormat = "(undefined)";
}
if ($strLevel eq "TRACE")
if ($strLevel eq TRACE || $strLevel eq TEST)
{
$strMessageFormat =~ s/\n/\n /g;
$strMessageFormat = " " . $strMessageFormat;
}
elsif ($strLevel eq "DEBUG")
elsif ($strLevel eq DEBUG)
{
$strMessageFormat =~ s/\n/\n /g;
$strMessageFormat = " " . $strMessageFormat;
@ -436,13 +438,19 @@ sub log
(" " x (7 - length($strLevel))) . "${strLevel}: ${strMessageFormat}" .
(defined($iCode) ? " (code ${iCode})" : "") . "\n";
if ($oLogLevelRank{"${strLevel}"}{rank} <= $oLogLevelRank{"${strLogLevelConsole}"}{rank} ||
# if ($strLevel eq TEST)
# {
# confess "log level rank $iLogLevelRank";
# }
if ($iLogLevelRank <= $oLogLevelRank{"${strLogLevelConsole}"}{rank} ||
$bTest && $strLevel eq TEST)
{
print $strMessageFormat;
}
if ($oLogLevelRank{"${strLevel}"}{rank} <= $oLogLevelRank{"${strLogLevelFile}"}{rank})
if ($iLogLevelRank <= $oLogLevelRank{"${strLogLevelFile}"}{rank} ||
$bTest && $strLevel eq TEST)
{
if (defined($hLogFile))
{
@ -481,7 +489,6 @@ sub config_load
while (my $strLine = readline($hFile))
{
$strLine = trim($strLine);
# print "line:${strLine}\n";
if ($strLine ne '')
{
@ -489,7 +496,6 @@ sub config_load
if (index($strLine, '[') == 0)
{
$strSection = substr($strLine, 1, length($strLine) - 2);
# print "found section ${strSection}\n";
}
else
{
@ -504,8 +510,6 @@ sub config_load
my $strKey = substr($strLine, 0, $iIndex);
my $strValue = substr($strLine, $iIndex + 1);
# print "found key ${strKey}:${strValue}\n";
# Try to store value as JSON
eval
{

View File

@ -69,8 +69,9 @@ sub BackRestTestBackup_ClusterCreate
" --config=" . BackRestTestCommon_DbPathGet() . "/pg_backrest.conf archive-push %p";
BackRestTestCommon_Execute("initdb -D $strPath -A trust");
BackRestTestCommon_Execute("/Library/PostgreSQL/9.3/bin/pg_ctl start -o \"-c port=$iPort -c checkpoint_segments=1 " .
BackRestTestCommon_Execute("pg_ctl start -o \"-c port=$iPort -c checkpoint_segments=1 " .
"-c wal_level=archive -c archive_mode=on -c archive_command='$strArchive'\" " .
# "-c unix_socket_directories='" . BackRestTestCommon_DbCommonPathGet() . "'\" " .
"-D $strPath -l $strPath/postgresql.log -w -s");
}

View File

@ -142,7 +142,7 @@ sub BackRestTestCommon_Execute
if ($iExitStatus != 0 && !$bSuppressError)
{
confess &log(ERROR, "command '${strCommand}' returned " . $iExitStatus .
confess &log(ERROR, "command '${strCommand}' returned " . $iExitStatus . "\n" .
($strOutLog ne '' ? "STDOUT:\n${strOutLog}" : '') .
($strErrorLog ne '' ? "STDERR:\n${strErrorLog}" : ''));
}