1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Add --no-back-trace option to test.pl.

Running valgrind and backtrace together has been causing tests to timeout in CI, mostly likely due to limited resources. This has not been a problem in normal development environments.

Since it is still important to run backtraces for debugging, split the u22 test that was doing all this work to run coverage and backtrace together and valgrind-only as a separate test. As a bonus these tests run faster separately and since they run in parallel the total execution time is faster.
This commit is contained in:
David Steele 2023-01-28 18:55:53 +07:00
parent 16c625353d
commit a28f3d49c2
11 changed files with 80 additions and 23 deletions

View File

@ -40,8 +40,11 @@ jobs:
# All integration tests # All integration tests
- param: test --vm=u22 --param=build-package --param=module=mock --param=module=real - param: test --vm=u22 --param=build-package --param=module=mock --param=module=real
# All unit tests with coverage and alternate timezone # All unit tests with coverage, backtrace and alternate timezone
- param: test --vm=u22 --param=c-only --param=tz=America/New_York - param: test --vm=u22 --param=c-only --param=no-valgrind --param=tz=America/New_York
# All unit tests with valgrind (disable coverage and backtrace for performance)
- param: test --vm=u22 --param=c-only --param=no-coverage --param=no-back-trace
# All unit tests on the newest gcc available # All unit tests on the newest gcc available
- param: test --vm=f36 --param=c-only --param=no-valgrind --param=no-coverage --param=no-performance - param: test --vm=f36 --param=c-only --param=no-valgrind --param=no-coverage --param=no-performance

View File

@ -65,6 +65,7 @@ sub new
$self->{bShowOutputAsync}, $self->{bShowOutputAsync},
$self->{bNoCleanup}, $self->{bNoCleanup},
$self->{iRetry}, $self->{iRetry},
$self->{bBackTraceUnit},
$self->{bValgrindUnit}, $self->{bValgrindUnit},
$self->{bCoverageUnit}, $self->{bCoverageUnit},
$self->{bCoverageSummary}, $self->{bCoverageSummary},
@ -97,6 +98,7 @@ sub new
{name => 'bShowOutputAsync'}, {name => 'bShowOutputAsync'},
{name => 'bNoCleanup'}, {name => 'bNoCleanup'},
{name => 'iRetry'}, {name => 'iRetry'},
{name => 'bBackTraceUnit'},
{name => 'bValgrindUnit'}, {name => 'bValgrindUnit'},
{name => 'bCoverageUnit'}, {name => 'bCoverageUnit'},
{name => 'bCoverageSummary'}, {name => 'bCoverageSummary'},
@ -261,7 +263,7 @@ sub run
' --repo-path=' . $self->{strTestPath} . '/repo' . ' --test-path=' . $self->{strTestPath} . ' --repo-path=' . $self->{strTestPath} . '/repo' . ' --test-path=' . $self->{strTestPath} .
" --log-level=$self->{strLogLevel}" . ' --vm=' . $self->{oTest}->{&TEST_VM} . " --log-level=$self->{strLogLevel}" . ' --vm=' . $self->{oTest}->{&TEST_VM} .
' --vm-id=' . $self->{iVmIdx} . ($self->{bProfile} ? ' --profile' : '') . ' --vm-id=' . $self->{iVmIdx} . ($self->{bProfile} ? ' --profile' : '') .
($bCoverage ? '' : ' --no-coverage') . ' test ' . ($self->{bBackTraceUnit} ? '' : ' --no-back-trace') . ($bCoverage ? '' : ' --no-coverage') . ' test ' .
$self->{oTest}->{&TEST_MODULE} . '/' . $self->{oTest}->{&TEST_NAME} . " && \\\n" . $self->{oTest}->{&TEST_MODULE} . '/' . $self->{oTest}->{&TEST_NAME} . " && \\\n" .
# Allow stderr to be copied to stderr and stdout # Allow stderr to be copied to stderr and stdout
"exec 3>&1 && \\\n" . "exec 3>&1 && \\\n" .

View File

@ -32,6 +32,13 @@ optionGroup:
option: option:
# General options # General options
#--------------------------------------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------------------------------------
back-trace:
type: boolean
default: true
negate: true
command:
test: {}
buffer-size: buffer-size:
type: size type: size
internal: true internal: true

View File

