You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-05-22 10:15:16 +02:00
Add performance test capability in C with scaling.
Scaling allows the starting values to be increased from the command-line without code changes. Also suppress valgrind and assertions when running performance testing. Optimization is left at -O0 because we should not be depending on compiler optimizations to make our code performant, and it makes profiling more informative.
This commit is contained in:
@@ -59,6 +59,8 @@ use constant TESTDEF_INDIVIDUAL => 'individu
|
||||
push @EXPORT, qw(TESTDEF_INDIVIDUAL);
|
||||
use constant TESTDEF_TOTAL => 'total';
|
||||
push @EXPORT, qw(TESTDEF_TOTAL);
|
||||
use constant TESTDEF_TYPE => 'type';
|
||||
push @EXPORT, qw(TESTDEF_TYPE);
|
||||
use constant TESTDEF_PERL_REQ => 'perlReq';
|
||||
push @EXPORT, qw(TESTDEF_PERL_REQ);
|
||||
use constant TESTDEF_VM => 'vm';
|
||||
@@ -137,6 +139,7 @@ sub testDefLoad
|
||||
}
|
||||
|
||||
# Set module type variables
|
||||
$hTestDefHash->{$strModule}{$strTest}{&TESTDEF_TYPE} = $strModuleType;
|
||||
$hTestDefHash->{$strModule}{$strTest}{&TESTDEF_C} =
|
||||
$strModuleType ne TESTDEF_INTEGRATION && $strTest !~ /perl$/ ? true : false;
|
||||
$hTestDefHash->{$strModule}{$strTest}{&TESTDEF_INTEGRATION} = $strModuleType eq TESTDEF_INTEGRATION ? true : false;
|
||||
|
||||
@@ -75,6 +75,7 @@ sub new
|
||||
$self->{bOptimize},
|
||||
$self->{bBackTrace},
|
||||
$self->{bProfile},
|
||||
$self->{iScale},
|
||||
$self->{bDebug},
|
||||
$self->{bDebugTestTrace},
|
||||
$self->{iBuildMax},
|
||||
@@ -105,6 +106,7 @@ sub new
|
||||
{name => 'bOptimize'},
|
||||
{name => 'bBackTrace'},
|
||||
{name => 'bProfile'},
|
||||
{name => 'iScale'},
|
||||
{name => 'bDebug'},
|
||||
{name => 'bDebugTestTrace'},
|
||||
{name => 'iBuildMax'},
|
||||
@@ -254,7 +256,8 @@ sub run
|
||||
'docker exec -i -u ' . TEST_USER . " ${strImage} bash -l -c '" .
|
||||
"cd $self->{strGCovPath} && " .
|
||||
"make -j $self->{iBuildMax} -s 2>&1 &&" .
|
||||
($self->{oTest}->{&TEST_VM} ne VM_CO6 && $self->{bValgrindUnit}?
|
||||
($self->{oTest}->{&TEST_VM} ne VM_CO6 && $self->{bValgrindUnit} &&
|
||||
$self->{oTest}->{&TEST_TYPE} ne TESTDEF_PERFORMANCE ?
|
||||
" valgrind -q --gen-suppressions=all --suppressions=$self->{strGCovPath}/test/valgrind.suppress" .
|
||||
" --leak-check=full --leak-resolution=high --error-exitcode=25" : '') .
|
||||
" ./test.bin 2>&1'";
|
||||
@@ -344,7 +347,16 @@ sub run
|
||||
|
||||
# Update C test file with test module
|
||||
my $strTestC = ${$self->{oStorageTest}->get("$self->{strGCovPath}/test/test.c")};
|
||||
$strTestC =~ s/\{\[C\_INCLUDE\]\}/$strCInclude/g;
|
||||
|
||||
if (defined($strCInclude))
|
||||
{
|
||||
$strTestC =~ s/\{\[C\_INCLUDE\]\}/$strCInclude/g;
|
||||
}
|
||||
else
|
||||
{
|
||||
$strTestC =~ s/\{\[C\_INCLUDE\]\}//g;
|
||||
}
|
||||
|
||||
$strTestC =~ s/\{\[C\_TEST\_INCLUDE\]\}/\#include \"$strTestFile\"/g;
|
||||
$strTestDepend .= " ${strTestFile}";
|
||||
|
||||
@@ -364,6 +376,7 @@ sub run
|
||||
$strTestC =~ s/\{\[C\_TEST\_PATH\]\}/$strVmTestPath/g;
|
||||
$strTestC =~ s/\{\[C\_TEST\_EXPECT_PATH\]\}/$self->{strExpectPath}/g;
|
||||
$strTestC =~ s/\{\[C\_TEST\_REPO_PATH\]\}/$self->{strBackRestBase}/g;
|
||||
$strTestC =~ s/\{\[C\_TEST\_SCALE\]\}/$self->{iScale}/g;
|
||||
|
||||
# Set default log level
|
||||
my $strLogLevelTestC = "logLevel" . ucfirst($self->{strLogLevelTest});
|
||||
@@ -417,7 +430,7 @@ sub run
|
||||
(vmWithBackTrace($self->{oTest}->{&TEST_VM}) && $self->{bBackTrace} ? ' -DWITH_BACKTRACE' : '') .
|
||||
($self->{oTest}->{&TEST_CDEF} ? " $self->{oTest}->{&TEST_CDEF}" : '') .
|
||||
(vmCoverageC($self->{oTest}->{&TEST_VM}) && $self->{bCoverageUnit} ? ' -DDEBUG_COVERAGE' : '') .
|
||||
($self->{bDebug} ? '' : ' -DNDEBUG') .
|
||||
($self->{bDebug} && $self->{oTest}->{&TEST_TYPE} ne TESTDEF_PERFORMANCE ? '' : ' -DNDEBUG') .
|
||||
($self->{bDebugTestTrace} && $self->{bDebug} ? ' -DDEBUG_TEST_TRACE' : '');
|
||||
|
||||
# Flags used to build harness files
|
||||
|
||||
@@ -46,6 +46,8 @@ use constant TEST_PGSQL_BIN => 'pgsql-bi
|
||||
push @EXPORT, qw(TEST_PGSQL_BIN);
|
||||
use constant TEST_INTEGRATION => 'integration';
|
||||
push @EXPORT, qw(TEST_INTEGRATION);
|
||||
use constant TEST_TYPE => 'type';
|
||||
push @EXPORT, qw(TEST_TYPE);
|
||||
use constant TEST_RUN => 'run';
|
||||
push @EXPORT, qw(TEST_RUN);
|
||||
use constant TEST_VM => 'os';
|
||||
@@ -150,6 +152,7 @@ sub testListGet
|
||||
|
||||
my $oTestRun =
|
||||
{
|
||||
&TEST_TYPE => $hTest->{&TESTDEF_TYPE},
|
||||
&TEST_VM => $strTestOS,
|
||||
&TEST_C => coalesce($hTest->{&TESTDEF_C}, $hModule->{&TESTDEF_C}, false),
|
||||
&TEST_CDEF => $hTest->{&TESTDEF_DEFINE},
|
||||
|
||||
Reference in New Issue
Block a user