mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Added tests for large files (16MB archive log).
Fixed a sync error in binary_xfer().
This commit is contained in:
parent
ed4bcf3e46
commit
375545320d
@ -389,6 +389,8 @@ sub binary_xfer_thread
|
||||
}
|
||||
|
||||
close($hOut);
|
||||
|
||||
$self->{oThreadResult}->enqueue('complete');
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,6 +432,7 @@ sub binary_xfer
|
||||
my $hPipeIn;
|
||||
my $hPipeOut;
|
||||
my $pId;
|
||||
my $bThreadRunning = false;
|
||||
|
||||
# Both the in and out streams must be defined
|
||||
if (!defined($hIn) || !defined($hOut))
|
||||
@ -461,8 +464,10 @@ sub binary_xfer
|
||||
# If any other message is returned then error
|
||||
else
|
||||
{
|
||||
confess "unknown thread message $strMessage";
|
||||
confess "unknown thread message while waiting for running: $strMessage";
|
||||
}
|
||||
|
||||
$bThreadRunning = true;
|
||||
}
|
||||
# Spawn a child process to do decompression
|
||||
elsif ($strRemote eq "in" && !$bDestinationCompress)
|
||||
@ -485,8 +490,10 @@ sub binary_xfer
|
||||
# If any other message is returned then error
|
||||
else
|
||||
{
|
||||
confess "unknown thread message $strMessage";
|
||||
confess "unknown thread message while waiting for running: $strMessage";
|
||||
}
|
||||
|
||||
$bThreadRunning = true;
|
||||
}
|
||||
|
||||
while (1)
|
||||
@ -569,14 +576,29 @@ sub binary_xfer
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure the de/compress pipes are closed
|
||||
if ($strRemote eq "out" && !$bSourceCompressed)
|
||||
if ($bThreadRunning)
|
||||
{
|
||||
close($hPipeOut);
|
||||
}
|
||||
elsif ($strRemote eq "in" && !$bDestinationCompress)
|
||||
{
|
||||
close($hPipeIn);
|
||||
# Make sure the de/compress pipes are closed
|
||||
if ($strRemote eq "out" && !$bSourceCompressed)
|
||||
{
|
||||
close($hPipeOut);
|
||||
}
|
||||
elsif ($strRemote eq "in" && !$bDestinationCompress)
|
||||
{
|
||||
close($hPipeIn);
|
||||
}
|
||||
|
||||
# Wait for the thread to acknowledge that it has completed
|
||||
my $strMessage = $self->{oThreadResult}->dequeue();
|
||||
|
||||
if ($strMessage eq 'complete')
|
||||
{
|
||||
}
|
||||
# If any other message is returned then error
|
||||
else
|
||||
{
|
||||
confess "unknown thread message while waiting for complete: $strMessage";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
test/data/test.archive.bin
Normal file
BIN
test/data/test.archive.bin
Normal file
Binary file not shown.
@ -26,9 +26,9 @@ our @EXPORT = qw(BackRestTestCommon_Setup BackRestTestCommon_Execute BackRestTes
|
||||
BackRestTestCommon_ConfigCreate
|
||||
BackRestTestCommon_StanzaGet BackRestTestCommon_CommandMainGet BackRestTestCommon_CommandRemoteGet
|
||||
BackRestTestCommon_HostGet BackRestTestCommon_UserGet BackRestTestCommon_GroupGet
|
||||
BackRestTestCommon_UserBackRestGet BackRestTestCommon_TestPathGet BackRestTestCommon_BackupPathGet
|
||||
BackRestTestCommon_ArchivePathGet BackRestTestCommon_DbPathGet BackRestTestCommon_DbCommonPathGet
|
||||
BackRestTestCommon_DbPortGet);
|
||||
BackRestTestCommon_UserBackRestGet BackRestTestCommon_TestPathGet BackRestTestCommon_DataPathGet
|
||||
BackRestTestCommon_BackupPathGet BackRestTestCommon_ArchivePathGet BackRestTestCommon_DbPathGet
|
||||
BackRestTestCommon_DbCommonPathGet BackRestTestCommon_DbPortGet);
|
||||
|
||||
my $strCommonStanza;
|
||||
my $strCommonCommandMain;
|
||||
@ -39,6 +39,7 @@ my $strCommonUser;
|
||||
my $strCommonGroup;
|
||||
my $strCommonUserBackRest;
|
||||
my $strCommonTestPath;
|
||||
my $strCommonDataPath;
|
||||
my $strCommonBackupPath;
|
||||
my $strCommonArchivePath;
|
||||
my $strCommonDbPath;
|
||||
@ -111,6 +112,7 @@ sub BackRestTestCommon_Setup
|
||||
$strCommonGroup = getgrgid($();
|
||||
$strCommonUserBackRest = 'backrest';
|
||||
$strCommonTestPath = dirname(abs_path($0)) . '/test';
|
||||
$strCommonDataPath = dirname(abs_path($0)) . '/data';
|
||||
$strCommonBackupPath = "${strCommonTestPath}/backrest";
|
||||
$strCommonArchivePath = "${strCommonTestPath}/archive";
|
||||
$strCommonDbPath = "${strCommonTestPath}/db";
|
||||
@ -159,6 +161,7 @@ sub BackRestTestCommon_ConfigCreate
|
||||
elsif ($strLocal eq REMOTE_DB)
|
||||
{
|
||||
$oParamHash{'global:log'}{'level-console'} = 'trace';
|
||||
$oParamHash{'global:backup'}{compress} = 'n';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -168,6 +171,7 @@ sub BackRestTestCommon_ConfigCreate
|
||||
if ($bArchiveLocal)
|
||||
{
|
||||
$oParamHash{'global:archive'}{path} = BackRestTestCommon_ArchivePathGet();
|
||||
$oParamHash{'global:archive'}{compress} = 'n';
|
||||
}
|
||||
|
||||
$oParamHash{$strCommonStanza}{'path'} = $strCommonDbCommonPath;
|
||||
@ -250,6 +254,11 @@ sub BackRestTestCommon_TestPathGet
|
||||
return $strCommonTestPath;
|
||||
}
|
||||
|
||||
sub BackRestTestCommon_DataPathGet
|
||||
{
|
||||
return $strCommonDataPath;
|
||||
}
|
||||
|
||||
sub BackRestTestCommon_BackupPathGet
|
||||
{
|
||||
return $strCommonBackupPath;
|
||||
|
@ -95,8 +95,7 @@ sub BackRestTestFile_Test
|
||||
(
|
||||
strHost => $strHost,
|
||||
strUser => $strUser,
|
||||
strCommand => BackRestTestCommon_CommandRemoteGet(),
|
||||
iBlockSize => 2
|
||||
strCommand => BackRestTestCommon_CommandRemoteGet()
|
||||
);
|
||||
|
||||
#-------------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1028,7 +1027,7 @@ sub BackRestTestFile_Test
|
||||
strStanza => $strStanza,
|
||||
strBackupPath => $strTestPath,
|
||||
strRemote => $strRemote,
|
||||
oRemote => $bBackupRemote || $bDbRemote ? $oRemote : undef
|
||||
oRemote => defined($strRemote) ? $oRemote : undef
|
||||
);
|
||||
|
||||
# Loop through source compression
|
||||
@ -1043,11 +1042,14 @@ sub BackRestTestFile_Test
|
||||
# Loop through destination path types
|
||||
for (my $bDestinationPathType = 0; $bDestinationPathType <= 1; $bDestinationPathType++)
|
||||
{
|
||||
# Loop through source ignore/require
|
||||
for (my $bSourceIgnoreMissing = 0; $bSourceIgnoreMissing <= 1; $bSourceIgnoreMissing++)
|
||||
{
|
||||
# Loop through source missing/present
|
||||
for (my $bSourceMissing = 0; $bSourceMissing <= 1; $bSourceMissing++)
|
||||
{
|
||||
# Loop through source ignore/require
|
||||
for (my $bSourceIgnoreMissing = 0; $bSourceIgnoreMissing <= 1; $bSourceIgnoreMissing++)
|
||||
# Loop through small/large
|
||||
for (my $bLarge = false; $bLarge <= defined($strRemote) && !$bSourceMissing; $bLarge++)
|
||||
{
|
||||
my $strSourcePathType = $bSourcePathType ? PATH_DB_ABSOLUTE : PATH_BACKUP_ABSOLUTE;
|
||||
my $strSourcePath = $bSourcePathType ? "db" : "backup";
|
||||
@ -1062,7 +1064,9 @@ sub BackRestTestFile_Test
|
||||
next;
|
||||
}
|
||||
|
||||
&log(INFO, "run ${iRun} - " .
|
||||
&log(INFO, "run ${iRun} - rmt " .
|
||||
(defined($strRemote) && ($strRemote eq $strSourcePath || $strRemote eq $strDestinationPath) ? 1 : 0) .
|
||||
", lrg ${bLarge}, " .
|
||||
"srcpth " . (defined($strRemote) && $strRemote eq $strSourcePath ? "remote" : "local") .
|
||||
":${strSourcePath}, srccmp $bSourceCompressed, srcmiss ${bSourceMissing}, " .
|
||||
"srcignmiss ${bSourceIgnoreMissing}, " .
|
||||
@ -1074,15 +1078,29 @@ sub BackRestTestFile_Test
|
||||
system("mkdir ${strTestPath}/backup") == 0 or confess "Unable to create test/backup directory";
|
||||
system("mkdir ${strTestPath}/db") == 0 or confess "Unable to create test/db directory";
|
||||
|
||||
my $strSourceFile = "${strTestPath}/${strSourcePath}/test-source.txt";
|
||||
my $strDestinationFile = "${strTestPath}/${strDestinationPath}/test-destination.txt";
|
||||
my $strSourceFile = "${strTestPath}/${strSourcePath}/test-source";
|
||||
my $strDestinationFile = "${strTestPath}/${strDestinationPath}/test-destination";
|
||||
|
||||
# Create the compressed or uncompressed test file
|
||||
my $strSourceHash;
|
||||
|
||||
if (!$bSourceMissing)
|
||||
{
|
||||
system("echo 'TESTDATA' > ${strSourceFile}");
|
||||
if ($bLarge)
|
||||
{
|
||||
$strSourceFile .= ".bin";
|
||||
$strDestinationFile .= ".bin";
|
||||
|
||||
BackRestTestCommon_Execute('cp ' . BackRestTestCommon_DataPathGet() . "/test.archive.bin ${strSourceFile}");
|
||||
}
|
||||
else
|
||||
{
|
||||
$strSourceFile .= ".txt";
|
||||
$strDestinationFile .= ".txt";
|
||||
|
||||
system("echo 'TESTDATA' > ${strSourceFile}");
|
||||
}
|
||||
|
||||
$strSourceHash = $oFile->hash(PATH_ABSOLUTE, $strSourceFile);
|
||||
|
||||
if ($bSourceCompressed)
|
||||
@ -1154,22 +1172,17 @@ sub BackRestTestFile_Test
|
||||
confess "could not find destination file ${strDestinationFile}";
|
||||
}
|
||||
|
||||
my $strDestinationTest = $strDestinationFile;
|
||||
|
||||
if ($bDestinationCompress)
|
||||
{
|
||||
system("gzip -d ${strDestinationFile}") == 0 or die "could not decompress ${strDestinationFile}";
|
||||
$strDestinationFile = substr($strDestinationFile, 0, length($strDestinationFile) - 3);
|
||||
$strDestinationTest = substr($strDestinationFile, 0, length($strDestinationFile) - 3) . '.test';
|
||||
|
||||
system("gzip -dc ${strDestinationFile} > ${strDestinationTest}") == 0
|
||||
or die "could not decompress ${strDestinationFile}";
|
||||
}
|
||||
|
||||
my $strDestinationHash = $oFile->hash(PATH_ABSOLUTE, $strDestinationFile);
|
||||
|
||||
# !!!Not sure why this would fail the first time!!! Suspect it is because it is being written remotely and then
|
||||
# read locally. Change the hash function to work remotely once it can.
|
||||
if ($strSourceHash ne $strDestinationHash)
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
$strDestinationHash = $oFile->hash(PATH_ABSOLUTE, $strDestinationFile);
|
||||
my $strDestinationHash = $oFile->hash(PATH_ABSOLUTE, $strDestinationTest);
|
||||
|
||||
if ($strSourceHash ne $strDestinationHash)
|
||||
{
|
||||
@ -1181,11 +1194,10 @@ sub BackRestTestFile_Test
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BackRestTestFile_Setup(false, true);
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -61,9 +61,10 @@ BackRestTestCommon_Setup();
|
||||
####################################################################################################################################
|
||||
# Clean whitespace
|
||||
####################################################################################################################################
|
||||
BackRestTestCommon_Execute("find .. -type f -not -path \"../.git/*\" -not -path \"*.DS_Store\" " .
|
||||
BackRestTestCommon_Execute("find .. -type f -not -path \"../.git/*\" -not -path \"*.DS_Store\" -not -path \"../test/test/*\" " .
|
||||
"-not -path \"../test/data/*\" " .
|
||||
"-exec sh -c 'for i;do echo \"\$i\" && sed 's/[[:space:]]*\$//' \"\$i\">/tmp/.\$\$ && cat /tmp/.\$\$ " .
|
||||
"> \"\$i\";done' arg0 {} + > /dev/null");
|
||||
"> \"\$i\";done' arg0 {} + > /dev/null", false, true);
|
||||
|
||||
####################################################################################################################################
|
||||
# Make sure version number matches in README.md and VERSION
|
||||
|
Loading…
Reference in New Issue
Block a user