@ -21,6 +21,16 @@
<option id="spool-path"><summary></summary><text><p></p></text></option> <option id="spool-path"><summary></summary><text><p></p></text></option>
<option id="stanza"><summary></summary><text><p></p></text></option> <option id="stanza"><summary></summary><text><p></p></text></option>
<option id="back-trace">
<summary>Enable back trace.</summary>
<text>
<p>Back tracing helps with debugging by showing more detail about were an error happened.</p>
</text>
<example>false</example>
</option>
<option id="buffer-size"> <option id="buffer-size">
<summary>Buffer size for I/O operations.</summary> <summary>Buffer size for I/O operations.</summary>

View File

@ -31,7 +31,7 @@ TestBuild *
testBldNew( testBldNew(
const String *const pathRepo, const String *const pathTest, const String *const vm, const unsigned int vmId, const String *const pathRepo, const String *const pathTest, const String *const vm, const unsigned int vmId,
const TestDefModule *const module, const unsigned int test, const uint64_t scale, const LogLevel logLevel, const bool logTime, const TestDefModule *const module, const unsigned int test, const uint64_t scale, const LogLevel logLevel, const bool logTime,
const String *const timeZone, const bool coverage, const bool profile, const bool optimize) const String *const timeZone, const bool coverage, const bool profile, const bool optimize, const bool backTrace)
{ {
FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STRING, pathRepo); FUNCTION_LOG_PARAM(STRING, pathRepo);
@ -47,6 +47,7 @@ testBldNew(
FUNCTION_LOG_PARAM(BOOL, coverage); FUNCTION_LOG_PARAM(BOOL, coverage);
FUNCTION_LOG_PARAM(BOOL, profile); FUNCTION_LOG_PARAM(BOOL, profile);
FUNCTION_LOG_PARAM(BOOL, optimize); FUNCTION_LOG_PARAM(BOOL, optimize);
FUNCTION_LOG_PARAM(BOOL, backTrace);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
ASSERT(pathRepo != NULL); ASSERT(pathRepo != NULL);
@ -79,6 +80,7 @@ testBldNew(
.coverage = coverage, .coverage = coverage,
.profile = profile, .profile = profile,
.optimize = optimize, .optimize = optimize,
.backTrace = backTrace,
}, },
}; };
@ -377,6 +379,13 @@ testBldUnit(TestBuild *const this)
// Comment out subdirs that are not used for testing // Comment out subdirs that are not used for testing
strReplace(mesonBuild, STRDEF("subdir('"), STRDEF("# subdir('")); strReplace(mesonBuild, STRDEF("subdir('"), STRDEF("# subdir('"));
if (!testBldBackTrace(this))
{
strReplace(
mesonBuild, STRDEF(" configuration.set('HAVE_LIBBACKTRACE'"),
STRDEF("# configuration.set('HAVE_LIBBACKTRACE'"));
}
// Write build.auto.in // Write build.auto.in
strCatZ( strCatZ(
mesonBuild, mesonBuild,
@ -532,8 +541,18 @@ testBldUnit(TestBuild *const this)
" '%s/src',\n" " '%s/src',\n"
" '%s/test/src',\n" " '%s/test/src',\n"
" ),\n" " ),\n"
" dependencies: [\n" " dependencies: [\n",
" lib_backtrace,\n" strZ(pathRepoRel), strZ(pathRepoRel));
if (testBldBackTrace(this))
{
strCatZ(
mesonBuild,
" lib_backtrace,\n");
}
strCatZ(
mesonBuild,
" lib_bz2,\n" " lib_bz2,\n"
" lib_openssl,\n" " lib_openssl,\n"
" lib_lz4,\n" " lib_lz4,\n"
@ -543,8 +562,7 @@ testBldUnit(TestBuild *const this)
" lib_z,\n" " lib_z,\n"
" lib_zstd,\n" " lib_zstd,\n"
" ],\n" " ],\n"
")\n", ")\n");
strZ(pathRepoRel), strZ(pathRepoRel));
testBldWrite(storageUnit, storageUnitList, "meson.build", BUFSTR(mesonBuild)); testBldWrite(storageUnit, storageUnitList, "meson.build", BUFSTR(mesonBuild));

View File

