2013-11-17 21:58:21 +03:00
|
|
|
#!/usr/bin/perl
|
2014-04-03 00:25:37 +03:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# test.pl - pgBackRest Unit Tests
|
2014-04-03 00:25:37 +03:00
|
|
|
####################################################################################################################################
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
2015-04-19 23:27:40 +02:00
|
|
|
use warnings FATAL => qw(all);
|
2015-06-14 00:25:49 +02:00
|
|
|
use Carp qw(confess longmess);
|
2016-09-06 15:44:50 +02:00
|
|
|
use English '-no_match_vars';
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Convert die to confess to capture the stack trace
|
2015-06-14 00:25:49 +02:00
|
|
|
$SIG{__DIE__} = sub { Carp::confess @_ };
|
2014-04-03 00:25:37 +03:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
use File::Basename qw(dirname);
|
|
|
|
use Getopt::Long qw(GetOptions);
|
2016-01-15 02:37:06 +02:00
|
|
|
use Cwd qw(abs_path cwd);
|
2017-04-10 18:31:30 +02:00
|
|
|
use JSON::PP;
|
2015-08-29 20:20:46 +02:00
|
|
|
use Pod::Usage qw(pod2usage);
|
2017-02-18 05:31:16 +02:00
|
|
|
use POSIX qw(ceil strftime);
|
2016-01-09 15:21:53 +02:00
|
|
|
use Time::HiRes qw(gettimeofday);
|
2014-04-03 00:25:37 +03:00
|
|
|
|
2016-11-04 13:56:26 +02:00
|
|
|
use lib dirname($0) . '/lib';
|
2017-06-09 23:51:41 +02:00
|
|
|
use lib dirname(dirname($0)) . '/lib';
|
2017-08-25 22:47:47 +02:00
|
|
|
use lib dirname(dirname($0)) . '/build/lib';
|
2017-06-09 23:51:41 +02:00
|
|
|
use lib dirname(dirname($0)) . '/doc/lib';
|
2016-11-04 13:56:26 +02:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
use pgBackRest::Common::Exception;
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Common::Ini;
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::Common::String;
|
|
|
|
use pgBackRest::Common::Wait;
|
2016-08-12 04:35:24 +02:00
|
|
|
use pgBackRest::DbVersion;
|
2017-06-09 23:51:41 +02:00
|
|
|
use pgBackRest::Storage::Posix::Driver;
|
|
|
|
use pgBackRest::Storage::Local;
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Version;
|
2014-06-22 17:30:17 +03:00
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
use pgBackRestBuild::Build;
|
|
|
|
use pgBackRestBuild::Build::Common;
|
|
|
|
use pgBackRestBuild::Config::Build;
|
|
|
|
use pgBackRestBuild::Config::BuildDefine;
|
2017-11-29 04:44:05 +02:00
|
|
|
use pgBackRestBuild::Config::BuildParse;
|
2018-02-08 23:11:47 +02:00
|
|
|
use pgBackRestBuild::Error::Build;
|
|
|
|
use pgBackRestBuild::Error::Data;
|
2017-11-02 14:14:13 +02:00
|
|
|
|
2016-06-28 02:37:25 +02:00
|
|
|
use BackRestDoc::Custom::DocCustomRelease;
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
use pgBackRestTest::Common::ContainerTest;
|
2017-02-21 15:59:23 +02:00
|
|
|
use pgBackRestTest::Common::CiTest;
|
2017-04-10 18:31:30 +02:00
|
|
|
use pgBackRestTest::Common::DefineTest;
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRestTest::Common::ExecuteTest;
|
2016-06-24 14:12:58 +02:00
|
|
|
use pgBackRestTest::Common::HostGroupTest;
|
2017-02-21 15:59:23 +02:00
|
|
|
use pgBackRestTest::Common::JobTest;
|
2016-06-24 14:12:58 +02:00
|
|
|
use pgBackRestTest::Common::ListTest;
|
2016-12-23 15:22:59 +02:00
|
|
|
use pgBackRestTest::Common::RunTest;
|
2016-12-13 01:54:07 +02:00
|
|
|
use pgBackRestTest::Common::VmTest;
|
2014-04-03 00:25:37 +03:00
|
|
|
|
2015-01-11 18:52:16 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Usage
|
|
|
|
####################################################################################################################################
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
test.pl - pgBackRest Unit Tests
|
2015-01-11 18:52:16 +02:00
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
test.pl [options]
|
|
|
|
|
|
|
|
Test Options:
|
2016-01-09 15:21:53 +02:00
|
|
|
--module test module to execute
|
2015-06-27 17:12:44 +02:00
|
|
|
--test execute the specified test in a module
|
|
|
|
--run execute only the specified test run
|
2015-01-12 16:05:26 +02:00
|
|
|
--dry-run show only the tests that would be executed but don't execute them
|
|
|
|
--no-cleanup don't cleaup after the last test is complete - useful for debugging
|
2018-02-04 01:27:38 +02:00
|
|
|
--pg-version version of postgres to test (all, defaults to minimal)
|
2015-05-05 19:08:48 +02:00
|
|
|
--log-force force overwrite of current test log files
|
2017-01-10 03:49:04 +02:00
|
|
|
--no-lint disable static source code analysis
|
2017-02-18 05:31:16 +02:00
|
|
|
--build-only compile the C library / packages and run tests only
|
2017-04-10 18:31:30 +02:00
|
|
|
--coverage-only only run coverage tests (as a subset of selected tests)
|
2017-10-12 18:55:48 +02:00
|
|
|
--c-only only run C tests
|
2017-11-02 14:14:13 +02:00
|
|
|
--gen-only only run auto-generation
|
2017-02-18 05:31:16 +02:00
|
|
|
--smart perform libc/package builds only when source timestamps have changed
|
|
|
|
--no-package do not build packages
|
2017-02-26 19:53:41 +02:00
|
|
|
--no-ci-config don't overwrite the current continuous integration config
|
2017-06-24 16:59:00 +02:00
|
|
|
--dev --no-lint --smart --no-package
|
|
|
|
--expect --no-lint --smart --no-package --vm=co7 --db=9.6 --log-force
|
2015-01-11 18:52:16 +02:00
|
|
|
|
|
|
|
Configuration Options:
|
2015-01-12 16:05:26 +02:00
|
|
|
--psql-bin path to the psql executables (e.g. /usr/lib/postgresql/9.3/bin/)
|
|
|
|
--test-path path where tests are executed (defaults to ./test)
|
|
|
|
--log-level log level to use for tests (defaults to INFO)
|
|
|
|
--quiet, -q equivalent to --log-level=off
|
2015-01-11 18:52:16 +02:00
|
|
|
|
2016-01-09 15:21:53 +02:00
|
|
|
VM Options:
|
2016-04-14 00:47:29 +02:00
|
|
|
--vm docker container to build/test (u12, u14, co6, co7)
|
2016-01-09 15:21:53 +02:00
|
|
|
--vm-build build Docker containers
|
2016-04-14 00:47:29 +02:00
|
|
|
--vm-force force a rebuild of Docker containers
|
2016-01-09 15:21:53 +02:00
|
|
|
--vm-out Show VM output (default false)
|
2016-09-06 15:35:02 +02:00
|
|
|
--vm-max max VMs to run in parallel (default 1)
|
2016-01-09 15:21:53 +02:00
|
|
|
|
2015-01-11 18:52:16 +02:00
|
|
|
General Options:
|
2015-01-12 16:05:26 +02:00
|
|
|
--version display version and exit
|
|
|
|
--help display usage and exit
|
2015-01-11 18:52:16 +02:00
|
|
|
=cut
|
|
|
|
|
2014-04-03 00:25:37 +03:00
|
|
|
####################################################################################################################################
|
2014-06-04 04:22:07 +03:00
|
|
|
# Command line parameters
|
|
|
|
####################################################################################################################################
|
2017-02-21 15:59:23 +02:00
|
|
|
my $strLogLevel = lc(INFO);
|
2016-01-09 15:21:53 +02:00
|
|
|
my $bVmOut = false;
|
2017-01-05 01:29:13 +02:00
|
|
|
my @stryModule;
|
|
|
|
my @stryModuleTest;
|
|
|
|
my @iyModuleTestRun;
|
2016-09-06 15:35:02 +02:00
|
|
|
my $iVmMax = 1;
|
|
|
|
my $iVmId = undef;
|
2014-07-16 05:32:41 +03:00
|
|
|
my $bDryRun = false;
|
|
|
|
my $bNoCleanup = false;
|
2014-08-11 04:22:17 +03:00
|
|
|
my $strPgSqlBin;
|
|
|
|
my $strTestPath;
|
2015-01-11 18:52:16 +02:00
|
|
|
my $bVersion = false;
|
|
|
|
my $bHelp = false;
|
|
|
|
my $bQuiet = false;
|
2018-02-04 01:27:38 +02:00
|
|
|
my $strPgVersion = 'minimal';
|
2015-05-05 19:08:48 +02:00
|
|
|
my $bLogForce = false;
|
2017-04-10 18:31:30 +02:00
|
|
|
my $strVm;
|
2017-02-21 15:59:23 +02:00
|
|
|
my $strVmHost = VM_HOST_DEFAULT;
|
2016-01-09 15:21:53 +02:00
|
|
|
my $bVmBuild = false;
|
2016-04-14 00:47:29 +02:00
|
|
|
my $bVmForce = false;
|
2016-02-23 16:25:22 +02:00
|
|
|
my $bNoLint = false;
|
2017-02-18 05:31:16 +02:00
|
|
|
my $bBuildOnly = false;
|
2017-04-10 18:31:30 +02:00
|
|
|
my $bCoverageOnly = false;
|
2017-10-12 18:55:48 +02:00
|
|
|
my $bCOnly = false;
|
2017-11-02 14:14:13 +02:00
|
|
|
my $bGenOnly = false;
|
2017-02-18 05:31:16 +02:00
|
|
|
my $bSmart = false;
|
|
|
|
my $bNoPackage = false;
|
2017-02-26 19:53:41 +02:00
|
|
|
my $bNoCiConfig = false;
|
2017-02-18 05:31:16 +02:00
|
|
|
my $bDev = false;
|
2017-06-09 23:51:41 +02:00
|
|
|
my $bExpect = false;
|
2017-02-23 01:43:10 +02:00
|
|
|
my $iRetry = 0;
|
2015-01-11 18:52:16 +02:00
|
|
|
|
|
|
|
GetOptions ('q|quiet' => \$bQuiet,
|
|
|
|
'version' => \$bVersion,
|
|
|
|
'help' => \$bHelp,
|
|
|
|
'pgsql-bin=s' => \$strPgSqlBin,
|
2014-09-16 18:22:55 +03:00
|
|
|
'test-path=s' => \$strTestPath,
|
|
|
|
'log-level=s' => \$strLogLevel,
|
2016-04-14 00:47:29 +02:00
|
|
|
'vm=s' => \$strVm,
|
2017-02-21 15:59:23 +02:00
|
|
|
'vm-host=s' => \$strVmHost,
|
2016-01-09 15:21:53 +02:00
|
|
|
'vm-out' => \$bVmOut,
|
|
|
|
'vm-build' => \$bVmBuild,
|
2016-04-14 00:47:29 +02:00
|
|
|
'vm-force' => \$bVmForce,
|
2017-01-05 01:29:13 +02:00
|
|
|
'module=s@' => \@stryModule,
|
|
|
|
'test=s@' => \@stryModuleTest,
|
|
|
|
'run=s@' => \@iyModuleTestRun,
|
2016-09-06 15:35:02 +02:00
|
|
|
'vm-id=s' => \$iVmId,
|
2016-09-30 00:26:32 +02:00
|
|
|
'vm-max=s' => \$iVmMax,
|
2014-09-16 18:22:55 +03:00
|
|
|
'dry-run' => \$bDryRun,
|
2015-02-28 06:31:39 +02:00
|
|
|
'no-cleanup' => \$bNoCleanup,
|
2018-02-04 01:27:38 +02:00
|
|
|
'pg-version=s' => \$strPgVersion,
|
2016-02-23 16:25:22 +02:00
|
|
|
'log-force' => \$bLogForce,
|
2016-12-13 01:54:07 +02:00
|
|
|
'no-lint' => \$bNoLint,
|
2017-02-18 05:31:16 +02:00
|
|
|
'build-only' => \$bBuildOnly,
|
|
|
|
'no-package' => \$bNoPackage,
|
2017-02-26 19:53:41 +02:00
|
|
|
'no-ci-config' => \$bNoCiConfig,
|
2017-04-10 18:31:30 +02:00
|
|
|
'coverage-only' => \$bCoverageOnly,
|
2017-10-12 18:55:48 +02:00
|
|
|
'c-only' => \$bCOnly,
|
2017-11-02 14:14:13 +02:00
|
|
|
'gen-only' => \$bGenOnly,
|
2017-02-18 05:31:16 +02:00
|
|
|
'smart' => \$bSmart,
|
2017-02-22 05:10:02 +02:00
|
|
|
'dev' => \$bDev,
|
2017-06-09 23:51:41 +02:00
|
|
|
'expect' => \$bExpect,
|
2017-02-22 05:10:02 +02:00
|
|
|
'retry=s' => \$iRetry)
|
2015-01-11 18:52:16 +02:00
|
|
|
or pod2usage(2);
|
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Run in eval block to catch errors
|
|
|
|
####################################################################################################################################
|
|
|
|
eval
|
2015-01-11 18:52:16 +02:00
|
|
|
{
|
2016-09-06 15:44:50 +02:00
|
|
|
# Display version and exit if requested
|
|
|
|
if ($bVersion || $bHelp)
|
|
|
|
{
|
|
|
|
syswrite(*STDOUT, BACKREST_NAME . ' ' . BACKREST_VERSION . " Test Engine\n");
|
|
|
|
|
|
|
|
if ($bHelp)
|
|
|
|
{
|
|
|
|
syswrite(*STDOUT, "\n");
|
|
|
|
pod2usage();
|
|
|
|
}
|
2015-01-11 18:52:16 +02:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (@ARGV > 0)
|
2015-01-11 18:52:16 +02:00
|
|
|
{
|
2016-09-06 15:44:50 +02:00
|
|
|
syswrite(*STDOUT, "invalid parameter\n\n");
|
2015-01-11 18:52:16 +02:00
|
|
|
pod2usage();
|
|
|
|
}
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Update options for --dev
|
|
|
|
################################################################################################################################
|
|
|
|
if ($bDev)
|
|
|
|
{
|
|
|
|
$bNoLint = true;
|
|
|
|
$bSmart = true;
|
|
|
|
$bNoPackage = true;
|
|
|
|
}
|
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Update options for --expect
|
|
|
|
################################################################################################################################
|
|
|
|
if ($bExpect)
|
|
|
|
{
|
|
|
|
$bNoLint = true;
|
|
|
|
$bSmart = true;
|
|
|
|
$bNoPackage = true;
|
2017-11-15 00:16:39 +02:00
|
|
|
$strVm = VM_EXPECT;
|
2018-02-04 01:27:38 +02:00
|
|
|
$strPgVersion = '9.6';
|
2017-06-09 23:51:41 +02:00
|
|
|
$bLogForce = true;
|
|
|
|
}
|
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Setup
|
|
|
|
################################################################################################################################
|
|
|
|
# Set a neutral umask so tests work as expected
|
|
|
|
umask(0);
|
2014-06-04 04:22:07 +03:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
# Set console log level
|
|
|
|
if ($bQuiet)
|
|
|
|
{
|
|
|
|
$strLogLevel = 'off';
|
|
|
|
}
|
2015-01-11 18:52:16 +02:00
|
|
|
|
2016-10-05 15:09:30 +02:00
|
|
|
logLevelSet(uc($strLogLevel), uc($strLogLevel), OFF);
|
2014-06-04 04:22:07 +03:00
|
|
|
|
2017-01-05 01:29:13 +02:00
|
|
|
if (@stryModuleTest != 0 && @stryModule != 1)
|
2016-09-06 15:44:50 +02:00
|
|
|
{
|
2017-01-05 01:29:13 +02:00
|
|
|
confess "Only one --module can be provided when --test is specified";
|
2016-09-06 15:44:50 +02:00
|
|
|
}
|
2014-06-05 17:20:03 +03:00
|
|
|
|
2017-01-05 01:29:13 +02:00
|
|
|
if (@iyModuleTestRun != 0 && @stryModuleTest != 1)
|
2016-09-06 15:44:50 +02:00
|
|
|
{
|
2017-01-05 01:29:13 +02:00
|
|
|
confess "Only one --test can be provided when --run is specified";
|
2016-09-06 15:44:50 +02:00
|
|
|
}
|
2014-06-22 17:54:31 +03:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
# Set test path if not expicitly set
|
|
|
|
if (!defined($strTestPath))
|
|
|
|
{
|
|
|
|
$strTestPath = cwd() . '/test';
|
|
|
|
}
|
2016-05-11 00:12:37 +02:00
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
my $oStorageTest = new pgBackRest::Storage::Local(
|
|
|
|
$strTestPath, new pgBackRest::Storage::Posix::Driver({bFileSync => false, bPathSync => false}));
|
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
if ($bCoverageOnly)
|
2017-01-10 03:49:04 +02:00
|
|
|
{
|
2017-04-10 18:31:30 +02:00
|
|
|
if (!defined($strVm))
|
2017-01-10 03:49:04 +02:00
|
|
|
{
|
2017-02-21 15:59:23 +02:00
|
|
|
&log(INFO, "Set --vm=${strVmHost} for coverage testing");
|
|
|
|
$strVm = $strVmHost;
|
2017-01-10 03:49:04 +02:00
|
|
|
}
|
2017-04-10 18:31:30 +02:00
|
|
|
elsif ($strVm eq VM_ALL)
|
2017-01-10 03:49:04 +02:00
|
|
|
{
|
2017-04-10 18:31:30 +02:00
|
|
|
confess &log(ERROR, "select a single Debian-based VM for coverage testing");
|
2017-01-10 03:49:04 +02:00
|
|
|
}
|
2017-04-10 18:31:30 +02:00
|
|
|
elsif (!vmCoverage($strVm))
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "only Debian-based VMs can be used for coverage testing");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# If VM is not defined then set it to all
|
|
|
|
if (!defined($strVm))
|
|
|
|
{
|
|
|
|
$strVm = VM_ALL;
|
2017-01-10 03:49:04 +02:00
|
|
|
}
|
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
# Get the base backrest path
|
|
|
|
my $strBackRestBase = dirname(dirname(abs_path($0)));
|
2016-06-02 15:32:56 +02:00
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
my $oStorageBackRest = new pgBackRest::Storage::Local(
|
|
|
|
$strBackRestBase, new pgBackRest::Storage::Posix::Driver({bFileSync => false, bPathSync => false}));
|
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Build Docker containers
|
|
|
|
################################################################################################################################
|
|
|
|
if ($bVmBuild)
|
|
|
|
{
|
2017-06-24 16:59:00 +02:00
|
|
|
containerBuild($oStorageBackRest, $strVm, $bVmForce);
|
2016-09-06 15:44:50 +02:00
|
|
|
exit 0;
|
|
|
|
}
|
2016-01-09 15:21:53 +02:00
|
|
|
|
|
|
|
################################################################################################################################
|
|
|
|
# Start VM and run
|
|
|
|
################################################################################################################################
|
2016-09-06 15:35:02 +02:00
|
|
|
if (!defined($iVmId))
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2017-11-29 04:44:05 +02:00
|
|
|
# Auto-generate C files
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2018-02-08 23:11:47 +02:00
|
|
|
errorDefineLoad(${$oStorageBackRest->get("build/error.yaml")});
|
|
|
|
|
2017-11-29 04:44:05 +02:00
|
|
|
my $rhBuild =
|
|
|
|
{
|
|
|
|
'config' =>
|
|
|
|
{
|
|
|
|
&BLD_DATA => buildConfig(),
|
|
|
|
&BLD_PATH => 'config',
|
|
|
|
},
|
|
|
|
|
|
|
|
'configDefine' =>
|
|
|
|
{
|
|
|
|
&BLD_DATA => buildConfigDefine(),
|
|
|
|
&BLD_PATH => 'config',
|
|
|
|
},
|
|
|
|
|
|
|
|
'configParse' =>
|
|
|
|
{
|
|
|
|
&BLD_DATA => buildConfigParse(),
|
|
|
|
&BLD_PATH => 'config',
|
|
|
|
},
|
2018-02-08 23:11:47 +02:00
|
|
|
|
|
|
|
'error' =>
|
|
|
|
{
|
|
|
|
&BLD_DATA => buildError(),
|
|
|
|
&BLD_PATH => 'common',
|
|
|
|
},
|
2017-11-29 04:44:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
buildAll("${strBackRestBase}/src", $rhBuild);
|
|
|
|
|
|
|
|
# Auto-generate XS files
|
|
|
|
#
|
|
|
|
# Use statements are put here so this will be easy to get rid of someday.
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
use lib dirname(dirname($0)) . '/libc/build/lib';
|
|
|
|
use pgBackRestLibC::Build; ## no critic (Modules::ProhibitConditionalUseStatements)
|
|
|
|
|
|
|
|
buildXsAll("${strBackRestBase}/libc");
|
|
|
|
|
|
|
|
if ($bGenOnly)
|
|
|
|
{
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
2017-11-28 05:16:24 +02:00
|
|
|
# Sync time to prevent build failures when running on VirtualBox.
|
|
|
|
my $strVBoxService = '/usr/sbin/VBoxService';
|
|
|
|
|
|
|
|
if ($oStorageTest->exists($strVBoxService))
|
|
|
|
{
|
2018-01-23 19:58:35 +02:00
|
|
|
executeTest("sudo killall VBoxService");
|
2017-11-28 05:16:24 +02:00
|
|
|
executeTest("sudo ${strVBoxService} --timesync-set-start");
|
|
|
|
}
|
|
|
|
|
2017-02-26 19:53:41 +02:00
|
|
|
# Build CI configuration
|
|
|
|
if (!$bNoCiConfig)
|
|
|
|
{
|
2017-06-09 23:51:41 +02:00
|
|
|
(new pgBackRestTest::Common::CiTest($oStorageBackRest))->process();
|
2017-02-26 19:53:41 +02:00
|
|
|
}
|
|
|
|
|
2016-05-24 02:04:36 +02:00
|
|
|
# Load the doc module dynamically since it is not supported on all systems
|
|
|
|
require BackRestDoc::Common::Doc;
|
|
|
|
BackRestDoc::Common::Doc->import();
|
|
|
|
|
|
|
|
# Make sure version number matches the latest release
|
2016-06-02 15:32:56 +02:00
|
|
|
my $strReleaseFile = dirname(dirname(abs_path($0))) . '/doc/xml/release.xml';
|
2016-06-28 02:37:25 +02:00
|
|
|
my $oRelease = (new BackRestDoc::Custom::DocCustomRelease(new BackRestDoc::Common::Doc($strReleaseFile)))->releaseLast();
|
|
|
|
my $strVersion = $oRelease->paramGet('version');
|
2017-02-18 05:31:16 +02:00
|
|
|
my $bVersionDev = false;
|
|
|
|
my $strVersionBase = $strVersion;
|
2016-05-24 02:04:36 +02:00
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
if ($strVersion =~ /dev$/)
|
2016-05-24 02:04:36 +02:00
|
|
|
{
|
2017-02-18 05:31:16 +02:00
|
|
|
$bVersionDev = true;
|
|
|
|
$strVersionBase = substr($strVersion, 0, length($strVersion) - 3);
|
|
|
|
|
|
|
|
if (BACKREST_VERSION !~ /dev$/ && $oRelease->nodeTest('release-core-list'))
|
2016-05-26 16:34:10 +02:00
|
|
|
{
|
2016-06-28 02:37:25 +02:00
|
|
|
confess "dev release ${strVersion} must match the program version when core changes have been made";
|
2016-05-26 16:34:10 +02:00
|
|
|
}
|
2016-06-28 02:37:25 +02:00
|
|
|
}
|
2016-07-19 21:22:20 +02:00
|
|
|
elsif ($strVersion ne BACKREST_VERSION)
|
2016-06-28 02:37:25 +02:00
|
|
|
{
|
|
|
|
confess 'unable to find version ' . BACKREST_VERSION . " as the most recent release in ${strReleaseFile}";
|
2016-05-24 02:04:36 +02:00
|
|
|
}
|
|
|
|
|
2017-11-29 04:44:05 +02:00
|
|
|
# Update version for the C code based on the current Perl version
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $strCVersionFile = "${strBackRestBase}/src/version.h";
|
|
|
|
my $strCVersionOld = ${$oStorageTest->get($strCVersionFile)};
|
|
|
|
my $strCVersionNew;
|
|
|
|
|
|
|
|
foreach my $strLine (split("\n", $strCVersionOld))
|
|
|
|
{
|
|
|
|
if ($strLine =~ /^#define PGBACKREST_VERSION/)
|
|
|
|
{
|
|
|
|
$strLine = '#define PGBACKREST_VERSION' . (' ' x 42) . '"' . BACKREST_VERSION . '"';
|
|
|
|
}
|
|
|
|
|
|
|
|
$strCVersionNew .= "${strLine}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($strCVersionNew ne $strCVersionOld)
|
|
|
|
{
|
|
|
|
$oStorageTest->put($strCVersionFile, $strCVersionNew);
|
|
|
|
}
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
# Clean up
|
2017-08-19 14:48:13 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-02-18 05:31:16 +02:00
|
|
|
my $iTestFail = 0;
|
2017-02-21 15:59:23 +02:00
|
|
|
my $iTestRetry = 0;
|
2017-02-18 05:31:16 +02:00
|
|
|
my $oyProcess = [];
|
|
|
|
my $strCoveragePath = "${strTestPath}/cover_db";
|
|
|
|
|
|
|
|
if (!$bDryRun || $bVmOut)
|
|
|
|
{
|
|
|
|
containerRemove('test-([0-9]+|build)');
|
|
|
|
|
|
|
|
for (my $iVmIdx = 0; $iVmIdx < 8; $iVmIdx++)
|
|
|
|
{
|
|
|
|
push(@{$oyProcess}, undef);
|
|
|
|
}
|
|
|
|
|
2017-10-22 19:11:03 +02:00
|
|
|
|
|
|
|
executeTest("sudo umount ${strTestPath}", {bSuppressError => true});
|
2017-02-18 05:31:16 +02:00
|
|
|
executeTest("sudo rm -rf ${strTestPath}/*");
|
2017-10-22 19:11:03 +02:00
|
|
|
$oStorageTest->pathCreate($strTestPath, {strMode => '0770', bIgnoreExists => true});
|
|
|
|
executeTest("sudo mount -t tmpfs -o size=2560M test ${strTestPath}");
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageTest->pathCreate($strCoveragePath, {strMode => '0770', bIgnoreMissing => true, bCreateParent => true});
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
|
|
|
|
2017-11-28 04:19:59 +02:00
|
|
|
# Determine which tests to run
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $oyTestRun;
|
|
|
|
my $bBuildRequired = false;
|
|
|
|
|
2018-02-14 17:33:21 +02:00
|
|
|
# Only get the test list when they can run
|
2017-11-28 04:19:59 +02:00
|
|
|
if (!$bBuildOnly)
|
|
|
|
{
|
|
|
|
# Get the test list
|
|
|
|
$oyTestRun = testListGet(
|
2018-02-04 01:27:38 +02:00
|
|
|
$strVm, \@stryModule, \@stryModuleTest, \@iyModuleTestRun, $strPgVersion, $bCoverageOnly, $bCOnly);
|
2017-11-28 04:19:59 +02:00
|
|
|
|
|
|
|
# Search for any tests that are not C unit tests to determine if the C binary and lib need to be built for testing. If
|
|
|
|
# all the tests are C unit tests then no builds are required. This saves a lot ot time.
|
|
|
|
foreach my $hTest (@{$oyTestRun})
|
|
|
|
{
|
2018-02-14 17:33:21 +02:00
|
|
|
if (!$hTest->{&TEST_C} || $hTest->{&TEST_PERL_REQ})
|
2017-11-28 04:19:59 +02:00
|
|
|
{
|
|
|
|
$bBuildRequired = true;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-27 01:43:51 +02:00
|
|
|
# Build the binary, library and packages
|
2017-08-19 14:48:13 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-11-28 04:19:59 +02:00
|
|
|
if (!$bDryRun && $bBuildRequired)
|
2016-12-13 01:54:07 +02:00
|
|
|
{
|
2017-11-27 01:43:51 +02:00
|
|
|
my $oVm = vmGet();
|
|
|
|
my $strVagrantPath = "${strBackRestBase}/test/.vagrant";
|
|
|
|
|
|
|
|
# Build the binary
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $strBinPath = "${strVagrantPath}/bin";
|
|
|
|
my $strBinSmart = "${strBinPath}/build.timestamp";
|
|
|
|
my @stryBinSrcPath = ('src');
|
|
|
|
|
|
|
|
# Find the lastest modified time for dirs that affect the bin build
|
|
|
|
my $lTimestampLast = $oStorageBackRest->exists($strBinSmart) ? $oStorageBackRest->info($strBinSmart)->mtime : 0;
|
|
|
|
|
|
|
|
foreach my $strBinSrcPath (@stryBinSrcPath)
|
|
|
|
{
|
|
|
|
my $hManifest = $oStorageBackRest->manifest($strBinSrcPath);
|
|
|
|
|
|
|
|
foreach my $strFile (sort(keys(%{$hManifest})))
|
|
|
|
{
|
|
|
|
if ($hManifest->{$strFile}{type} eq 'f' && $hManifest->{$strFile}{modification_time} > $lTimestampLast)
|
|
|
|
{
|
|
|
|
$lTimestampLast = $hManifest->{$strFile}{modification_time};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Rebuild if the modification time of the smart file does equal the last changes in source paths
|
|
|
|
if (!$bSmart || !$oStorageBackRest->exists($strBinSmart) ||
|
|
|
|
$oStorageBackRest->info($strBinSmart)->mtime < $lTimestampLast)
|
|
|
|
{
|
|
|
|
if ($bSmart)
|
|
|
|
{
|
|
|
|
&log(INFO, 'bin dependencies have changed, rebuilding...');
|
|
|
|
}
|
|
|
|
|
|
|
|
executeTest("sudo rm -rf ${strBinPath}");
|
|
|
|
executeTest('sudo rm -rf /usr/bin/' . BACKREST_EXE);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Loop through VMs to do the C Library builds
|
|
|
|
my $bLogDetail = $strLogLevel eq 'detail';
|
|
|
|
my @stryBuildVm = $strVm eq VM_ALL ? VM_LIST : ($strVm);
|
|
|
|
|
|
|
|
foreach my $strBuildVM (sort(@stryBuildVm))
|
|
|
|
{
|
|
|
|
my $strBuildPath = "${strBinPath}/${strBuildVM}/src";
|
|
|
|
|
|
|
|
if (!$oStorageBackRest->pathExists($strBuildPath))
|
|
|
|
{
|
|
|
|
&log(INFO, "build bin for ${strBuildVM} (${strBuildPath})");
|
|
|
|
|
|
|
|
executeTest(
|
|
|
|
"docker run -itd -h test-build --name=test-build" .
|
|
|
|
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-build",
|
|
|
|
{bSuppressStdErr => true});
|
|
|
|
|
|
|
|
foreach my $strBinSrcPath (@stryBinSrcPath)
|
|
|
|
{
|
|
|
|
$oStorageBackRest->pathCreate(
|
|
|
|
"${strBinPath}/${strBuildVM}/${strBinSrcPath}", {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
executeTest("cp -r ${strBackRestBase}/${strBinSrcPath}/* ${strBinPath}/${strBuildVM}/${strBinSrcPath}");
|
|
|
|
}
|
|
|
|
|
|
|
|
executeTest(
|
2018-02-18 17:44:58 +02:00
|
|
|
"docker exec -i test-build make --silent --directory ${strBuildPath} CEXTRA=-g",
|
2017-11-27 01:43:51 +02:00
|
|
|
{bShowOutputAsync => $bLogDetail});
|
|
|
|
|
|
|
|
executeTest(
|
|
|
|
"docker exec -i test-build make --silent --directory ${strBuildPath} install",
|
|
|
|
{bShowOutputAsync => $bLogDetail});
|
|
|
|
|
|
|
|
executeTest("docker rm -f test-build");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Write files to indicate the last time a build was successful
|
|
|
|
$oStorageBackRest->put($strBinSmart);
|
|
|
|
utime($lTimestampLast, $lTimestampLast, $strBinSmart) or
|
|
|
|
confess "unable to set time for ${strBinSmart}" . (defined($!) ? ":$!" : '');
|
|
|
|
|
2017-08-19 14:48:13 +02:00
|
|
|
# Build the C Library
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-02-18 05:31:16 +02:00
|
|
|
my $strLibCPath = "${strVagrantPath}/libc";
|
|
|
|
my $strLibCSmart = "${strLibCPath}/build.timestamp";
|
2017-11-02 14:14:13 +02:00
|
|
|
my @stryLibCSrcPath = ('libc', 'src');
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2017-08-19 14:48:13 +02:00
|
|
|
# Find the lastest modified time for dirs that affect the libc build
|
|
|
|
foreach my $strLibCSrcPath (@stryLibCSrcPath)
|
2017-01-10 20:12:53 +02:00
|
|
|
{
|
2017-08-19 14:48:13 +02:00
|
|
|
my $hManifest = $oStorageBackRest->manifest($strLibCSrcPath);
|
|
|
|
|
|
|
|
foreach my $strFile (sort(keys(%{$hManifest})))
|
2017-01-10 20:12:53 +02:00
|
|
|
{
|
2017-08-19 14:48:13 +02:00
|
|
|
if ($hManifest->{$strFile}{type} eq 'f' && $hManifest->{$strFile}{modification_time} > $lTimestampLast)
|
|
|
|
{
|
|
|
|
$lTimestampLast = $hManifest->{$strFile}{modification_time};
|
|
|
|
}
|
2017-01-10 20:12:53 +02:00
|
|
|
}
|
|
|
|
}
|
2016-12-13 01:54:07 +02:00
|
|
|
|
2017-08-19 14:48:13 +02:00
|
|
|
# Rebuild if the modification time of the smart file does equal the last changes in source paths
|
2017-06-09 23:51:41 +02:00
|
|
|
if (!$bSmart || !$oStorageBackRest->exists($strLibCSmart) ||
|
2017-08-19 14:48:13 +02:00
|
|
|
$oStorageBackRest->info($strLibCSmart)->mtime < $lTimestampLast)
|
2017-01-10 20:12:53 +02:00
|
|
|
{
|
2017-02-18 05:31:16 +02:00
|
|
|
if ($bSmart)
|
|
|
|
{
|
2017-08-19 14:48:13 +02:00
|
|
|
&log(INFO, 'libc dependencies have changed, rebuilding...');
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
2016-12-13 01:54:07 +02:00
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
executeTest("sudo rm -rf ${strLibCPath}");
|
2017-02-21 15:59:23 +02:00
|
|
|
executeTest('sudo rm -rf ' . $oVm->{$strVmHost}{&VMDEF_PERL_ARCH_PATH} . '/auto/pgBackRest/LibC');
|
|
|
|
executeTest('sudo rm -rf ' . $oVm->{$strVmHost}{&VMDEF_PERL_ARCH_PATH} . '/pgBackRest');
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
2016-12-13 01:54:07 +02:00
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
# Loop through VMs to do the C Library builds
|
2017-11-27 01:43:51 +02:00
|
|
|
$bLogDetail = $strLogLevel eq 'detail';
|
|
|
|
@stryBuildVm = $strVm eq VM_ALL ? VM_LIST : ($strVm eq $strVmHost ? ($strVm) : ($strVm, $strVmHost));
|
2016-12-13 01:54:07 +02:00
|
|
|
|
|
|
|
foreach my $strBuildVM (sort(@stryBuildVm))
|
|
|
|
{
|
2017-08-19 14:48:13 +02:00
|
|
|
my $strBuildPath = "${strLibCPath}/${strBuildVM}/libc";
|
2017-02-21 15:59:23 +02:00
|
|
|
my $bContainerExists = $strVm eq VM_ALL || $strBuildVM ne $strVmHost;
|
2016-12-13 01:54:07 +02:00
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
if (!$oStorageBackRest->pathExists($strBuildPath))
|
2017-01-10 20:12:53 +02:00
|
|
|
{
|
2017-11-27 01:43:51 +02:00
|
|
|
&log(INFO, "build C library for ${strBuildVM} (${strBuildPath})");
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
if ($bContainerExists)
|
|
|
|
{
|
|
|
|
executeTest(
|
|
|
|
"docker run -itd -h test-build --name=test-build" .
|
|
|
|
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-build",
|
|
|
|
{bSuppressStdErr => true});
|
|
|
|
}
|
2017-01-10 20:12:53 +02:00
|
|
|
|
2017-08-19 14:48:13 +02:00
|
|
|
foreach my $strLibCSrcPath (@stryLibCSrcPath)
|
|
|
|
{
|
|
|
|
$oStorageBackRest->pathCreate(
|
|
|
|
"${strLibCPath}/${strBuildVM}/${strLibCSrcPath}", {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
executeTest("cp -r ${strBackRestBase}/${strLibCSrcPath}/* ${strLibCPath}/${strBuildVM}/${strLibCSrcPath}");
|
|
|
|
}
|
2017-01-10 20:12:53 +02:00
|
|
|
|
|
|
|
executeTest(
|
2017-02-21 15:59:23 +02:00
|
|
|
($bContainerExists ? "docker exec -i test-build bash -c '" : '') .
|
|
|
|
"cd ${strBuildPath} && perl Makefile.PL INSTALLMAN1DIR=none INSTALLMAN3DIR=none" .
|
|
|
|
($bContainerExists ? "'" : ''),
|
2017-04-10 23:20:21 +02:00
|
|
|
{bSuppressStdErr => true, bShowOutputAsync => $bLogDetail});
|
2017-08-25 22:47:47 +02:00
|
|
|
|
2017-01-10 20:12:53 +02:00
|
|
|
executeTest(
|
2017-02-21 15:59:23 +02:00
|
|
|
($bContainerExists ? 'docker exec -i test-build ' : '') .
|
2017-09-30 16:48:25 +02:00
|
|
|
"make --silent --directory ${strBuildPath}",
|
|
|
|
{bShowOutputAsync => $bLogDetail});
|
2017-01-10 20:12:53 +02:00
|
|
|
executeTest(
|
2017-02-21 15:59:23 +02:00
|
|
|
($bContainerExists ? 'docker exec -i test-build ' : '') .
|
2017-09-30 16:48:25 +02:00
|
|
|
"make --silent --directory ${strBuildPath} test",
|
|
|
|
{bShowOutputAsync => $bLogDetail});
|
2017-01-10 20:12:53 +02:00
|
|
|
executeTest(
|
2017-02-21 15:59:23 +02:00
|
|
|
($bContainerExists ? 'docker exec -i test-build ' : 'sudo ') .
|
2017-09-30 16:48:25 +02:00
|
|
|
"make --silent --directory ${strBuildPath} install",
|
|
|
|
{bShowOutputAsync => $bLogDetail});
|
2017-01-10 20:12:53 +02:00
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
if ($bContainerExists)
|
|
|
|
{
|
|
|
|
executeTest("docker rm -f test-build");
|
|
|
|
}
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
if ($strBuildVM eq $strVmHost)
|
2017-02-18 05:31:16 +02:00
|
|
|
{
|
2017-04-10 23:20:21 +02:00
|
|
|
executeTest("sudo make -C ${strBuildPath} install", {bSuppressStdErr => true});
|
2017-02-18 05:31:16 +02:00
|
|
|
|
|
|
|
# Load the module dynamically
|
|
|
|
require pgBackRest::LibC;
|
|
|
|
pgBackRest::LibC->import(qw(:debug));
|
|
|
|
|
|
|
|
# Do a basic test to make sure it installed correctly
|
|
|
|
if (&UVSIZE != 8)
|
|
|
|
{
|
|
|
|
confess &log(ERROR, 'UVSIZE in C library does not equal 8');
|
|
|
|
}
|
|
|
|
|
|
|
|
# Also check the version number
|
|
|
|
my $strLibCVersion =
|
|
|
|
BACKREST_VERSION =~ /dev$/ ?
|
|
|
|
substr(BACKREST_VERSION, 0, length(BACKREST_VERSION) - 3) . '.999' : BACKREST_VERSION;
|
|
|
|
|
2017-11-02 14:14:13 +02:00
|
|
|
if (libcVersion() ne $strLibCVersion)
|
2017-02-18 05:31:16 +02:00
|
|
|
{
|
2017-11-02 14:14:13 +02:00
|
|
|
confess &log(ERROR, $strLibCVersion . ' was expected for LibC version but found ' . libcVersion());
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-10 20:12:53 +02:00
|
|
|
}
|
2016-12-13 01:54:07 +02:00
|
|
|
}
|
2017-02-18 05:31:16 +02:00
|
|
|
|
|
|
|
# Write files to indicate the last time a build was successful
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageBackRest->put($strLibCSmart);
|
2017-08-19 14:48:13 +02:00
|
|
|
utime($lTimestampLast, $lTimestampLast, $strLibCSmart) or
|
2017-02-18 05:31:16 +02:00
|
|
|
confess "unable to set time for ${strLibCSmart}" . (defined($!) ? ":$!" : '');
|
|
|
|
|
2017-08-19 14:48:13 +02:00
|
|
|
# Build the package
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $strPackagePath = "${strVagrantPath}/package";
|
|
|
|
my $strPackageSmart = "${strPackagePath}/build.timestamp";
|
2017-11-27 01:43:51 +02:00
|
|
|
my @stryPackageSrcPath = ('lib');
|
2017-08-19 14:48:13 +02:00
|
|
|
|
|
|
|
# Find the lastest modified time for additional dirs that affect the package build
|
|
|
|
foreach my $strPackageSrcPath (@stryPackageSrcPath)
|
|
|
|
{
|
|
|
|
my $hManifest = $oStorageBackRest->manifest($strPackageSrcPath);
|
|
|
|
|
|
|
|
foreach my $strFile (sort(keys(%{$hManifest})))
|
|
|
|
{
|
|
|
|
if ($hManifest->{$strFile}{type} eq 'f' && $hManifest->{$strFile}{modification_time} > $lTimestampLast)
|
|
|
|
{
|
|
|
|
$lTimestampLast = $hManifest->{$strFile}{modification_time};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Rebuild if the modification time of the smart file does equal the last changes in source paths
|
|
|
|
if (!$bNoPackage &&
|
|
|
|
(!$bSmart || !$oStorageBackRest->exists($strPackageSmart) ||
|
|
|
|
$oStorageBackRest->info($strPackageSmart)->mtime < $lTimestampLast))
|
|
|
|
{
|
|
|
|
if ($bSmart)
|
|
|
|
{
|
|
|
|
&log(INFO, 'package dependencies have changed, rebuilding...');
|
|
|
|
}
|
|
|
|
|
|
|
|
executeTest("sudo rm -rf ${strPackagePath}");
|
|
|
|
}
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
# Loop through VMs to do the package builds
|
|
|
|
if (!$bNoPackage)
|
|
|
|
{
|
|
|
|
my @stryBuildVm = $strVm eq VM_ALL ? VM_LIST : ($strVm);
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageBackRest->pathCreate($strPackagePath, {bIgnoreExists => true, bCreateParent => true});
|
2017-02-18 05:31:16 +02:00
|
|
|
|
|
|
|
foreach my $strBuildVM (sort(@stryBuildVm))
|
|
|
|
{
|
|
|
|
my $strBuildPath = "${strPackagePath}/${strBuildVM}/src";
|
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
if (!$oStorageBackRest->pathExists($strBuildPath) && $oVm->{$strBuildVM}{&VM_OS_BASE} eq VM_OS_BASE_DEBIAN)
|
2017-02-18 05:31:16 +02:00
|
|
|
{
|
2017-08-19 14:48:13 +02:00
|
|
|
&log(INFO, "build package for ${strBuildVM} (${strBuildPath})");
|
2017-02-18 05:31:16 +02:00
|
|
|
|
|
|
|
executeTest(
|
|
|
|
"docker run -itd -h test-build --name=test-build" .
|
2017-02-21 15:59:23 +02:00
|
|
|
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-build",
|
|
|
|
{bSuppressStdErr => true});
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageBackRest->pathCreate($strBuildPath, {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
executeTest("rsync -r --exclude .vagrant --exclude .git ${strBackRestBase}/ ${strBuildPath}/");
|
|
|
|
executeTest(
|
|
|
|
"docker exec -i test-build " .
|
2017-02-21 15:59:23 +02:00
|
|
|
"bash -c 'cp -r /root/package-src/debian ${strBuildPath}' && sudo chown -R " . TEST_USER .
|
|
|
|
" ${strBuildPath}");
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2017-11-27 01:43:51 +02:00
|
|
|
# Patch files in debian package builds
|
|
|
|
#
|
|
|
|
# Use these commands to create a new patch (may need to modify first line):
|
|
|
|
# BRDIR=/backrest;BRVM=u16;BRPATCHFILE=${BRDIR?}/test/patch/debian-package.patch
|
|
|
|
# DBDIR=${BRDIR?}/test/.vagrant/package/${BRVM}/src/debian
|
|
|
|
# diff -Naur ${DBDIR?}.old ${DBDIR}.new > ${BRPATCHFILE?}
|
|
|
|
my $strDebianPackagePatch = "${strBackRestBase}/test/patch/debian-package.patch";
|
|
|
|
|
|
|
|
if ($oStorageBackRest->exists($strDebianPackagePatch))
|
|
|
|
{
|
|
|
|
executeTest("cp -r ${strBuildPath}/debian ${strBuildPath}/debian.old");
|
|
|
|
executeTest("patch -d ${strBuildPath}/debian < ${strDebianPackagePatch}");
|
|
|
|
executeTest("cp -r ${strBuildPath}/debian ${strBuildPath}/debian.new");
|
|
|
|
}
|
|
|
|
|
2017-06-24 16:59:00 +02:00
|
|
|
# If dev build then disable static release date used for reproducibility
|
2017-02-18 05:31:16 +02:00
|
|
|
if ($bVersionDev)
|
|
|
|
{
|
2017-06-09 23:51:41 +02:00
|
|
|
my $strRules = ${$oStorageBackRest->get("${strBuildPath}/debian/rules")};
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2017-02-21 21:22:03 +02:00
|
|
|
$strRules =~ s/\-\-var\=release-date-static\=y/\-\-var\=release-date-static\=n/g;
|
|
|
|
$strRules =~ s/\-\-out\=html \-\-cache\-only/\-\-out\=html \-\-no\-exe/g;
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageBackRest->put("${strBuildPath}/debian/rules", $strRules);
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
|
|
|
|
2017-06-22 18:37:21 +02:00
|
|
|
# Remove patches that should be applied to core code
|
2017-07-25 18:44:38 +02:00
|
|
|
$oStorageBackRest->remove("${strBuildPath}/debian/patches", {bRecurse => true, bIgnoreExists => true});
|
2017-06-22 18:37:21 +02:00
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
# Update changelog to add experimental version
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageBackRest->put("${strBuildPath}/debian/changelog",
|
2017-03-01 19:22:47 +02:00
|
|
|
"pgbackrest (${strVersionBase}-0." . ($bVersionDev ? 'D' : 'P') . strftime("%Y%m%d%H%M%S", gmtime) .
|
2017-02-18 05:31:16 +02:00
|
|
|
") experimental; urgency=medium\n" .
|
|
|
|
"\n" .
|
|
|
|
' * Automated experimental ' . ($bVersionDev ? 'development' : 'production') . " build.\n" .
|
|
|
|
"\n" .
|
|
|
|
' -- David Steele <david@pgbackrest.org> ' . strftime("%a, %e %b %Y %H:%M:%S %z", gmtime) . "\n\n" .
|
2017-06-09 23:51:41 +02:00
|
|
|
${$oStorageBackRest->get("${strBuildPath}/debian/changelog")});
|
2017-02-18 05:31:16 +02:00
|
|
|
|
|
|
|
executeTest(
|
|
|
|
"docker exec -i test-build " .
|
|
|
|
"bash -c 'cd ${strBuildPath} && debuild -i -us -uc -b'");
|
|
|
|
|
|
|
|
executeTest(
|
|
|
|
"docker exec -i test-build " .
|
|
|
|
"bash -c 'rm -f ${strPackagePath}/${strBuildVM}/*.build ${strPackagePath}/${strBuildVM}/*.changes" .
|
|
|
|
" ${strPackagePath}/${strBuildVM}/pgbackrest-doc*'");
|
|
|
|
|
|
|
|
executeTest("docker rm -f test-build");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Write files to indicate the last time a build was successful
|
|
|
|
if (!$bNoPackage)
|
|
|
|
{
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageBackRest->put($strPackageSmart);
|
2017-08-19 14:48:13 +02:00
|
|
|
utime($lTimestampLast, $lTimestampLast, $strPackageSmart) or
|
2017-02-18 05:31:16 +02:00
|
|
|
confess "unable to set time for ${strPackageSmart}" . (defined($!) ? ":$!" : '');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Exit if only testing builds
|
|
|
|
exit 0 if $bBuildOnly;
|
|
|
|
}
|
|
|
|
|
2017-08-19 14:48:13 +02:00
|
|
|
# Perform static source code analysis
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
if (!$bDryRun)
|
|
|
|
{
|
|
|
|
# Run Perl critic
|
|
|
|
if (!$bNoLint && !$bBuildOnly)
|
|
|
|
{
|
|
|
|
my $strBasePath = dirname(dirname(abs_path($0)));
|
|
|
|
|
|
|
|
&log(INFO, "Performing static code analysis using perlcritic");
|
|
|
|
|
|
|
|
executeTest('perlcritic --quiet --verbose=8 --brutal --top=10' .
|
|
|
|
' --verbose "[%p] %f: %m at line %l, column %c. %e. (Severity: %s)\n"' .
|
|
|
|
" \"--profile=${strBasePath}/test/lint/perlcritic.policy\"" .
|
2017-11-27 01:43:51 +02:00
|
|
|
" ${strBasePath}/lib/*" .
|
2017-08-19 14:48:13 +02:00
|
|
|
" ${strBasePath}/test/test.pl ${strBasePath}/test/lib/*" .
|
|
|
|
" ${strBasePath}/doc/doc.pl ${strBasePath}/doc/lib/*");
|
|
|
|
}
|
|
|
|
|
|
|
|
logFileSet($oStorageTest, cwd() . "/test");
|
|
|
|
}
|
|
|
|
|
2017-11-28 04:19:59 +02:00
|
|
|
# Run the tests
|
2017-08-19 14:48:13 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-02-18 05:31:16 +02:00
|
|
|
if (@{$oyTestRun} == 0)
|
|
|
|
{
|
|
|
|
confess &log(ERROR, 'no tests were selected');
|
|
|
|
}
|
|
|
|
|
|
|
|
&log(INFO, @{$oyTestRun} . ' test' . (@{$oyTestRun} > 1 ? 's': '') . " selected\n");
|
|
|
|
|
2017-11-28 04:19:59 +02:00
|
|
|
# Don't allow --no-cleanup when more than one test will run. How would the prior results be preserved?
|
2017-02-18 05:31:16 +02:00
|
|
|
if ($bNoCleanup && @{$oyTestRun} > 1)
|
|
|
|
{
|
|
|
|
confess &log(ERROR, '--no-cleanup is not valid when more than one test will run')
|
2016-12-13 01:54:07 +02:00
|
|
|
}
|
|
|
|
|
2017-11-28 04:19:59 +02:00
|
|
|
# Only use one vm for dry run so results are printed in order
|
2016-01-14 05:43:26 +02:00
|
|
|
if ($bDryRun)
|
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
$iVmMax = 1;
|
2016-01-14 05:43:26 +02:00
|
|
|
}
|
|
|
|
|
2016-01-09 15:21:53 +02:00
|
|
|
my $iTestIdx = 0;
|
2016-09-06 15:35:02 +02:00
|
|
|
my $iVmTotal;
|
2016-01-09 15:21:53 +02:00
|
|
|
my $iTestMax = @{$oyTestRun};
|
|
|
|
my $lStartTime = time();
|
2016-09-06 15:35:02 +02:00
|
|
|
my $bShowOutputAsync = $bVmOut && (@{$oyTestRun} == 1 || $iVmMax == 1) && ! $bDryRun ? true : false;
|
2016-01-09 15:21:53 +02:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
$iVmTotal = 0;
|
2016-01-09 15:21:53 +02:00
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
for (my $iVmIdx = 0; $iVmIdx < $iVmMax; $iVmIdx++)
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
if (defined($$oyProcess[$iVmIdx]))
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2017-02-21 15:59:23 +02:00
|
|
|
my ($bDone, $bFail) = $$oyProcess[$iVmIdx]->end();
|
2016-01-09 15:21:53 +02:00
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
if ($bDone)
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2017-02-21 15:59:23 +02:00
|
|
|
if ($bFail)
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2017-02-21 15:59:23 +02:00
|
|
|
if ($oyProcess->[$iVmIdx]->run())
|
|
|
|
{
|
|
|
|
$iTestRetry++;
|
|
|
|
$iVmTotal++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$iTestFail++;
|
|
|
|
$$oyProcess[$iVmIdx] = undef;
|
|
|
|
}
|
2016-01-09 15:21:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-21 15:59:23 +02:00
|
|
|
$$oyProcess[$iVmIdx] = undef;
|
2016-01-09 15:21:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
$iVmTotal++;
|
2016-01-09 15:21:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-24 16:35:42 +02:00
|
|
|
# Only wait when all VMs are running or all tests have been assigned. Otherwise, there is something to do.
|
|
|
|
if ($iVmTotal == $iVmMax || $iTestIdx == @{$oyTestRun})
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2017-10-24 16:35:42 +02:00
|
|
|
waitHiRes(.05);
|
2016-01-09 15:21:53 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-06 15:35:02 +02:00
|
|
|
while ($iVmTotal == $iVmMax);
|
2016-01-09 15:21:53 +02:00
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
for (my $iVmIdx = 0; $iVmIdx < $iVmMax; $iVmIdx++)
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2016-09-06 15:35:02 +02:00
|
|
|
if (!defined($$oyProcess[$iVmIdx]) && $iTestIdx < @{$oyTestRun})
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2017-02-21 15:59:23 +02:00
|
|
|
my $oJob = new pgBackRestTest::Common::JobTest(
|
2017-06-09 23:51:41 +02:00
|
|
|
$oStorageTest, $strBackRestBase, $strTestPath, $strCoveragePath, $$oyTestRun[$iTestIdx], $bDryRun, $bVmOut,
|
|
|
|
$iVmIdx, $iVmMax, $iTestIdx, $iTestMax, $strLogLevel, $bLogForce, $bShowOutputAsync, $bNoCleanup, $iRetry);
|
2016-01-09 15:21:53 +02:00
|
|
|
$iTestIdx++;
|
|
|
|
|
2017-02-21 15:59:23 +02:00
|
|
|
if ($oJob->run())
|
2016-01-09 15:21:53 +02:00
|
|
|
{
|
2017-02-21 15:59:23 +02:00
|
|
|
$$oyProcess[$iVmIdx] = $oJob;
|
2016-01-09 15:21:53 +02:00
|
|
|
}
|
|
|
|
|
2016-09-06 15:35:02 +02:00
|
|
|
$iVmTotal++;
|
2016-01-09 15:21:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-06 15:35:02 +02:00
|
|
|
while ($iVmTotal > 0);
|
2016-01-09 15:21:53 +02:00
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
# Write out coverage info and test coverage
|
2017-08-19 14:48:13 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-04-10 18:31:30 +02:00
|
|
|
my $iUncoveredCodeModuleTotal = 0;
|
|
|
|
|
|
|
|
if (vmCoverage($strVm) && !$bDryRun)
|
2017-01-10 03:49:04 +02:00
|
|
|
{
|
2017-04-10 18:31:30 +02:00
|
|
|
&log(INFO, 'writing coverage report');
|
2017-01-10 03:49:04 +02:00
|
|
|
executeTest("rm -rf ${strBackRestBase}/test/coverage");
|
|
|
|
executeTest("cp -rp ${strCoveragePath} ${strCoveragePath}_temp");
|
2017-04-10 18:31:30 +02:00
|
|
|
executeTest(
|
2018-01-26 23:41:17 +02:00
|
|
|
"cd ${strCoveragePath}_temp && " .
|
2017-04-10 18:31:30 +02:00
|
|
|
LIB_COVER_EXE . " -report json -outputdir ${strBackRestBase}/test/coverage ${strCoveragePath}_temp",
|
|
|
|
{bSuppressStdErr => true});
|
|
|
|
executeTest("sudo rm -rf ${strCoveragePath}_temp");
|
|
|
|
executeTest("sudo cp -rp ${strCoveragePath} ${strCoveragePath}_temp");
|
|
|
|
executeTest(
|
2018-01-26 23:41:17 +02:00
|
|
|
"cd ${strCoveragePath}_temp && " .
|
2017-04-10 18:31:30 +02:00
|
|
|
LIB_COVER_EXE . " -outputdir ${strBackRestBase}/test/coverage ${strCoveragePath}_temp",
|
|
|
|
{bSuppressStdErr => true});
|
|
|
|
executeTest("sudo rm -rf ${strCoveragePath}_temp");
|
|
|
|
|
|
|
|
# Determine which modules were covered (only check coverage if all tests were successful)
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
if ($iTestFail == 0)
|
|
|
|
{
|
|
|
|
my $hModuleTest; # Everything that was run
|
|
|
|
|
|
|
|
# Build a hash of all modules, tests, and runs that were executed
|
|
|
|
foreach my $hTestRun (@{$oyTestRun})
|
|
|
|
{
|
|
|
|
# Get coverage for the module
|
|
|
|
my $strModule = $hTestRun->{&TEST_MODULE};
|
|
|
|
my $hModule = testDefModule($strModule);
|
|
|
|
|
|
|
|
# Get coverage for the test
|
|
|
|
my $strTest = $hTestRun->{&TEST_NAME};
|
|
|
|
my $hTest = testDefModuleTest($strModule, $strTest);
|
|
|
|
|
|
|
|
# If no tests are listed it means all of them were run
|
|
|
|
if (@{$hTestRun->{&TEST_RUN}} == 0)
|
|
|
|
{
|
|
|
|
$hModuleTest->{$strModule}{$strTest} = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Load the results of coverage testing from JSON
|
|
|
|
my $oJSON = JSON::PP->new()->allow_nonref();
|
2017-06-09 23:51:41 +02:00
|
|
|
my $hCoverageResult = $oJSON->decode(${$oStorageBackRest->get('test/coverage/cover.json')});
|
2017-04-10 18:31:30 +02:00
|
|
|
|
|
|
|
# Now compare against code modules that should have full coverage
|
|
|
|
my $hCoverageList = testDefCoverageList();
|
|
|
|
my $hCoverageType = testDefCoverageType();
|
|
|
|
my $hCoverageActual;
|
|
|
|
|
|
|
|
foreach my $strCodeModule (sort(keys(%{$hCoverageList})))
|
|
|
|
{
|
|
|
|
if (@{$hCoverageList->{$strCodeModule}} > 0)
|
|
|
|
{
|
|
|
|
my $iCoverageTotal = 0;
|
|
|
|
|
|
|
|
foreach my $hTest (@{$hCoverageList->{$strCodeModule}})
|
|
|
|
{
|
|
|
|
if (!defined($hModuleTest->{$hTest->{strModule}}{$hTest->{strTest}}))
|
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$iCoverageTotal++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (@{$hCoverageList->{$strCodeModule}} == $iCoverageTotal)
|
|
|
|
{
|
2017-10-12 18:55:48 +02:00
|
|
|
$hCoverageActual->{testRunName($strCodeModule, false)} = $hCoverageType->{$strCodeModule};
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (keys(%{$hCoverageActual}) > 0)
|
|
|
|
{
|
|
|
|
&log(INFO, 'test coverage for: ' . join(', ', sort(keys(%{$hCoverageActual}))));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
&log(INFO, 'no code modules had all tests run required for coverage');
|
|
|
|
}
|
|
|
|
|
2017-10-12 18:55:48 +02:00
|
|
|
my $strPartialCoverage;
|
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
foreach my $strCodeModule (sort(keys(%{$hCoverageActual})))
|
|
|
|
{
|
2017-10-12 18:55:48 +02:00
|
|
|
my $strCodeModulePath = "${strBackRestBase}/";
|
|
|
|
|
|
|
|
# If the first char of the module is lower case when this is a c module
|
|
|
|
if (substr($strCodeModule, 0, 1) eq lc(substr($strCodeModule, 0, 1)))
|
|
|
|
{
|
|
|
|
# If it ends with Test then it is a test modile
|
|
|
|
if ($strCodeModule =~ /Test$/)
|
|
|
|
{
|
|
|
|
$strCodeModulePath .= "test/src/${strCodeModule}.c";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strCodeModulePath .= "src/${strCodeModule}.c";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# Else a Perl module
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strCodeModulePath .= "lib/" . BACKREST_NAME . "/${strCodeModule}.pm"
|
|
|
|
}
|
|
|
|
|
2018-02-14 23:46:52 +02:00
|
|
|
# Get summary results
|
2017-10-12 18:55:48 +02:00
|
|
|
my $hCoverageResultAll = $hCoverageResult->{'summary'}{$strCodeModulePath}{total};
|
|
|
|
|
|
|
|
# Try an extra / if the module is not found
|
|
|
|
if (!defined($hCoverageResultAll))
|
|
|
|
{
|
|
|
|
$strCodeModulePath = "/${strCodeModulePath}";
|
|
|
|
$hCoverageResultAll = $hCoverageResult->{'summary'}{$strCodeModulePath}{total};
|
|
|
|
}
|
|
|
|
|
|
|
|
# If module is marked as having no code
|
|
|
|
if ($hCoverageActual->{$strCodeModule} eq TESTDEF_COVERAGE_NOCODE)
|
|
|
|
{
|
|
|
|
# Error if it really does have coverage
|
|
|
|
if ($hCoverageResultAll)
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "module ${strCodeModule} is marked 'no code' but has code");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Skip to next module
|
|
|
|
next;
|
|
|
|
}
|
2017-04-10 18:31:30 +02:00
|
|
|
|
|
|
|
if (!defined($hCoverageResultAll))
|
|
|
|
{
|
|
|
|
confess &log(ERROR, "unable to find coverage results for ${strCodeModule}");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check that all code has been covered
|
2017-04-14 02:10:28 +02:00
|
|
|
my $iCoverageTotal = $hCoverageResultAll->{total};
|
|
|
|
my $iCoverageUncoverable = coalesce($hCoverageResultAll->{uncoverable}, 0);
|
2017-10-12 18:55:48 +02:00
|
|
|
my $iCoverageCovered = coalesce($hCoverageResultAll->{covered}, 0);
|
2017-04-14 02:10:28 +02:00
|
|
|
|
2017-10-12 18:55:48 +02:00
|
|
|
if ($hCoverageActual->{$strCodeModule} eq TESTDEF_COVERAGE_FULL)
|
2017-04-10 18:31:30 +02:00
|
|
|
{
|
2017-04-14 02:10:28 +02:00
|
|
|
my $iUncoveredLines = $iCoverageTotal - $iCoverageCovered - $iCoverageUncoverable;
|
2017-04-10 18:31:30 +02:00
|
|
|
|
|
|
|
if ($iUncoveredLines != 0)
|
|
|
|
{
|
2018-02-15 00:13:18 +02:00
|
|
|
&log(ERROR, "\ncode module ${strCodeModule} is not fully covered");
|
|
|
|
&log(ERROR, ('-' x 80));
|
2017-04-10 18:31:30 +02:00
|
|
|
$iUncoveredCodeModuleTotal++;
|
2018-02-15 00:13:18 +02:00
|
|
|
|
|
|
|
executeTest(
|
|
|
|
"/usr/bin/cover -report text ${strCoveragePath} --select ${strBackRestBase}/lib/" . BACKREST_NAME .
|
|
|
|
"/${strCodeModule}.pm",
|
|
|
|
{bShowOutputAsync => true});
|
|
|
|
&log(ERROR, ('-' x 80));
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-12 18:55:48 +02:00
|
|
|
# Else test how much partial coverage there was
|
|
|
|
elsif ($hCoverageActual->{$strCodeModule} eq TESTDEF_COVERAGE_PARTIAL)
|
2017-04-10 18:31:30 +02:00
|
|
|
{
|
2017-04-14 02:10:28 +02:00
|
|
|
my $iCoveragePercent = int(($iCoverageCovered + $iCoverageUncoverable) * 100 / $iCoverageTotal);
|
2017-04-10 18:31:30 +02:00
|
|
|
|
|
|
|
if ($iCoveragePercent == 100)
|
|
|
|
{
|
2018-02-14 23:46:52 +02:00
|
|
|
# This has been changed to a warning for now so archive/async tests will pass
|
|
|
|
&log(WARN, "code module ${strCodeModule} has 100% coverage but is not marked fully covered");
|
|
|
|
# $iUncoveredCodeModuleTotal++;
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-12 18:55:48 +02:00
|
|
|
$strPartialCoverage .=
|
|
|
|
(defined($strPartialCoverage) ? ', ' : '') . "${strCodeModule} (${iCoveragePercent}%)";
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-12 18:55:48 +02:00
|
|
|
|
|
|
|
# If any modules had partial coverage then display them
|
|
|
|
if (defined($strPartialCoverage))
|
|
|
|
{
|
|
|
|
&log(INFO, "module (expected) partial coverage: ${strPartialCoverage}");
|
|
|
|
}
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
2017-01-10 03:49:04 +02:00
|
|
|
}
|
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
# Print test info and exit
|
2017-08-19 14:48:13 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2017-05-12 22:27:06 +02:00
|
|
|
&log(INFO,
|
|
|
|
($bDryRun ? 'DRY RUN COMPLETED' : 'TESTS COMPLETED') . ($iTestFail == 0 ? ' SUCCESSFULLY' .
|
|
|
|
($iUncoveredCodeModuleTotal == 0 ? '' : " WITH ${iUncoveredCodeModuleTotal} MODULE(S) MISSING COVERAGE") :
|
|
|
|
" WITH ${iTestFail} FAILURE(S)") . ($iTestRetry == 0 ? '' : ", ${iTestRetry} RETRY(IES)") .
|
|
|
|
' (' . (time() - $lStartTime) . 's)');
|
2017-04-10 18:31:30 +02:00
|
|
|
|
2017-05-12 22:27:06 +02:00
|
|
|
exit 1 if ($iTestFail > 0 || $iUncoveredCodeModuleTotal > 0);
|
2016-01-09 15:21:53 +02:00
|
|
|
|
2017-04-10 18:31:30 +02:00
|
|
|
exit 0;
|
2016-01-09 15:21:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################################################################
|
|
|
|
# Runs tests
|
|
|
|
################################################################################################################################
|
|
|
|
my $iRun = 0;
|
2014-07-17 06:38:38 +03:00
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Create host group for containers
|
2016-06-24 14:12:58 +02:00
|
|
|
my $oHostGroup = hostGroupGet();
|
2015-09-08 18:58:13 +02:00
|
|
|
|
2016-12-23 15:22:59 +02:00
|
|
|
# Run the test
|
2017-01-05 01:29:13 +02:00
|
|
|
testRun($stryModule[0], $stryModuleTest[0])->process(
|
2016-12-23 15:22:59 +02:00
|
|
|
$strVm, $iVmId, # Vm info
|
|
|
|
$strBackRestBase, # Base backrest directory
|
|
|
|
$strTestPath, # Path where the tests will run
|
2017-11-27 01:43:51 +02:00
|
|
|
'/usr/bin/' . BACKREST_EXE, # Path to the backrest executable
|
|
|
|
"${strBackRestBase}/bin/" . BACKREST_EXE, # Path to the backrest Perl helper
|
2018-02-04 01:27:38 +02:00
|
|
|
$strPgVersion ne 'minimal' ? $strPgSqlBin: undef, # Pg bin path
|
|
|
|
$strPgVersion ne 'minimal' ? $strPgVersion: undef, # Pg version
|
2017-01-05 01:29:13 +02:00
|
|
|
$stryModule[0], $stryModuleTest[0], \@iyModuleTestRun, # Module info
|
2017-06-22 01:21:16 +02:00
|
|
|
$bVmOut, $bDryRun, $bNoCleanup, $bLogForce, # Test options
|
2016-12-23 15:22:59 +02:00
|
|
|
TEST_USER, BACKREST_USER, TEST_GROUP); # User/group info
|
2015-09-09 21:40:54 +02:00
|
|
|
|
2016-06-24 14:12:58 +02:00
|
|
|
if (!$bNoCleanup)
|
|
|
|
{
|
|
|
|
if ($oHostGroup->removeAll() > 0)
|
|
|
|
{
|
|
|
|
executeTest("sudo rm -rf ${strTestPath}");
|
2015-06-14 00:25:49 +02:00
|
|
|
}
|
2015-02-28 06:31:39 +02:00
|
|
|
}
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
if (!$bDryRun && !$bVmOut)
|
2015-04-08 00:36:59 +02:00
|
|
|
{
|
2016-09-06 15:44:50 +02:00
|
|
|
&log(INFO, 'TESTS COMPLETED SUCCESSFULLY (DESPITE ANY ERROR MESSAGES YOU SAW)');
|
2015-04-08 00:36:59 +02:00
|
|
|
}
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
# Exit with success
|
|
|
|
exit 0;
|
2014-06-22 18:56:01 +03:00
|
|
|
}
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Check for errors
|
|
|
|
####################################################################################################################################
|
|
|
|
or do
|
2014-07-16 05:32:41 +03:00
|
|
|
{
|
2016-09-06 15:44:50 +02:00
|
|
|
# If a backrest exception then return the code
|
2017-10-16 16:47:31 +02:00
|
|
|
exit $EVAL_ERROR->code() if (isException(\$EVAL_ERROR));
|
2016-09-06 15:44:50 +02:00
|
|
|
|
|
|
|
# Else output the unhandled error
|
2017-08-25 22:47:47 +02:00
|
|
|
syswrite(*STDOUT, $EVAL_ERROR);
|
2016-09-06 15:44:50 +02:00
|
|
|
exit ERROR_UNHANDLED;
|
|
|
|
};
|
|
|
|
|
|
|
|
# It shouldn't be possible to get here
|
|
|
|
&log(ASSERT, 'execution reached invalid location in ' . __FILE__ . ', line ' . __LINE__);
|
|
|
|
exit ERROR_ASSERT;
|