2016-06-24 14:12:58 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# HostBackupTest.pm - Backup host
|
|
|
|
####################################################################################################################################
|
2017-05-12 22:43:04 +02:00
|
|
|
package pgBackRestTest::Env::Host::HostBaseTest;
|
2016-06-24 14:12:58 +02:00
|
|
|
use parent 'pgBackRestTest::Common::HostTest';
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# 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);
|
|
|
|
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::FileCommon;
|
|
|
|
use pgBackRest::Version;
|
|
|
|
|
2016-10-01 19:39:44 +02:00
|
|
|
use pgBackRestTest::Common::ContainerTest;
|
2017-02-21 15:59:23 +02:00
|
|
|
use pgBackRestTest::Common::ExecuteTest;
|
2016-12-23 15:22:59 +02:00
|
|
|
use pgBackRestTest::Common::RunTest;
|
2016-12-13 01:54:07 +02:00
|
|
|
use pgBackRestTest::Common::VmTest;
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Host constants
|
|
|
|
####################################################################################################################################
|
|
|
|
use constant HOST_BASE => 'base';
|
|
|
|
push @EXPORT, qw(HOST_BASE);
|
2016-08-24 18:39:27 +02:00
|
|
|
use constant HOST_DB_MASTER => 'db-master';
|
|
|
|
push @EXPORT, qw(HOST_DB_MASTER);
|
|
|
|
use constant HOST_DB_STANDBY => 'db-standby';
|
|
|
|
push @EXPORT, qw(HOST_DB_STANDBY);
|
|
|
|
use constant HOST_BACKUP => 'backup';
|
|
|
|
push @EXPORT, qw(HOST_BACKUP);
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# new
|
|
|
|
####################################################################################################################################
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift; # Class name
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
$strName,
|
|
|
|
$oParam,
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
__PACKAGE__ . '->new', \@_,
|
|
|
|
{name => 'strName', default => HOST_BASE, trace => true},
|
|
|
|
{name => 'oParam', required => false, trace => true},
|
|
|
|
);
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
my $strTestPath = testRunGet()->testPath() . ($strName eq HOST_BASE ? '' : "/${strName}");
|
2016-06-24 14:12:58 +02:00
|
|
|
filePathCreate($strTestPath, '0770');
|
|
|
|
|
|
|
|
# Create the host
|
|
|
|
my $strProjectPath = dirname(dirname(abs_path($0)));
|
2016-12-23 15:22:59 +02:00
|
|
|
my $strContainer = 'test-' . testRunGet()->vmId() . "-$strName";
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
my $self = $class->SUPER::new(
|
2016-12-23 15:22:59 +02:00
|
|
|
$strName, $strContainer, $$oParam{strImage}, $$oParam{strUser}, testRunGet()->vm(),
|
2017-01-10 03:49:04 +02:00
|
|
|
["${strProjectPath}:${strProjectPath}", "${strTestPath}:${strTestPath}"
|
|
|
|
,dirname(dirname($strTestPath)) . '/cover_db:' . dirname(dirname($strTestPath)) . '/cover_db']);
|
2016-06-24 14:12:58 +02:00
|
|
|
bless $self, $class;
|
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Set test path
|
|
|
|
$self->{strTestPath} = $strTestPath;
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
# Set permissions on the test path
|
2017-02-21 15:59:23 +02:00
|
|
|
$self->executeSimple('chown -R ' . $self->userGet() . ':'. TEST_GROUP . ' ' . $self->testPath(), undef, 'root');
|
2016-06-24 14:12:58 +02:00
|
|
|
|
2016-12-13 01:54:07 +02:00
|
|
|
# Install Perl C Library
|
|
|
|
my $oVm = vmGet();
|
2016-12-23 15:22:59 +02:00
|
|
|
my $strBuildPath = testRunGet()->basePath() . "/test/.vagrant/libc/$self->{strOS}";
|
2016-12-13 01:54:07 +02:00
|
|
|
my $strPerlAutoPath = $$oVm{$self->{strOS}}{&VMDEF_PERL_ARCH_PATH} . '/auto/pgBackRest/LibC';
|
|
|
|
my $strPerlModulePath = $$oVm{$self->{strOS}}{&VMDEF_PERL_ARCH_PATH} . '/pgBackRest';
|
|
|
|
|
|
|
|
$self->executeSimple(
|
|
|
|
"mkdir -p -m 755 ${strPerlAutoPath} && " .
|
|
|
|
# "cp ${strBuildPath}/blib/arch/auto/pgBackRest/LibC/LibC.bs ${strPerlAutoPath} && " .
|
|
|
|
"cp ${strBuildPath}/blib/arch/auto/pgBackRest/LibC/LibC.so ${strPerlAutoPath} && " .
|
|
|
|
"cp ${strBuildPath}/blib/lib/auto/pgBackRest/LibC/autosplit.ix ${strPerlAutoPath} && " .
|
|
|
|
"mkdir -p -m 755 ${strPerlModulePath} && " .
|
2016-12-23 15:22:59 +02:00
|
|
|
"cp ${strBuildPath}/blib/lib/pgBackRest/LibC.pm ${strPerlModulePath}",
|
2016-12-13 01:54:07 +02:00
|
|
|
undef, 'root');
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'self', value => $self, trace => true}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Getters
|
|
|
|
####################################################################################################################################
|
2016-12-23 15:22:59 +02:00
|
|
|
sub testPath {return shift->{strTestPath}}
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
1;
|