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
|
|
|
|
2020-03-10 21:41:56 +02:00
|
|
|
use pgBackRestDoc::Common::Exception;
|
|
|
|
use pgBackRestDoc::Common::Log;
|
|
|
|
use pgBackRestDoc::Common::String;
|
2020-03-10 23:57:02 +02:00
|
|
|
use pgBackRestDoc::ProjectInfo;
|
2020-03-10 21:12:44 +02: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
|
|
|
|
2018-03-10 06:00:20 +02:00
|
|
|
use pgBackRestTest::Common::BuildTest;
|
2018-04-16 21:52:17 +02:00
|
|
|
use pgBackRestTest::Common::CodeCountTest;
|
2016-06-24 14:12:58 +02:00
|
|
|
use pgBackRestTest::Common::ContainerTest;
|
2018-11-12 00:32:42 +02:00
|
|
|
use pgBackRestTest::Common::CoverageTest;
|
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;
|
2019-06-17 15:16:44 +02:00
|
|
|
use pgBackRestTest::Common::Storage;
|
|
|
|
use pgBackRestTest::Common::StoragePosix;
|
2016-12-13 01:54:07 +02:00
|
|
|
use pgBackRestTest::Common::VmTest;
|
2020-03-10 21:12:44 +02:00
|
|
|
use pgBackRestTest::Common::Wait;
|
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
|
2019-08-26 18:05:36 +02:00
|
|
|
--no-cleanup don't cleanup 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
|
2018-05-22 18:53:08 +02:00
|
|
|
--build-only compile the test library / packages and run tests only
|
2019-04-24 02:52:03 +02:00
|
|
|
--build-max max processes to use for builds (default 4)
|
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
|
2019-10-08 18:06:30 +02:00
|
|
|
--container-only only run tests that must be run in a container
|
2017-11-02 14:14:13 +02:00
|
|
|
--gen-only only run auto-generation
|
2018-05-22 18:53:08 +02:00
|
|
|
--no-gen do not run code generation
|
2018-04-16 21:52:17 +02:00
|
|
|
--code-count generate code counts
|
2020-03-09 23:41:59 +02:00
|
|
|
--smart perform bin/package builds only when source timestamps have changed
|
2017-02-18 05:31:16 +02:00
|
|
|
--no-package do not build packages
|
2019-07-06 00:34:15 +02:00
|
|
|
--dev --smart --no-package --no-optimize
|
|
|
|
--dev-test --no-package
|
|
|
|
--expect --no-package --vm=co7 --db=9.6 --log-force
|
2018-05-18 12:45:14 +02:00
|
|
|
--no-valgrind don't run valgrind on C unit tests (saves time)
|
|
|
|
--no-coverage don't run coverage on C unit tests (saves time)
|
|
|
|
--no-optimize don't do compile optimization for C (saves compile time)
|
2018-05-18 17:57:32 +02:00
|
|
|
--backtrace enable backtrace when available (adds stack trace line numbers -- very slow)
|
2018-05-18 12:45:14 +02:00
|
|
|
--profile generate profile info
|
|
|
|
--no-debug don't generate a debug build
|
2019-09-28 20:02:12 +02:00
|
|
|
--scale scale performance tests
|
2019-12-12 05:11:04 +02:00
|
|
|
--tz test with the specified timezone
|
2019-02-27 17:09:19 +02:00
|
|
|
--debug-test-trace test stack trace for low-level functions (slow, esp w/valgrind, may cause timeouts)
|
2015-01-11 18:52:16 +02:00
|
|
|
|
2019-05-15 19:04:56 +02:00
|
|
|
Report Options:
|
|
|
|
--coverage-summary generate a coverage summary report for the documentation
|
|
|
|
|
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)
|
2018-07-21 01:03:46 +02:00
|
|
|
--log-level log level to use for test harness (and Perl tests) (defaults to INFO)
|
|
|
|
--log-level-test log level to use for C tests (defaults to OFF)
|
2019-12-17 22:23:07 +02:00
|
|
|
--log-level-test-file log level to use for file logging in integration tests (defaults to TRACE)
|
2015-01-12 16:05:26 +02:00
|
|
|
--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);
|
2018-07-21 01:03:46 +02:00
|
|
|
my $strLogLevelTest = lc(OFF);
|
2019-12-17 22:23:07 +02:00
|
|
|
my $strLogLevelTestFile = lc(TRACE);
|
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;
|
2017-02-18 05:31:16 +02:00
|
|
|
my $bBuildOnly = false;
|
2019-04-24 02:52:03 +02:00
|
|
|
my $iBuildMax = 4;
|
2017-04-10 18:31:30 +02:00
|
|
|
my $bCoverageOnly = false;
|
2019-05-15 19:04:56 +02:00
|
|
|
my $bCoverageSummary = false;
|
2018-05-18 12:45:14 +02:00
|
|
|
my $bNoCoverage = false;
|
2017-10-12 18:55:48 +02:00
|
|
|
my $bCOnly = false;
|
2019-10-08 18:06:30 +02:00
|
|
|
my $bContainerOnly = false;
|
2017-11-02 14:14:13 +02:00
|
|
|
my $bGenOnly = false;
|
2018-05-22 18:53:08 +02:00
|
|
|
my $bNoGen = false;
|
2018-04-16 21:52:17 +02:00
|
|
|
my $bCodeCount = false;
|
2017-02-18 05:31:16 +02:00
|
|
|
my $bSmart = false;
|
|
|
|
my $bNoPackage = false;
|
|
|
|
my $bDev = false;
|
2018-05-18 12:45:14 +02:00
|
|
|
my $bDevTest = false;
|
2018-05-18 17:57:32 +02:00
|
|
|
my $bBackTrace = false;
|
2018-05-18 12:45:14 +02:00
|
|
|
my $bProfile = false;
|
2017-06-09 23:51:41 +02:00
|
|
|
my $bExpect = false;
|
2018-05-18 12:45:14 +02:00
|
|
|
my $bNoValgrind = false;
|
|
|
|
my $bNoOptimize = false;
|
|
|
|
my $bNoDebug = false;
|
2019-09-28 20:02:12 +02:00
|
|
|
my $iScale = 1;
|
2019-02-27 17:09:19 +02:00
|
|
|
my $bDebugTestTrace = false;
|
2017-02-23 01:43:10 +02:00
|
|
|
my $iRetry = 0;
|
2019-12-12 05:11:04 +02:00
|
|
|
my $strTimeZone = undef;
|
2015-01-11 18:52:16 +02:00
|
|
|
|
2019-05-15 19:04:56 +02:00
|
|
|
my @cmdOptions = @ARGV;
|
|
|
|
|
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,
|
2018-07-21 01:03:46 +02:00
|
|
|
'log-level-test=s' => \$strLogLevelTest,
|
2019-12-17 22:23:07 +02:00
|
|
|
'log-level-test-file=s' => \$strLogLevelTestFile,
|
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,
|
2017-02-18 05:31:16 +02:00
|
|
|
'build-only' => \$bBuildOnly,
|
2019-04-24 02:52:03 +02:00
|
|
|
'build-max=s' => \$iBuildMax,
|
2017-02-18 05:31:16 +02:00
|
|
|
'no-package' => \$bNoPackage,
|
2017-04-10 18:31:30 +02:00
|
|
|
'coverage-only' => \$bCoverageOnly,
|
2019-05-15 19:04:56 +02:00
|
|
|
'coverage-summary' => \$bCoverageSummary,
|
2018-05-18 12:45:14 +02:00
|
|
|
'no-coverage' => \$bNoCoverage,
|
2017-10-12 18:55:48 +02:00
|
|
|
'c-only' => \$bCOnly,
|
2019-10-08 18:06:30 +02:00
|
|
|
'container-only' => \$bContainerOnly,
|
2017-11-02 14:14:13 +02:00
|
|
|
'gen-only' => \$bGenOnly,
|
2018-05-22 18:53:08 +02:00
|
|
|
'no-gen' => \$bNoGen,
|
2018-04-16 21:52:17 +02:00
|
|
|
'code-count' => \$bCodeCount,
|
2017-02-18 05:31:16 +02:00
|
|
|
'smart' => \$bSmart,
|
2017-02-22 05:10:02 +02:00
|
|
|
'dev' => \$bDev,
|
2018-05-18 12:45:14 +02:00
|
|
|
'dev-test' => \$bDevTest,
|
2018-05-18 17:57:32 +02:00
|
|
|
'backtrace' => \$bBackTrace,
|
2018-05-18 12:45:14 +02:00
|
|
|
'profile' => \$bProfile,
|
2017-06-09 23:51:41 +02:00
|
|
|
'expect' => \$bExpect,
|
2018-05-18 12:45:14 +02:00
|
|
|
'no-valgrind' => \$bNoValgrind,
|
|
|
|
'no-optimize' => \$bNoOptimize,
|
|
|
|
'no-debug', => \$bNoDebug,
|
2019-09-28 20:02:12 +02:00
|
|
|
'scale=s' => \$iScale,
|
2019-12-12 05:11:04 +02:00
|
|
|
'tz=s', => \$strTimeZone,
|
2019-02-27 17:09:19 +02:00
|
|
|
'debug-test-trace', => \$bDebugTestTrace,
|
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
|
|
|
{
|
2018-03-10 04:24:30 +02:00
|
|
|
# Record the start time
|
|
|
|
my $lStartTime = time();
|
|
|
|
|
2016-09-06 15:44:50 +02:00
|
|
|
# Display version and exit if requested
|
|
|
|
if ($bVersion || $bHelp)
|
|
|
|
{
|
2018-11-25 02:05:03 +02:00
|
|
|
syswrite(*STDOUT, PROJECT_NAME . ' ' . PROJECT_VERSION . " Test Engine\n");
|
2016-09-06 15:44:50 +02:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2019-10-17 11:56:45 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Disable code generation on dry-run
|
|
|
|
################################################################################################################################
|
|
|
|
if ($bDryRun)
|
|
|
|
{
|
|
|
|
$bNoGen = true;
|
|
|
|
}
|
|
|
|
|
2019-05-15 19:04:56 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Update options for --coverage-summary
|
|
|
|
################################################################################################################################
|
|
|
|
if ($bCoverageSummary)
|
|
|
|
{
|
|
|
|
$bCoverageOnly = true;
|
|
|
|
$bCOnly = true;
|
|
|
|
}
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
################################################################################################################################
|
2018-05-18 12:45:14 +02:00
|
|
|
# Update options for --dev and --dev-fast and --dev-test
|
2017-02-18 05:31:16 +02:00
|
|
|
################################################################################################################################
|
2018-05-18 12:45:14 +02:00
|
|
|
if ($bDev && $bDevTest)
|
|
|
|
{
|
|
|
|
confess "cannot combine --dev and --dev-test";
|
|
|
|
}
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
if ($bDev)
|
|
|
|
{
|
|
|
|
$bSmart = true;
|
|
|
|
$bNoPackage = true;
|
2018-05-18 12:45:14 +02:00
|
|
|
$bNoOptimize = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($bDevTest)
|
|
|
|
{
|
|
|
|
$bNoPackage = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################################################################
|
|
|
|
# Update options for --profile
|
|
|
|
################################################################################################################################
|
|
|
|
if ($bProfile)
|
|
|
|
{
|
|
|
|
$bNoValgrind = true;
|
|
|
|
$bNoCoverage = true;
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
|
|
|
|
2017-06-09 23:51:41 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Update options for --expect
|
|
|
|
################################################################################################################################
|
|
|
|
if ($bExpect)
|
|
|
|
{
|
|
|
|
$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);
|
2018-03-10 06:00:20 +02:00
|
|
|
&log(INFO, "test begin - log level ${strLogLevel}");
|
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
|
|
|
|
2019-08-26 18:05:36 +02:00
|
|
|
# Set test path if not explicitly set
|
2016-09-06 15:44:50 +02:00
|
|
|
if (!defined($strTestPath))
|
|
|
|
{
|
|
|
|
$strTestPath = cwd() . '/test';
|
|
|
|
}
|
2016-05-11 00:12:37 +02:00
|
|
|
|
2019-06-17 15:16:44 +02:00
|
|
|
my $oStorageTest = new pgBackRestTest::Common::Storage(
|
|
|
|
$strTestPath, new pgBackRestTest::Common::StoragePosix({bFileSync => false, bPathSync => false}));
|
2017-06-09 23:51:41 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
# If VM is not defined then set it to all
|
|
|
|
if (!defined($strVm))
|
|
|
|
{
|
|
|
|
$strVm = VM_ALL;
|
2017-01-10 03:49:04 +02:00
|
|
|
}
|
2019-10-17 14:00:18 +02:00
|
|
|
# Else make sure vm is valid
|
|
|
|
elsif ($strVm ne VM_ALL)
|
|
|
|
{
|
|
|
|
vmValid($strVm);
|
|
|
|
}
|
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)));
|
2020-03-09 23:41:59 +02:00
|
|
|
my $strVagrantPath = "${strBackRestBase}/test/.vagrant";
|
2016-06-02 15:32:56 +02:00
|
|
|
|
2019-06-17 15:16:44 +02:00
|
|
|
my $oStorageBackRest = new pgBackRestTest::Common::Storage(
|
|
|
|
$strBackRestBase, new pgBackRestTest::Common::StoragePosix({bFileSync => false, bPathSync => false}));
|
2017-06-09 23:51:41 +02:00
|
|
|
|
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
|
|
|
|
2018-04-08 16:19:24 +02:00
|
|
|
################################################################################################################################
|
|
|
|
# Load test definition
|
|
|
|
################################################################################################################################
|
|
|
|
testDefLoad(${$oStorageBackRest->get("test/define.yaml")});
|
|
|
|
|
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
|
|
|
{
|
2018-11-04 01:52:46 +02:00
|
|
|
# Make a copy of the repo to track which files have been changed. Eventually all builds will be done from this directory.
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $strRepoCachePath = "${strTestPath}/repo";
|
|
|
|
my $strRepoCacheManifest = 'repo.manifest';
|
|
|
|
|
|
|
|
# Create the repo path -- this should hopefully prevent obvious rsync errors below
|
|
|
|
$oStorageTest->pathCreate("${strTestPath}/repo", {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
|
|
|
|
|
|
|
# Check if there are any files existing already. If none, that means a full copy is happening and we shouldn't report
|
|
|
|
# modified files
|
|
|
|
my @stryExistingList = $oStorageTest->list($strRepoCachePath, {bIgnoreMissing => true});
|
|
|
|
|
|
|
|
# First check if there is an old manifest that has not been cleared. This indicates that an error happened before all new
|
|
|
|
# files could be processed, which means they should be processed again.
|
|
|
|
my @stryModifiedList;
|
|
|
|
my $rstrModifiedList = $oStorageTest->get(
|
|
|
|
$oStorageTest->openRead("${strRepoCachePath}/${strRepoCacheManifest}", {bIgnoreMissing => true}));
|
|
|
|
|
|
|
|
if (defined($rstrModifiedList))
|
|
|
|
{
|
|
|
|
@stryModifiedList = split("\n", trim($$rstrModifiedList));
|
|
|
|
}
|
|
|
|
|
|
|
|
push(
|
|
|
|
@stryModifiedList,
|
|
|
|
split(
|
|
|
|
"\n",
|
|
|
|
trim(
|
|
|
|
executeTest(
|
|
|
|
"git -C ${strBackRestBase} ls-files -c --others --exclude-standard |" .
|
2018-11-04 15:39:48 +02:00
|
|
|
" rsync -rtW --out-format=\"\%n\" --delete --ignore-missing-args --exclude=repo.manifest" .
|
|
|
|
" ${strBackRestBase}/ --files-from=- ${strRepoCachePath}"))));
|
2018-11-04 01:52:46 +02:00
|
|
|
|
|
|
|
if (@stryModifiedList > 0)
|
|
|
|
{
|
|
|
|
$oStorageTest->put("${strRepoCachePath}/${strRepoCacheManifest}", join("\n", @stryModifiedList));
|
|
|
|
|
|
|
|
if (@stryExistingList > 0)
|
|
|
|
{
|
|
|
|
&log(INFO, "modified since last run: " . join(', ', @stryModifiedList));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-16 21:52:17 +02:00
|
|
|
# Generate code counts
|
2018-11-04 01:52:46 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2018-04-16 21:52:17 +02:00
|
|
|
if ($bCodeCount)
|
|
|
|
{
|
|
|
|
&log(INFO, "classify code files");
|
|
|
|
|
|
|
|
codeCountScan($oStorageBackRest, $strBackRestBase);
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
# Auto-generate files unless --no-gen specified
|
2017-11-29 04:44:05 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2018-05-22 18:53:08 +02:00
|
|
|
if (!$bNoGen)
|
|
|
|
{
|
2018-11-04 01:52:46 +02:00
|
|
|
my @stryBuiltAll;
|
2018-05-22 18:53:08 +02:00
|
|
|
&log(INFO, "check code autogenerate");
|
2018-03-10 06:00:20 +02:00
|
|
|
|
2019-04-26 14:08:23 +02:00
|
|
|
# Auto-generate version for configure.ac script
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2020-03-10 23:57:02 +02:00
|
|
|
if (!$bSmart || grep(/^src\/version\.h/, @stryModifiedList))
|
2019-04-26 14:08:23 +02:00
|
|
|
{
|
|
|
|
my $strConfigureAcOld = ${$oStorageTest->get("${strBackRestBase}/src/configure.ac")};
|
|
|
|
my $strConfigureAcNew;
|
|
|
|
|
|
|
|
foreach my $strLine (split("\n", $strConfigureAcOld))
|
|
|
|
{
|
|
|
|
if ($strLine =~ /^AC_INIT\(/)
|
|
|
|
{
|
|
|
|
$strLine = 'AC_INIT([' . PROJECT_NAME . '], [' . PROJECT_VERSION . '])';
|
|
|
|
}
|
|
|
|
|
|
|
|
$strConfigureAcNew .= "${strLine}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Save into the src dir
|
|
|
|
my @stryBuilt;
|
|
|
|
my $strBuilt = 'src/configure.ac';
|
|
|
|
|
|
|
|
if (buildPutDiffers($oStorageBackRest, "${strBackRestBase}/${strBuilt}", $strConfigureAcNew))
|
|
|
|
{
|
|
|
|
push(@stryBuilt, $strBuilt);
|
|
|
|
push(@stryBuiltAll, @stryBuilt);
|
|
|
|
push(@stryModifiedList, @stryBuilt);
|
|
|
|
}
|
|
|
|
|
|
|
|
&log(INFO,
|
|
|
|
" autogenerated version in configure.ac script: " . (@stryBuilt ? join(', ', @stryBuilt) : 'no changes'));
|
|
|
|
}
|
|
|
|
|
|
|
|
# Auto-generate configure script
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
if (!$bSmart || grep(/^src\/configure\.ac/, @stryModifiedList))
|
|
|
|
{
|
|
|
|
my $strConfigure = executeTest("autoconf ${strBackRestBase}/src/configure.ac");
|
|
|
|
|
|
|
|
# Trim off any trailing LFs
|
|
|
|
$strConfigure = trim($strConfigure) . "\n";
|
|
|
|
|
|
|
|
# Save into the src dir
|
|
|
|
my @stryBuilt;
|
|
|
|
my $strBuilt = 'src/configure';
|
|
|
|
|
|
|
|
if (buildPutDiffers($oStorageBackRest, "${strBackRestBase}/${strBuilt}", $strConfigure))
|
|
|
|
{
|
|
|
|
push(@stryBuilt, $strBuilt);
|
|
|
|
push(@stryBuiltAll, @stryBuilt);
|
|
|
|
push(@stryModifiedList, @stryBuilt);
|
|
|
|
}
|
|
|
|
|
|
|
|
&log(INFO, " autogenerated configure script: " . (@stryBuilt ? join(', ', @stryBuilt) : 'no changes'));
|
|
|
|
}
|
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
# Auto-generate C files
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2020-03-12 00:33:11 +02:00
|
|
|
if (!$bSmart || grep(/^build\//, @stryModifiedList) || grep(/^doc\/xml\/reference\.xml/, @stryModifiedList))
|
2018-05-22 18:53:08 +02:00
|
|
|
{
|
|
|
|
errorDefineLoad(${$oStorageBackRest->get("build/error.yaml")});
|
2018-03-28 04:48:22 +02:00
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
my $rhBuild =
|
|
|
|
{
|
|
|
|
'config' =>
|
|
|
|
{
|
|
|
|
&BLD_DATA => buildConfig(),
|
|
|
|
&BLD_PATH => 'config',
|
|
|
|
},
|
2018-03-28 04:48:22 +02:00
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
'configDefine' =>
|
|
|
|
{
|
|
|
|
&BLD_DATA => buildConfigDefine(),
|
|
|
|
&BLD_PATH => 'config',
|
|
|
|
},
|
|
|
|
|
|
|
|
'configParse' =>
|
|
|
|
{
|
|
|
|
&BLD_DATA => buildConfigParse(),
|
|
|
|
&BLD_PATH => 'config',
|
|
|
|
},
|
|
|
|
|
|
|
|
'error' =>
|
|
|
|
{
|
|
|
|
&BLD_DATA => buildError(),
|
|
|
|
&BLD_PATH => 'common',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2018-11-04 01:52:46 +02:00
|
|
|
my @stryBuilt = buildAll("${strBackRestBase}/src", $rhBuild);
|
|
|
|
&log(INFO, " autogenerated C code: " . (@stryBuilt ? join(', ', @stryBuilt) : 'no changes'));
|
|
|
|
|
|
|
|
if (@stryBuilt)
|
|
|
|
{
|
|
|
|
push(@stryBuiltAll, @stryBuilt);
|
|
|
|
push(@stryModifiedList, @stryBuilt);
|
|
|
|
}
|
2018-05-22 18:53:08 +02:00
|
|
|
}
|
2017-11-29 04:44:05 +02:00
|
|
|
|
2018-05-23 20:57:08 +02:00
|
|
|
# Auto-generate C Makefile
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2020-03-09 23:41:59 +02:00
|
|
|
if (!$bSmart || grep(/^src\//, @stryModifiedList))
|
2018-05-23 20:57:08 +02:00
|
|
|
{
|
2018-11-04 01:52:46 +02:00
|
|
|
my @stryBuilt;
|
2019-04-26 14:08:23 +02:00
|
|
|
my $strBuilt = 'src/Makefile.in';
|
2018-05-23 20:57:08 +02:00
|
|
|
|
2018-11-04 01:52:46 +02:00
|
|
|
if (buildPutDiffers(
|
|
|
|
$oStorageBackRest,
|
|
|
|
$strBuilt,
|
2018-05-23 20:57:08 +02:00
|
|
|
buildMakefile(
|
|
|
|
$oStorageBackRest,
|
2019-04-26 14:08:23 +02:00
|
|
|
${$oStorageBackRest->get("src/Makefile.in")},
|
2020-03-05 21:23:01 +02:00
|
|
|
{rhOption => {'postgres/interface/page.o' => '@COPTIMIZE_PAGE_CHECKSUM@'}})))
|
2018-11-04 01:52:46 +02:00
|
|
|
{
|
|
|
|
push(@stryBuilt, $strBuilt);
|
|
|
|
push(@stryBuiltAll, @stryBuilt);
|
|
|
|
push(@stryModifiedList, @stryBuilt);
|
|
|
|
}
|
|
|
|
|
|
|
|
&log(INFO, " autogenerated C Makefile: " . (@stryBuilt ? join(', ', @stryBuilt) : 'no changes'));
|
|
|
|
}
|
|
|
|
|
2020-03-12 00:34:59 +02:00
|
|
|
# Copy the files that were auto-generated to the repo cache so they will be included in the current build
|
2018-11-04 01:52:46 +02:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
foreach my $strBuilt (@stryBuiltAll)
|
|
|
|
{
|
|
|
|
executeTest("cp -p ${strBackRestBase}/${strBuilt} ${strRepoCachePath}/${strBuilt}");
|
2018-05-23 20:57:08 +02:00
|
|
|
}
|
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
if ($bGenOnly)
|
|
|
|
{
|
|
|
|
exit 0;
|
|
|
|
}
|
2017-11-29 04:44:05 +02:00
|
|
|
}
|
|
|
|
|
2018-04-09 22:46:36 +02:00
|
|
|
# Check Perl version against release notes and update version in C code if needed
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $bVersionDev = true;
|
|
|
|
my $strVersionBase;
|
2016-05-24 02:04:36 +02:00
|
|
|
|
2018-04-09 22:46:36 +02:00
|
|
|
if (!$bDev)
|
2016-05-24 02:04:36 +02:00
|
|
|
{
|
2018-04-09 22:46:36 +02:00
|
|
|
# Make sure version number matches the latest release
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
|
|
|
&log(INFO, "check version info");
|
|
|
|
|
|
|
|
# Load the doc modules dynamically since they are not supported on all systems
|
2020-03-10 21:41:56 +02:00
|
|
|
require pgBackRestDoc::Common::Doc;
|
|
|
|
pgBackRestDoc::Common::Doc->import();
|
|
|
|
require pgBackRestDoc::Custom::DocCustomRelease;
|
|
|
|
pgBackRestDoc::Custom::DocCustomRelease->import();
|
2018-04-09 22:46:36 +02:00
|
|
|
|
|
|
|
my $strReleaseFile = dirname(dirname(abs_path($0))) . '/doc/xml/release.xml';
|
|
|
|
my $oRelease =
|
2020-03-10 21:41:56 +02:00
|
|
|
(new pgBackRestDoc::Custom::DocCustomRelease(new pgBackRestDoc::Common::Doc($strReleaseFile)))->releaseLast();
|
2018-04-09 22:46:36 +02:00
|
|
|
my $strVersion = $oRelease->paramGet('version');
|
|
|
|
$bVersionDev = false;
|
|
|
|
$strVersionBase = $strVersion;
|
|
|
|
|
|
|
|
if ($strVersion =~ /dev$/)
|
|
|
|
{
|
|
|
|
$bVersionDev = true;
|
|
|
|
$strVersionBase = substr($strVersion, 0, length($strVersion) - 3);
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2018-11-25 02:05:03 +02:00
|
|
|
if (PROJECT_VERSION !~ /dev$/ && $oRelease->nodeTest('release-core-list'))
|
2018-04-09 22:46:36 +02:00
|
|
|
{
|
|
|
|
confess "dev release ${strVersion} must match the program version when core changes have been made";
|
|
|
|
}
|
|
|
|
}
|
2018-11-25 02:05:03 +02:00
|
|
|
elsif ($strVersion ne PROJECT_VERSION)
|
2016-05-26 16:34:10 +02:00
|
|
|
{
|
2018-11-25 02:05:03 +02:00
|
|
|
confess 'unable to find version ' . PROJECT_VERSION . " as the most recent release in ${strReleaseFile}";
|
2016-05-26 16:34:10 +02:00
|
|
|
}
|
2017-11-29 04:44:05 +02:00
|
|
|
}
|
|
|
|
|
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 = [];
|
2018-03-20 05:33:28 +02:00
|
|
|
my $strCodePath = "${strBackRestBase}/test/.vagrant/code";
|
2017-02-18 05:31:16 +02:00
|
|
|
|
|
|
|
if (!$bDryRun || $bVmOut)
|
|
|
|
{
|
2019-10-08 18:06:30 +02:00
|
|
|
&log(INFO, "cleanup old data" . ($strVm ne VM_NONE ? " and containers" : ''));
|
|
|
|
|
|
|
|
if ($strVm ne VM_NONE)
|
|
|
|
{
|
|
|
|
containerRemove('test-([0-9]+|build)');
|
|
|
|
}
|
2017-02-18 05:31:16 +02:00
|
|
|
|
|
|
|
for (my $iVmIdx = 0; $iVmIdx < 8; $iVmIdx++)
|
|
|
|
{
|
|
|
|
push(@{$oyProcess}, undef);
|
|
|
|
}
|
|
|
|
|
2019-10-12 15:45:18 +02:00
|
|
|
executeTest("rm -rf ${strTestPath}/test-* ${strTestPath}/data-*" . ($bDev ? '' : " ${strTestPath}/gcov-*"));
|
2019-10-08 18:06:30 +02:00
|
|
|
$oStorageTest->pathCreate($strTestPath, {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
2018-03-20 05:33:28 +02:00
|
|
|
|
|
|
|
# Remove old coverage dirs -- do it this way so the dirs stay open in finder/explorer, etc.
|
2019-07-05 22:55:17 +02:00
|
|
|
executeTest("rm -rf ${strBackRestBase}/test/coverage/c/*");
|
2018-03-20 05:33:28 +02:00
|
|
|
|
2018-11-12 00:32:42 +02:00
|
|
|
# Overwrite the C coverage report so it will load but not show old coverage
|
|
|
|
$oStorageTest->pathCreate("${strBackRestBase}/test/coverage", {strMode => '0770', bIgnoreExists => true});
|
|
|
|
$oStorageBackRest->put(
|
|
|
|
"${strBackRestBase}/test/coverage/c-coverage.html", "<center>[ Generating New Report ]</center>");
|
|
|
|
|
2018-03-20 05:33:28 +02:00
|
|
|
# Copy C code for coverage tests
|
2018-09-15 19:27:06 +02:00
|
|
|
if (vmCoverageC($strVm) && !$bDryRun)
|
2018-03-20 05:33:28 +02:00
|
|
|
{
|
|
|
|
$oStorageTest->pathCreate("${strCodePath}/test", {strMode => '0770', bIgnoreExists => true, bCreateParent => true});
|
|
|
|
|
2018-11-02 17:56:13 +02:00
|
|
|
executeTest(
|
|
|
|
"rsync -rt --delete --exclude=test ${strBackRestBase}/src/ ${strCodePath} && " .
|
|
|
|
"rsync -rt --delete ${strBackRestBase}/test/src/module/ ${strCodePath}/test");
|
2018-03-20 05:33:28 +02:00
|
|
|
}
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
|
|
|
|
2017-11-28 04:19:59 +02:00
|
|
|
# Determine which tests to run
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
my $oyTestRun;
|
2018-05-22 18:53:08 +02:00
|
|
|
my $bBinRequired = $bBuildOnly;
|
2020-03-09 23:41:59 +02:00
|
|
|
my $bHostBinRequired = $bBuildOnly;
|
2017-11-28 04:19:59 +02:00
|
|
|
|
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(
|
2019-10-08 18:06:30 +02:00
|
|
|
$strVm, \@stryModule, \@stryModuleTest, \@iyModuleTestRun, $strPgVersion, $bCoverageOnly, $bCOnly, $bContainerOnly);
|
2017-11-28 04:19:59 +02:00
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
# Determine if the C binary and test library need to be built
|
2017-11-28 04:19:59 +02:00
|
|
|
foreach my $hTest (@{$oyTestRun})
|
|
|
|
{
|
2018-05-22 18:53:08 +02:00
|
|
|
# Bin build required for all Perl tests or if a C unit test calls Perl
|
2019-12-14 00:55:41 +02:00
|
|
|
if (!$hTest->{&TEST_C} || $hTest->{&TEST_BIN_REQ})
|
2017-11-28 04:19:59 +02:00
|
|
|
{
|
2018-05-22 18:53:08 +02:00
|
|
|
$bBinRequired = true;
|
|
|
|
}
|
|
|
|
|
2020-03-09 23:41:59 +02:00
|
|
|
# Host bin required if a Perl test
|
2018-05-22 18:53:08 +02:00
|
|
|
if (!$hTest->{&TEST_C})
|
|
|
|
{
|
2020-03-09 23:41:59 +02:00
|
|
|
$bHostBinRequired = true;
|
2017-11-28 04:19:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
my $strBuildRequired;
|
|
|
|
|
2020-03-09 23:41:59 +02:00
|
|
|
if ($bBinRequired || $bHostBinRequired)
|
2018-05-22 18:53:08 +02:00
|
|
|
{
|
|
|
|
if ($bBinRequired)
|
|
|
|
{
|
|
|
|
$strBuildRequired = "bin";
|
|
|
|
}
|
|
|
|
|
2020-03-09 23:41:59 +02:00
|
|
|
if ($bHostBinRequired)
|
2018-05-22 18:53:08 +02:00
|
|
|
{
|
2020-03-09 23:41:59 +02:00
|
|
|
$strBuildRequired .= ", bin host";
|
2018-05-22 18:53:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strBuildRequired = "none";
|
|
|
|
}
|
|
|
|
|
|
|
|
&log(INFO, "builds required: ${strBuildRequired}");
|
|
|
|
|
2017-11-27 01:43:51 +02:00
|
|
|
# Build the binary, library and packages
|
2017-08-19 14:48:13 +02:00
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
2018-05-22 18:53:08 +02:00
|
|
|
if (!$bDryRun)
|
2016-12-13 01:54:07 +02:00
|
|
|
{
|
2017-11-27 01:43:51 +02:00
|
|
|
my $oVm = vmGet();
|
2018-05-22 18:53:08 +02:00
|
|
|
my $lTimestampLast;
|
2020-03-09 23:41:59 +02:00
|
|
|
my @stryBinSrcPath = ('src');
|
2018-05-24 20:01:24 +02:00
|
|
|
my $strBinPath = "${strVagrantPath}/bin";
|
|
|
|
my $rhBinBuild = {};
|
2017-11-27 01:43:51 +02:00
|
|
|
|
2018-05-24 20:01:24 +02:00
|
|
|
# Build the binary
|
2018-05-22 18:53:08 +02:00
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2018-05-24 20:01:24 +02:00
|
|
|
if ($bBinRequired)
|
2018-05-22 18:53:08 +02:00
|
|
|
{
|
2018-05-24 20:01:24 +02:00
|
|
|
# Find the lastest modified time for dirs that affect the bin build
|
|
|
|
$lTimestampLast = buildLastModTime($oStorageBackRest, $strBackRestBase, \@stryBinSrcPath);
|
2017-11-27 01:43:51 +02:00
|
|
|
|
2018-05-24 20:01:24 +02:00
|
|
|
# Loop through VMs to do the C bin builds
|
|
|
|
my $bLogDetail = $strLogLevel eq 'detail';
|
|
|
|
my @stryBuildVm = $strVm eq VM_ALL ? VM_LIST : ($strVm);
|
2017-11-27 01:43:51 +02:00
|
|
|
|
2020-03-09 23:41:59 +02:00
|
|
|
# Build binary for the host
|
|
|
|
if ($bHostBinRequired)
|
|
|
|
{
|
|
|
|
push(@stryBuildVm, VM_NONE);
|
|
|
|
}
|
|
|
|
|
2018-05-24 20:01:24 +02:00
|
|
|
foreach my $strBuildVM (@stryBuildVm)
|
2017-11-27 01:43:51 +02:00
|
|
|
{
|
2018-05-24 20:01:24 +02:00
|
|
|
my $strBuildPath = "${strBinPath}/${strBuildVM}/src";
|
|
|
|
my $bRebuild = !$bSmart;
|
|
|
|
$rhBinBuild->{$strBuildVM} = true;
|
|
|
|
|
2019-04-26 14:08:23 +02:00
|
|
|
# Build configure/compile options and see if they have changed from the previous build
|
|
|
|
my $strCFlags =
|
2020-03-09 23:41:59 +02:00
|
|
|
"-Wfatal-errors -g" .
|
2019-07-06 00:34:15 +02:00
|
|
|
(vmWithBackTrace($strBuildVM) && $bBackTrace ? ' -DWITH_BACKTRACE' : '') .
|
2019-04-26 14:08:23 +02:00
|
|
|
($bDebugTestTrace ? ' -DDEBUG_TEST_TRACE' : '');
|
2019-07-06 00:34:15 +02:00
|
|
|
my $strLdFlags = vmWithBackTrace($strBuildVM) && $bBackTrace ? '-lbacktrace' : '';
|
2019-04-26 14:08:23 +02:00
|
|
|
my $strConfigOptions = (vmDebugIntegration($strBuildVM) ? ' --enable-test' : '');
|
2019-06-01 00:37:31 +02:00
|
|
|
my $strBuildFlags = "CFLAGS=${strCFlags}\nLDFLAGS=${strLdFlags}\nCONFIGURE=${strConfigOptions}";
|
|
|
|
my $strBuildFlagFile = "${strBinPath}/${strBuildVM}/build.flags";
|
2019-04-26 14:08:23 +02:00
|
|
|
|
2019-06-01 00:37:31 +02:00
|
|
|
my $bBuildOptionsDiffer = buildPutDiffers($oStorageBackRest, $strBuildFlagFile, $strBuildFlags);
|
2019-04-26 14:08:23 +02:00
|
|
|
$bBuildOptionsDiffer |= grep(/^src\/configure|src\/Makefile.in|src\/build\.auto\.h$/, @stryModifiedList);
|
|
|
|
|
2018-05-24 20:01:24 +02:00
|
|
|
# Rebuild if the modification time of the smart file does equal the last changes in source paths
|
2019-04-26 14:08:23 +02:00
|
|
|
my $strBinSmart = "${strBuildPath}/pgbackrest";
|
2018-05-24 20:01:24 +02:00
|
|
|
|
2019-04-26 14:08:23 +02:00
|
|
|
if ($bBuildOptionsDiffer ||
|
|
|
|
($bSmart &&
|
|
|
|
(!$oStorageBackRest->exists($strBinSmart) ||
|
|
|
|
$oStorageBackRest->info($strBinSmart)->mtime < $lTimestampLast)))
|
|
|
|
{
|
|
|
|
&log(INFO, " bin dependencies have changed for ${strBuildVM}, rebuilding...");
|
2017-11-27 01:43:51 +02:00
|
|
|
|
2019-04-26 14:08:23 +02:00
|
|
|
$bRebuild = true;
|
2018-05-22 18:53:08 +02:00
|
|
|
}
|
2017-11-27 01:43:51 +02:00
|
|
|
|
2018-05-24 20:01:24 +02:00
|
|
|
if ($bRebuild)
|
|
|
|
{
|
|
|
|
&log(INFO, " build bin for ${strBuildVM} (${strBuildPath})");
|
|
|
|
|
2019-10-08 18:06:30 +02:00
|
|
|
if ($strBuildVM ne VM_NONE)
|
|
|
|
{
|
|
|
|
executeTest(
|
|
|
|
"docker run -itd -h test-build --name=test-build" .
|
2020-03-12 14:48:45 +02:00
|
|
|
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-test",
|
2019-10-08 18:06:30 +02:00
|
|
|
{bSuppressStdErr => true});
|
|
|
|
}
|
2018-05-24 20:01:24 +02:00
|
|
|
|
|
|
|
foreach my $strBinSrcPath (@stryBinSrcPath)
|
|
|
|
{
|
|
|
|
$oStorageBackRest->pathCreate(
|
|
|
|
"${strBinPath}/${strBuildVM}/${strBinSrcPath}", {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
}
|
|
|
|
|
|
|
|
executeTest(
|
2019-04-26 14:08:23 +02:00
|
|
|
"rsync -rt" . (!$bSmart || $bBuildOptionsDiffer ? " --delete-excluded" : '') .
|
2018-05-24 20:01:24 +02:00
|
|
|
" --include=" . join('/*** --include=', @stryBinSrcPath) . '/*** --exclude=*' .
|
|
|
|
" ${strBackRestBase}/ ${strBinPath}/${strBuildVM}");
|
2019-06-01 00:37:31 +02:00
|
|
|
buildPutDiffers($oStorageBackRest, $strBuildFlagFile, $strBuildFlags);
|
2018-05-24 20:01:24 +02:00
|
|
|
|
2019-04-26 14:08:23 +02:00
|
|
|
if ($bBuildOptionsDiffer || !$oStorageBackRest->exists("${strBuildPath}/Makefile"))
|
|
|
|
{
|
|
|
|
executeTest(
|
2019-10-08 18:06:30 +02:00
|
|
|
($strBuildVM ne VM_NONE ? 'docker exec -i test-build ' : '') .
|
|
|
|
"bash -c 'cd ${strBuildPath} && ./configure${strConfigOptions}'",
|
2019-04-26 14:08:23 +02:00
|
|
|
{bShowOutputAsync => $bLogDetail});
|
|
|
|
}
|
2018-05-24 20:01:24 +02:00
|
|
|
|
|
|
|
executeTest(
|
2019-10-08 18:06:30 +02:00
|
|
|
($strBuildVM ne VM_NONE ? 'docker exec -i test-build ' : '') .
|
|
|
|
"make -j ${iBuildMax}" . ($bLogDetail ? '' : ' --silent') .
|
2019-04-26 14:08:23 +02:00
|
|
|
" --directory ${strBuildPath} CFLAGS='${strCFlags}' LDFLAGS='${strLdFlags}'",
|
2018-05-24 20:01:24 +02:00
|
|
|
{bShowOutputAsync => $bLogDetail});
|
|
|
|
|
2019-10-08 18:06:30 +02:00
|
|
|
if ($strBuildVM ne VM_NONE)
|
|
|
|
{
|
|
|
|
executeTest("docker rm -f test-build");
|
|
|
|
}
|
2018-05-24 20:01:24 +02:00
|
|
|
}
|
2018-05-22 18:53:08 +02:00
|
|
|
}
|
2018-05-24 20:01:24 +02:00
|
|
|
}
|
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
# Build the package
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2019-10-08 18:06:30 +02:00
|
|
|
if (!$bNoPackage && $strVm ne VM_NONE)
|
2018-05-22 18:53:08 +02:00
|
|
|
{
|
|
|
|
my $strPackagePath = "${strVagrantPath}/package";
|
|
|
|
my $strPackageSmart = "${strPackagePath}/build.timestamp";
|
2020-03-10 23:57:02 +02:00
|
|
|
my @stryPackageSrcPath = ('src');
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
# Find the lastest modified time for additional dirs that affect the package build
|
|
|
|
foreach my $strPackageSrcPath (@stryPackageSrcPath)
|
|
|
|
{
|
|
|
|
my $hManifest = $oStorageBackRest->manifest($strPackageSrcPath);
|
2017-02-18 05:31:16 +02:00
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
foreach my $strFile (sort(keys(%{$hManifest})))
|
|
|
|
{
|
|
|
|
if ($hManifest->{$strFile}{type} eq 'f' && $hManifest->{$strFile}{modification_time} > $lTimestampLast)
|
2017-02-18 05:31:16 +02:00
|
|
|
{
|
2018-05-22 18:53:08 +02:00
|
|
|
$lTimestampLast = $hManifest->{$strFile}{modification_time};
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
|
|
|
}
|
2017-01-10 20:12:53 +02:00
|
|
|
}
|
2017-08-19 14:48:13 +02:00
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
# Rebuild if the modification time of the smart file does not equal the last changes in source paths
|
|
|
|
if ((!$bSmart || !$oStorageBackRest->exists($strPackageSmart) ||
|
|
|
|
$oStorageBackRest->info($strPackageSmart)->mtime < $lTimestampLast))
|
2017-08-19 14:48:13 +02:00
|
|
|
{
|
2018-05-22 18:53:08 +02:00
|
|
|
if ($bSmart)
|
2017-08-19 14:48:13 +02:00
|
|
|
{
|
2018-05-22 18:53:08 +02:00
|
|
|
&log(INFO, 'package dependencies have changed, rebuilding...');
|
2017-08-19 14:48:13 +02:00
|
|
|
}
|
|
|
|
|
2019-10-12 15:45:18 +02:00
|
|
|
executeTest("rm -rf ${strPackagePath}");
|
2017-08-19 14:48:13 +02:00
|
|
|
}
|
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
# Loop through VMs to do the package builds
|
2017-02-18 05:31:16 +02:00
|
|
|
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
|
|
|
|
2018-05-22 18:53:08 +02:00
|
|
|
foreach my $strBuildVM (@stryBuildVm)
|
2017-02-18 05:31:16 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2019-10-12 15:45:18 +02:00
|
|
|
if ($strVm ne VM_NONE)
|
|
|
|
{
|
|
|
|
executeTest(
|
|
|
|
"docker run -itd -h test-build --name=test-build" .
|
2020-03-12 14:48:45 +02:00
|
|
|
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-test",
|
2019-10-12 15:45:18 +02:00
|
|
|
{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});
|
|
|
|
|
2020-03-12 14:48:45 +02:00
|
|
|
# Clone a copy of the debian package repo
|
|
|
|
executeTest(
|
|
|
|
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
|
|
|
|
"bash -c 'git clone https://salsa.debian.org/postgresql/pgbackrest.git /root/package-src 2>&1'");
|
|
|
|
|
2017-02-18 05:31:16 +02:00
|
|
|
executeTest("rsync -r --exclude .vagrant --exclude .git ${strBackRestBase}/ ${strBuildPath}/");
|
|
|
|
executeTest(
|
2019-10-12 15:45:18 +02:00
|
|
|
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
|
2019-10-15 13:27:03 +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):
|
2018-06-06 21:52:28 +02:00
|
|
|
# BRDIR=/backrest;BRVM=u18;BRPATCHFILE=${BRDIR?}/test/patch/debian-package.patch
|
2017-11-27 01:43:51 +02:00
|
|
|
# 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(
|
2019-10-12 15:45:18 +02:00
|
|
|
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
|
2017-02-18 05:31:16 +02:00
|
|
|
"bash -c 'cd ${strBuildPath} && debuild -i -us -uc -b'");
|
|
|
|
|
|
|
|
executeTest(
|
2019-10-12 15:45:18 +02:00
|
|
|
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
|
2017-02-18 05:31:16 +02:00
|
|
|
"bash -c 'rm -f ${strPackagePath}/${strBuildVM}/*.build ${strPackagePath}/${strBuildVM}/*.changes" .
|
|
|
|
" ${strPackagePath}/${strBuildVM}/pgbackrest-doc*'");
|
|
|
|
|
2019-10-12 15:45:18 +02:00
|
|
|
if ($strVm ne VM_NONE)
|
|
|
|
{
|
|
|
|
executeTest("docker rm -f test-build");
|
|
|
|
}
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
2018-02-27 02:32:27 +02:00
|
|
|
|
|
|
|
if (!$oStorageBackRest->pathExists($strBuildPath) && $oVm->{$strBuildVM}{&VM_OS_BASE} eq VM_OS_BASE_RHEL)
|
|
|
|
{
|
|
|
|
&log(INFO, "build package for ${strBuildVM} (${strBuildPath})");
|
|
|
|
|
|
|
|
# Create build container
|
2019-10-12 15:45:18 +02:00
|
|
|
if ($strVm ne VM_NONE)
|
|
|
|
{
|
|
|
|
executeTest(
|
|
|
|
"docker run -itd -h test-build --name=test-build" .
|
2020-03-12 14:48:45 +02:00
|
|
|
" -v ${strBackRestBase}:${strBackRestBase} " . containerRepo() . ":${strBuildVM}-test",
|
2019-10-12 15:45:18 +02:00
|
|
|
{bSuppressStdErr => true});
|
|
|
|
}
|
2018-02-27 02:32:27 +02:00
|
|
|
|
2020-03-12 14:48:45 +02:00
|
|
|
# Fetching specific files is fragile but even a shallow clone of the entire pgrpms repo is very expensive.
|
|
|
|
# Using 'git archive' does not seem to work: access denied or repository not exported: /git/pgrpms.git.
|
|
|
|
executeTest(
|
|
|
|
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
|
|
|
|
"bash -c \"" .
|
|
|
|
"mkdir /root/package-src && " .
|
|
|
|
"wget -q -O /root/package-src/pgbackrest-conf.patch " .
|
|
|
|
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
|
|
|
|
"f=rpm/redhat/master/pgbackrest/master/pgbackrest-conf.patch;hb=refs/heads/master' && " .
|
|
|
|
"wget -q -O /root/package-src/pgbackrest-libxmlinclude.patch " .
|
|
|
|
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
|
|
|
|
"f=rpm/redhat/master/pgbackrest/master/pgbackrest-libxmlinclude.patch;hb=refs/heads/master' && " .
|
|
|
|
"wget -q -O /root/package-src/pgbackrest.spec " .
|
|
|
|
"'https://git.postgresql.org/gitweb/?p=pgrpms.git;a=blob_plain;" .
|
|
|
|
"f=rpm/redhat/master/pgbackrest/master/pgbackrest.spec;hb=refs/heads/master'\"");
|
|
|
|
|
2018-02-27 02:32:27 +02:00
|
|
|
# Create build directories
|
|
|
|
$oStorageBackRest->pathCreate($strBuildPath, {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
$oStorageBackRest->pathCreate("${strBuildPath}/SOURCES", {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
$oStorageBackRest->pathCreate("${strBuildPath}/SPECS", {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
$oStorageBackRest->pathCreate("${strBuildPath}/RPMS", {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
$oStorageBackRest->pathCreate("${strBuildPath}/BUILD", {bIgnoreExists => true, bCreateParent => true});
|
|
|
|
|
2019-08-09 20:52:26 +02:00
|
|
|
# Install PostreSQL 11 development for package builds
|
2019-10-12 15:45:18 +02:00
|
|
|
executeTest(
|
|
|
|
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
|
|
|
|
"bash -c 'yum install -y postgresql11-devel 2>&1'");
|
2019-08-09 20:52:26 +02:00
|
|
|
|
2018-02-27 02:32:27 +02:00
|
|
|
# Copy source files
|
|
|
|
executeTest(
|
|
|
|
"tar --transform='s_^_pgbackrest-release-${strVersionBase}/_'" .
|
|
|
|
" -czf ${strBuildPath}/SOURCES/${strVersionBase}.tar.gz -C ${strBackRestBase}" .
|
2020-03-09 23:41:59 +02:00
|
|
|
" src LICENSE");
|
2018-02-27 02:32:27 +02:00
|
|
|
|
|
|
|
# Copy package files
|
|
|
|
executeTest(
|
2019-10-12 15:45:18 +02:00
|
|
|
($strVm ne VM_NONE ? "docker exec -i test-build " : '') . "bash -c '" .
|
2018-02-27 02:32:27 +02:00
|
|
|
"ln -s ${strBuildPath} /root/rpmbuild && " .
|
|
|
|
"cp /root/package-src/pgbackrest.spec ${strBuildPath}/SPECS && " .
|
|
|
|
"cp /root/package-src/*.patch ${strBuildPath}/SOURCES && " .
|
|
|
|
"sudo chown -R " . TEST_USER . " ${strBuildPath}'");
|
|
|
|
|
|
|
|
# Patch files in RHEL package builds
|
|
|
|
#
|
|
|
|
# Use these commands to create a new patch (may need to modify first line):
|
|
|
|
# BRDIR=/backrest;BRVM=co7;BRPATCHFILE=${BRDIR?}/test/patch/rhel-package.patch
|
|
|
|
# PKDIR=${BRDIR?}/test/.vagrant/package/${BRVM}/src/SPECS
|
|
|
|
# diff -Naur ${PKDIR?}.old ${PKDIR}.new > ${BRPATCHFILE?}
|
|
|
|
my $strPackagePatch = "${strBackRestBase}/test/patch/rhel-package.patch";
|
|
|
|
|
|
|
|
if ($oStorageBackRest->exists($strPackagePatch))
|
|
|
|
{
|
|
|
|
executeTest("cp -r ${strBuildPath}/SPECS ${strBuildPath}/SPECS.old");
|
|
|
|
executeTest("patch -d ${strBuildPath}/SPECS < ${strPackagePatch}");
|
|
|
|
executeTest("cp -r ${strBuildPath}/SPECS ${strBuildPath}/SPECS.new");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Update version number to match current version
|
|
|
|
my $strSpec = ${$oStorageBackRest->get("${strBuildPath}/SPECS/pgbackrest.spec")};
|
|
|
|
$strSpec =~ s/^Version\:.*$/Version\:\t${strVersionBase}/gm;
|
|
|
|
$oStorageBackRest->put("${strBuildPath}/SPECS/pgbackrest.spec", $strSpec);
|
|
|
|
|
|
|
|
# Build package
|
|
|
|
executeTest(
|
2019-10-12 15:45:18 +02:00
|
|
|
($strVm ne VM_NONE ? "docker exec -i test-build " : '') .
|
|
|
|
"rpmbuild --define 'pgmajorversion %{nil}' -v -bb --clean root/rpmbuild/SPECS/pgbackrest.spec",
|
2018-02-27 02:32:27 +02:00
|
|
|
{bSuppressStdErr => true});
|
|
|
|
|
|
|
|
# Remove build container
|
2019-10-12 15:45:18 +02:00
|
|
|
if ($strVm ne VM_NONE)
|
|
|
|
{
|
|
|
|
executeTest("docker rm -f test-build");
|
|
|
|
}
|
2018-02-27 02:32:27 +02:00
|
|
|
}
|
2017-02-18 05:31:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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;
|
|
|
|
}
|
|
|
|
|
2018-11-04 01:52:46 +02:00
|
|
|
# Remove repo.manifest now that all processing that depends on modified files has been completed
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
$oStorageTest->remove("${strRepoCachePath}/${strRepoCacheManifest}");
|
|
|
|
|
2017-08-19 14:48:13 +02:00
|
|
|
# Perform static source code analysis
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
if (!$bDryRun)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-12-17 22:23:07 +02:00
|
|
|
# Disable file logging for integration tests when there is more than one test since it will be overwritten
|
|
|
|
if (@{$oyTestRun} > 1)
|
|
|
|
{
|
|
|
|
$strLogLevelTestFile = lc(OFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Don't allow --no-cleanup when more than one test will run. How would the prior results be preserved?
|
|
|
|
|
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};
|
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(
|
2019-10-12 15:45:18 +02:00
|
|
|
$oStorageTest, $strBackRestBase, $strTestPath, $$oyTestRun[$iTestIdx], $bDryRun, $strVmHost, $bVmOut,
|
2019-12-17 22:23:07 +02:00
|
|
|
$iVmIdx, $iVmMax, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $strLogLevelTestFile, $bLogForce,
|
|
|
|
$bShowOutputAsync, $bNoCleanup, $iRetry, !$bNoValgrind, !$bNoCoverage, $bCoverageSummary, !$bNoOptimize,
|
|
|
|
$bBackTrace, $bProfile, $iScale, $strTimeZone, !$bNoDebug, $bDebugTestTrace,
|
2019-12-12 05:11:04 +02:00
|
|
|
$iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax));
|
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;
|
|
|
|
|
2019-07-05 22:55:17 +02:00
|
|
|
if (vmCoverageC($strVm) && !$bNoCoverage && !$bDryRun && $iTestFail == 0)
|
2017-01-10 03:49:04 +02:00
|
|
|
{
|
2017-04-10 18:31:30 +02:00
|
|
|
# Determine which modules were covered (only check coverage if all tests were successful)
|
|
|
|
#-----------------------------------------------------------------------------------------------------------------------
|
2018-09-15 19:27:06 +02:00
|
|
|
my $hModuleTest; # Everything that was run
|
2017-04-10 18:31:30 +02:00
|
|
|
|
2018-09-15 19:27:06 +02:00
|
|
|
# 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);
|
2017-04-10 18:31:30 +02:00
|
|
|
|
2018-09-15 19:27:06 +02:00
|
|
|
# Get coverage for the test
|
|
|
|
my $strTest = $hTestRun->{&TEST_NAME};
|
|
|
|
my $hTest = testDefModuleTest($strModule, $strTest);
|
2017-04-10 18:31:30 +02:00
|
|
|
|
2018-09-15 19:27:06 +02:00
|
|
|
# If no tests are listed it means all of them were run
|
|
|
|
if (@{$hTestRun->{&TEST_RUN}} == 0)
|
|
|
|
{
|
|
|
|
$hModuleTest->{$strModule}{$strTest} = true;
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
2018-09-15 19:27:06 +02:00
|
|
|
}
|
2017-04-10 18:31:30 +02:00
|
|
|
|
2018-09-15 19:27:06 +02:00
|
|
|
# Now compare against code modules that should have full coverage
|
|
|
|
my $hCoverageList = testDefCoverageList();
|
|
|
|
my $hCoverageType = testDefCoverageType();
|
|
|
|
my $hCoverageActual;
|
2017-04-10 18:31:30 +02:00
|
|
|
|
2018-09-15 19:27:06 +02:00
|
|
|
foreach my $strCodeModule (sort(keys(%{$hCoverageList})))
|
|
|
|
{
|
|
|
|
if (@{$hCoverageList->{$strCodeModule}} > 0)
|
2017-04-10 18:31:30 +02:00
|
|
|
{
|
2018-09-15 19:27:06 +02:00
|
|
|
my $iCoverageTotal = 0;
|
2017-04-10 18:31:30 +02:00
|
|
|
|
2018-09-15 19:27:06 +02:00
|
|
|
foreach my $hTest (@{$hCoverageList->{$strCodeModule}})
|
|
|
|
{
|
|
|
|
if (!defined($hModuleTest->{$hTest->{strModule}}{$hTest->{strTest}}))
|
2017-04-10 18:31:30 +02:00
|
|
|
{
|
2018-09-15 19:27:06 +02:00
|
|
|
next;
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
|
|
|
|
2018-09-15 19:27:06 +02:00
|
|
|
$iCoverageTotal++;
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
|
|
|
|
2018-09-15 19:27:06 +02:00
|
|
|
if (@{$hCoverageList->{$strCodeModule}} == $iCoverageTotal)
|
|
|
|
{
|
|
|
|
$hCoverageActual->{testRunName($strCodeModule, false)} = $hCoverageType->{$strCodeModule};
|
|
|
|
}
|
2017-04-10 18:31:30 +02:00
|
|
|
}
|
2018-09-15 19:27:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (keys(%{$hCoverageActual}) == 0)
|
|
|
|
{
|
|
|
|
&log(INFO, 'no code modules had all tests run required for coverage');
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate C coverage report
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
if (vmCoverageC($strVm))
|
|
|
|
{
|
|
|
|
&log(INFO, 'writing C coverage report');
|
2017-10-12 18:55:48 +02:00
|
|
|
|
2018-03-20 05:33:28 +02:00
|
|
|
my $strLCovFile = "${strBackRestBase}/test/.vagrant/code/all.lcov";
|
|
|
|
|
|
|
|
if ($oStorageBackRest->exists($strLCovFile))
|
|
|
|
{
|
|
|
|
executeTest(
|
2019-05-15 19:04:56 +02:00
|
|
|
"genhtml ${strLCovFile} --config-file=${strBackRestBase}/test/.vagrant/code/lcov.conf" .
|
2018-03-20 22:01:38 +02:00
|
|
|
" --prefix=${strBackRestBase}/test/.vagrant/code" .
|
2018-03-20 15:47:51 +02:00
|
|
|
" --output-directory=${strBackRestBase}/test/coverage/c");
|
2018-03-20 05:33:28 +02:00
|
|
|
|
|
|
|
foreach my $strCodeModule (sort(keys(%{$hCoverageActual})))
|
|
|
|
{
|
|
|
|
# If the first char of the module is upper case then it's a Perl module
|
|
|
|
if (substr($strCodeModule, 0, 1) eq uc(substr($strCodeModule, 0, 1)))
|
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $strCoverageFile = $strCodeModule;
|
|
|
|
$strCoverageFile =~ s/^module/test/mg;
|
|
|
|
$strCoverageFile = "${strBackRestBase}/test/.vagrant/code/${strCoverageFile}.lcov";
|
|
|
|
|
|
|
|
my $strCoverage = $oStorageBackRest->get(
|
|
|
|
$oStorageBackRest->openRead($strCoverageFile, {bIgnoreMissing => true}));
|
|
|
|
|
|
|
|
if (defined($strCoverage) && defined($$strCoverage))
|
|
|
|
{
|
2018-05-05 17:50:11 +02:00
|
|
|
my $iTotalLines = (split(':', ($$strCoverage =~ m/^LF\:.*$/mg)[0]))[1] + 0;
|
|
|
|
my $iCoveredLines = (split(':', ($$strCoverage =~ m/^LH\:.*$/mg)[0]))[1] + 0;
|
|
|
|
|
|
|
|
my $iTotalBranches = 0;
|
|
|
|
my $iCoveredBranches = 0;
|
|
|
|
|
|
|
|
if ($$strCoverage =~ /^BRF\:/mg && $$strCoverage =~ /^BRH\:/mg)
|
|
|
|
{
|
|
|
|
# If this isn't here the statements below fail -- huh?
|
|
|
|
my @match = $$strCoverage =~ m/^BRF\:.*$/mg;
|
|
|
|
|
|
|
|
$iTotalBranches = (split(':', ($$strCoverage =~ m/^BRF\:.*$/mg)[0]))[1] + 0;
|
|
|
|
$iCoveredBranches = (split(':', ($$strCoverage =~ m/^BRH\:.*$/mg)[0]))[1] + 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Generate detail if there is missing coverage
|
|
|
|
my $strDetail = undef;
|
2018-03-20 05:33:28 +02:00
|
|
|
|
|
|
|
if ($iCoveredLines != $iTotalLines)
|
|
|
|
{
|
2018-05-05 17:50:11 +02:00
|
|
|
$strDetail .= "$iCoveredLines/$iTotalLines lines";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($iTotalBranches != $iCoveredBranches)
|
|
|
|
{
|
|
|
|
$strDetail .= (defined($strDetail) ? ', ' : '') . "$iCoveredBranches/$iTotalBranches branches";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined($strDetail))
|
|
|
|
{
|
|
|
|
&log(ERROR, "c module ${strCodeModule} is not fully covered ($strDetail)");
|
2018-03-20 05:33:28 +02:00
|
|
|
$iUncoveredCodeModuleTotal++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-12 00:32:42 +02:00
|
|
|
|
2019-05-15 19:04:56 +02:00
|
|
|
$oStorageBackRest->remove("${strBackRestBase}/test/.vagrant/code/all.lcov", {bIgnoreMissing => true});
|
|
|
|
coverageGenerate(
|
|
|
|
$oStorageBackRest, "${strBackRestBase}/test/.vagrant/code",
|
|
|
|
"${strBackRestBase}/test/coverage/c-coverage.html");
|
|
|
|
|
|
|
|
if ($bCoverageSummary)
|
|
|
|
{
|
|
|
|
&log(INFO, 'writing C coverage summary report');
|
|
|
|
|
|
|
|
coverageDocSummaryGenerate(
|
|
|
|
$oStorageBackRest, "${strBackRestBase}/test/.vagrant/code",
|
|
|
|
"${strBackRestBase}/doc/xml/auto/metric-coverage-report.auto.xml");
|
|
|
|
}
|
2018-03-20 05:33:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
executeTest("rm -rf ${strBackRestBase}/test/coverage/c");
|
2017-10-12 18:55:48 +02:00
|
|
|
}
|
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
|
|
|
|
2019-05-15 19:04:56 +02:00
|
|
|
exit 1 if ($iTestFail > 0 || ($iUncoveredCodeModuleTotal > 0 && !$bCoverageSummary));
|
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
|
|
|
|
2019-12-12 05:11:04 +02:00
|
|
|
# Set timezone
|
|
|
|
if (defined($strTimeZone))
|
|
|
|
{
|
|
|
|
$ENV{TZ} = $strTimeZone;
|
|
|
|
}
|
|
|
|
|
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
|
2018-11-25 02:05:03 +02:00
|
|
|
'/usr/bin/' . PROJECT_EXE, # Path to the backrest executable
|
2020-03-09 23:41:59 +02:00
|
|
|
"${strVagrantPath}/bin/" . VM_NONE . '/src/' . PROJECT_EXE, # Path to the backrest Perl storage 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
|
2019-12-17 22:23:07 +02:00
|
|
|
$strLogLevelTestFile, # Log options
|
2019-10-12 15:45:18 +02:00
|
|
|
TEST_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)
|
|
|
|
{
|
2019-10-12 15:45:18 +02:00
|
|
|
executeTest("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
|
2018-03-15 17:03:28 +02:00
|
|
|
if (isException(\$EVAL_ERROR))
|
|
|
|
{
|
2019-10-17 14:00:18 +02:00
|
|
|
if ($EVAL_ERROR->code() != ERROR_OPTION_INVALID_VALUE)
|
|
|
|
{
|
|
|
|
syswrite(*STDOUT, $EVAL_ERROR->message() . "\n" . $EVAL_ERROR->trace());
|
|
|
|
}
|
|
|
|
|
2018-03-15 17:03:28 +02:00
|
|
|
exit $EVAL_ERROR->code();
|
|
|
|
}
|
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;
|