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

Remove mock integration tests.

These tests have not been maintained for several years, i.e. no tests for new features have been added. They are highly duplicative of the unit tests but do have the advantage of mixing in different storage drivers. They were allowed to remain because they were not doing any harm even if they were probably not doing any good.

However, the real integration tests (that run directly against PostgreSQL) also test storage drivers and have been updated with new features over time. The real integration tests are now being migrated to C and as part of that effort the mock integration tests need to be removed or migrated, and they do not provide enough value to migrate.

Remove all mock integration tests and a leftover Perl performance test.
This commit is contained in:
David Steele 2024-02-17 10:52:37 +13:00
parent 68351785f6
commit d41b21c8f7
9 changed files with 2 additions and 2209 deletions

View File

@ -358,7 +358,7 @@ pgbackrest/test/test.pl --vm-build --vm=u20
pgbackrest-dev => Run a Specific Test Run
```
pgbackrest/test/test.pl --vm=u20 --module=mock --test=archive --run=2
pgbackrest/test/test.pl --vm=u20 --module=postgres --test=interface --run=2
--- output ---

View File

@ -398,7 +398,7 @@ pgbackrest/doc/doc.pl --help
<title>Run a Specific Test Run</title>
<execute output="y">
<exe-cmd>pgbackrest/test/test.pl {[dash]}-vm=u20 {[dash]}-module=mock {[dash]}-test=archive {[dash]}-run=2</exe-cmd>
<exe-cmd>pgbackrest/test/test.pl {[dash]}-vm=u20 {[dash]}-module=postgres {[dash]}-test=interface {[dash]}-run=2</exe-cmd>
<exe-cmd-extra>{[test-cmd-extra]}</exe-cmd-extra>
</execute>
</execute-list>

View File

@ -1003,30 +1003,6 @@ unit:
# **********************************************************************************************************************************
integration:
# ********************************************************************************************************************************
- name: mock
test:
# ----------------------------------------------------------------------------------------------------------------------------
- name: stanza
total: 2
# ----------------------------------------------------------------------------------------------------------------------------
- name: expire
total: 2
# ----------------------------------------------------------------------------------------------------------------------------
- name: archive
total: 2
# ----------------------------------------------------------------------------------------------------------------------------
- name: archive-stop
total: 2
# ----------------------------------------------------------------------------------------------------------------------------
- name: all
total: 2
# ********************************************************************************************************************************
- name: real
db: true
@ -1048,11 +1024,6 @@ performance:
- name: performance
test:
# ----------------------------------------------------------------------------------------------------------------------------
- name: archive-perl
total: 1
binReq: true
# ----------------------------------------------------------------------------------------------------------------------------
- name: type
total: 6

File diff suppressed because it is too large Load Diff

View File

@ -1,142 +0,0 @@
####################################################################################################################################
# Tests for archive-push command to make sure aync queue limits are implemented correctly
####################################################################################################################################
package pgBackRestTest::Module::Mock::MockArchiveStopTest;
use parent 'pgBackRestTest::Env::HostEnvTest';
####################################################################################################################################
# Perl includes
####################################################################################################################################
use strict;
use warnings FATAL => qw(all);
use Carp qw(confess);
use File::Basename qw(dirname);
use pgBackRestDoc::Common::Exception;
use pgBackRestDoc::Common::Ini;
use pgBackRestDoc::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
####################################################################################################################################
sub run
{
my $self = shift;
# Generate test WAL file
my $strWalTestFile = $self->testPath() . '/test-wal-' . PG_VERSION_94;
my $strWalHash = $self->walGenerateContentChecksum(PG_VERSION_94);
storageTest()->put($strWalTestFile, $self->walGenerateContent(PG_VERSION_94));
foreach my $rhRun
(
{vm => VM2, remote => false, tls => false, storage => S3, encrypt => false, compress => NONE, error => 0},
{vm => VM2, remote => true, tls => true, storage => POSIX, encrypt => true, compress => NONE, error => 0},
{vm => VM3, remote => false, tls => false, storage => GCS, encrypt => true, compress => BZ2, error => 0},
{vm => VM3, remote => true, tls => false, storage => AZURE, encrypt => false, compress => LZ4, error => 1},
{vm => VM4, remote => false, tls => false, storage => S3, encrypt => true, compress => NONE, error => 0},
{vm => VM4, remote => true, tls => true, storage => GCS, encrypt => false, compress => ZST, error => 0},
)
{
# Only run tests for this vm
next if ($rhRun->{vm} ne vmTest($self->vm()));
# Increment the run, log, and decide whether this unit test should be run
my $bRemote = $rhRun->{remote};
my $bTls = $rhRun->{tls};
my $strStorage = $rhRun->{storage};
my $bEncrypt = $rhRun->{encrypt};
my $strCompressType = $rhRun->{compress};
my $iError = $rhRun->{error};
# Increment the run, log, and decide whether this unit test should be run
if (!$self->begin(
"rmt ${bRemote}, tls ${bTls}, cmp ${strCompressType}, error " . ($iError ? 'connect' : 'version') .
", storage ${strStorage}, enc ${bEncrypt}")) {next}
# Create hosts, file object, and config
my ($oHostDbPrimary, $oHostDbStandby, $oHostBackup) = $self->setup(
true,
{bHostBackup => $bRemote, bTls => $bTls, strCompressType => $strCompressType, bArchiveAsync => true,
strStorage => $strStorage, bRepoEncrypt => $bEncrypt});
# Create compression extension
my $strCompressExt = $strCompressType ne NONE ? ".${strCompressType}" : '';
# Create the wal path
my $strWalPath = $oHostDbPrimary->dbBasePath() . '/pg_xlog';
storageTest()->pathCreate($strWalPath, {bCreateParent => true});
# Create the test path for pg_control and generate pg_control for stanza-create
storageTest()->pathCreate($oHostDbPrimary->dbBasePath() . '/' . DB_PATH_GLOBAL, {bCreateParent => true});
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_94);
# Create the archive info file
$oHostBackup->stanzaCreate('create required data for stanza', {strOptionalParam => '--no-online'});
# Push a WAL segment
&log(INFO, ' push first WAL');
$oHostDbPrimary->archivePush($strWalPath, $strWalTestFile, 1);
# Break the database version of the archive info file
if ($iError == 0)
{
$oHostBackup->infoMunge(
$oHostBackup->repoArchivePath(ARCHIVE_INFO_FILE),
{&INFO_ARCHIVE_SECTION_DB => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'},
&INFO_ARCHIVE_SECTION_DB_HISTORY => {1 => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'}}});
}
# Push two more segments with errors to exceed archive-push-queue-max
&log(INFO, ' push second WAL');
$oHostDbPrimary->archivePush(
$strWalPath, $strWalTestFile, 2, ERROR_REPO_INVALID, undef, $iError ? '--repo1-host=bogus' : undef);
&log(INFO, ' push third WAL');
$oHostDbPrimary->archivePush(
$strWalPath, $strWalTestFile, 3, ERROR_REPO_INVALID, undef, $iError ? '--repo1-host=bogus' : undef);
# Now this segment will get dropped
&log(INFO, ' push fourth WAL');
$oHostDbPrimary->archivePush($strWalPath, $strWalTestFile, 4, undef, undef, '--repo1-host=bogus');
# Fix the database version
if ($iError == 0)
{
$oHostBackup->infoRestore($oHostBackup->repoArchivePath(ARCHIVE_INFO_FILE));
}
#---------------------------------------------------------------------------------------------------------------------------
$self->testResult(
sub {storageRepo()->list($oHostBackup->repoArchivePath(PG_VERSION_94 . '-1/0000000100000001'))},
"000000010000000100000001-${strWalHash}${strCompressExt}",
'segment 2-4 not pushed', {iWaitSeconds => 5});
#---------------------------------------------------------------------------------------------------------------------------
$oHostDbPrimary->archivePush($strWalPath, $strWalTestFile, 5);
$self->testResult(
sub {storageRepo()->list($oHostBackup->repoArchivePath(PG_VERSION_94 . '-1/0000000100000001'))},
"(000000010000000100000001-${strWalHash}${strCompressExt}, " .
"000000010000000100000005-${strWalHash}${strCompressExt})",
'segment 5 is pushed', {iWaitSeconds => 5});
}
}
1;

View File

@ -1,390 +0,0 @@
####################################################################################################################################
# Mock Archive Tests
####################################################################################################################################
package pgBackRestTest::Module::Mock::MockArchiveTest;
use parent 'pgBackRestTest::Env::HostEnvTest';
####################################################################################################################################
# Perl includes
####################################################################################################################################
use strict;
use warnings FATAL => qw(all);
use Carp qw(confess);
use File::Basename qw(dirname);
use pgBackRestDoc::Common::Exception;
use pgBackRestDoc::Common::Ini;
use pgBackRestDoc::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
#
# Check that a WAL segment is present in the repository.
####################################################################################################################################
sub archiveCheck
{
my $self = shift;
my $oHostBackup = shift;
my $strArchiveFile = shift;
my $strArchiveChecksum = shift;
my $strCompressType = shift;
my $strSpoolPath = shift;
# Build the archive name to check for at the destination
my $strArchiveCheck = $oHostBackup->repoArchivePath(
PG_VERSION_94 . "-1/" . substr($strArchiveFile, 0, 16) . "/${strArchiveFile}-${strArchiveChecksum}");
if (defined($strCompressType))
{
$strArchiveCheck .= ".${strCompressType}";
}
my $oWait = waitInit(5);
my $bFound = false;
do
{
$bFound = storageRepo()->exists($strArchiveCheck);
}
while (!$bFound && waitMore($oWait));
if (!$bFound)
{
confess "unable to find ${strArchiveCheck}";
}
if (defined($strSpoolPath))
{
storageTest()->remove("${strSpoolPath}/archive/" . $self->stanza() . "/out/${strArchiveFile}.ok");
}
}
####################################################################################################################################
# run
####################################################################################################################################
sub run
{
my $self = shift;
my $strArchiveChecksum = $self->walGenerateContentChecksum(PG_VERSION_94, {iSourceNo => 2});
foreach my $rhRun
(
{vm => VM2, remote => false, tls => false, storage => S3, encrypt => true, compress => BZ2},
{vm => VM2, remote => true, tls => false, storage => POSIX, encrypt => true, compress => BZ2},
{vm => VM3, remote => false, tls => false, storage => POSIX, encrypt => true, compress => LZ4},
{vm => VM3, remote => true, tls => true, storage => S3, encrypt => false, compress => ZST},
{vm => VM4, remote => false, tls => false, storage => AZURE, encrypt => true, compress => ZST},
{vm => VM4, remote => true, tls => true, storage => POSIX, encrypt => false, compress => GZ},
)
{
# Only run tests for this vm
next if ($rhRun->{vm} ne vmTest($self->vm()));
# Increment the run, log, and decide whether this unit test should be run
my $bRemote = $rhRun->{remote};
my $bTls = $rhRun->{tls};
my $strStorage = $rhRun->{storage};
my $bEncrypt = $rhRun->{encrypt};
my $strCompressType = $rhRun->{compress};
if (!$self->begin("rmt ${bRemote}, tls ${bTls}, storage ${strStorage}, enc ${bEncrypt}, cmp ${strCompressType}")) {next}
# Create hosts, file object, and config
my ($oHostDbPrimary, $oHostDbStandby, $oHostBackup) = $self->setup(
true,
{bHostBackup => $bRemote, bTls => $bTls, strStorage => $strStorage, bRepoEncrypt => $bEncrypt,
strCompressType => NONE});
# Reduce console logging to detail
$oHostDbPrimary->configUpdate({&CFGDEF_SECTION_GLOBAL => {'log-level-console' => lc(DETAIL)}});
# Create the wal path
my $strWalPath = $oHostDbPrimary->dbBasePath() . '/pg_xlog';
storageTest()->pathCreate($strWalPath, {bCreateParent => true});
# Generate pg_control for stanza-create
storageTest()->pathCreate($oHostDbPrimary->dbBasePath() . '/' . DB_PATH_GLOBAL, {bCreateParent => true});
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_94);
# Create archive-push command
my $strCommandPush =
$oHostDbPrimary->backrestExe() . ' --config=' . $oHostDbPrimary->backrestConfig() . ' --stanza=' . $self->stanza() .
' archive-push';
my $strCommandGet =
$oHostDbPrimary->backrestExe() . ' --config=' . $oHostDbPrimary->backrestConfig() . ' --stanza=' . $self->stanza() .
' archive-get';
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' archive.info missing');
my $strSourceFile1 = $self->walSegment(1, 1, 1);
storageTest()->pathCreate("${strWalPath}/archive_status");
my $strArchiveFile1 = $self->walGenerate($strWalPath, PG_VERSION_94, 1, $strSourceFile1);
$oHostDbPrimary->executeSimple(
$strCommandPush . " ${strWalPath}/${strSourceFile1}", {iExpectedExitStatus => ERROR_REPO_INVALID});
$oHostDbPrimary->executeSimple(
$strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG", {iExpectedExitStatus => ERROR_REPO_INVALID});
#---------------------------------------------------------------------------------------------------------------------------
$oHostBackup->stanzaCreate('stanza create', {strOptionalParam => '--no-online'});
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' push first WAL');
my @stryExpectedWAL;
my $strSourceFile = $self->walSegment(1, 1, 1);
my $strArchiveFile = $self->walGenerate($strWalPath, PG_VERSION_94, 2, $strSourceFile);
$oHostDbPrimary->executeSimple(
$strCommandPush . ($bRemote ? ' --cmd-ssh=/usr/bin/ssh' : '') .
" --compress-type=${strCompressType} ${strWalPath}/${strSourceFile}");
push(@stryExpectedWAL, "${strSourceFile}-${strArchiveChecksum}.${strCompressType}");
# Test that the WAL was pushed
$self->archiveCheck($oHostBackup, $strSourceFile, $strArchiveChecksum, $strCompressType);
# Remove from archive_status
storageTest()->remove("${strWalPath}/archive_status/${strSourceFile}.ready");
# Remove WAL
storageTest()->remove("${strWalPath}/${strSourceFile}", {bIgnoreMissing => false});
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' get missing WAL');
$oHostDbPrimary->executeSimple(
$strCommandGet . " 700000007000000070000000 ${strWalPath}/RECOVERYXLOG", {iExpectedExitStatus => 1});
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' get first WAL');
$oHostDbPrimary->executeSimple(
$strCommandGet . " ${strSourceFile} ${strWalPath}/RECOVERYXLOG");
# Check that the destination file exists
if (storageTest()->exists("${strWalPath}/RECOVERYXLOG"))
{
my ($strActualChecksum) = storageTest()->hashSize("${strWalPath}/RECOVERYXLOG");
if ($strActualChecksum ne $strArchiveChecksum)
{
confess "recovered file hash '${strActualChecksum}' does not match expected '${strArchiveChecksum}'";
}
}
else
{
confess "archive file '${strWalPath}/RECOVERYXLOG' is not in destination";
}
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' push second WAL');
# Generate second WAL segment
$strSourceFile = $self->walSegment(1, 1, 2);
$strArchiveFile = $self->walGenerate($strWalPath, PG_VERSION_94, 2, $strSourceFile);
# Create a temp file to make sure it is deleted later (skip when S3 since it doesn't use temp files)
my $strArchiveTmp;
if ($strStorage eq POSIX)
{
# Should succeed when temp file already exists
&log(INFO, ' succeed when tmp WAL file exists');
$strArchiveTmp =
$oHostBackup->repoPath() . '/archive/' . $self->stanza() . '/' . PG_VERSION_94 . '-1/' .
substr($strSourceFile, 0, 16) . "/${strSourceFile}-${strArchiveChecksum}.${strCompressType}" . qw{.} .
STORAGE_TEMP_EXT;
storageTest()->put($strArchiveTmp, 'JUNK');
}
# Push the WAL
$oHostDbPrimary->executeSimple(
"${strCommandPush} --compress-type=${strCompressType} --archive-async --process-max=2 ${strWalPath}/${strSourceFile}");
push(@stryExpectedWAL, "${strSourceFile}-${strArchiveChecksum}.${strCompressType}");
# Make sure the temp file no longer exists if it was created
if (defined($strArchiveTmp))
{
my $oWait = waitInit(5);
my $bFound = true;
do
{
$bFound = storageTest()->exists($strArchiveTmp);
}
while ($bFound && waitMore($oWait));
if ($bFound)
{
confess "${strArchiveTmp} should have been removed by archive command";
}
}
# Test that the WAL was pushed
$self->archiveCheck($oHostBackup, $strSourceFile, $strArchiveChecksum, $strCompressType, $oHostDbPrimary->spoolPath());
# Remove from archive_status
storageTest()->remove("${strWalPath}/archive_status/${strSourceFile}.ready");
# Remove from spool
storageTest()->remove($oHostDbPrimary->spoolPath() . '/archive/' . $self->stanza() . "/out/${strSourceFile}.ok");
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' push history file');
storageTest()->put("${strWalPath}/00000002.history", 'HISTORYDATA');
storageTest()->put("${strWalPath}/archive_status/00000002.history.ready", undef);
$oHostDbPrimary->executeSimple("${strCommandPush} --archive-async ${strWalPath}/00000002.history");
if (!storageRepo()->exists($oHostBackup->repoArchivePath(PG_VERSION_94 . '-1/00000002.history')))
{
confess 'unable to find history file in archive';
}
storageTest()->remove("${strWalPath}/archive_status/00000002.history.ready");
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' db version mismatch error - archive-get unable to retrieve archiveId');
# db section and corresponding history munged
$oHostBackup->infoMunge(
$oHostBackup->repoArchivePath(ARCHIVE_INFO_FILE),
{&INFO_ARCHIVE_SECTION_DB_HISTORY => {'1' => {&INFO_ARCHIVE_KEY_DB_VERSION => '8.0'}}});
$oHostDbPrimary->executeSimple(
$strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG", {iExpectedExitStatus => ERROR_REPO_INVALID});
# Restore the file to its original condition
$oHostBackup->infoRestore($oHostBackup->repoArchivePath(ARCHIVE_INFO_FILE));
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' db system-id mismatch error');
$oHostBackup->infoMunge(
$oHostBackup->repoArchivePath(ARCHIVE_INFO_FILE),
{&INFO_ARCHIVE_SECTION_DB => {&INFO_BACKUP_KEY_SYSTEM_ID => 5000900090001855000},
&INFO_ARCHIVE_SECTION_DB_HISTORY => {'1' => {&INFO_ARCHIVE_KEY_DB_ID => 5000900090001855000}}});
$oHostDbPrimary->executeSimple(
$strCommandPush . " ${strWalPath}/${strSourceFile}", {iExpectedExitStatus => ERROR_REPO_INVALID});
$oHostDbPrimary->executeSimple(
$strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG", {iExpectedExitStatus => ERROR_REPO_INVALID});
# Restore the file to its original condition
$oHostBackup->infoRestore($oHostBackup->repoArchivePath(ARCHIVE_INFO_FILE));
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' stop');
$oHostDbPrimary->stop({strStanza => $oHostDbPrimary->stanza()});
$oHostDbPrimary->executeSimple($strCommandPush . " ${strWalPath}/${strSourceFile}", {iExpectedExitStatus => ERROR_STOP});
$oHostDbPrimary->executeSimple($strCommandGet . " ${strSourceFile1} ${strWalPath}/RECOVERYXLOG");
$oHostDbPrimary->start({strStanza => $oHostDbPrimary->stanza()});
storageTest->remove("${strWalPath}/RECOVERYXLOG", {bIgnoreMissing => false});
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' WAL duplicate ok');
$oHostDbPrimary->executeSimple($strCommandPush . " ${strWalPath}/${strSourceFile}");
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' WAL duplicate error');
$strArchiveFile = $self->walGenerate($strWalPath, PG_VERSION_94, 1, $strSourceFile);
$oHostDbPrimary->executeSimple(
$strCommandPush . " ${strWalPath}/${strSourceFile}", {iExpectedExitStatus => ERROR_ARCHIVE_DUPLICATE});
# Remove WAL
storageTest()->remove("${strWalPath}/${strSourceFile}", {bIgnoreMissing => false});
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, " get second WAL (${strSourceFile})");
$oHostDbPrimary->executeSimple(
$strCommandGet . ($bRemote ? ' --cmd-ssh=/usr/bin/ssh' : '') . " --archive-async" .
($strStorage eq POSIX ? " --repo-type=cifs" : '') . " ${strSourceFile} ${strWalPath}/RECOVERYXLOG");
# Check that the destination file exists
if (storageTest()->exists("${strWalPath}/RECOVERYXLOG"))
{
my ($strActualChecksum) = storageTest()->hashSize("${strWalPath}/RECOVERYXLOG");
if ($strActualChecksum ne $strArchiveChecksum)
{
confess "recovered file hash '${strActualChecksum}' does not match expected '${strArchiveChecksum}'";
}
}
else
{
confess "archive file '${strWalPath}/RECOVERYXLOG' is not in destination";
}
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, " get history file");
$oHostDbPrimary->executeSimple(
$strCommandGet . " --archive-async 00000001.history ${strWalPath}/00000001.history", {iExpectedExitStatus => 1});
$oHostDbPrimary->executeSimple($strCommandGet . " --archive-async 00000002.history ${strWalPath}/00000002.history");
if (${storageTest()->get("${strWalPath}/00000002.history")} ne 'HISTORYDATA')
{
confess 'history contents do not match original';
}
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' .partial WAL');
$strArchiveFile = $self->walGenerate($strWalPath, PG_VERSION_94, 2, "${strSourceFile}.partial");
$oHostDbPrimary->executeSimple($strCommandPush . " ${strWalPath}/${strSourceFile}.partial");
$self->archiveCheck($oHostBackup, "${strSourceFile}.partial", $strArchiveChecksum);
push(@stryExpectedWAL, "${strSourceFile}.partial-${strArchiveChecksum}");
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' .partial WAL duplicate');
$oHostDbPrimary->executeSimple($strCommandPush . " ${strWalPath}/${strSourceFile}.partial");
$self->archiveCheck($oHostBackup, "${strSourceFile}.partial", $strArchiveChecksum);
#---------------------------------------------------------------------------------------------------------------------------
&log(INFO, ' .partial WAL with different checksum');
$strArchiveFile = $self->walGenerate($strWalPath, PG_VERSION_94, 1, "${strSourceFile}.partial");
$oHostDbPrimary->executeSimple(
$strCommandPush . " ${strWalPath}/${strSourceFile}.partial", {iExpectedExitStatus => ERROR_ARCHIVE_DUPLICATE});
#---------------------------------------------------------------------------------------------------------------------------
$self->testResult(
sub {storageRepo()->list($oHostBackup->repoArchivePath(PG_VERSION_94 . '-1/0000000100000001'))},
'(' . join(', ', @stryExpectedWAL) . ')',
'all WAL in archive', {iWaitSeconds => 5});
}
}
1;

View File

@ -1,205 +0,0 @@
####################################################################################################################################
# Tests for expire command
####################################################################################################################################
package pgBackRestTest::Module::Mock::MockExpireTest;
use parent 'pgBackRestTest::Env::HostEnvTest';
####################################################################################################################################
# Perl includes
####################################################################################################################################
use strict;
use warnings FATAL => qw(all);
use Carp qw(confess);
use File::Basename qw(dirname);
use Storable qw(dclone);
use pgBackRestDoc::Common::Exception;
use pgBackRestDoc::Common::Ini;
use pgBackRestDoc::Common::Log;
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
####################################################################################################################################
sub run
{
my $self = shift;
use constant SECONDS_PER_DAY => 86400;
my $lBaseTime = time() - (SECONDS_PER_DAY * 56);
my $strDescription;
foreach my $rhRun
(
{vm => VM2, storage => S3, encrypt => true},
{vm => VM3, storage => POSIX, encrypt => false},
{vm => VM4, storage => AZURE, encrypt => true},
)
{
# Only run tests for this vm
next if ($rhRun->{vm} ne vmTest($self->vm()));
# Increment the run, log, and decide whether this unit test should be run
my $strStorage = $rhRun->{storage};
my $bEncrypt = $rhRun->{encrypt};
############################################################################################################################
if ($self->begin("simple, enc ${bEncrypt}, storage ${strStorage}"))
{
# Create hosts, file object, and config
my ($oHostDbPrimary, $oHostDbStandby, $oHostBackup) = $self->setup(
true, {strStorage => $strStorage, bRepoEncrypt => $bEncrypt});
# Create the test object
my $oExpireTest = new pgBackRestTest::Env::ExpireEnvTest(
$oHostBackup, $self->backrestExe(), storageRepo(), $oHostDbPrimary->dbPath(), $self);
$oExpireTest->stanzaCreate($self->stanza(), PG_VERSION_96);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Nothing to expire';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_INCR, $lBaseTime += SECONDS_PER_DAY, 246);
$oExpireTest->process($self->stanza(), 1, 1, CFGOPTVAL_BACKUP_TYPE_FULL, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire oldest full backup, archive expire falls on segment major boundary';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), 1, 1, CFGOPTVAL_BACKUP_TYPE_FULL, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire oldest full backup';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY, 256);
$oExpireTest->process($self->stanza(), 1, 1, CFGOPTVAL_BACKUP_TYPE_FULL, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire oldest diff backup, archive expire does not fall on major segment boundary';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY, undef, 0);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_INCR, $lBaseTime += SECONDS_PER_DAY, undef, 0);
$oExpireTest->process($self->stanza(), 1, 1, CFGOPTVAL_BACKUP_TYPE_DIFF, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire oldest diff backup (cascade to incr)';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), 1, 1, CFGOPTVAL_BACKUP_TYPE_DIFF, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire archive based on newest incr backup';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_INCR, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), 1, 1, CFGOPTVAL_BACKUP_TYPE_INCR, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire diff treating full as diff';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), 2, 1, CFGOPTVAL_BACKUP_TYPE_DIFF, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire diff with repo-retention-archive with warning repo-retention-diff not set';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), undef, undef, CFGOPTVAL_BACKUP_TYPE_DIFF, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire full with repo-retention-archive with warning repo-retention-full not set';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), undef, undef, CFGOPTVAL_BACKUP_TYPE_FULL, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire no archive with warning since repo-retention-archive not set for INCR';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_INCR, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), 1, 1, CFGOPTVAL_BACKUP_TYPE_INCR, undef, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire no archive with warning since neither repo-retention-archive nor repo-retention-diff is set';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), undef, undef, CFGOPTVAL_BACKUP_TYPE_DIFF, undef, $strDescription);
}
############################################################################################################################
if ($self->begin("stanzaUpgrade, enc ${bEncrypt}, storage ${strStorage}"))
{
# Create hosts, file object, and config
my ($oHostDbPrimary, $oHostDbStandby, $oHostBackup) = $self->setup(
true, {strStorage => $strStorage, bRepoEncrypt => $bEncrypt});
# Create the test object
my $oExpireTest = new pgBackRestTest::Env::ExpireEnvTest(
$oHostBackup, $self->backrestExe(), storageRepo(), $oHostDbPrimary->dbPath(), $self);
$oExpireTest->stanzaCreate($self->stanza(), PG_VERSION_96);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Create backups in current db version';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_INCR, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), undef, undef, CFGOPTVAL_BACKUP_TYPE_DIFF, undef, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Upgrade stanza and expire only earliest db backup and archive';
$oExpireTest->stanzaUpgrade($self->stanza(), PG_VERSION_94);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_INCR, $lBaseTime += SECONDS_PER_DAY, 246);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_DIFF, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), 3, undef, CFGOPTVAL_BACKUP_TYPE_FULL, undef, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Upgrade the stanza, create full back - earliest db orphaned archive removed and earliest full backup ' .
'and archive in previous db version removed';
$oExpireTest->stanzaUpgrade($self->stanza(), PG_VERSION_10);
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), 2, undef, CFGOPTVAL_BACKUP_TYPE_FULL, undef, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire all archive last full backup through pitr';
$oExpireTest->backupCreate($self->stanza(), CFGOPTVAL_BACKUP_TYPE_FULL, $lBaseTime += SECONDS_PER_DAY);
$oExpireTest->process($self->stanza(), 3, 1, CFGOPTVAL_BACKUP_TYPE_DIFF, 1, $strDescription);
#-----------------------------------------------------------------------------------------------------------------------
$strDescription = 'Expire all archive except for the current database';
$oExpireTest->process($self->stanza(), 2, undef, CFGOPTVAL_BACKUP_TYPE_FULL, undef, $strDescription);
}
}
}
1;

View File

@ -1,249 +0,0 @@
####################################################################################################################################
# Mock Stanza Module Tests
####################################################################################################################################
package pgBackRestTest::Module::Mock::MockStanzaTest;
use parent 'pgBackRestTest::Env::HostEnvTest';
####################################################################################################################################
# Perl includes
####################################################################################################################################
use strict;
use warnings FATAL => qw(all);
use Carp qw(confess);
use File::Basename qw(dirname);
use pgBackRestDoc::Common::Exception;
use pgBackRestDoc::Common::Ini;
use pgBackRestDoc::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
####################################################################################################################################
sub run
{
my $self = shift;
foreach my $rhRun
(
{vm => VM2, remote => false, tls => false, storage => AZURE, encrypt => true, compress => BZ2},
{vm => VM2, remote => true, tls => true, storage => POSIX, encrypt => false, compress => GZ},
{vm => VM3, remote => false, tls => false, storage => GCS, encrypt => false, compress => ZST},
{vm => VM3, remote => true, tls => true, storage => AZURE, encrypt => true, compress => LZ4},
{vm => VM4, remote => false, tls => false, storage => S3, encrypt => false, compress => GZ},
{vm => VM4, remote => true, tls => false, storage => GCS, encrypt => true, compress => ZST},
)
{
# Only run tests for this vm
next if ($rhRun->{vm} ne vmTest($self->vm()));
# Increment the run, log, and decide whether this unit test should be run
my $bRemote = $rhRun->{remote};
my $bTls = $rhRun->{tls};
my $strStorage = $rhRun->{storage};
my $bEncrypt = $rhRun->{encrypt};
my $strCompressType = $rhRun->{compress};
# Increment the run, log, and decide whether this unit test should be run
if (!$self->begin("remote ${bRemote}, tls ${bTls}, storage ${strStorage}, enc ${bEncrypt}, cmp ${strCompressType}")) {next}
# Create hosts, file object, and config
my ($oHostDbPrimary, $oHostDbStandby, $oHostBackup) = $self->setup(
true,
{bHostBackup => $bRemote, bTls => $bTls, strStorage => $strStorage, bRepoEncrypt => $bEncrypt,
strCompressType => $strCompressType});
# Archive and backup info file names
my $strArchiveInfoFile = $oHostBackup->repoArchivePath(ARCHIVE_INFO_FILE);
my $strArchiveInfoCopyFile = $oHostBackup->repoArchivePath(ARCHIVE_INFO_FILE . INI_COPY_EXT);
my $strArchiveInfoOldFile = "${strArchiveInfoFile}.old";
my $strArchiveInfoCopyOldFile = "${strArchiveInfoCopyFile}.old";
my $strBackupInfoFile = $oHostBackup->repoBackupPath(FILE_BACKUP_INFO);
my $strBackupInfoCopyFile = $oHostBackup->repoBackupPath(FILE_BACKUP_INFO . INI_COPY_EXT);
my $strBackupInfoOldFile = "${strBackupInfoFile}.old";
my $strBackupInfoCopyOldFile = "${strBackupInfoCopyFile}.old";
# Create the stanza
$oHostBackup->stanzaCreate('fail on missing control file', {iExpectedExitStatus => ERROR_FILE_MISSING,
strOptionalParam => '--no-online --log-level-file=info'});
# Generate pg_control for stanza-create
storageTest()->pathCreate(($oHostDbPrimary->dbBasePath() . '/' . DB_PATH_GLOBAL), {bCreateParent => true});
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_94);
# Fail stanza upgrade before stanza-create has been performed
#--------------------------------------------------------------------------------------------------------------------------
$oHostBackup->stanzaUpgrade('fail on stanza not initialized since archive.info is missing',
{iExpectedExitStatus => ERROR_FILE_MISSING, strOptionalParam => '--no-online'});
# Create the stanza successfully without force - run from the db server to ensure ability to run remotely
#--------------------------------------------------------------------------------------------------------------------------
$oHostDbPrimary->stanzaCreate('successfully create the stanza', {strOptionalParam => '--no-online'});
# Rerun stanza-create and confirm it does not fail
#--------------------------------------------------------------------------------------------------------------------------
$oHostDbPrimary->stanzaCreate(
'do not fail on rerun of stanza-create - info files exist and DB section ok',
{strOptionalParam => '--no-online'});
# Stanza Create fails when not using force - database mismatch with pg_control file
#--------------------------------------------------------------------------------------------------------------------------
# Change the database version by copying a new pg_control file
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_95);
$oHostBackup->stanzaCreate('fail on database mismatch and warn force option deprecated',
{iExpectedExitStatus => ERROR_FILE_INVALID, strOptionalParam => '--no-online --force'});
# Restore pg_control
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_94);
# Perform a stanza upgrade which will indicate already up to date
#--------------------------------------------------------------------------------------------------------------------------
$oHostBackup->stanzaUpgrade('already up to date', {strOptionalParam => '--no-online'});
# Create the wal path
my $strWalPath = $oHostDbPrimary->dbBasePath() . '/pg_xlog';
storageTest()->pathCreate("${strWalPath}/archive_status", {bCreateParent => true});
# Stanza Create fails - missing archive.info from non-empty archive dir
#--------------------------------------------------------------------------------------------------------------------------
# Generate WAL then push to get valid archive data in the archive directory
my $strArchiveFile = $self->walSegment(1, 1, 1);
my $strSourceFile = $self->walGenerate($strWalPath, PG_VERSION_94, 1, $strArchiveFile);
my $strCommand = $oHostDbPrimary->backrestExe() . ' --config=' . $oHostDbPrimary->backrestConfig() .
' --stanza=db archive-push';
$oHostDbPrimary->executeSimple($strCommand . " ${strSourceFile}");
# With data existing in the archive dir, move the info files and confirm failure
forceStorageMove(storageRepo(), $strArchiveInfoFile, $strArchiveInfoOldFile, {bRecurse => false});
forceStorageMove(storageRepo(), $strArchiveInfoCopyFile, $strArchiveInfoCopyOldFile, {bRecurse => false});
if (!$bEncrypt)
{
$oHostBackup->stanzaCreate('fail on archive info file missing from non-empty dir',
{iExpectedExitStatus => ERROR_FILE_MISSING, strOptionalParam => '--no-online'});
}
# Restore info files from copy
forceStorageMove(storageRepo(), $strArchiveInfoOldFile, $strArchiveInfoFile, {bRecurse => false});
forceStorageMove(storageRepo(), $strArchiveInfoCopyOldFile, $strArchiveInfoCopyFile, {bRecurse => false});
# Just before upgrading push one last WAL on the old version to ensure it can be retrieved later
#--------------------------------------------------------------------------------------------------------------------------
$strArchiveFile = $self->walSegment(1, 1, 2);
$strSourceFile = $self->walGenerate($strWalPath, PG_VERSION_94, 1, $strArchiveFile);
$oHostDbPrimary->executeSimple($strCommand . " ${strSourceFile}");
# Fail on archive push due to mismatch of DB since stanza not upgraded
#--------------------------------------------------------------------------------------------------------------------------
my $strArchiveTestFile = $self->testPath() . '/test-wal';
storageTest()->put($strArchiveTestFile, $self->walGenerateContent(PG_VERSION_95));
# Upgrade the DB by copying new pg_control
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_95);
forceStorageMode(storageTest(), $oHostDbPrimary->dbBasePath() . '/' . DB_FILE_PGCONTROL, '600');
# Fail on attempt to push an archive
$oHostDbPrimary->archivePush($strWalPath, $strArchiveTestFile, 1, ERROR_REPO_INVALID);
# Perform a successful stanza upgrade noting additional history lines in info files for new version of the database
#--------------------------------------------------------------------------------------------------------------------------
# Save a pre-upgrade copy of archive info for testing db-id mismatch
forceStorageMove(storageRepo(), $strArchiveInfoCopyFile, $strArchiveInfoCopyOldFile, {bRecurse => false});
$oHostBackup->stanzaUpgrade('successful upgrade creates additional history', {strOptionalParam => '--no-online'});
# Make sure that WAL from the old version can still be retrieved
#--------------------------------------------------------------------------------------------------------------------------
# Generate the old pg_control so it looks like the original db has been restored
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_94);
# Attempt to get the last archive log that was pushed to this repo
$oHostDbPrimary->executeSimple(
$oHostDbPrimary->backrestExe() . ' --config=' . $oHostDbPrimary->backrestConfig() .
" --stanza=db archive-get ${strArchiveFile} " . $oHostDbPrimary->dbBasePath() . '/pg_xlog/RECOVERYXLOG');
# Copy the new pg_control back so the tests can continue with the upgraded stanza
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_95);
forceStorageMode(storageTest(), $oHostDbPrimary->dbBasePath() . '/' . DB_FILE_PGCONTROL, '600');
# After stanza upgrade, make sure archives are pushed to the new db verion-id directory (9.4-2)
#--------------------------------------------------------------------------------------------------------------------------
# Push a WAL segment so have a valid file in the latest DB archive dir only
$oHostDbPrimary->archivePush($strWalPath, $strArchiveTestFile, 1);
$self->testResult(
sub {storageRepo()->list($oHostBackup->repoArchivePath(PG_VERSION_95 . '-2/0000000100000001'))},
'000000010000000100000001-' . $self->walGenerateContentChecksum(PG_VERSION_95) . ".${strCompressType}",
'check that WAL is in the archive at -2');
# Create the tablespace directory and perform a backup
#--------------------------------------------------------------------------------------------------------------------------
storageTest()->pathCreate($oHostDbPrimary->dbBasePath() . '/' . DB_PATH_PGTBLSPC);
$oHostBackup->backup(
'full', 'create first full backup ', {strOptionalParam => '--repo1-retention-full=2 --no-online'}, false);
# Upgrade the stanza
#--------------------------------------------------------------------------------------------------------------------------
# Copy pg_control for 9.6
$self->controlGenerate($oHostDbPrimary->dbBasePath(), PG_VERSION_96);
forceStorageMode(storageTest(), $oHostDbPrimary->dbBasePath() . '/' . DB_FILE_PGCONTROL, '600');
# Run from the db server to ensure ability to run remotely
$oHostDbPrimary->stanzaUpgrade('successfully upgrade', {strOptionalParam => '--no-online'});
# Copy archive.info and restore really old version
forceStorageMove(storageRepo(), $strArchiveInfoFile, $strArchiveInfoOldFile, {bRecurse => false});
forceStorageRemove(storageRepo(), $strArchiveInfoCopyFile, {bRecurse => false});
forceStorageMove(storageRepo(), $strArchiveInfoCopyOldFile, $strArchiveInfoFile, {bRecurse => false});
# Confirm versions
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_94)}, true, 'archive at old pg version');
$self->testResult(sub {$oBackupInfo->test(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_DB_VERSION, undef,
PG_VERSION_96)}, true, 'backup at new pg version');
$oHostBackup->stanzaUpgrade(
'upgrade fails with mismatched db-ids', {iExpectedExitStatus => ERROR_FILE_INVALID, strOptionalParam => '--no-online'});
# Restore archive.info
forceStorageMove(storageRepo(), $strArchiveInfoOldFile, $strArchiveInfoFile, {bRecurse => false});
# Push a WAL and create a backup in the new DB to confirm diff changed to full
#--------------------------------------------------------------------------------------------------------------------------
storageTest()->put($strArchiveTestFile, $self->walGenerateContent(PG_VERSION_96));
$oHostDbPrimary->archivePush($strWalPath, $strArchiveTestFile, 1);
# Test backup is changed from type=DIFF to FULL (WARN message displayed)
my $oExecuteBackup = $oHostBackup->backupBegin(
'diff', 'diff changed to full backup', {strOptionalParam => '--repo1-retention-full=2 --no-online'});
$oHostBackup->backupEnd('full', $oExecuteBackup, undef, false);
# Delete the stanza
#--------------------------------------------------------------------------------------------------------------------------
$oHostDbPrimary->stanzaDelete('fail on missing stop file', {iExpectedExitStatus => ERROR_FILE_MISSING});
$oHostDbPrimary->stop({strStanza => $self->stanza()});
$oHostDbPrimary->stanzaDelete('successfully delete the stanza');
}
}
1;

View File

@ -1,81 +0,0 @@
####################################################################################################################################
# Archive Performance Tests
####################################################################################################################################
package pgBackRestTest::Module::Performance::PerformanceArchivePerlTest;
use parent 'pgBackRestTest::Common::RunTest';
####################################################################################################################################
# Perl includes
####################################################################################################################################
use strict;
use warnings FATAL => qw(all);
use Carp qw(confess);
use English '-no_match_vars';
use Storable qw(dclone);
use Time::HiRes qw(gettimeofday);
use pgBackRestDoc::Common::Log;
use pgBackRestTest::Common::ExecuteTest;
use pgBackRestTest::Common::RunTest;
####################################################################################################################################
# initModule
####################################################################################################################################
sub initModule
{
my $self = shift;
$self->{strSpoolPath} = $self->testPath() . '/spool';
$self->{strLogPath} = $self->testPath() . '/log';
}
####################################################################################################################################
# initTest
####################################################################################################################################
sub initTest
{
my $self = shift;
# Create spool path
storageTest()->pathCreate($self->{strSpoolPath}, {bIgnoreExists => true, bCreateParent => true});
storageTest()->pathCreate($self->{strLogPath}, {bIgnoreExists => true, bCreateParent => true});
}
####################################################################################################################################
# run
####################################################################################################################################
sub run
{
my $self = shift;
################################################################################################################################
if ($self->begin("archive-push async (detect ok file)"))
{
#---------------------------------------------------------------------------------------------------------------------------
storageTest()->put(
storageTest()->openWrite(
'spool/archive/' . $self->stanza() . '/out/000000010000000100000001.ok', {bPathCreate => true}));
my $iRunTotal = 100;
my $lTimeBegin = gettimeofday();
for (my $iIndex = 0; $iIndex < $iRunTotal; $iIndex++)
{
my $iResult = system(
$self->backrestExe() . ' --stanza=' . $self->stanza() . ' --archive-async --spool-path=' . $self->{strSpoolPath} .
' --log-level-file=detail --log-path=' . $self->{strLogPath} . ' --archive-timeout=1' .
' --pg1-path=/not/used archive-push /pg_xlog/000000010000000100000001');
if ($iResult != 0)
{
confess "archive-push returned ${iResult}";
}
}
&log(INFO, 'time per execution: ' . ((gettimeofday() - $lTimeBegin) / $iRunTotal));
}
}
1;