You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-05-22 10:15:16 +02:00
Allow timezones to be explicitly set for testing.
The TZ environment variable was not reliably pushed down to the test processes. Instead pass TZ via a command line parameter and set explicitly in the test process.
This commit is contained in:
+1
-2
@@ -21,8 +21,7 @@ matrix:
|
||||
- env: PGB_CI="test --vm=co7 --param=module=mock --param=module=real"
|
||||
- dist: bionic
|
||||
env:
|
||||
- PGB_CI="test --vm=none"
|
||||
- TZ="America/New_York"
|
||||
- PGB_CI="test --vm=none --param=tz=America/New_York"
|
||||
services:
|
||||
- env: PGB_CI=" doc --vm=co6"
|
||||
- env: PGB_CI=" doc --vm=co7"
|
||||
|
||||
@@ -76,6 +76,7 @@ sub new
|
||||
$self->{bBackTrace},
|
||||
$self->{bProfile},
|
||||
$self->{iScale},
|
||||
$self->{strTimeZone},
|
||||
$self->{bDebug},
|
||||
$self->{bDebugTestTrace},
|
||||
$self->{iBuildMax},
|
||||
@@ -107,6 +108,7 @@ sub new
|
||||
{name => 'bBackTrace'},
|
||||
{name => 'bProfile'},
|
||||
{name => 'iScale'},
|
||||
{name => 'strTimeZone', required => false},
|
||||
{name => 'bDebug'},
|
||||
{name => 'bDebugTestTrace'},
|
||||
{name => 'iBuildMax'},
|
||||
@@ -278,6 +280,7 @@ sub run
|
||||
(defined($self->{oTest}->{&TEST_DB}) ? ' --pg-version=' . $self->{oTest}->{&TEST_DB} : '') .
|
||||
($self->{strLogLevel} ne lc(INFO) ? " --log-level=$self->{strLogLevel}" : '') .
|
||||
' --pgsql-bin=' . $self->{oTest}->{&TEST_PGSQL_BIN} .
|
||||
($self->{strTimeZone} ? " --tz='$self->{strTimeZone}'" : '') .
|
||||
($self->{bLogForce} ? ' --log-force' : '') .
|
||||
($self->{bDryRun} ? ' --dry-run' : '') .
|
||||
($self->{bDryRun} ? ' --vm-out' : '') .
|
||||
@@ -394,6 +397,16 @@ sub run
|
||||
$strTestC =~ s/\{\[C\_TEST\_REPO_PATH\]\}/$self->{strBackRestBase}/g;
|
||||
$strTestC =~ s/\{\[C\_TEST\_SCALE\]\}/$self->{iScale}/g;
|
||||
|
||||
# Set timezone
|
||||
if (defined($self->{strTimeZone}))
|
||||
{
|
||||
$strTestC =~ s/\{\[C\_TEST\_TZ\]\}/setenv\("TZ", "$self->{strTimeZone}", true\);/g;
|
||||
}
|
||||
else
|
||||
{
|
||||
$strTestC =~ s/\{\[C\_TEST\_TZ\]\}/\/\/ No timezone specified/g;
|
||||
}
|
||||
|
||||
# Set default log level
|
||||
my $strLogLevelTestC = "logLevel" . ucfirst($self->{strLogLevelTest});
|
||||
$strTestC =~ s/\{\[C\_LOG\_LEVEL\_TEST\]\}/$strLogLevelTestC/g;
|
||||
|
||||
@@ -73,6 +73,9 @@ main(int argListSize, const char *argList[])
|
||||
// Set neutral umask for testing
|
||||
umask(0000);
|
||||
|
||||
// Set timezone if specified
|
||||
{[C_TEST_TZ]}
|
||||
|
||||
// Ignore SIGPIPE and check for EPIPE errors on write() instead
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
|
||||
+11
-1
@@ -97,6 +97,7 @@ test.pl [options]
|
||||
--profile generate profile info
|
||||
--no-debug don't generate a debug build
|
||||
--scale scale performance tests
|
||||
--tz test with the specified timezone
|
||||
--debug-test-trace test stack trace for low-level functions (slow, esp w/valgrind, may cause timeouts)
|
||||
|
||||
Report Options:
|
||||
@@ -169,6 +170,7 @@ my $bNoDebug = false;
|
||||
my $iScale = 1;
|
||||
my $bDebugTestTrace = false;
|
||||
my $iRetry = 0;
|
||||
my $strTimeZone = undef;
|
||||
|
||||
my @cmdOptions = @ARGV;
|
||||
|
||||
@@ -215,6 +217,7 @@ GetOptions ('q|quiet' => \$bQuiet,
|
||||
'no-optimize' => \$bNoOptimize,
|
||||
'no-debug', => \$bNoDebug,
|
||||
'scale=s' => \$iScale,
|
||||
'tz=s', => \$strTimeZone,
|
||||
'debug-test-trace', => \$bDebugTestTrace,
|
||||
'retry=s' => \$iRetry)
|
||||
or pod2usage(2);
|
||||
@@ -1322,7 +1325,8 @@ eval
|
||||
$oStorageTest, $strBackRestBase, $strTestPath, $$oyTestRun[$iTestIdx], $bDryRun, $strVmHost, $bVmOut,
|
||||
$iVmIdx, $iVmMax, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $bLogForce, $bShowOutputAsync,
|
||||
$bNoCleanup, $iRetry, !$bNoValgrind, !$bNoCoverage, $bCoverageSummary, !$bNoOptimize, $bBackTrace,
|
||||
$bProfile, $iScale, !$bNoDebug, $bDebugTestTrace, $iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax));
|
||||
$bProfile, $iScale, $strTimeZone, !$bNoDebug, $bDebugTestTrace,
|
||||
$iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax));
|
||||
$iTestIdx++;
|
||||
|
||||
if ($oJob->run())
|
||||
@@ -1514,6 +1518,12 @@ eval
|
||||
# Create host group for containers
|
||||
my $oHostGroup = hostGroupGet();
|
||||
|
||||
# Set timezone
|
||||
if (defined($strTimeZone))
|
||||
{
|
||||
$ENV{TZ} = $strTimeZone;
|
||||
}
|
||||
|
||||
# Run the test
|
||||
testRun($stryModule[0], $stryModuleTest[0])->process(
|
||||
$strVm, $iVmId, # Vm info
|
||||
|
||||
Reference in New Issue
Block a user