1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-09-16 09:06:18 +02:00

Added Ubuntu 16.04 and Debian 8 to regression tests.

Also added some new fields to make container generation simpler for distros that share a common package base.
This commit is contained in:
David Steele
2016-05-24 08:17:13 -04:00
parent f2a14a06e5
commit e7d4a25d6a
3 changed files with 153 additions and 70 deletions

View File

@@ -18,23 +18,61 @@ use pgBackRest::Db;
use Exporter qw(import); use Exporter qw(import);
our @EXPORT = qw(); our @EXPORT = qw();
####################################################################################################################################
# VM hash keywords
####################################################################################################################################
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);
####################################################################################################################################
# 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);
#################################################################################################################################### ####################################################################################################################################
# Valid OS list # Valid OS list
#################################################################################################################################### ####################################################################################################################################
use constant OS_CO6 => 'co6'; use constant VM_OS_CENTOS => 'centos';
push @EXPORT, qw(OS_CO6); push @EXPORT, qw(VM_OS_CENTOS);
use constant OS_CO7 => 'co7'; use constant VM_OS_DEBIAN => 'debian';
push @EXPORT, qw(OS_CO7); push @EXPORT, qw(VM_OS_DEBIAN);
use constant OS_U12 => 'u12'; use constant VM_OS_UBUNTU => 'ubuntu';
push @EXPORT, qw(OS_U12); push @EXPORT, qw(VM_OS_DEBIAN);
use constant OS_U14 => 'u14';
push @EXPORT, qw(OS_U14); ####################################################################################################################################
# Valid VM list
####################################################################################################################################
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);
my $oyVm = my $oyVm =
{ {
# CentOS 6 # CentOS 6
&OS_CO6 => &VM_CO6 =>
{ {
&VM_OS_BASE => VM_OS_BASE_RHEL,
&VM_OS => VM_OS_CENTOS,
&VM_IMAGE => 'centos:6',
db => db =>
[ [
PG_VERSION_90, PG_VERSION_90,
@@ -54,8 +92,12 @@ my $oyVm =
}, },
# CentOS 7 # CentOS 7
&OS_CO7 => &VM_CO7 =>
{ {
&VM_OS_BASE => VM_OS_BASE_RHEL,
&VM_OS => VM_OS_CENTOS,
&VM_IMAGE => 'centos:7',
db => db =>
[ [
PG_VERSION_93, PG_VERSION_93,
@@ -66,15 +108,46 @@ my $oyVm =
db_minimal => db_minimal =>
[ [
PG_VERSION_93,
PG_VERSION_95, PG_VERSION_95,
PG_VERSION_96, 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',
db =>
[
PG_VERSION_84,
PG_VERSION_90,
PG_VERSION_91,
PG_VERSION_92,
PG_VERSION_93,
PG_VERSION_94,
PG_VERSION_95,
PG_VERSION_96,
],
db_minimal =>
[
PG_VERSION_84,
PG_VERSION_93,
],
},
# Ubuntu 12.04 # Ubuntu 12.04
&OS_U12 => &VM_U12 =>
{ {
&VM_OS_BASE => VM_OS_BASE_DEBIAN,
&VM_OS => VM_OS_UBUNTU,
&VM_OS_REPO => 'precise',
&VM_IMAGE => 'ubuntu:12.04',
db => db =>
[ [
PG_VERSION_83, PG_VERSION_83,
@@ -91,13 +164,17 @@ my $oyVm =
db_minimal => db_minimal =>
[ [
PG_VERSION_83, PG_VERSION_83,
PG_VERSION_84,
], ],
}, },
# Ubuntu 14.04 # Ubuntu 14.04
&OS_U14 => &VM_U14 =>
{ {
&VM_OS_BASE => VM_OS_BASE_DEBIAN,
&VM_OS => VM_OS_UBUNTU,
&VM_OS_REPO => 'trusty',
&VM_IMAGE => 'ubuntu:14.04',
db => db =>
[ [
PG_VERSION_90, PG_VERSION_90,
@@ -112,6 +189,29 @@ my $oyVm =
db_minimal => db_minimal =>
[ [
PG_VERSION_92, PG_VERSION_92,
],
},
# 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',
db =>
[
PG_VERSION_91,
PG_VERSION_92,
PG_VERSION_93,
PG_VERSION_94,
PG_VERSION_95,
PG_VERSION_96,
],
db_minimal =>
[
PG_VERSION_94, PG_VERSION_94,
], ],
}, },

View File

@@ -59,11 +59,13 @@ sub userCreate
my $iId = shift; my $iId = shift;
my $strGroup = shift; my $strGroup = shift;
if ($strOS eq OS_CO6 || $strOS eq OS_CO7) my $oVm = vmGet();
if ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_RHEL)
{ {
return "RUN adduser -g${strGroup} -u${iId} -n ${strName}"; return "RUN adduser -g${strGroup} -u${iId} -n ${strName}";
} }
elsif ($strOS eq OS_U12 || $strOS eq OS_U14) elsif ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
{ {
return "RUN adduser --uid=${iId} --ingroup=${strGroup} --disabled-password --gecos \"\" ${strName}"; return "RUN adduser --uid=${iId} --ingroup=${strGroup} --disabled-password --gecos \"\" ${strName}";
} }
@@ -176,23 +178,28 @@ sub perlInstall
my $strImage = my $strImage =
"# Install Perl packages\n"; "# Install Perl packages\n";
if ($strOS eq OS_CO6) if ($strOS eq VM_CO6)
{ {
$strImage .= return $strImage .
"RUN yum -y install perl perl-Time-HiRes perl-parent perl-JSON perl-Digest-SHA perl-DBD-Pg"; "RUN yum -y install perl perl-Time-HiRes perl-parent perl-JSON perl-Digest-SHA perl-DBD-Pg";
} }
elsif ($strOS eq OS_CO7) elsif ($strOS eq VM_CO7)
{ {
$strImage .= return $strImage .
"RUN yum -y install perl perl-Thread-Queue perl-JSON-PP perl-Digest-SHA perl-DBD-Pg"; "RUN yum -y install perl perl-Thread-Queue perl-JSON-PP perl-Digest-SHA perl-DBD-Pg";
} }
elsif ($strOS eq OS_U12 || $strOS eq OS_U14) elsif ($strOS eq VM_U12 || $strOS eq VM_U14)
{ {
$strImage .= return $strImage .
"RUN apt-get -y install libdbd-pg-perl libdbi-perl libnet-daemon-perl libplrpc-perl"; "RUN apt-get -y install libdbd-pg-perl libdbi-perl libnet-daemon-perl libplrpc-perl";
} }
elsif ($strOS eq VM_U16 || $strOS eq VM_D8)
{
return $strImage .
"RUN apt-get -y install libdbd-pg-perl libdbi-perl";
}
return $strImage; confess &log(ERROR, "unable to install perl for os '${strOS}'");
} }
#################################################################################################################################### ####################################################################################################################################
@@ -221,19 +228,19 @@ sub containerBuild
{ {
&log(INFO, "Building SSH keys..."); &log(INFO, "Building SSH keys...");
executeTest("ssh-keygen -f ${strTempPath}/id_rsa -t rsa -b 768 -N ''", {bSuppressStdErr => true}); executeTest("ssh-keygen -f ${strTempPath}/id_rsa -t rsa -b 1024 -N ''", {bSuppressStdErr => true});
} }
my $oyVm = vmGet(); my $oVm = vmGet();
foreach my $strOS (sort(keys(%$oyVm))) foreach my $strOS (sort(keys(%$oVm)))
{ {
if ($strVm ne 'all' && $strVm ne $strOS) if ($strVm ne 'all' && $strVm ne $strOS)
{ {
next; next;
} }
my $oOS = $$oyVm{$strOS}; my $oOS = $$oVm{$strOS};
my $strImage; my $strImage;
my $strImageName; my $strImageName;
@@ -242,33 +249,16 @@ sub containerBuild
$strImageName = "${strOS}-base"; $strImageName = "${strOS}-base";
&log(INFO, "Building ${strImageName} image..."); &log(INFO, "Building ${strImageName} image...");
$strImage = "# Base Container\nFROM "; $strImage = "# Base Container\nFROM " . $$oVm{$strOS}{&VM_IMAGE};
if ($strOS eq OS_CO6)
{
$strImage .= 'centos:6';
}
elsif ($strOS eq OS_CO7)
{
$strImage .= 'centos:7';
}
elsif ($strOS eq OS_U12)
{
$strImage .= 'ubuntu:12.04';
}
elsif ($strOS eq OS_U14)
{
$strImage .= 'ubuntu:14.04';
}
# Install SSH # Install SSH
$strImage .= "\n\n# Install SSH\n"; $strImage .= "\n\n# Install SSH\n";
if ($strOS eq OS_CO6 || $strOS eq OS_CO7) if ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_RHEL)
{ {
$strImage .= "RUN yum -y install openssh-server openssh-clients\n"; $strImage .= "RUN yum -y install openssh-server openssh-clients\n";
} }
elsif ($strOS eq OS_U12 || $strOS eq OS_U14) elsif ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
{ {
$strImage .= $strImage .=
"RUN apt-get update\n" . "RUN apt-get update\n" .
@@ -277,7 +267,7 @@ sub containerBuild
$strImage .= $strImage .=
"RUN rm -f /etc/ssh/ssh_host_rsa_key*\n" . "RUN rm -f /etc/ssh/ssh_host_rsa_key*\n" .
"RUN ssh-keygen -t rsa -b 768 -f /etc/ssh/ssh_host_rsa_key"; "RUN ssh-keygen -t rsa -b 1024 -f /etc/ssh/ssh_host_rsa_key";
# Create PostgreSQL Group # Create PostgreSQL Group
$strImage .= "\n\n" . postgresGroupCreate($strOS); $strImage .= "\n\n" . postgresGroupCreate($strOS);
@@ -285,7 +275,7 @@ sub containerBuild
# Add PostgreSQL packages # Add PostgreSQL packages
$strImage .= "\n\n# Add PostgreSQL packages\n"; $strImage .= "\n\n# Add PostgreSQL packages\n";
if ($strOS eq OS_CO6) if ($strOS eq VM_CO6)
{ {
$strImage .= $strImage .=
"RUN rpm -ivh http://yum.postgresql.org/9.0/redhat/rhel-6-x86_64/pgdg-centos90-9.0-5.noarch.rpm\n" . "RUN rpm -ivh http://yum.postgresql.org/9.0/redhat/rhel-6-x86_64/pgdg-centos90-9.0-5.noarch.rpm\n" .
@@ -296,7 +286,7 @@ sub containerBuild
"RUN rpm -ivh http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-2.noarch.rpm\n" . "RUN rpm -ivh http://yum.postgresql.org/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-2.noarch.rpm\n" .
"RUN rpm -ivh http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-1.noarch.rpm"; "RUN rpm -ivh http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/pgdg-centos96-9.6-1.noarch.rpm";
} }
elsif ($strOS eq OS_CO7) elsif ($strOS eq VM_CO7)
{ {
$strImage .= $strImage .=
"RUN rpm -ivh http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-1.noarch.rpm\n" . "RUN rpm -ivh http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-1.noarch.rpm\n" .
@@ -304,18 +294,17 @@ sub containerBuild
"RUN rpm -ivh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-1.noarch.rpm\n" . "RUN rpm -ivh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-1.noarch.rpm\n" .
"RUN rpm -ivh http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-1.noarch.rpm"; "RUN rpm -ivh http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-1.noarch.rpm";
} }
elsif ($strOS eq OS_U12 || $strOS eq OS_U14) elsif ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
{ {
if ($strOS eq OS_U12) if ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
{ {
$strImage .= $strImage .=
"RUN apt-get install -y sudo\n"; "RUN apt-get install -y sudo wget\n";
} }
$strImage .= $strImage .=
"RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ " . "RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ " .
($strOS eq OS_U12 ? 'precise' : 'trusty') . $$oVm{$strOS}{&VM_OS_REPO} . "-pgdg main 9.6' >> /etc/apt/sources.list.d/pgdg.list\n" .
"-pgdg main 9.6' >> /etc/apt/sources.list.d/pgdg.list\n" .
"RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -\n" . "RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -\n" .
"RUN apt-get update"; "RUN apt-get update";
} }
@@ -325,14 +314,14 @@ sub containerBuild
"\n\n# Create test group\n" . "\n\n# Create test group\n" .
groupCreate($strOS, TEST_GROUP, TEST_GROUP_ID) . "\n"; groupCreate($strOS, TEST_GROUP, TEST_GROUP_ID) . "\n";
if ($strOS eq OS_CO6 || $strOS eq OS_CO7) if ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_RHEL)
{ {
$strImage .= $strImage .=
"RUN yum -y install sudo\n" . "RUN yum -y install sudo\n" .
"RUN echo '%" . TEST_GROUP . " ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/" . TEST_GROUP . "\n" . "RUN echo '%" . TEST_GROUP . " ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/" . TEST_GROUP . "\n" .
"RUN sed -i 's/^Defaults requiretty\$/\\# Defaults requiretty/' /etc/sudoers"; "RUN sed -i 's/^Defaults requiretty\$/\\# Defaults requiretty/' /etc/sudoers";
} }
elsif ($strOS eq OS_U12 || $strOS eq OS_U14) elsif ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
{ {
$strImage .= $strImage .=
"RUN sed -i 's/^\\\%admin.*\$/\\\%" . TEST_GROUP . " ALL\\=\\(ALL\\) NOPASSWD\\: ALL/' /etc/sudoers"; "RUN sed -i 's/^\\\%admin.*\$/\\\%" . TEST_GROUP . " ALL\\=\\(ALL\\) NOPASSWD\\: ALL/' /etc/sudoers";
@@ -344,7 +333,7 @@ sub containerBuild
userCreate($strOS, TEST_USER, TEST_USER_ID, TEST_GROUP); userCreate($strOS, TEST_USER, TEST_USER_ID, TEST_GROUP);
# Suppress dpkg interactive output # Suppress dpkg interactive output
if ($strOS eq OS_U12 || $strOS eq OS_U14) if ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
{ {
$strImage .= $strImage .=
"\n\n# Suppress dpkg interactive output\n" . "\n\n# Suppress dpkg interactive output\n" .
@@ -355,14 +344,14 @@ sub containerBuild
$strImage .= $strImage .=
"\n\n# Start SSH when container starts\n"; "\n\n# Start SSH when container starts\n";
# This is required in newer versions of u12 containers - seems like a bug in the caontainer # This is required in newer versions of u12 containers - seems like a bug in the container
if ($strOS eq OS_U12) if ($strOS eq VM_U12)
{ {
$strImage .= $strImage .=
"RUN mkdir /var/run/sshd\n"; "RUN mkdir /var/run/sshd\n";
} }
if ($strOS eq OS_U14) if ($strOS eq VM_U14 || $strOS eq VM_D8 || $strOS eq VM_U16)
{ {
$strImage .= $strImage .=
"ENTRYPOINT service ssh restart && bash"; "ENTRYPOINT service ssh restart && bash";
@@ -399,18 +388,13 @@ sub containerBuild
$strImage .= $strImage .=
"\n\n# Install PostgreSQL"; "\n\n# Install PostgreSQL";
if ($strOS eq OS_U12 || $strOS eq OS_U14) if ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
{ {
$strImage .= $strImage .=
"\nRUN apt-get install -y postgresql-${strDbVersion}" . "\nRUN apt-get install -y postgresql-${strDbVersion}" .
"\nRUN pg_dropcluster --stop ${strDbVersion} main"; "\nRUN pg_dropcluster --stop ${strDbVersion} main";
} }
elsif ($strOS eq OS_CO6) elsif ($$oVm{$strOS}{&VM_OS_BASE} eq VM_OS_BASE_RHEL)
{
$strImage .=
"\nRUN yum -y install postgresql${strDbVersionNoDot}-server";
}
elsif ($strOS eq OS_CO7)
{ {
$strImage .= $strImage .=
"\nRUN yum -y install postgresql${strDbVersionNoDot}-server"; "\nRUN yum -y install postgresql${strDbVersionNoDot}-server";

View File

@@ -377,12 +377,11 @@ eval
# Determine which tests to run # Determine which tests to run
my $iTestsToRun = 0; my $iTestsToRun = 0;
my $stryTestOS = []; my $stryTestOS = [];
if ($strVm eq 'all') if ($strVm eq 'all')
{ {
$stryTestOS = ['co6', 'u12', 'co7', 'u14']; $stryTestOS = [VM_CO6, VM_U16, VM_D8, VM_CO7, VM_U14, VM_U12];
} }
else else
{ {