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();
|
|
|
|
|
2020-03-10 21:41:56 +02:00
|
|
|
use pgBackRestDoc::Common::Log;
|
|
|
|
use pgBackRestDoc::Common::String;
|
2016-06-24 14:12:58 +02:00
|
|
|
|
|
|
|
use pgBackRestTest::Common::DefineTest;
|
|
|
|
use pgBackRestTest::Common::VmTest;
|
|
|
|
|
|
|
|
################################################################################################################################
|
|
|
|
# Test constants
|
|
|
|
################################################################################################################################
|
|
|
|
use constant TEST_DB => 'db';
|
|
|
|
push @EXPORT, qw(TEST_DB);
|
2017-10-12 18:55:48 +02:00
|
|
|
use constant TEST_C => 'c';
|
|
|
|
push @EXPORT, qw(TEST_C);
|
2016-06-24 14:12:58 +02:00
|
|
|
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);
|
2019-12-14 00:55:41 +02:00
|
|
|
use constant TEST_BIN_REQ => 'bin-req';
|
|
|
|
push @EXPORT, qw(TEST_BIN_REQ);
|
2022-11-14 06:47:27 +02:00
|
|
|
use constant TEST_PGSQL_BIN => 'psql-bin';
|
2016-06-24 14:12:58 +02:00
|
|
|
push @EXPORT, qw(TEST_PGSQL_BIN);
|
2018-05-22 18:53:08 +02:00
|
|
|
use constant TEST_INTEGRATION => 'integration';
|
|
|
|
push @EXPORT, qw(TEST_INTEGRATION);
|
2019-09-28 20:02:12 +02:00
|
|
|
use constant TEST_TYPE => 'type';
|
|
|
|
push @EXPORT, qw(TEST_TYPE);
|
2016-06-24 14:12:58 +02:00
|
|
|
use constant TEST_RUN => 'run';
|
|
|
|
push @EXPORT, qw(TEST_RUN);
|
|
|
|
use constant TEST_VM => 'os';
|
|
|
|
push @EXPORT, qw(TEST_VM);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# 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;
|
2017-04-10 18:31:30 +02:00
|
|
|
my $bCoverageOnly = shift;
|
2017-10-12 18:55:48 +02:00
|
|
|
my $bCOnly = shift;
|
2019-10-08 18:06:30 +02:00
|
|
|
my $bContainerOnly = shift;
|
2020-03-27 02:36:09 +02:00
|
|
|
my $bNoPerformance = 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;
|
|
|
|
|
2017-06-27 21:48:34 +02:00
|
|
|
# Database versions to test
|
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;
|
2017-06-27 21:48:34 +02:00
|
|
|
$iDbVersionMax = @{$$oyVm{$strTestOS}{&VM_DB_TEST}} - 1;
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2017-10-12 18:55:48 +02:00
|
|
|
# Skip this test if only C tests are requested and this is not a C test
|
|
|
|
next if ($bCOnly && !$hTest->{&TESTDEF_C});
|
|
|
|
|
2019-10-08 18:06:30 +02:00
|
|
|
# Skip this test if it is integration and vm=none
|
|
|
|
next if ($strVm eq VM_NONE && $hTest->{&TESTDEF_TYPE} eq TESTDEF_INTEGRATION);
|
|
|
|
|
2020-03-27 02:36:09 +02:00
|
|
|
# Skip this test if it is performance and no performance is specified
|
|
|
|
next if ($bNoPerformance && $hTest->{&TESTDEF_TYPE} eq TESTDEF_PERFORMANCE);
|
|
|
|
|
2020-03-09 23:41:59 +02:00
|
|
|
# Skip this test if it is not C and vm=none. Perl tests require Docker which is not supported.
|
2019-10-08 18:06:30 +02:00
|
|
|
next if ($strVm eq VM_NONE && !$hTest->{&TESTDEF_C});
|
|
|
|
|
|
|
|
# Skip this test if a container is required and vm=none.
|
|
|
|
next if ($strVm eq VM_NONE && $hTest->{&TESTDEF_CONTAINER_REQUIRED});
|
|
|
|
|
|
|
|
# Skip this if it does not require a container and container only tests are required.
|
|
|
|
next if ($bContainerOnly && $hTest->{&TESTDEF_C} && !$hTest->{&TESTDEF_CONTAINER_REQUIRED});
|
|
|
|
|
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' &&
|
2017-06-27 21:48:34 +02:00
|
|
|
$strDbVersion eq ${$$oyVm{$strTestOS}{&VM_DB_TEST}}[$iDbVersionIdx]))
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
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
|
|
|
|
2017-06-22 01:21:16 +02:00
|
|
|
my $strDbVersion = $iDbVersionIdx == -1 ? undef :
|
2017-06-27 21:48:34 +02:00
|
|
|
${$$oyVm{$strTestOS}{&VM_DB_TEST}}[$iDbVersionIdx];
|
2016-06-24 14:12:58 +02:00
|
|
|
|
2017-06-22 01:21:16 +02:00
|
|
|
my $strPgSqlBin = $$oyVm{$strTestOS}{&VMDEF_PGSQL_BIN};
|
|
|
|
|
|
|
|
if (defined($strDbVersion))
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-06-22 01:21:16 +02:00
|
|
|
$strPgSqlBin =~ s/\{\[version\]\}/$strDbVersion/g;
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
2017-06-22 01:21:16 +02:00
|
|
|
else
|
2016-06-24 14:12:58 +02:00
|
|
|
{
|
2017-06-22 01:21:16 +02:00
|
|
|
$strPgSqlBin =~ s/\{\[version\]\}/9\.4/g;
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
2017-06-22 01:21:16 +02:00
|
|
|
|
|
|
|
my $oTestRun =
|
|
|
|
{
|
2019-09-28 20:02:12 +02:00
|
|
|
&TEST_TYPE => $hTest->{&TESTDEF_TYPE},
|
2017-06-22 01:21:16 +02:00
|
|
|
&TEST_VM => $strTestOS,
|
2017-10-12 18:55:48 +02:00
|
|
|
&TEST_C => coalesce($hTest->{&TESTDEF_C}, $hModule->{&TESTDEF_C}, false),
|
2017-06-22 01:21:16 +02:00
|
|
|
&TEST_CONTAINER => defined($hTest->{&TESTDEF_CONTAINER}) ?
|
|
|
|
$hTest->{&TESTDEF_CONTAINER} : $hModule->{&TESTDEF_CONTAINER},
|
|
|
|
&TEST_PGSQL_BIN => $strPgSqlBin,
|
2019-12-14 00:55:41 +02:00
|
|
|
&TEST_BIN_REQ => $hTest->{&TESTDEF_BIN_REQ},
|
2018-05-22 18:53:08 +02:00
|
|
|
&TEST_INTEGRATION => $hTest->{&TESTDEF_INTEGRATION},
|
2017-06-22 01:21:16 +02:00
|
|
|
&TEST_MODULE => $strModule,
|
|
|
|
&TEST_NAME => $strModuleTest,
|
|
|
|
&TEST_RUN =>
|
|
|
|
$iTestRunIdx == -1 ? (@{$iyModuleTestRun} == 0 ? undef : $iyModuleTestRun) :
|
|
|
|
[$iTestRunIdx],
|
|
|
|
&TEST_DB => $strDbVersion
|
|
|
|
};
|
|
|
|
|
|
|
|
push(@{$oyTestRun}, $oTestRun);
|
2016-06-24 14:12:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$bFirstDbVersion = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $oyTestRun;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @EXPORT, qw(testListGet);
|
|
|
|
|
|
|
|
1;
|