2016-01-11 02:30:51 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# VmTest.pm - Vm constants and data
|
|
|
|
####################################################################################################################################
|
2016-04-14 15:30:54 +02:00
|
|
|
package pgBackRestTest::Common::VmTest;
|
2016-01-11 02:30:51 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use Exporter qw(import);
|
|
|
|
our @EXPORT = qw();
|
|
|
|
|
2016-07-30 14:43:38 +02:00
|
|
|
use pgBackRest::Common::Log;
|
2016-08-12 04:35:24 +02:00
|
|
|
use pgBackRest::DbVersion;
|
2016-06-24 14:12:58 +02:00
|
|
|
|
2016-05-24 14:17:13 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# VM hash keywords
|
|
|
|
####################################################################################################################################
|
2017-11-19 03:14:14 +02:00
|
|
|
use constant VM_ARCH => 'arch';
|
|
|
|
push @EXPORT, qw(VM_ARCH);
|
2016-06-12 15:00:16 +02:00
|
|
|
use constant VM_DB => 'db';
|
|
|
|
push @EXPORT, qw(VM_DB);
|
2017-06-27 21:48:34 +02:00
|
|
|
use constant VM_DB_TEST => 'db-test';
|
|
|
|
push @EXPORT, qw(VM_DB_TEST);
|
2016-07-30 14:43:38 +02:00
|
|
|
use constant VM_CONTROL_MASTER => 'control-master';
|
|
|
|
push @EXPORT, qw(VM_CONTROL_MASTER);
|
2017-06-24 16:59:00 +02:00
|
|
|
use constant VM_DEPRECATED => 'deprecated';
|
|
|
|
push @EXPORT, qw(VM_DEPRECATED);
|
2016-05-24 14:17:13 +02:00
|
|
|
use constant VM_IMAGE => 'image';
|
|
|
|
push @EXPORT, qw(VM_IMAGE);
|
|
|
|
use constant VM_OS => 'os';
|
|
|
|
push @EXPORT, qw(VM_OS);
|
|
|
|
use constant VM_OS_BASE => 'os-base';
|
|
|
|
push @EXPORT, qw(VM_OS_BASE);
|
|
|
|
use constant VM_OS_REPO => 'os-repo';
|
|
|
|
push @EXPORT, qw(VM_OS_REPO);
|
2016-06-12 15:00:16 +02:00
|
|
|
use constant VMDEF_PGSQL_BIN => 'pgsql-bin';
|
|
|
|
push @EXPORT, qw(VMDEF_PGSQL_BIN);
|
2016-12-13 01:54:07 +02:00
|
|
|
use constant VMDEF_PERL_ARCH_PATH => 'perl-arch-path';
|
|
|
|
push @EXPORT, qw(VMDEF_PERL_ARCH_PATH);
|
2016-05-24 14:17:13 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Valid OS base List
|
|
|
|
####################################################################################################################################
|
|
|
|
use constant VM_OS_BASE_DEBIAN => 'debian';
|
|
|
|
push @EXPORT, qw(VM_OS_BASE_DEBIAN);
|
|
|
|
use constant VM_OS_BASE_RHEL => 'rhel';
|
|
|
|
push @EXPORT, qw(VM_OS_BASE_RHEL);
|
|
|
|
|
2016-01-11 02:30:51 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Valid OS list
|
|
|
|
####################################################################################################################################
|
2016-05-24 14:17:13 +02:00
|
|
|
use constant VM_OS_CENTOS => 'centos';
|
|
|
|
push @EXPORT, qw(VM_OS_CENTOS);
|
|
|
|
use constant VM_OS_DEBIAN => 'debian';
|
|
|
|
push @EXPORT, qw(VM_OS_DEBIAN);
|
|
|
|
use constant VM_OS_UBUNTU => 'ubuntu';
|
|
|
|
push @EXPORT, qw(VM_OS_DEBIAN);
|
|
|
|
|
2017-11-19 03:14:14 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Valid architecture list
|
|
|
|
####################################################################################################################################
|
|
|
|
use constant VM_ARCH_I386 => 'i386';
|
|
|
|
push @EXPORT, qw(VM_ARCH_I386);
|
|
|
|
use constant VM_ARCH_AMD64 => 'amd64';
|
|
|
|
push @EXPORT, qw(VM_ARCH_AMD64);
|
|
|
|
|
2016-05-24 14:17:13 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Valid VM list
|
|
|
|
####################################################################################################################################
|
2017-01-10 03:49:04 +02:00
|
|
|
use constant VM_ALL => 'all';
|
|
|
|
push @EXPORT, qw(VM_ALL);
|
|
|
|
|
2016-05-24 14:17:13 +02:00
|
|
|
use constant VM_CO6 => 'co6';
|
|
|
|
push @EXPORT, qw(VM_CO6);
|
|
|
|
use constant VM_CO7 => 'co7';
|
|
|
|
push @EXPORT, qw(VM_CO7);
|
|
|
|
use constant VM_U12 => 'u12';
|
|
|
|
push @EXPORT, qw(VM_U12);
|
|
|
|
use constant VM_U14 => 'u14';
|
|
|
|
push @EXPORT, qw(VM_U14);
|
|
|
|
use constant VM_U16 => 'u16';
|
|
|
|
push @EXPORT, qw(VM_U16);
|
|
|
|
use constant VM_D8 => 'd8';
|
|
|
|
push @EXPORT, qw(VM_D8);
|
2017-06-28 00:29:48 +02:00
|
|
|
use constant VM_D9 => 'd9';
|
|
|
|
push @EXPORT, qw(VM_D9);
|
2016-01-11 02:30:51 +02:00
|
|
|
|
2017-11-15 00:16:39 +02:00
|
|
|
# Defines the vm that will be used for expect testing
|
|
|
|
use constant VM_EXPECT => VM_CO7;
|
|
|
|
push @EXPORT, qw(VM_EXPECT);
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
# Defines the host VM (the VM that the containers run in)
|
2017-02-21 15:59:23 +02:00
|
|
|
use constant VM_HOST_DEFAULT => VM_U16;
|
|
|
|
push @EXPORT, qw(VM_HOST_DEFAULT);
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2017-11-19 02:53:41 +02:00
|
|
|
# Defines the VM that will do coverage testing
|
|
|
|
use constant VM_COVERAGE => VM_U16;
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
# Lists valid VMs
|
2017-06-27 21:58:02 +02:00
|
|
|
use constant VM_LIST => (VM_CO6, VM_U16, VM_CO7, VM_U12);
|
2017-02-18 05:31:16 +02:00
|
|
|
push @EXPORT, qw(VM_LIST);
|
|
|
|
|
2016-01-11 02:30:51 +02:00
|
|
|
my $oyVm =
|
|
|
|
{
|
|
|
|
# CentOS 6
|
2016-05-24 14:17:13 +02:00
|
|
|
&VM_CO6 =>
|
2016-01-11 02:30:51 +02:00
|
|
|
{
|
2016-05-24 14:17:13 +02:00
|
|
|
&VM_OS_BASE => VM_OS_BASE_RHEL,
|
|
|
|
&VM_OS => VM_OS_CENTOS,
|
|
|
|
&VM_IMAGE => 'centos:6',
|
2017-11-19 03:14:14 +02:00
|
|
|
&VM_ARCH => VM_ARCH_AMD64,
|
2016-06-12 15:00:16 +02:00
|
|
|
&VMDEF_PGSQL_BIN => '/usr/pgsql-{[version]}/bin',
|
2016-12-13 01:54:07 +02:00
|
|
|
&VMDEF_PERL_ARCH_PATH => '/usr/local/lib64/perl5',
|
2016-05-24 14:17:13 +02:00
|
|
|
|
2016-06-12 15:00:16 +02:00
|
|
|
&VM_DB =>
|
2016-05-14 16:33:12 +02:00
|
|
|
[
|
|
|
|
PG_VERSION_90,
|
|
|
|
PG_VERSION_91,
|
|
|
|
PG_VERSION_95,
|
2016-05-16 23:59:26 +02:00
|
|
|
PG_VERSION_96,
|
2016-05-14 16:33:12 +02:00
|
|
|
],
|
|
|
|
|
2017-06-27 21:48:34 +02:00
|
|
|
&VM_DB_TEST =>
|
2016-05-14 16:33:12 +02:00
|
|
|
[
|
|
|
|
PG_VERSION_90,
|
|
|
|
PG_VERSION_91,
|
2017-06-22 20:44:21 +02:00
|
|
|
PG_VERSION_95,
|
2016-05-14 16:33:12 +02:00
|
|
|
],
|
2016-01-11 02:30:51 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
# CentOS 7
|
2016-05-24 14:17:13 +02:00
|
|
|
&VM_CO7 =>
|
2016-01-11 02:30:51 +02:00
|
|
|
{
|
2016-05-24 14:17:13 +02:00
|
|
|
&VM_OS_BASE => VM_OS_BASE_RHEL,
|
|
|
|
&VM_OS => VM_OS_CENTOS,
|
|
|
|
&VM_IMAGE => 'centos:7',
|
2017-11-19 03:14:14 +02:00
|
|
|
&VM_ARCH => VM_ARCH_AMD64,
|
2016-06-12 15:00:16 +02:00
|
|
|
&VMDEF_PGSQL_BIN => '/usr/pgsql-{[version]}/bin',
|
2016-12-13 01:54:07 +02:00
|
|
|
&VMDEF_PERL_ARCH_PATH => '/usr/local/lib64/perl5',
|
2016-05-24 14:17:13 +02:00
|
|
|
|
2016-06-12 15:00:16 +02:00
|
|
|
&VM_DB =>
|
2016-05-14 16:33:12 +02:00
|
|
|
[
|
2016-05-24 14:17:13 +02:00
|
|
|
PG_VERSION_96,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
# Debian 8
|
|
|
|
&VM_D8 =>
|
|
|
|
{
|
|
|
|
&VM_OS_BASE => VM_OS_BASE_DEBIAN,
|
|
|
|
&VM_OS => VM_OS_DEBIAN,
|
|
|
|
&VM_OS_REPO => 'jessie',
|
|
|
|
&VM_IMAGE => 'debian:8',
|
2017-11-19 03:14:14 +02:00
|
|
|
&VM_ARCH => VM_ARCH_AMD64,
|
2016-06-12 15:00:16 +02:00
|
|
|
&VMDEF_PGSQL_BIN => '/usr/lib/postgresql/{[version]}/bin',
|
2016-12-13 01:54:07 +02:00
|
|
|
&VMDEF_PERL_ARCH_PATH => '/usr/local/lib/x86_64-linux-gnu/perl/5.20.2',
|
2017-10-17 00:21:47 +02:00
|
|
|
|
|
|
|
&VM_DB =>
|
|
|
|
[
|
|
|
|
PG_VERSION_95,
|
|
|
|
],
|
2016-01-11 02:30:51 +02:00
|
|
|
},
|
|
|
|
|
2017-06-28 00:29:48 +02:00
|
|
|
# Debian 9
|
|
|
|
&VM_D9 =>
|
|
|
|
{
|
|
|
|
&VM_OS_BASE => VM_OS_BASE_DEBIAN,
|
|
|
|
&VM_OS => VM_OS_DEBIAN,
|
|
|
|
&VM_OS_REPO => 'stretch',
|
|
|
|
&VM_IMAGE => 'debian:9',
|
2017-11-19 03:14:14 +02:00
|
|
|
&VM_ARCH => VM_ARCH_AMD64,
|
2017-06-28 00:29:48 +02:00
|
|
|
&VMDEF_PGSQL_BIN => '/usr/lib/postgresql/{[version]}/bin',
|
2017-11-19 03:14:14 +02:00
|
|
|
&VMDEF_PERL_ARCH_PATH => '/usr/local/lib/i386-linux-gnu/perl/5.24.1',
|
2017-10-17 00:21:47 +02:00
|
|
|
|
|
|
|
&VM_DB =>
|
|
|
|
[
|
|
|
|
PG_VERSION_96,
|
|
|
|
],
|
2017-06-28 00:29:48 +02:00
|
|
|
},
|
|
|
|
|
2017-06-27 21:58:02 +02:00
|
|
|
# Ubuntu 12.04
|
2016-05-24 14:17:13 +02:00
|
|
|
&VM_U12 =>
|
2016-01-11 02:30:51 +02:00
|
|
|
{
|
2016-05-24 14:17:13 +02:00
|
|
|
&VM_OS_BASE => VM_OS_BASE_DEBIAN,
|
|
|
|
&VM_OS => VM_OS_UBUNTU,
|
|
|
|
&VM_OS_REPO => 'precise',
|
2017-11-19 03:14:14 +02:00
|
|
|
&VM_IMAGE => 'i386/ubuntu:12.04',
|
|
|
|
&VM_ARCH => VM_ARCH_I386,
|
2016-06-12 15:00:16 +02:00
|
|
|
&VMDEF_PGSQL_BIN => '/usr/lib/postgresql/{[version]}/bin',
|
2016-12-13 01:54:07 +02:00
|
|
|
&VMDEF_PERL_ARCH_PATH => '/usr/local/lib/perl/5.14.2',
|
2017-06-27 21:58:02 +02:00
|
|
|
|
|
|
|
&VM_DB =>
|
|
|
|
[
|
|
|
|
PG_VERSION_83,
|
|
|
|
PG_VERSION_84,
|
|
|
|
PG_VERSION_92,
|
2017-09-01 18:29:34 +02:00
|
|
|
PG_VERSION_93,
|
2017-06-27 21:58:02 +02:00
|
|
|
],
|
2016-01-11 02:30:51 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
# Ubuntu 14.04
|
2016-05-24 14:17:13 +02:00
|
|
|
&VM_U14 =>
|
2016-01-11 02:30:51 +02:00
|
|
|
{
|
2016-05-24 14:17:13 +02:00
|
|
|
&VM_OS_BASE => VM_OS_BASE_DEBIAN,
|
|
|
|
&VM_OS => VM_OS_UBUNTU,
|
|
|
|
&VM_OS_REPO => 'trusty',
|
|
|
|
&VM_IMAGE => 'ubuntu:14.04',
|
2017-11-19 03:14:14 +02:00
|
|
|
&VM_ARCH => VM_ARCH_AMD64,
|
2016-06-12 15:00:16 +02:00
|
|
|
&VMDEF_PGSQL_BIN => '/usr/lib/postgresql/{[version]}/bin',
|
2016-12-13 01:54:07 +02:00
|
|
|
&VMDEF_PERL_ARCH_PATH => '/usr/local/lib/perl/5.18.2',
|
2016-05-24 14:17:13 +02:00
|
|
|
|
2016-06-12 15:00:16 +02:00
|
|
|
&VM_DB =>
|
2016-05-14 16:33:12 +02:00
|
|
|
[
|
2016-06-12 15:00:16 +02:00
|
|
|
PG_VERSION_94,
|
|
|
|
],
|
2016-05-24 14:17:13 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
# Ubuntu 16.04
|
|
|
|
&VM_U16 =>
|
|
|
|
{
|
|
|
|
&VM_OS_BASE => VM_OS_BASE_DEBIAN,
|
|
|
|
&VM_OS => VM_OS_UBUNTU,
|
|
|
|
&VM_OS_REPO => 'xenial',
|
|
|
|
&VM_IMAGE => 'ubuntu:16.04',
|
2017-11-19 03:14:14 +02:00
|
|
|
&VM_ARCH => VM_ARCH_AMD64,
|
2016-06-12 15:00:16 +02:00
|
|
|
&VMDEF_PGSQL_BIN => '/usr/lib/postgresql/{[version]}/bin',
|
2016-12-13 01:54:07 +02:00
|
|
|
&VMDEF_PERL_ARCH_PATH => '/usr/local/lib/x86_64-linux-gnu/perl/5.22.1',
|
2016-05-24 14:17:13 +02:00
|
|
|
|
2016-06-12 15:00:16 +02:00
|
|
|
&VM_DB =>
|
2016-05-24 14:17:13 +02:00
|
|
|
[
|
2017-06-27 21:58:02 +02:00
|
|
|
PG_VERSION_94,
|
2017-09-01 18:29:34 +02:00
|
|
|
PG_VERSION_95,
|
|
|
|
PG_VERSION_10,
|
|
|
|
],
|
|
|
|
|
|
|
|
&VM_DB_TEST =>
|
|
|
|
[
|
|
|
|
PG_VERSION_94,
|
|
|
|
PG_VERSION_10,
|
2016-05-14 16:33:12 +02:00
|
|
|
],
|
|
|
|
},
|
2016-01-11 02:30:51 +02:00
|
|
|
};
|
|
|
|
|
2017-06-27 21:48:34 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Set VM_DB_TEST to VM_DB if it is not defined so it doesn't have to be checked everywere
|
|
|
|
####################################################################################################################################
|
|
|
|
foreach my $strVm (sort(keys(%{$oyVm})))
|
|
|
|
{
|
|
|
|
if (!defined($oyVm->{$strVm}{&VM_DB_TEST}))
|
|
|
|
{
|
|
|
|
$oyVm->{$strVm}{&VM_DB_TEST} = $oyVm->{$strVm}{&VM_DB};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Verify that each version of PostgreSQL is represented in one and only one default VM
|
|
|
|
####################################################################################################################################
|
|
|
|
foreach my $strPgVersion (versionSupport())
|
|
|
|
{
|
|
|
|
my $strVmPgVersionRun;
|
2017-11-19 02:53:41 +02:00
|
|
|
my $strVmCoverage;
|
2017-06-27 21:48:34 +02:00
|
|
|
|
|
|
|
foreach my $strVm (VM_LIST)
|
|
|
|
{
|
2017-11-19 02:53:41 +02:00
|
|
|
if ($strVm eq VM_COVERAGE)
|
|
|
|
{
|
|
|
|
$strVmCoverage = $strVm;
|
|
|
|
}
|
|
|
|
|
2017-06-27 21:48:34 +02:00
|
|
|
foreach my $strVmPgVersion (@{$oyVm->{$strVm}{&VM_DB_TEST}})
|
|
|
|
{
|
|
|
|
if ($strPgVersion eq $strVmPgVersion)
|
|
|
|
{
|
|
|
|
if (defined($strVmPgVersionRun))
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, "PostgreSQL $strPgVersion is already configured to run on default vm $strVm");
|
|
|
|
}
|
|
|
|
|
|
|
|
$strVmPgVersionRun = $strVm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-19 02:53:41 +02:00
|
|
|
my $strErrorSuffix = 'is not configured to run on a default vm';
|
|
|
|
|
|
|
|
if (!defined($strVmCoverage))
|
|
|
|
{
|
|
|
|
confess &log(ASSERT, 'vm designated for coverage testing (' . VM_COVERAGE . ") ${strErrorSuffix}");
|
|
|
|
}
|
|
|
|
|
2017-06-27 21:48:34 +02:00
|
|
|
if (!defined($strVmPgVersionRun))
|
|
|
|
{
|
2017-11-19 02:53:41 +02:00
|
|
|
confess &log(ASSERT, "PostgreSQL ${strPgVersion} ${strErrorSuffix}");
|
2017-06-27 21:48:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-11 02:30:51 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# vmGet
|
|
|
|
####################################################################################################################################
|
|
|
|
sub vmGet
|
|
|
|
{
|
|
|
|
return $oyVm;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(vmGet);
|
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# vmBaseTest
|
|
|
|
####################################################################################################################################
|
|
|
|
sub vmBaseTest
|
|
|
|
{
|
|
|
|
my $strVm = shift;
|
|
|
|
my $strDistroTest = shift;
|
|
|
|
|
|
|
|
return $oyVm->{$strVm}{&VM_OS_BASE} eq $strDistroTest ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(vmBaseTest);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# vmCoverage
|
|
|
|
####################################################################################################################################
|
|
|
|
sub vmCoverage
|
|
|
|
{
|
|
|
|
my $strVm = shift;
|
|
|
|
|
2017-11-19 02:53:41 +02:00
|
|
|
return ($strVm eq VM_COVERAGE ? true : false)
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(vmCoverage);
|
|
|
|
|
2017-11-19 03:14:14 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Get vm architecture bits
|
|
|
|
####################################################################################################################################
|
|
|
|
sub vmArchBits
|
|
|
|
{
|
|
|
|
my $strVm = shift;
|
|
|
|
|
|
|
|
return ($oyVm->{$strVm}{&VM_ARCH} eq VM_ARCH_AMD64 ? 64 : 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(vmArchBits);
|
|
|
|
|
2016-01-11 02:30:51 +02:00
|
|
|
1;
|