@ -21,7 +21,7 @@ Constructors
TestBuild *testBldNew( TestBuild *testBldNew(
const String *pathRepo, const String *pathTest, const String *const vm, unsigned int vmId, const TestDefModule *module, const String *pathRepo, const String *pathTest, const String *const vm, unsigned int vmId, const TestDefModule *module,
unsigned int test, uint64_t scale, LogLevel logLevel, bool logTime, const String *timeZone, bool coverage, bool profile, unsigned int test, uint64_t scale, LogLevel logLevel, bool logTime, const String *timeZone, bool coverage, bool profile,
bool optimize); bool optimize, bool backTrace);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Getters/Setters Getters/Setters
@ -43,6 +43,7 @@ typedef struct TestBuildPub
bool coverage; // Generate coverage? bool coverage; // Generate coverage?
bool profile; // Generate profile report? bool profile; // Generate profile report?
bool optimize; // Optimize code? bool optimize; // Optimize code?
bool backTrace; // Run with back trace?
TestDef tstDef; // Test definitions TestDef tstDef; // Test definitions
} TestBuildPub; } TestBuildPub;
@ -152,6 +153,13 @@ testBldScale(const TestBuild *const this)
return THIS_PUB(TestBuild)->scale; return THIS_PUB(TestBuild)->scale;
} }
// Run with back trace?
FN_INLINE_ALWAYS bool
testBldBackTrace(const TestBuild *const this)
{
return THIS_PUB(TestBuild)->backTrace;
}
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -75,7 +75,7 @@ void
cmdTest( cmdTest(
const String *const pathRepo, const String *const pathTest, const String *const vm, const unsigned int vmId, const String *const pathRepo, const String *const pathTest, const String *const vm, const unsigned int vmId,
const String *moduleName, const unsigned int test, const uint64_t scale, const LogLevel logLevel, const bool logTime, const String *moduleName, const unsigned int test, const uint64_t scale, const LogLevel logLevel, const bool logTime,
const String *const timeZone, const bool coverage, const bool profile, const bool optimize) const String *const timeZone, const bool coverage, const bool profile, const bool optimize, const bool backTrace)
{ {
FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STRING, pathRepo); FUNCTION_LOG_PARAM(STRING, pathRepo);
@ -91,6 +91,7 @@ cmdTest(
FUNCTION_LOG_PARAM(BOOL, coverage); FUNCTION_LOG_PARAM(BOOL, coverage);
FUNCTION_LOG_PARAM(BOOL, profile); FUNCTION_LOG_PARAM(BOOL, profile);
FUNCTION_LOG_PARAM(BOOL, optimize); FUNCTION_LOG_PARAM(BOOL, optimize);
FUNCTION_LOG_PARAM(BOOL, backTrace);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
MEM_CONTEXT_TEMP_BEGIN() MEM_CONTEXT_TEMP_BEGIN()
@ -118,7 +119,8 @@ cmdTest(
{ {
// Build unit // Build unit
TestBuild *const testBld = testBldNew( TestBuild *const testBld = testBldNew(
pathRepo, pathTest, vm, vmId, module, test, scale, logLevel, logTime, timeZone, coverage, profile, optimize); pathRepo, pathTest, vm, vmId, module, test, scale, logLevel, logTime, timeZone, coverage, profile, optimize,
backTrace);
testBldUnit(testBld); testBldUnit(testBld);
// Meson setup // Meson setup

View File

@ -15,6 +15,6 @@ Functions
void cmdTest( void cmdTest(
const String *pathRepo, const String *pathTest, const String *const vm, unsigned int vmId, const String *moduleName, const String *pathRepo, const String *pathTest, const String *const vm, unsigned int vmId, const String *moduleName,
unsigned int test, uint64_t scale, LogLevel logLevel, bool logTime, const String *timeZone, bool coverage, bool profile, unsigned int test, uint64_t scale, LogLevel logLevel, bool logTime, const String *timeZone, bool coverage, bool profile,
bool optimize); bool optimize, bool backTrace);
#endif #endif

View File

@ -76,7 +76,7 @@ main(int argListSize, const char *argList[])
cfgOptionTest(cfgOptTest) ? cfgOptionUInt(cfgOptTest) : 0, cfgOptionUInt64(cfgOptScale), cfgOptionTest(cfgOptTest) ? cfgOptionUInt(cfgOptTest) : 0, cfgOptionUInt64(cfgOptScale),
logLevelEnum(cfgOptionStrId(cfgOptLogLevelTest)), cfgOptionBool(cfgOptLogTimestamp), logLevelEnum(cfgOptionStrId(cfgOptLogLevelTest)), cfgOptionBool(cfgOptLogTimestamp),
cfgOptionStrNull(cfgOptTz), cfgOptionBool(cfgOptCoverage), cfgOptionBool(cfgOptProfile), cfgOptionStrNull(cfgOptTz), cfgOptionBool(cfgOptCoverage), cfgOptionBool(cfgOptProfile),
cfgOptionBool(cfgOptOptimize)); cfgOptionBool(cfgOptOptimize), cfgOptionBool(cfgOptBackTrace));
break; break;
} }

View File

@ -260,7 +260,7 @@ testRun(void)
TEST_RESULT_VOID( TEST_RESULT_VOID(
cmdTest( cmdTest(
STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("none"), 3, STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("none"), 3,
STRDEF("common/stack-trace"), 0, 1, logLevelDebug, true, NULL, false, false, false), STRDEF("common/stack-trace"), 0, 1, logLevelDebug, true, NULL, false, false, false, true),
"new build"); "new build");
const Storage *storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/none")); const Storage *storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/none"));
@ -379,7 +379,7 @@ testRun(void)
TEST_RESULT_VOID( TEST_RESULT_VOID(
cmdTest( cmdTest(
STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("none"), 3, STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("none"), 3,
STRDEF("common/error"), 5, 1, logLevelDebug, true, NULL, false, false, false), STRDEF("common/error"), 5, 1, logLevelDebug, true, NULL, false, false, false, true),
"new build"); "new build");
fileList = testStorageList(storageUnit); fileList = testStorageList(storageUnit);
@ -568,7 +568,7 @@ testRun(void)
TEST_RESULT_VOID( TEST_RESULT_VOID(
cmdTest( cmdTest(
STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3,
STRDEF("test/shim"), 0, 1, logLevelDebug, true, NULL, true, true, true), STRDEF("test/shim"), 0, 1, logLevelDebug, true, NULL, true, true, true, true),
"new build"); "new build");
storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/uXX")); storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/uXX"));
@ -706,12 +706,16 @@ testRun(void)
TEST_RESULT_VOID( TEST_RESULT_VOID(
cmdTest( cmdTest(
STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3,
STRDEF("test/shim"), 0, 1, logLevelDebug, true, NULL, true, true, true), STRDEF("test/shim"), 0, 1, logLevelDebug, true, NULL, true, true, true, true),
"new build"); "new build");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("Test performance/type"); TEST_TITLE("Test performance/type");
strReplace(
mesonBuildRoot, STRDEF(" configuration.set('HAVE_LIBBACKTRACE'"),
STRDEF("# configuration.set('HAVE_LIBBACKTRACE'"));
HRN_STORAGE_PUT_Z( HRN_STORAGE_PUT_Z(
storageTest, "repo/test/src/module/performance/typeTest.c", storageTest, "repo/test/src/module/performance/typeTest.c",
"static void\n" "static void\n"
@ -731,7 +735,7 @@ testRun(void)
TEST_RESULT_VOID( TEST_RESULT_VOID(
cmdTest( cmdTest(
STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3,
STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, true, false), STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, true, false, false),
"new build"); "new build");
TEST_RESULT_LOG( TEST_RESULT_LOG(
@ -801,7 +805,6 @@ testRun(void)
" '../../../repo/test/src',\n" " '../../../repo/test/src',\n"
" ),\n" " ),\n"
" dependencies: [\n" " dependencies: [\n"
" lib_backtrace,\n"
" lib_bz2,\n" " lib_bz2,\n"
" lib_openssl,\n" " lib_openssl,\n"
" lib_lz4,\n" " lib_lz4,\n"
@ -866,7 +869,7 @@ testRun(void)
TEST_RESULT_VOID( TEST_RESULT_VOID(
cmdTest( cmdTest(
STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3,
STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, false, false), STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, false, false, false),
"new build"); "new build");
storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/uXX")); storageUnit = storagePosixNewP(STRDEF(TEST_PATH "/test/unit-3/uXX"));
@ -900,7 +903,7 @@ testRun(void)
TEST_ERROR( TEST_ERROR(
cmdTest( cmdTest(
STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3, STRDEF(TEST_PATH "/repo"), storagePathP(storageTest, STRDEF("test")), STRDEF("uXX"), 3,
STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, false, false), STRDEF("performance/type"), 0, 1, logLevelDebug, true, STRDEF("America/New_York"), false, false, false, false),
FileOpenError, FileOpenError,
"build failed for unit performance/type: unable to open file '" TEST_PATH "/repo/meson.build' for read: [13] Permission" "build failed for unit performance/type: unable to open file '" TEST_PATH "/repo/meson.build' for read: [13] Permission"
" denied"); " denied");

View File

@ -80,6 +80,7 @@ test.pl [options]
--min-gen only run required code generation --min-gen only run required code generation
--gen-check check that auto-generated files are correct (used in CI to detect changes) --gen-check check that auto-generated files are correct (used in CI to detect changes)
--code-count generate code counts --code-count generate code counts
--no-back-trace don't run backrace on C unit tests (may be slow with valgrind)
--no-valgrind don't run valgrind on C unit tests (saves time) --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-coverage don't run coverage on C unit tests (saves time)
--no-coverage-report run coverage but don't generate coverage report (saves time) --no-coverage-report run coverage but don't generate coverage report (saves time)
@ -158,6 +159,7 @@ my $bGenCheck = false;
my $bMinGen = false; my $bMinGen = false;
my $bCodeCount = false; my $bCodeCount = false;
my $bProfile = false; my $bProfile = false;
my $bNoBackTrace = false;
my $bNoValgrind = false; my $bNoValgrind = false;
my $bNoOptimize = false; my $bNoOptimize = false;
my $bNoDebug = false; my $bNoDebug = false;
@ -207,6 +209,7 @@ GetOptions ('q|quiet' => \$bQuiet,
'min-gen' => \$bMinGen, 'min-gen' => \$bMinGen,
'code-count' => \$bCodeCount, 'code-count' => \$bCodeCount,
'profile' => \$bProfile, 'profile' => \$bProfile,
'no-back-trace' => \$bNoBackTrace,
'no-valgrind' => \$bNoValgrind, 'no-valgrind' => \$bNoValgrind,
'no-optimize' => \$bNoOptimize, 'no-optimize' => \$bNoOptimize,
'no-debug', => \$bNoDebug, 'no-debug', => \$bNoDebug,
@ -266,6 +269,7 @@ eval
################################################################################################################################ ################################################################################################################################
if ($bProfile) if ($bProfile)
{ {
$bNoBackTrace = true;
$bNoValgrind = true; $bNoValgrind = true;
$bNoCoverage = true; $bNoCoverage = true;
} }
@ -1054,8 +1058,8 @@ eval
my $oJob = new pgBackRestTest::Common::JobTest( my $oJob = new pgBackRestTest::Common::JobTest(
$oStorageTest, $strBackRestBase, $strTestPath, $$oyTestRun[$iTestIdx], $bDryRun, $bVmOut, $iVmIdx, $iVmMax, $oStorageTest, $strBackRestBase, $strTestPath, $$oyTestRun[$iTestIdx], $bDryRun, $bVmOut, $iVmIdx, $iVmMax,
$strMakeCmd, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $strLogLevelTestFile, !$bNoLogTimestamp, $strMakeCmd, $iTestIdx, $iTestMax, $strLogLevel, $strLogLevelTest, $strLogLevelTestFile, !$bNoLogTimestamp,
$bShowOutputAsync, $bNoCleanup, $iRetry, !$bNoValgrind, !$bNoCoverage, $bCoverageSummary, !$bNoOptimize, $bShowOutputAsync, $bNoCleanup, $iRetry, !$bNoBackTrace, !$bNoValgrind, !$bNoCoverage, $bCoverageSummary,
$bProfile, $iScale, $strTimeZone, !$bNoDebug, $bDebugTestTrace, !$bNoOptimize, $bProfile, $iScale, $strTimeZone, !$bNoDebug, $bDebugTestTrace,
$iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax)); $iBuildMax / $iVmMax < 1 ? 1 : int($iBuildMax / $iVmMax));
$iTestIdx++; $iTestIdx++;