1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00
Files
pgbackrest/test/lib/pgBackRestTest/Env/Host/HostBaseTest.pm
T

97 lines
4.0 KiB
Perl
Raw Normal View History

2016-06-24 08:12:58 -04:00
####################################################################################################################################
# HostBackupTest.pm - Backup host
####################################################################################################################################
package pgBackRestTest::Env::Host::HostBaseTest;
2016-06-24 08:12:58 -04: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 pgBackRestDoc::Common::Log;
use pgBackRestDoc::ProjectInfo;
2020-03-10 15:12:44 -04:00
use pgBackRestTest::Common::ContainerTest;
2017-02-21 08:59:23 -05:00
use pgBackRestTest::Common::ExecuteTest;
use pgBackRestTest::Common::JobTest;
2016-12-23 08:22:59 -05:00
use pgBackRestTest::Common::RunTest;
2020-03-10 15:12:44 -04:00
use pgBackRestTest::Common::StorageRepo;
2016-12-12 18:54:07 -05:00
use pgBackRestTest::Common::VmTest;
2016-06-24 08:12:58 -04:00
####################################################################################################################################
# Host constants
####################################################################################################################################
use constant HOST_BASE => 'base';
push @EXPORT, qw(HOST_BASE);
2016-08-24 12:39:27 -04: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);
2017-06-09 17:51:41 -04:00
use constant HOST_S3 => 's3-server';
push @EXPORT, qw(HOST_S3);
2016-06-24 08:12:58 -04: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 08:22:59 -05:00
my $strTestPath = testRunGet()->testPath() . ($strName eq HOST_BASE ? '' : "/${strName}");
2017-06-09 17:51:41 -04:00
storageTest()->pathCreate($strTestPath, {strMode => '0770'});
2016-06-24 08:12:58 -04:00
# Create the host
my $strProjectPath = dirname(dirname(abs_path($0)));
my $strBinPath = dirname(dirname($strTestPath)) . '/bin/' . testRunGet()->vm() . '/' . PROJECT_EXE;
2016-12-23 08:22:59 -05:00
my $strContainer = 'test-' . testRunGet()->vmId() . "-$strName";
2016-06-24 08:12:58 -04:00
my $self = $class->SUPER::new(
2016-12-23 08:22:59 -05:00
$strName, $strContainer, $$oParam{strImage}, $$oParam{strUser}, testRunGet()->vm(),
["${strProjectPath}:${strProjectPath}", "${strTestPath}:${strTestPath}", "${strBinPath}:${strBinPath}:ro"]);
2016-06-24 08:12:58 -04:00
bless $self, $class;
2016-12-23 08:22:59 -05:00
# Set test path
$self->{strTestPath} = $strTestPath;
2016-06-24 08:12:58 -04:00
# Set permissions on the test path
2017-02-21 08:59:23 -05:00
$self->executeSimple('chown -R ' . $self->userGet() . ':'. TEST_GROUP . ' ' . $self->testPath(), undef, 'root');
2016-06-24 08:12:58 -04:00
# Return from function and log return values if any
return logDebugReturn
(
$strOperation,
{name => 'self', value => $self, trace => true}
);
}
####################################################################################################################################
# Getters
####################################################################################################################################
2016-12-23 08:22:59 -05:00
sub testPath {return shift->{strTestPath}}
2016-06-24 08:12:58 -04:00
1;