1####################################################################################################################################
2# HostBackupTest.pm - Backup host
3####################################################################################################################################
4package pgBackRestTest::Env::Host::HostBaseTest;
5use parent 'pgBackRestTest::Common::HostTest';
6
7####################################################################################################################################
8# Perl includes
9####################################################################################################################################
10use strict;
11use warnings FATAL => qw(all);
12use Carp qw(confess);
13
14use Cwd qw(abs_path);
15use Exporter qw(import);
16    our @EXPORT = qw();
17use File::Basename qw(dirname);
18
19use pgBackRestDoc::Common::Log;
20use pgBackRestDoc::ProjectInfo;
21
22use pgBackRestTest::Common::ContainerTest;
23use pgBackRestTest::Common::ExecuteTest;
24use pgBackRestTest::Common::JobTest;
25use pgBackRestTest::Common::RunTest;
26use pgBackRestTest::Common::StorageRepo;
27use pgBackRestTest::Common::VmTest;
28
29####################################################################################################################################
30# Host constants
31####################################################################################################################################
32use constant HOST_BASE                                              => 'base';
33    push @EXPORT, qw(HOST_BASE);
34use constant HOST_DB_PRIMARY                                        => 'db-primary';
35    push @EXPORT, qw(HOST_DB_PRIMARY);
36use constant HOST_DB_STANDBY                                        => 'db-standby';
37    push @EXPORT, qw(HOST_DB_STANDBY);
38use constant HOST_BACKUP                                            => 'backup';
39    push @EXPORT, qw(HOST_BACKUP);
40use constant HOST_GCS                                               => 'gcs';
41    push @EXPORT, qw(HOST_GCS);
42use constant HOST_AZURE                                             => 'azure';
43    push @EXPORT, qw(HOST_AZURE);
44use constant HOST_S3                                                => 's3-server';
45    push @EXPORT, qw(HOST_S3);
46
47####################################################################################################################################
48# new
49####################################################################################################################################
50sub new
51{
52    my $class = shift;          # Class name
53
54    # Assign function parameters, defaults, and log debug info
55    my
56    (
57        $strOperation,
58        $strName,
59        $oParam,
60    ) =
61        logDebugParam
62        (
63            __PACKAGE__ . '->new', \@_,
64            {name => 'strName', default => HOST_BASE, trace => true},
65            {name => 'oParam', required => false, trace => true},
66        );
67
68    my $strTestPath = testRunGet()->testPath() . ($strName eq HOST_BASE ? '' : "/${strName}");
69    storageTest()->pathCreate($strTestPath, {strMode => '0770'});
70
71    # Create the host
72    my $strProjectPath = dirname(dirname(abs_path($0)));
73    my $strBinPath = dirname(dirname($strTestPath)) . '/bin/' . testRunGet()->vm() . '/' . PROJECT_EXE;
74    my $strContainer = 'test-' . testRunGet()->vmId() . "-$strName";
75
76    my $self = $class->SUPER::new(
77        $strName, $strContainer, $$oParam{strImage}, $$oParam{strUser}, testRunGet()->vm(),
78        ["${strProjectPath}:${strProjectPath}", "${strTestPath}:${strTestPath}", "${strBinPath}:${strBinPath}:ro"]);
79    bless $self, $class;
80
81    # Set test path
82    $self->{strTestPath} = $strTestPath;
83
84    # Set permissions on the test path
85    $self->executeSimple('chown -R ' . $self->userGet() . ':'. TEST_GROUP . ' ' . $self->testPath(), undef, 'root');
86
87    # Return from function and log return values if any
88    return logDebugReturn
89    (
90        $strOperation,
91        {name => 'self', value => $self, trace => true}
92    );
93}
94
95####################################################################################################################################
96# Getters
97####################################################################################################################################
98sub testPath {return shift->{strTestPath}}
99
1001;
101