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

Allow parameters to be passed to travis.pl.

This makes configuring tests easier.

Also add a parameter for tests that require sudo.  This should be retired at some point but some tests still require it.
This commit is contained in:
David Steele 2019-10-15 17:19:42 +02:00
parent f3b2189659
commit b4aeb217e6
2 changed files with 32 additions and 41 deletions

View File

@ -13,17 +13,19 @@ services:
matrix: matrix:
include: include:
- env: PGB_CI="--vm=u12 test" - env: PGB_CI="test --vm=u12 --sudo"
- env: PGB_CI="--vm=f30 test" - env: PGB_CI="test --vm=f30 --param=no-package --param=c-only"
- env: PGB_CI="--vm=co6 test" - env: PGB_CI="test --vm=co6 --param=module=real"
- env: PGB_CI="--vm=u18 test" - env: PGB_CI="test --vm=u18 --sudo --param=container-only"
- env: PGB_CI="--vm=u18 doc" - env: PGB_CI=" doc --vm=u18"
- env: PGB_CI="--vm=co7 test" - env: PGB_CI="test --vm=co7 --param=module=real"
- dist: bionic - dist: bionic
env: PGB_CI="--vm=none test" env:
- PGB_CI="test --vm=none"
- TZ="America/New_York"
services: services:
- env: PGB_CI="--vm=co6 doc" - env: PGB_CI=" doc --vm=co6"
- env: PGB_CI="--vm=co7 doc" - env: PGB_CI=" doc --vm=co7"
install: install:
- umask 0022 && cd ~ && pwd && whoami && umask && groups - umask 0022 && cd ~ && pwd && whoami && umask && groups

View File

@ -17,6 +17,7 @@ $SIG{__DIE__} = sub { Carp::confess @_ };
use File::Basename qw(dirname); use File::Basename qw(dirname);
use Getopt::Long qw(GetOptions); use Getopt::Long qw(GetOptions);
use Cwd qw(abs_path); use Cwd qw(abs_path);
use Pod::Usage qw(pod2usage);
use lib dirname($0) . '/lib'; use lib dirname($0) . '/lib';
use lib dirname(dirname($0)) . '/lib'; use lib dirname(dirname($0)) . '/lib';
@ -42,6 +43,8 @@ test.pl [options] doc|test
VM Options: VM Options:
--vm docker container to build/test --vm docker container to build/test
--param parameters to pass to test.pl
--sudo test requires sudo
General Options: General Options:
--help display usage and exit --help display usage and exit
@ -51,9 +54,13 @@ test.pl [options] doc|test
# Command line parameters # Command line parameters
#################################################################################################################################### ####################################################################################################################################
my $strVm; my $strVm;
my @stryParam;
my $bSudo;
my $bHelp; my $bHelp;
GetOptions ('help' => \$bHelp, GetOptions ('help' => \$bHelp,
'param=s@' => \@stryParam,
'sudo' => \$bSudo,
'vm=s' => \$strVm) 'vm=s' => \$strVm)
or pod2usage(2); or pod2usage(2);
@ -149,6 +156,10 @@ eval
processExec('sudo apt-get install -y texlive-font-utils latex-xcolor', {bSuppressStdErr => true}); processExec('sudo apt-get install -y texlive-font-utils latex-xcolor', {bSuppressStdErr => true});
} }
processBegin('remove sudo');
processExec('sudo rm /etc/sudoers.d/travis');
processEnd();
processBegin('release documentation'); processBegin('release documentation');
processExec("${strReleaseExe} --build --no-gen --vm=${strVm}", {bShowOutputAsync => true, bOutLogOnError => false}); processExec("${strReleaseExe} --build --no-gen --vm=${strVm}", {bShowOutputAsync => true, bOutLogOnError => false});
processEnd(); processEnd();
@ -159,9 +170,6 @@ eval
################################################################################################################################ ################################################################################################################################
elsif ($ARGV[0] eq 'test') elsif ($ARGV[0] eq 'test')
{ {
my $strParam = "";
my $strVmHost = VM_U14;
# Build list of packages that need to be installed # Build list of packages that need to be installed
my $strPackage = "libperl-dev"; my $strPackage = "libperl-dev";
@ -179,52 +187,33 @@ eval
$strPackage .= " libdbd-pg-perl"; $strPackage .= " libdbd-pg-perl";
} }
processBegin('/tmp/pgbackrest owned by root so tests cannot use it');
processExec('sudo mkdir -p /tmp/pgbackrest && sudo chown root:root /tmp/pgbackrest && sudo chmod 700 /tmp/pgbackrest');
processEnd();
processBegin('install test packages'); processBegin('install test packages');
processExec("sudo apt-get install -y ${strPackage}", {bSuppressStdErr => true}); processExec("sudo apt-get install -y ${strPackage}", {bSuppressStdErr => true});
processEnd(); processEnd();
# Run tests that can be run without a container if (!$bSudo)
if ($strVm eq VM_NONE)
{ {
processBegin('/tmp/pgbackrest owned by root so tests cannot use it');
processExec('sudo mkdir -p /tmp/pgbackrest && sudo chown root:root /tmp/pgbackrest && sudo chmod 700 /tmp/pgbackrest');
processEnd();
# Set local timezone to make sure tests work in any timezone
$ENV{'TZ'} = 'America/New_York';
processBegin('remove sudo'); processBegin('remove sudo');
processExec('sudo rm /etc/sudoers.d/travis'); processExec('sudo rm /etc/sudoers.d/travis');
processEnd(); processEnd();
$strVmHost = VM_U18;
} }
# Else run tests that require a container
else # Build the container
if ($strVm ne VM_NONE)
{ {
# Build the container
processBegin("${strVm} build"); processBegin("${strVm} build");
processExec("${strTestExe} --vm-build --vm=${strVm}", {bShowOutputAsync => true, bOutLogOnError => false}); processExec("${strTestExe} --vm-build --vm=${strVm}", {bShowOutputAsync => true, bOutLogOnError => false});
processEnd(); processEnd();
# Run tests
if ($strVm eq VM_U18)
{
$strParam .= " --container-only";
}
elsif ($strVm eq VM_F30)
{
$strParam .= " --no-package --c-only";
}
elsif ($strVm ne VM_U12)
{
$strParam .= " --module=real";
}
} }
processBegin(($strVm eq VM_NONE ? "no container" : $strVm) . ' test'); processBegin(($strVm eq VM_NONE ? "no container" : $strVm) . ' test');
processExec( processExec(
"${strTestExe} --no-gen --vm-host=${strVmHost} --vm-max=2 --vm=${strVm}${strParam}", "${strTestExe} --no-gen --vm-host=none --vm-max=2 --vm=${strVm}" .
(@stryParam != 0 ? " --" . join(" --", @stryParam) : ''),
{bShowOutputAsync => true, bOutLogOnError => false}); {bShowOutputAsync => true, bOutLogOnError => false});
processEnd(); processEnd();
} }