mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-03 14:52:21 +02:00
Database versions are now run as separate tests.
This commit is contained in:
parent
cd9fa6f028
commit
0f88943b7b
65
test/lib/BackRestTest/Common/VmTest.pm
Normal file
65
test/lib/BackRestTest/Common/VmTest.pm
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
####################################################################################################################################
|
||||||
|
# VmTest.pm - Vm constants and data
|
||||||
|
####################################################################################################################################
|
||||||
|
package BackRestTest::Common::VmTest;
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Perl includes
|
||||||
|
####################################################################################################################################
|
||||||
|
use strict;
|
||||||
|
use warnings FATAL => qw(all);
|
||||||
|
use Carp qw(confess);
|
||||||
|
|
||||||
|
use Exporter qw(import);
|
||||||
|
our @EXPORT = qw();
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# Valid OS list
|
||||||
|
####################################################################################################################################
|
||||||
|
use constant OS_CO6 => 'co6';
|
||||||
|
push @EXPORT, qw(OS_CO6);
|
||||||
|
use constant OS_CO7 => 'co7';
|
||||||
|
push @EXPORT, qw(OS_CO7);
|
||||||
|
use constant OS_U12 => 'u12';
|
||||||
|
push @EXPORT, qw(OS_U12);
|
||||||
|
use constant OS_U14 => 'u14';
|
||||||
|
push @EXPORT, qw(OS_U14);
|
||||||
|
|
||||||
|
my $oyVm =
|
||||||
|
{
|
||||||
|
# CentOS 6
|
||||||
|
&OS_CO6 =>
|
||||||
|
{
|
||||||
|
db => ['9.0', '9.1', '9.2', '9.3', '9.4', '9.5']
|
||||||
|
},
|
||||||
|
|
||||||
|
# CentOS 7
|
||||||
|
&OS_CO7 =>
|
||||||
|
{
|
||||||
|
db => ['9.3', '9.4', '9.5']
|
||||||
|
},
|
||||||
|
|
||||||
|
# Ubuntu 12.04
|
||||||
|
&OS_U12 =>
|
||||||
|
{
|
||||||
|
db => ['8.4', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5']
|
||||||
|
},
|
||||||
|
|
||||||
|
# Ubuntu 14.04
|
||||||
|
&OS_U14 =>
|
||||||
|
{
|
||||||
|
db => ['9.0', '9.1', '9.2', '9.3', '9.4', '9.5']
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
####################################################################################################################################
|
||||||
|
# vmGet
|
||||||
|
####################################################################################################################################
|
||||||
|
sub vmGet
|
||||||
|
{
|
||||||
|
return $oyVm;
|
||||||
|
}
|
||||||
|
|
||||||
|
push @EXPORT, qw(vmGet);
|
||||||
|
|
||||||
|
1;
|
@ -1,7 +1,7 @@
|
|||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# Container.pm - Build docker containers for testing and documentation
|
# ContainerTest.pm - Build docker containers for testing and documentation
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
package BackRestTest::Docker::Container;
|
package BackRestTest::Docker::ContainerTest;
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# Perl includes
|
# Perl includes
|
||||||
@ -22,22 +22,7 @@ use BackRest::Common::Log;
|
|||||||
use BackRest::FileCommon;
|
use BackRest::FileCommon;
|
||||||
|
|
||||||
use BackRestTest::Common::ExecuteTest;
|
use BackRestTest::Common::ExecuteTest;
|
||||||
|
use BackRestTest::Common::VmTest;
|
||||||
####################################################################################################################################
|
|
||||||
# Valid OS list
|
|
||||||
####################################################################################################################################
|
|
||||||
use constant OS_CO6 => 'co6';
|
|
||||||
use constant OS_CO7 => 'co7';
|
|
||||||
use constant OS_U12 => 'u12';
|
|
||||||
use constant OS_U14 => 'u14';
|
|
||||||
|
|
||||||
my @stryOS =
|
|
||||||
(
|
|
||||||
OS_CO6, # CentOS 6
|
|
||||||
OS_CO7, # CentOS 7
|
|
||||||
OS_U12, # Ubuntu 12.04
|
|
||||||
OS_U14 # Ubuntu 14.04
|
|
||||||
);
|
|
||||||
|
|
||||||
use constant TEST_GROUP => 'admin';
|
use constant TEST_GROUP => 'admin';
|
||||||
use constant TEST_GROUP_ID => 1000;
|
use constant TEST_GROUP_ID => 1000;
|
||||||
@ -214,8 +199,11 @@ sub containerBuild
|
|||||||
executeTest("ssh-keygen -f ${strTempPath}/id_rsa -t rsa -b 768 -N ''", {bSuppressStdErr => true});
|
executeTest("ssh-keygen -f ${strTempPath}/id_rsa -t rsa -b 768 -N ''", {bSuppressStdErr => true});
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $strOS (@stryOS)
|
my $oyVm = vmGet();
|
||||||
|
|
||||||
|
foreach my $strOS (sort(keys(%$oyVm)))
|
||||||
{
|
{
|
||||||
|
my $oOS = $$oyVm{$strOS};
|
||||||
my $strImage;
|
my $strImage;
|
||||||
my $strImageName;
|
my $strImageName;
|
||||||
|
|
||||||
@ -378,58 +366,31 @@ sub containerBuild
|
|||||||
|
|
||||||
# Install PostgreSQL
|
# Install PostgreSQL
|
||||||
$strImage .=
|
$strImage .=
|
||||||
"\n\n# Install PostgreSQL\n";
|
"\n\n# Install PostgreSQL";
|
||||||
|
|
||||||
if ($strOS eq OS_CO6)
|
foreach my $strDbVersion (@{$$oOS{db}})
|
||||||
{
|
{
|
||||||
$strImage .=
|
if ($strOS eq OS_CO6 || $strOS eq OS_CO7)
|
||||||
"RUN yum -y install postgresql90-server\n" .
|
{
|
||||||
"RUN yum -y install postgresql91-server\n" .
|
$strDbVersion =~ s/\.//;
|
||||||
"RUN yum -y install postgresql92-server\n" .
|
}
|
||||||
"RUN yum -y install postgresql93-server\n" .
|
|
||||||
"RUN yum -y install postgresql94-server\n" .
|
if ($strOS eq OS_CO6)
|
||||||
"RUN yum -y install postgresql95-server";
|
{
|
||||||
}
|
$strImage .=
|
||||||
elsif ($strOS eq OS_CO7)
|
"\nRUN yum -y install postgresql${strDbVersion}-server";
|
||||||
{
|
}
|
||||||
$strImage .=
|
elsif ($strOS eq OS_CO7)
|
||||||
"RUN yum -y install postgresql93-server\n" .
|
{
|
||||||
"RUN yum -y install postgresql94-server\n" .
|
$strImage .=
|
||||||
"RUN yum -y install postgresql95-server";
|
"\nRUN yum -y install postgresql${strDbVersion}-server";
|
||||||
}
|
}
|
||||||
elsif ($strOS eq OS_U12)
|
elsif ($strOS eq OS_U12 || $strOS eq OS_U14)
|
||||||
{
|
{
|
||||||
$strImage .=
|
$strImage .=
|
||||||
"RUN apt-get install -y postgresql-9.5\n" .
|
"\nRUN apt-get install -y postgresql-${strDbVersion}" .
|
||||||
"RUN pg_dropcluster --stop 9.5 main\n" .
|
"\nRUN pg_dropcluster --stop ${strDbVersion} main";
|
||||||
"RUN apt-get install -y postgresql-9.4\n" .
|
}
|
||||||
"RUN pg_dropcluster --stop 9.4 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.3\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.3 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.2\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.2 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.1\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.1 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.0\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.0 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-8.4\n" .
|
|
||||||
"RUN pg_dropcluster --stop 8.4 main";
|
|
||||||
}
|
|
||||||
elsif ($strOS eq OS_U14)
|
|
||||||
{
|
|
||||||
$strImage .=
|
|
||||||
"RUN apt-get install -y postgresql-9.5\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.5 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.4\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.4 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.3\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.3 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.2\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.2 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.1\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.1 main\n" .
|
|
||||||
"RUN apt-get install -y postgresql-9.0\n" .
|
|
||||||
"RUN pg_dropcluster --stop 9.0 main";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write the image
|
# Write the image
|
||||||
@ -437,7 +398,6 @@ sub containerBuild
|
|||||||
executeTest("docker build -f ${strTempPath}/${strImageName} -t backrest/${strImageName} ${strTempPath}",
|
executeTest("docker build -f ${strTempPath}/${strImageName} -t backrest/${strImageName} ${strTempPath}",
|
||||||
{bSuppressStdErr => true});
|
{bSuppressStdErr => true});
|
||||||
|
|
||||||
|
|
||||||
# Db Doc image
|
# Db Doc image
|
||||||
###########################################################################################################################
|
###########################################################################################################################
|
||||||
$strImageName = "${strOS}-db-doc";
|
$strImageName = "${strOS}-db-doc";
|
122
test/test.pl
122
test/test.pl
@ -31,10 +31,11 @@ use BackRest::Db;
|
|||||||
use lib dirname($0) . '/lib';
|
use lib dirname($0) . '/lib';
|
||||||
use BackRestTest::BackupTest;
|
use BackRestTest::BackupTest;
|
||||||
use BackRestTest::Common::ExecuteTest;
|
use BackRestTest::Common::ExecuteTest;
|
||||||
|
use BackRestTest::Common::VmTest;
|
||||||
use BackRestTest::CommonTest;
|
use BackRestTest::CommonTest;
|
||||||
use BackRestTest::CompareTest;
|
use BackRestTest::CompareTest;
|
||||||
use BackRestTest::ConfigTest;
|
use BackRestTest::ConfigTest;
|
||||||
use BackRestTest::Docker::Container;
|
use BackRestTest::Docker::ContainerTest;
|
||||||
use BackRestTest::FileTest;
|
use BackRestTest::FileTest;
|
||||||
use BackRestTest::HelpTest;
|
use BackRestTest::HelpTest;
|
||||||
|
|
||||||
@ -316,7 +317,8 @@ eval
|
|||||||
{
|
{
|
||||||
name => 'full',
|
name => 'full',
|
||||||
total => 8,
|
total => 8,
|
||||||
thread => true
|
thread => true,
|
||||||
|
db => true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -330,66 +332,89 @@ eval
|
|||||||
################################################################################################################################
|
################################################################################################################################
|
||||||
if ($strOS ne 'none')
|
if ($strOS ne 'none')
|
||||||
{
|
{
|
||||||
|
my $oyVm = vmGet();
|
||||||
|
|
||||||
|
if ($strOS ne 'all' && !defined($${oyVm}{$strOS}))
|
||||||
|
{
|
||||||
|
confess &log(ERROR, "${strOS} is not a valid VM");
|
||||||
|
}
|
||||||
|
|
||||||
# Determine which tests to run
|
# Determine which tests to run
|
||||||
my $iTestsToRun = 0;
|
my $iTestsToRun = 0;
|
||||||
|
|
||||||
foreach my $oModule (@{$$oTestDefinition{module}})
|
my $stryTestOS = [];
|
||||||
|
|
||||||
|
if ($strOS eq 'all')
|
||||||
{
|
{
|
||||||
if ($strModule eq $$oModule{name} || $strModule eq 'all')
|
$stryTestOS = ['co6', 'u12', 'co7', 'u14'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$stryTestOS = [$strOS];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $strTestOS (@{$stryTestOS})
|
||||||
|
{
|
||||||
|
foreach my $oModule (@{$$oTestDefinition{module}})
|
||||||
{
|
{
|
||||||
&log(DEBUG, "Select Module $$oModule{name}");
|
if ($strModule eq $$oModule{name} || $strModule eq 'all')
|
||||||
|
|
||||||
foreach my $oTest (@{$$oModule{test}})
|
|
||||||
{
|
{
|
||||||
if ($strModuleTest eq $$oTest{name} || $strModuleTest eq 'all')
|
foreach my $oTest (@{$$oModule{test}})
|
||||||
{
|
{
|
||||||
&log(DEBUG, " Select Test $$oTest{name}");
|
if ($strModuleTest eq $$oTest{name} || $strModuleTest eq 'all')
|
||||||
|
|
||||||
my $iTestRunMin = defined($iModuleTestRun) ? $iModuleTestRun : (defined($$oTest{total}) ? 1 : -1);
|
|
||||||
my $iTestRunMax = defined($iModuleTestRun) ? $iModuleTestRun : (defined($$oTest{total}) ? $$oTest{total} : -1);
|
|
||||||
|
|
||||||
if (defined($$oTest{total}) && $iTestRunMax > $$oTest{total})
|
|
||||||
{
|
{
|
||||||
confess &log(ERROR, "invalid run - must be >= 1 and <= $$oTest{total}")
|
my $iDbVersionMin = -1;
|
||||||
}
|
my $iDbVersionMax = -1;
|
||||||
|
|
||||||
for (my $iTestRunIdx = $iTestRunMin; $iTestRunIdx <= $iTestRunMax; $iTestRunIdx++)
|
if (defined($$oTest{db}) && $$oTest{db})
|
||||||
{
|
|
||||||
&log(DEBUG, " Select Run $iTestRunIdx");
|
|
||||||
|
|
||||||
my $stryTestOS = [];
|
|
||||||
|
|
||||||
if ($strOS eq 'all')
|
|
||||||
{
|
{
|
||||||
$stryTestOS = ['u12', 'u14', 'co6', 'co7'];
|
$iDbVersionMin = 0;
|
||||||
}
|
$iDbVersionMax = @{$$oyVm{$strTestOS}{db}} - 1;
|
||||||
else
|
|
||||||
{
|
|
||||||
$stryTestOS = [$strOS];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $iyThreadMax = [defined($iThreadMax) ? $iThreadMax : 1];
|
my $bFirstDbVersion = true;
|
||||||
|
|
||||||
if (defined($$oTest{thread}) && $$oTest{thread} && !defined($iThreadMax))
|
for (my $iDbVersionIdx = $iDbVersionMax; $iDbVersionIdx >= $iDbVersionMin; $iDbVersionIdx--)
|
||||||
{
|
{
|
||||||
$iyThreadMax = [1, 4];
|
if ($iDbVersionIdx == -1 || $strDbVersion eq 'all' ||
|
||||||
}
|
($strDbVersion ne 'all' && $strDbVersion eq ${$$oyVm{$strTestOS}{db}}[$iDbVersionIdx]))
|
||||||
|
|
||||||
foreach my $iThreadTestMax (@{$iyThreadMax})
|
|
||||||
{
|
|
||||||
foreach my $strTestOS (@{$stryTestOS})
|
|
||||||
{
|
{
|
||||||
my $oTestRun =
|
my $iTestRunMin = defined($iModuleTestRun) ? $iModuleTestRun : (defined($$oTest{total}) ? 1 : -1);
|
||||||
{
|
my $iTestRunMax = defined($iModuleTestRun) ? $iModuleTestRun : (defined($$oTest{total}) ? $$oTest{total} : -1);
|
||||||
os => $strTestOS,
|
|
||||||
module => $$oModule{name},
|
|
||||||
test => $$oTest{name},
|
|
||||||
run => $iTestRunIdx == -1 ? undef : $iTestRunIdx,
|
|
||||||
thread => $iThreadTestMax
|
|
||||||
};
|
|
||||||
|
|
||||||
push(@{$oyTestRun}, $oTestRun);
|
if (defined($$oTest{total}) && $iTestRunMax > $$oTest{total})
|
||||||
$iTestsToRun++;
|
{
|
||||||
|
confess &log(ERROR, "invalid run - must be >= 1 and <= $$oTest{total}")
|
||||||
|
}
|
||||||
|
|
||||||
|
for (my $iTestRunIdx = $iTestRunMin; $iTestRunIdx <= $iTestRunMax; $iTestRunIdx++)
|
||||||
|
{
|
||||||
|
my $iyThreadMax = [defined($iThreadMax) ? $iThreadMax : 1];
|
||||||
|
|
||||||
|
if (defined($$oTest{thread}) && $$oTest{thread} &&
|
||||||
|
!defined($iThreadMax) && $bFirstDbVersion)
|
||||||
|
{
|
||||||
|
$iyThreadMax = [1, 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $iThreadTestMax (@{$iyThreadMax})
|
||||||
|
{
|
||||||
|
my $oTestRun =
|
||||||
|
{
|
||||||
|
os => $strTestOS,
|
||||||
|
module => $$oModule{name},
|
||||||
|
test => $$oTest{name},
|
||||||
|
run => $iTestRunIdx == -1 ? undef : $iTestRunIdx,
|
||||||
|
thread => $iThreadTestMax,
|
||||||
|
db => $iDbVersionIdx == -1 ? undef : ${$$oyVm{$strTestOS}{db}}[$iDbVersionIdx]
|
||||||
|
};
|
||||||
|
|
||||||
|
push(@{$oyTestRun}, $oTestRun);
|
||||||
|
$iTestsToRun++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$bFirstDbVersion = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -487,7 +512,8 @@ eval
|
|||||||
length($iTestMax) . "d - ", $iProcessIdx, $iTestIdx, $iTestMax) .
|
length($iTestMax) . "d - ", $iProcessIdx, $iTestIdx, $iTestMax) .
|
||||||
"vm=$$oTest{os}, module=$$oTest{module}, test=$$oTest{test}" .
|
"vm=$$oTest{os}, module=$$oTest{module}, test=$$oTest{test}" .
|
||||||
(defined($$oTest{run}) ? ", run=$$oTest{run}" : '') .
|
(defined($$oTest{run}) ? ", run=$$oTest{run}" : '') .
|
||||||
(defined($$oTest{thread}) ? ", thread-max=$$oTest{thread}" : '');
|
(defined($$oTest{thread}) ? ", thread-max=$$oTest{thread}" : '') .
|
||||||
|
(defined($$oTest{db}) ? ", db=$$oTest{db}" : '');
|
||||||
|
|
||||||
my $strImage = 'test-' . $iProcessIdx;
|
my $strImage = 'test-' . $iProcessIdx;
|
||||||
|
|
||||||
@ -504,11 +530,13 @@ eval
|
|||||||
$strCommandLine =~ s/\-\-module\=\S*//g;
|
$strCommandLine =~ s/\-\-module\=\S*//g;
|
||||||
$strCommandLine =~ s/\-\-test\=\S*//g;
|
$strCommandLine =~ s/\-\-test\=\S*//g;
|
||||||
$strCommandLine =~ s/\-\-run\=\S*//g;
|
$strCommandLine =~ s/\-\-run\=\S*//g;
|
||||||
|
$strCommandLine =~ s/\-\-db\-version\=\S*//g;
|
||||||
|
|
||||||
my $strCommand = "docker exec -i -u vagrant ${strImage} $0 ${strCommandLine} --test-path=/home/vagrant/test" .
|
my $strCommand = "docker exec -i -u vagrant ${strImage} $0 ${strCommandLine} --test-path=/home/vagrant/test" .
|
||||||
" --vm=none --module=$$oTest{module} --test=$$oTest{test}" .
|
" --vm=none --module=$$oTest{module} --test=$$oTest{test}" .
|
||||||
(defined($$oTest{run}) ? " --run=$$oTest{run}" : '') .
|
(defined($$oTest{run}) ? " --run=$$oTest{run}" : '') .
|
||||||
(defined($$oTest{thread}) ? " --thread-max=$$oTest{thread}" : '') .
|
(defined($$oTest{thread}) ? " --thread-max=$$oTest{thread}" : '') .
|
||||||
|
(defined($$oTest{db}) ? " --db-version=$$oTest{db}" : '') .
|
||||||
" --no-cleanup";
|
" --no-cleanup";
|
||||||
|
|
||||||
&log(DEBUG, $strCommand);
|
&log(DEBUG, $strCommand);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user