2017-04-06 19:36:37 -04:00
|
|
|
####################################################################################################################################
|
|
|
|
# BackupInfoUnitTest.pm - Unit tests for BackupInfo
|
|
|
|
####################################################################################################################################
|
2017-05-12 16:43:04 -04:00
|
|
|
package pgBackRestTest::Module::Backup::BackupInfoUnitTest;
|
|
|
|
use parent 'pgBackRestTest::Env::HostEnvTest';
|
2017-04-06 19:36:37 -04:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
use English '-no_match_vars';
|
|
|
|
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
use Storable qw(dclone);
|
|
|
|
|
2017-05-15 16:01:00 -04:00
|
|
|
use pgBackRest::Backup::Info;
|
2017-04-06 19:36:37 -04:00
|
|
|
use pgBackRest::Common::Exception;
|
|
|
|
use pgBackRest::Common::Lock;
|
|
|
|
use pgBackRest::Common::Log;
|
2017-06-09 17:51:41 -04:00
|
|
|
use pgBackRest::Config::Config;
|
2017-04-06 19:36:37 -04:00
|
|
|
use pgBackRest::DbVersion;
|
|
|
|
use pgBackRest::InfoCommon;
|
|
|
|
use pgBackRest::Manifest;
|
2017-06-09 17:51:41 -04:00
|
|
|
use pgBackRest::Protocol::Storage::Helper;
|
2017-04-06 19:36:37 -04:00
|
|
|
|
2017-05-12 16:43:04 -04:00
|
|
|
use pgBackRestTest::Env::HostEnvTest;
|
2017-04-06 19:36:37 -04:00
|
|
|
use pgBackRestTest::Common::ExecuteTest;
|
2017-05-12 16:43:04 -04:00
|
|
|
use pgBackRestTest::Env::Host::HostBackupTest;
|
2017-04-06 19:36:37 -04:00
|
|
|
use pgBackRestTest::Common::RunTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# initModule
|
|
|
|
####################################################################################################################################
|
|
|
|
sub initModule
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
$self->{strRepoPath} = $self->testPath() . '/repo';
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# initTest
|
|
|
|
####################################################################################################################################
|
|
|
|
sub initTest
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
2017-06-09 17:51:41 -04:00
|
|
|
# Load options
|
|
|
|
my $oOption = {};
|
|
|
|
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
|
|
|
|
$self->optionSetTest($oOption, OPTION_REPO_PATH, $self->testPath() . '/repo');
|
|
|
|
logDisable(); $self->configLoadExpect(dclone($oOption), CMD_ARCHIVE_PUSH); logEnable();
|
2017-04-06 19:36:37 -04:00
|
|
|
|
2017-06-09 17:51:41 -04:00
|
|
|
# Create the local file object
|
|
|
|
$self->{oStorage} = storageRepo();
|
2017-04-06 19:36:37 -04:00
|
|
|
|
2017-06-09 17:51:41 -04:00
|
|
|
# Create backup info path
|
|
|
|
$self->{oStorage}->pathCreate(STORAGE_REPO_BACKUP, {bCreateParent => true});
|
2017-04-06 19:36:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# run
|
|
|
|
####################################################################################################################################
|
|
|
|
sub run
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Increment the run, log, and decide whether this unit test should be run
|
|
|
|
################################################################################################################################
|
|
|
|
if ($self->begin("BackupInfo::confirmDb()"))
|
|
|
|
{
|
2017-06-09 17:51:41 -04:00
|
|
|
my $oBackupInfo = new pgBackRest::Backup::Info($self->{oStorage}->pathGet(STORAGE_REPO_BACKUP), false, false,
|
|
|
|
{bIgnoreMissing => true});
|
2017-04-06 19:36:37 -04:00
|
|
|
$oBackupInfo->create(PG_VERSION_93, WAL_VERSION_93_SYS_ID, '937', '201306121', true);
|
|
|
|
|
|
|
|
my $strBackupLabel = "20170403-175647F";
|
|
|
|
|
|
|
|
$oBackupInfo->set(INFO_BACKUP_SECTION_BACKUP_CURRENT, $strBackupLabel, INFO_BACKUP_KEY_HISTORY_ID,
|
|
|
|
$oBackupInfo->get(INFO_BACKUP_SECTION_DB, INFO_BACKUP_KEY_HISTORY_ID));
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
$self->testResult(sub {$oBackupInfo->confirmDb($strBackupLabel, PG_VERSION_93, WAL_VERSION_93_SYS_ID,)}, true,
|
|
|
|
'backup db matches');
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
$self->testResult(sub {$oBackupInfo->confirmDb($strBackupLabel, PG_VERSION_94, WAL_VERSION_93_SYS_ID,)}, false,
|
|
|
|
'backup db wrong version');
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
$self->testResult(sub {$oBackupInfo->confirmDb($strBackupLabel, PG_VERSION_93, WAL_VERSION_94_SYS_ID,)}, false,
|
|
|
|
'backup db wrong system-id');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|