2016-06-24 14:12:58 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# ListTest.pm - Creates a list of tests to be run based on input criteria
|
|
|
|
####################################################################################################################################
|
|
|
|
package pgBackRestTest::Common::ListTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use Exporter qw(import);
|
|
|
|
our @EXPORT = qw();
|
|
|
|
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
|
|
|
|
use pgBackRestTest::Common::DefineTest;
|
|
|
|
use pgBackRestTest::Common::VmTest;
|
|
|
|
|
|
|
|
################################################################################################################################
|
|
|
|
# Test constants
|
|
|
|
################################################################################################################################
|
|
|
|
use constant TEST_DB => 'db';
|
|
|
|
push @EXPORT, qw(TEST_DB);
|
|
|
|
use constant TEST_CONTAINER => 'container';
|
|
|
|
push @EXPORT, qw(TEST_CONTAINER);
|
|
|
|
use constant TEST_MODULE => 'module';
|
|
|
|
push @EXPORT, qw(TEST_MODULE);
|
|
|
|
use constant TEST_NAME => 'test';
|
|
|
|
push @EXPORT, qw(TEST_NAME);
|
|
|
|
use constant TEST_PGSQL_BIN => 'pgsql-bin';
|
|
|
|
push @EXPORT, qw(TEST_PGSQL_BIN);
|
|
|
|
use constant TEST_RUN => 'run';
|
|
|
|
push @EXPORT, qw(TEST_RUN);
|
2016-09-06 15:35:02 +02:00
|
|
|
use constant TEST_PROCESS => 'process';
|
|
|
|
push @EXPORT, qw(TEST_PROCESS);
|
2016-06-24 14:12:58 +02:00
|
|
|
use constant TEST_VM => 'os';
|
|
|
|
push @EXPORT, qw(TEST_VM);
|
2016-12-13 01:54:07 +02:00
|
|
|
use constant TEST_PERL_ARCH_PATH => VMDEF_PERL_ARCH_PATH;
|
|
|
|
push @EXPORT, qw(TEST_PERL_ARCH_PATH);
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# testListGet
|
|
|
|
####################################################################################################################################
|
|
|
|
sub testListGet
|
|
|
|
{
|
|
|
|
my $strVm = shift;
|
2017-01-05 01:29:13 +02:00
|
|
|
my $stryModule = shift;
|
|
|
|
my $stryModuleTest = shift;
|
|
|
|
my $iyModuleTestRun = shift;
|
2016-06-24 14:12:58 +02:00
|
|
|
my $strDbVersion = shift;
|
2016-09-06 15:35:02 +02:00
|
|
|
my $iProcessMax = shift;
|
2017-04-10 18:31:30 +02:00
|
|
|
my $bCoverageOnly = shift;
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
my $oyVm = vmGet();
|
|
|
|
my $oyTestRun = [];
|
|
|
|
|
|
|
|
if ($strVm ne 'all' && !defined($${oyVm}{$strVm}))
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "${strVm} is not a valid VM");
|
|
|
|
}
|
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
my @stryTestOS = VM_LIST;
|
2016-06-24 14:12:58 +02:00
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
if ($strVm ne 'all')
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-02-21 15:59:23 +02:00
|
|
|
@stryTestOS = ($strVm);
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
foreach my $strTestOS (@stryTestOS)
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-04-10 18:31:30 +02:00
|
|
|
foreach my $strModule (testDefModuleList())
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-04-10 18:31:30 +02:00
|
|
|
my $hModule = testDefModule($strModule);
|
|
|
|
|
|
|
|
if (@{$stryModule} == 0 || grep(/^$strModule$/i, @{$stryModule}))
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-04-10 18:31:30 +02:00
|
|
|
foreach my $strModuleTest (testDefModuleTestList($strModule))
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-04-10 18:31:30 +02:00
|
|
|
my $hTest = testDefModuleTest($strModule, $strModuleTest);
|
|
|
|
|
|
|
|
if (@{$stryModuleTest} == 0 || grep(/^$strModuleTest$/i, @{$stryModuleTest}))
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
|
|
|
my $iDbVersionMin = -1;
|
|
|
|
my $iDbVersionMax = -1;
|
|
|
|
|
|
|
|
# By default test every db version that is supported for each OS
|
|
|
|
my $strDbVersionKey = 'db';
|
|
|
|
|
|
|
|
# Run a reduced set of tests where each PG version is only tested on a single OS
|
|
|
|
if ($strDbVersion eq 'minimal')
|
|
|
|
{
|
|
|
|
$strDbVersionKey = &VM_DB_MINIMAL;
|
|
|
|
}
|
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
if (defined($hTest->{&TESTDEF_DB}) && $hTest->{&TESTDEF_DB})
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
|
|
|
$iDbVersionMin = 0;
|
|
|
|
$iDbVersionMax = @{$$oyVm{$strTestOS}{$strDbVersionKey}} - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $bFirstDbVersion = true;
|
|
|
|
|
2017-06-12 16:52:32 +02:00
|
|
|
# Skip this test if it can't run on this VM
|
|
|
|
next if (defined($hTest->{&TESTDEF_VM}) && grep(/^$strTestOS$/i, @{$hTest->{&TESTDEF_VM}}) == 0);
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
for (my $iDbVersionIdx = $iDbVersionMax; $iDbVersionIdx >= $iDbVersionMin; $iDbVersionIdx--)
|
|
|
|
{
|
|
|
|
if ($iDbVersionIdx == -1 || $strDbVersion eq 'all' || $strDbVersion eq 'minimal' ||
|
|
|
|
($strDbVersion ne 'all' &&
|
|
|
|
$strDbVersion eq ${$$oyVm{$strTestOS}{$strDbVersionKey}}[$iDbVersionIdx]))
|
|
|
|
{
|
2016-12-23 15:22:59 +02:00
|
|
|
# Individual tests will be each be run in a separate container. This is the default.
|
|
|
|
my $bTestIndividual =
|
2017-04-10 18:31:30 +02:00
|
|
|
!defined($hTest->{&TESTDEF_INDIVIDUAL}) || $hTest->{&TESTDEF_INDIVIDUAL} ? true : false;
|
2016-12-23 15:22:59 +02:00
|
|
|
|
2017-01-05 01:29:13 +02:00
|
|
|
my $iTestRunMin = $bTestIndividual ? 1 : -1;
|
2017-04-10 18:31:30 +02:00
|
|
|
my $iTestRunMax = $bTestIndividual ? $hTest->{&TESTDEF_TOTAL} : -1;
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
for (my $iTestRunIdx = $iTestRunMin; $iTestRunIdx <= $iTestRunMax; $iTestRunIdx++)
|
|
|
|
{
|
2017-01-05 01:29:13 +02:00
|
|
|
# Skip this run if a list was provided and this test is not in the list
|
|
|
|
next if (
|
|
|
|
$bTestIndividual && @{$iyModuleTestRun} != 0 &&
|
|
|
|
!grep(/^$iTestRunIdx$/i, @{$iyModuleTestRun}));
|
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
# Skip this run if only coverage tests are requested and this test does not provide coverage
|
|
|
|
next if ($bCoverageOnly && !defined($hTest->{&TESTDEF_COVERAGE}));
|
2017-01-10 03:49:04 +02:00
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
my $iyProcessMax = [defined($iProcessMax) ? $iProcessMax : 1];
|
2016-06-24 14:12:58 +02:00
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
if (defined($hTest->{&TESTDEF_PROCESS}) && $hTest->{&TESTDEF_PROCESS} &&
|
2016-09-06 15:35:02 +02:00
|
|
|
!defined($iProcessMax) && $bFirstDbVersion)
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
$iyProcessMax = [1, 4];
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
foreach my $iProcessTestMax (@{$iyProcessMax})
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
|
|
|
my $strDbVersion = $iDbVersionIdx == -1 ? undef :
|
|
|
|
${$$oyVm{$strTestOS}{$strDbVersionKey}}[$iDbVersionIdx];
|
|
|
|
|
|
|
|
my $strPgSqlBin = $$oyVm{$strTestOS}{&VMDEF_PGSQL_BIN};
|
|
|
|
|
|
|
|
if (defined($strDbVersion))
|
|
|
|
{
|
|
|
|
$strPgSqlBin =~ s/\{\[version\]\}/$strDbVersion/g;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strPgSqlBin =~ s/\{\[version\]\}/9\.4/g;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $oTestRun =
|
|
|
|
{
|
|
|
|
&TEST_VM => $strTestOS,
|
2017-04-10 18:31:30 +02:00
|
|
|
&TEST_CONTAINER => defined($hTest->{&TESTDEF_CONTAINER}) ?
|
|
|
|
$hTest->{&TESTDEF_CONTAINER} : $hModule->{&TESTDEF_CONTAINER},
|
2016-06-24 14:12:58 +02:00
|
|
|
&TEST_PGSQL_BIN => $strPgSqlBin,
|
2016-12-13 01:54:07 +02:00
|
|
|
&TEST_PERL_ARCH_PATH => $$oyVm{$strTestOS}{&VMDEF_PERL_ARCH_PATH},
|
2017-04-10 18:31:30 +02:00
|
|
|
&TEST_MODULE => $strModule,
|
|
|
|
&TEST_NAME => $strModuleTest,
|
2017-01-05 01:29:13 +02:00
|
|
|
&TEST_RUN =>
|
|
|
|
$iTestRunIdx == -1 ? (@{$iyModuleTestRun} == 0 ? undef : $iyModuleTestRun) :
|
|
|
|
[$iTestRunIdx],
|
2016-09-06 15:35:02 +02:00
|
|
|
&TEST_PROCESS => $iProcessTestMax,
|
2016-06-24 14:12:58 +02:00
|
|
|
&TEST_DB => $strDbVersion
|
|
|
|
};
|
|
|
|
|
|
|
|
push(@{$oyTestRun}, $oTestRun);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$bFirstDbVersion = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $oyTestRun;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(testListGet);
|
|
|
|
|
|
|
|
1;
|