1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Automatically check that all supported PostgreSQL versions are being tested on a single default VM.

This commit is contained in:
David Steele 2017-06-27 15:48:34 -04:00
parent 7a1385cc27
commit 001cff9eb9
4 changed files with 54 additions and 18 deletions

View File

@ -293,6 +293,10 @@
<release-item>
<p>Balance database versions between VMs to minimize test duration.</p>
</release-item>
<release-item>
<p>Automatically check that all supported <postgres/> versions are being tested on a single default VM.</p>
</release-item>
</release-refactor-list>
</release-test-list>
</release>

View File

@ -82,19 +82,11 @@ sub testListGet
my $iDbVersionMin = -1;
my $iDbVersionMax = -1;
# By default test every db version that is supported for each OS
my $strDbVersionKey = &VM_DB;
# Run a reduced set of tests where each PG version is only tested on a single OS
if ($strDbVersion eq 'minimal' && defined($oyVm->{$strTestOS}{&VM_DB_MINIMAL}))
{
$strDbVersionKey = &VM_DB_MINIMAL;
}
# Database versions to test
if (defined($hTest->{&TESTDEF_DB}) && $hTest->{&TESTDEF_DB})
{
$iDbVersionMin = 0;
$iDbVersionMax = @{$$oyVm{$strTestOS}{$strDbVersionKey}} - 1;
$iDbVersionMax = @{$$oyVm{$strTestOS}{&VM_DB_TEST}} - 1;
}
my $bFirstDbVersion = true;
@ -106,7 +98,7 @@ sub testListGet
{
if ($iDbVersionIdx == -1 || $strDbVersion eq 'all' || $strDbVersion eq 'minimal' ||
($strDbVersion ne 'all' &&
$strDbVersion eq ${$$oyVm{$strTestOS}{$strDbVersionKey}}[$iDbVersionIdx]))
$strDbVersion eq ${$$oyVm{$strTestOS}{&VM_DB_TEST}}[$iDbVersionIdx]))
{
# Individual tests will be each be run in a separate container. This is the default.
my $bTestIndividual =
@ -126,7 +118,7 @@ sub testListGet
next if ($bCoverageOnly && !defined($hTest->{&TESTDEF_COVERAGE}));
my $strDbVersion = $iDbVersionIdx == -1 ? undef :
${$$oyVm{$strTestOS}{$strDbVersionKey}}[$iDbVersionIdx];
${$$oyVm{$strTestOS}{&VM_DB_TEST}}[$iDbVersionIdx];
my $strPgSqlBin = $$oyVm{$strTestOS}{&VMDEF_PGSQL_BIN};

View File

@ -21,8 +21,8 @@ use pgBackRest::DbVersion;
####################################################################################################################################
use constant VM_DB => 'db';
push @EXPORT, qw(VM_DB);
use constant VM_DB_MINIMAL => 'db-minimal';
push @EXPORT, qw(VM_DB_MINIMAL);
use constant VM_DB_TEST => 'db-test';
push @EXPORT, qw(VM_DB_TEST);
use constant VM_CONTROL_MASTER => 'control-master';
push @EXPORT, qw(VM_CONTROL_MASTER);
use constant VM_DEPRECATED => 'deprecated';
@ -104,7 +104,7 @@ my $oyVm =
PG_VERSION_96,
],
&VM_DB_MINIMAL =>
&VM_DB_TEST =>
[
PG_VERSION_90,
PG_VERSION_91,
@ -185,6 +185,46 @@ my $oyVm =
},
};
####################################################################################################################################
# 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;
foreach my $strVm (VM_LIST)
{
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;
}
}
}
if (!defined($strVmPgVersionRun))
{
confess &log(ASSERT, "PostgreSQL ${strPgVersion} is not configured to run on a default vm");
}
}
####################################################################################################################################
# vmGet
####################################################################################################################################

View File

@ -66,10 +66,10 @@ sub run
my $hyVm = vmGet();
if (($bS3 || $bHostBackup) &&
(@{$hyVm->{$self->vm()}{&VM_DB}} > 1 && ${$hyVm->{$self->vm()}{&VM_DB}}[-1] ne $self->pgVersion()))
(@{$hyVm->{$self->vm()}{&VM_DB_TEST}} > 1 && ${$hyVm->{$self->vm()}{&VM_DB_TEST}}[-1] ne $self->pgVersion()))
{
&log(INFO,
'skipped - this test will be run for this OS using PG ' . ${$hyVm->{$self->vm()}{&VM_DB}}[-1]);
'skipped - this test is run this OS using PG ' . ${$hyVm->{$self->vm()}{&VM_DB_TEST}}[-1]);
next;
}
@ -83,7 +83,7 @@ sub run
# Skip backup destinations other than backup host when standby except for one arbitrary db version
if ($bHostStandby && $strBackupDestination ne HOST_BACKUP && $self->pgVersion() ne PG_VERSION_96)
{
&log(INFO, 'skipped - standby with backup destination other than backup host only tested on PG ' . PG_VERSION_96);
&log(INFO, 'skipped - standby with backup destination other than backup host is tested on PG ' . PG_VERSION_96);
next;
}