mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-02-09 13:46:51 +02:00
Replace double type with time in config module.
The C code does not use doubles to represent seconds like the Perl code did so time can be represented as an integer which reduces the number of data types that config has to understand. Also remove Variant doubles since they are no longer used. Note that not all double code was removed since we still need to display times to the user in seconds and it is possible for the times to be fractional. In the future this will likely be simplified by storing the original user input and using that value when the time needs to be displayed.
This commit is contained in:
parent
a137c6baaa
commit
87996558d2
@ -215,7 +215,7 @@ Note that `CFGDEF_SECTION` is not present thereby making this a command-line onl
|
|||||||
|
|
||||||
- `CFGOPT_ONLINE` - the name of the option as defined in **Section 1**
|
- `CFGOPT_ONLINE` - the name of the option as defined in **Section 1**
|
||||||
|
|
||||||
- `CFGDEF_TYPE` - the type of the option. Valid types are: `CFGDEF_TYPE_BOOLEAN`, `CFGDEF_TYPE_FLOAT`, `CFGDEF_TYPE_HASH`, `CFGDEF_TYPE_INTEGER`, `CFGDEF_TYPE_LIST`, `CFGDEF_TYPE_PATH`, `CFGDEF_TYPE_SIZE`, and `CFGDEF_TYPE_STRING`
|
- `CFGDEF_TYPE` - the type of the option. Valid types are: `CFGDEF_TYPE_BOOLEAN`, `CFGDEF_TYPE_HASH`, `CFGDEF_TYPE_INTEGER`, `CFGDEF_TYPE_LIST`, `CFGDEF_TYPE_PATH`, `CFGDEF_TYPE_SIZE`, `CFGDEF_TYPE_STRING`, and `CFGDEF_TYPE_TIME`
|
||||||
|
|
||||||
|
|
||||||
- `CFGDEF_NEGATE` - being a command-line only boolean option, this rule would automatically default to false so it must be defined if the option is negatable. Ask yourself if negation makes sense, for example, would a --dry-run option make sense as --no-dry-run? If the answer is no, then this rule can be omitted as it would automatically default to false. Any boolean option that cannot be negatable, must be a command-line only and not a configuration file option as all configuration boolean options must be negatable.
|
- `CFGDEF_NEGATE` - being a command-line only boolean option, this rule would automatically default to false so it must be defined if the option is negatable. Ask yourself if negation makes sense, for example, would a --dry-run option make sense as --no-dry-run? If the answer is no, then this rule can be omitted as it would automatically default to false. Any boolean option that cannot be negatable, must be a command-line only and not a configuration file option as all configuration boolean options must be negatable.
|
||||||
|
@ -222,9 +222,12 @@ sub renderOptional
|
|||||||
{
|
{
|
||||||
my @fyRange = @{$rhOptional->{&CFGDEF_ALLOW_RANGE}};
|
my @fyRange = @{$rhOptional->{&CFGDEF_ALLOW_RANGE}};
|
||||||
|
|
||||||
$strBuildSourceOptional .=
|
my $iMultiplier = $rhOptional->{&CFGDEF_TYPE} eq CFGDEF_TYPE_TIME ? 1000 : 1;
|
||||||
|
|
||||||
|
$strBuildSourceOptional =
|
||||||
(defined($strBuildSourceOptional) && !$bSingleLine ? "\n" : '') .
|
(defined($strBuildSourceOptional) && !$bSingleLine ? "\n" : '') .
|
||||||
"${strIndent} CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(" . $fyRange[0] . ', ' . $fyRange[1] . ")\n";
|
"${strIndent} CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(" . ($fyRange[0] * $iMultiplier) . ', ' .
|
||||||
|
($fyRange[1] * $iMultiplier) . ")\n";
|
||||||
|
|
||||||
$bSingleLine = true;
|
$bSingleLine = true;
|
||||||
}
|
}
|
||||||
@ -241,7 +244,10 @@ sub renderOptional
|
|||||||
{
|
{
|
||||||
$strBuildSourceOptional .=
|
$strBuildSourceOptional .=
|
||||||
(defined($strBuildSourceOptional) && !$bSingleLine ? "\n" : '') .
|
(defined($strBuildSourceOptional) && !$bSingleLine ? "\n" : '') .
|
||||||
"${strIndent} CFGDEFDATA_OPTION_OPTIONAL_DEFAULT(\"" . $rhOptional->{&CFGDEF_DEFAULT} . "\")\n";
|
"${strIndent} CFGDEFDATA_OPTION_OPTIONAL_DEFAULT(\"" .
|
||||||
|
(defined($rhOptional->{&CFGDEF_TYPE}) && $rhOptional->{&CFGDEF_TYPE} eq CFGDEF_TYPE_TIME ?
|
||||||
|
$rhOptional->{&CFGDEF_DEFAULT} * 1000 : $rhOptional->{&CFGDEF_DEFAULT}) .
|
||||||
|
"\")\n";
|
||||||
|
|
||||||
$bSingleLine = true;
|
$bSingleLine = true;
|
||||||
}
|
}
|
||||||
|
@ -474,8 +474,6 @@ use constant CFGDEF_TYPE => 'type';
|
|||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
use constant CFGDEF_TYPE_BOOLEAN => 'boolean';
|
use constant CFGDEF_TYPE_BOOLEAN => 'boolean';
|
||||||
push @EXPORT, qw(CFGDEF_TYPE_BOOLEAN);
|
push @EXPORT, qw(CFGDEF_TYPE_BOOLEAN);
|
||||||
use constant CFGDEF_TYPE_FLOAT => 'float';
|
|
||||||
push @EXPORT, qw(CFGDEF_TYPE_FLOAT);
|
|
||||||
use constant CFGDEF_TYPE_HASH => 'hash';
|
use constant CFGDEF_TYPE_HASH => 'hash';
|
||||||
push @EXPORT, qw(CFGDEF_TYPE_HASH);
|
push @EXPORT, qw(CFGDEF_TYPE_HASH);
|
||||||
use constant CFGDEF_TYPE_INTEGER => 'integer';
|
use constant CFGDEF_TYPE_INTEGER => 'integer';
|
||||||
@ -488,6 +486,8 @@ use constant CFGDEF_TYPE_STRING => 'string';
|
|||||||
push @EXPORT, qw(CFGDEF_TYPE_STRING);
|
push @EXPORT, qw(CFGDEF_TYPE_STRING);
|
||||||
use constant CFGDEF_TYPE_SIZE => 'size';
|
use constant CFGDEF_TYPE_SIZE => 'size';
|
||||||
push @EXPORT, qw(CFGDEF_TYPE_SIZE);
|
push @EXPORT, qw(CFGDEF_TYPE_SIZE);
|
||||||
|
use constant CFGDEF_TYPE_TIME => 'time';
|
||||||
|
push @EXPORT, qw(CFGDEF_TYPE_TIME);
|
||||||
|
|
||||||
# Option config sections
|
# Option config sections
|
||||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -1142,7 +1142,7 @@ my %hConfigDefine =
|
|||||||
&CFGOPT_ARCHIVE_TIMEOUT =>
|
&CFGOPT_ARCHIVE_TIMEOUT =>
|
||||||
{
|
{
|
||||||
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
||||||
&CFGDEF_TYPE => CFGDEF_TYPE_FLOAT,
|
&CFGDEF_TYPE => CFGDEF_TYPE_TIME,
|
||||||
&CFGDEF_DEFAULT => 60,
|
&CFGDEF_DEFAULT => 60,
|
||||||
&CFGDEF_ALLOW_RANGE => [WAIT_TIME_MINIMUM, 86400],
|
&CFGDEF_ALLOW_RANGE => [WAIT_TIME_MINIMUM, 86400],
|
||||||
&CFGDEF_COMMAND =>
|
&CFGDEF_COMMAND =>
|
||||||
@ -1248,7 +1248,7 @@ my %hConfigDefine =
|
|||||||
&CFGOPT_DB_TIMEOUT =>
|
&CFGOPT_DB_TIMEOUT =>
|
||||||
{
|
{
|
||||||
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
||||||
&CFGDEF_TYPE => CFGDEF_TYPE_FLOAT,
|
&CFGDEF_TYPE => CFGDEF_TYPE_TIME,
|
||||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_DB_TIMEOUT,
|
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_DB_TIMEOUT,
|
||||||
&CFGDEF_ALLOW_RANGE => [CFGDEF_DEFAULT_DB_TIMEOUT_MIN, CFGDEF_DEFAULT_DB_TIMEOUT_MAX],
|
&CFGDEF_ALLOW_RANGE => [CFGDEF_DEFAULT_DB_TIMEOUT_MIN, CFGDEF_DEFAULT_DB_TIMEOUT_MAX],
|
||||||
&CFGDEF_COMMAND =>
|
&CFGDEF_COMMAND =>
|
||||||
@ -1400,7 +1400,7 @@ my %hConfigDefine =
|
|||||||
&CFGOPT_IO_TIMEOUT =>
|
&CFGOPT_IO_TIMEOUT =>
|
||||||
{
|
{
|
||||||
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
||||||
&CFGDEF_TYPE => CFGDEF_TYPE_FLOAT,
|
&CFGDEF_TYPE => CFGDEF_TYPE_TIME,
|
||||||
&CFGDEF_DEFAULT => 60,
|
&CFGDEF_DEFAULT => 60,
|
||||||
&CFGDEF_ALLOW_RANGE => [.1, 3600],
|
&CFGDEF_ALLOW_RANGE => [.1, 3600],
|
||||||
&CFGDEF_COMMAND => CFGOPT_BUFFER_SIZE,
|
&CFGDEF_COMMAND => CFGOPT_BUFFER_SIZE,
|
||||||
@ -1458,7 +1458,7 @@ my %hConfigDefine =
|
|||||||
&CFGOPT_PROTOCOL_TIMEOUT =>
|
&CFGOPT_PROTOCOL_TIMEOUT =>
|
||||||
{
|
{
|
||||||
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
||||||
&CFGDEF_TYPE => CFGDEF_TYPE_FLOAT,
|
&CFGDEF_TYPE => CFGDEF_TYPE_TIME,
|
||||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_DB_TIMEOUT + 30,
|
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_DB_TIMEOUT + 30,
|
||||||
&CFGDEF_ALLOW_RANGE => [CFGDEF_DEFAULT_DB_TIMEOUT_MIN, CFGDEF_DEFAULT_DB_TIMEOUT_MAX],
|
&CFGDEF_ALLOW_RANGE => [CFGDEF_DEFAULT_DB_TIMEOUT_MIN, CFGDEF_DEFAULT_DB_TIMEOUT_MAX],
|
||||||
&CFGDEF_COMMAND =>
|
&CFGDEF_COMMAND =>
|
||||||
@ -3054,13 +3054,13 @@ foreach my $strKey (sort(keys(%hConfigDefine)))
|
|||||||
$hConfigDefine{$strKey}{&CFGDEF_INDEX_TOTAL} = 1;
|
$hConfigDefine{$strKey}{&CFGDEF_INDEX_TOTAL} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# All int and float options must have an allow range
|
# All int, size and time options must have an allow range
|
||||||
if (($hConfigDefine{$strKey}{&CFGDEF_TYPE} eq CFGDEF_TYPE_INTEGER ||
|
if (($hConfigDefine{$strKey}{&CFGDEF_TYPE} eq CFGDEF_TYPE_INTEGER ||
|
||||||
$hConfigDefine{$strKey}{&CFGDEF_TYPE} eq CFGDEF_TYPE_FLOAT ||
|
$hConfigDefine{$strKey}{&CFGDEF_TYPE} eq CFGDEF_TYPE_TIME ||
|
||||||
$hConfigDefine{$strKey}{&CFGDEF_TYPE} eq CFGDEF_TYPE_SIZE) &&
|
$hConfigDefine{$strKey}{&CFGDEF_TYPE} eq CFGDEF_TYPE_SIZE) &&
|
||||||
!(defined($hConfigDefine{$strKey}{&CFGDEF_ALLOW_RANGE}) || defined($hConfigDefine{$strKey}{&CFGDEF_ALLOW_LIST})))
|
!(defined($hConfigDefine{$strKey}{&CFGDEF_ALLOW_RANGE}) || defined($hConfigDefine{$strKey}{&CFGDEF_ALLOW_LIST})))
|
||||||
{
|
{
|
||||||
confess &log(ASSERT, "int/float option '${strKey}' must have allow range or list");
|
confess &log(ASSERT, "int/size/time option '${strKey}' must have allow range or list");
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ensure all commands are valid
|
# Ensure all commands are valid
|
||||||
|
@ -236,7 +236,7 @@
|
|||||||
|
|
||||||
<list>
|
<list>
|
||||||
<list-item><id>CFGOPT_ONLINE</id> - the name of the option as defined in <b>Section 1</b></list-item>
|
<list-item><id>CFGOPT_ONLINE</id> - the name of the option as defined in <b>Section 1</b></list-item>
|
||||||
<list-item><id>CFGDEF_TYPE</id> - the type of the option. Valid types are: <id>CFGDEF_TYPE_BOOLEAN</id>, <id>CFGDEF_TYPE_FLOAT</id>, <id>CFGDEF_TYPE_HASH</id>, <id>CFGDEF_TYPE_INTEGER</id>, <id>CFGDEF_TYPE_LIST</id>, <id>CFGDEF_TYPE_PATH</id>, <id>CFGDEF_TYPE_SIZE</id>, and <id>CFGDEF_TYPE_STRING</id>
|
<list-item><id>CFGDEF_TYPE</id> - the type of the option. Valid types are: <id>CFGDEF_TYPE_BOOLEAN</id>, <id>CFGDEF_TYPE_HASH</id>, <id>CFGDEF_TYPE_INTEGER</id>, <id>CFGDEF_TYPE_LIST</id>, <id>CFGDEF_TYPE_PATH</id>, <id>CFGDEF_TYPE_SIZE</id>, <id>CFGDEF_TYPE_STRING</id>, and <id>CFGDEF_TYPE_TIME</id>
|
||||||
</list-item>
|
</list-item>
|
||||||
<list-item><id>CFGDEF_NEGATE</id> - being a command-line only boolean option, this rule would automatically default to false so it must be defined if the option is negatable. Ask yourself if negation makes sense, for example, would a --dry-run option make sense as --no-dry-run? If the answer is no, then this rule can be omitted as it would automatically default to false. Any boolean option that cannot be negatable, must be a command-line only and not a configuration file option as all configuration boolean options must be negatable.</list-item>
|
<list-item><id>CFGDEF_NEGATE</id> - being a command-line only boolean option, this rule would automatically default to false so it must be defined if the option is negatable. Ask yourself if negation makes sense, for example, would a --dry-run option make sense as --no-dry-run? If the answer is no, then this rule can be omitted as it would automatically default to false. Any boolean option that cannot be negatable, must be a command-line only and not a configuration file option as all configuration boolean options must be negatable.</list-item>
|
||||||
<list-item><id>CFGDEF_DEFAULT</id> - sets a default for the option if the option is not provided when the command is run. The default can be global or it can be specified for a specific command in the <id>CFGDEF_COMMAND</id> section. For example, if it was desirable for the default to be false for the <id>CFGCMD_STANZA_CREATE</id> then CFGDEF_NEGATE => would be set to <id>true</id> in each command listed except for <id>CFGCMD_STANZA_CREATE</id> where it would be <id>false</id> and it would not be specified (as it is here) in the global section (meaning global for all commands listed).</list-item>
|
<list-item><id>CFGDEF_DEFAULT</id> - sets a default for the option if the option is not provided when the command is run. The default can be global or it can be specified for a specific command in the <id>CFGDEF_COMMAND</id> section. For example, if it was desirable for the default to be false for the <id>CFGCMD_STANZA_CREATE</id> then CFGDEF_NEGATE => would be set to <id>true</id> in each command listed except for <id>CFGCMD_STANZA_CREATE</id> where it would be <id>false</id> and it would not be specified (as it is here) in the global section (meaning global for all commands listed).</list-item>
|
||||||
|
@ -13,6 +13,17 @@
|
|||||||
|
|
||||||
<release-list>
|
<release-list>
|
||||||
<release date="XXXX-XX-XX" version="2.32dev" title="UNDER DEVELOPMENT">
|
<release date="XXXX-XX-XX" version="2.32dev" title="UNDER DEVELOPMENT">
|
||||||
|
<release-core-list>
|
||||||
|
<release-development-list>
|
||||||
|
<release-item>
|
||||||
|
<release-item-contributor-list>
|
||||||
|
<release-item-reviewer id="cynthia.shang"/>
|
||||||
|
</release-item-contributor-list>
|
||||||
|
|
||||||
|
<p>Replace <id>double</id> type with <id>time</id> in <id>config</id> module.</p>
|
||||||
|
</release-item>
|
||||||
|
</release-development-list>
|
||||||
|
</release-core-list>
|
||||||
</release>
|
</release>
|
||||||
|
|
||||||
<release date="2020-12-07" version="2.31" title="Minor Bug Fixes and Improvements">
|
<release date="2020-12-07" version="2.31" title="Minor Bug Fixes and Improvements">
|
||||||
|
@ -143,7 +143,7 @@ cmdArchiveGet(void)
|
|||||||
bool throwOnError = false; // Should we throw errors?
|
bool throwOnError = false; // Should we throw errors?
|
||||||
|
|
||||||
// Loop and wait for the WAL segment to be pushed
|
// Loop and wait for the WAL segment to be pushed
|
||||||
Wait *wait = waitNew((TimeMSec)(cfgOptionDbl(cfgOptArchiveTimeout) * MSEC_PER_SEC));
|
Wait *wait = waitNew(cfgOptionUInt64(cfgOptArchiveTimeout));
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -338,7 +338,7 @@ cmdArchiveGetAsync(void)
|
|||||||
|
|
||||||
// Create the parallel executor
|
// Create the parallel executor
|
||||||
ProtocolParallel *parallelExec = protocolParallelNew(
|
ProtocolParallel *parallelExec = protocolParallelNew(
|
||||||
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * MSEC_PER_SEC) / 2, archiveGetAsyncCallback, &jobData);
|
cfgOptionUInt64(cfgOptProtocolTimeout) / 2, archiveGetAsyncCallback, &jobData);
|
||||||
|
|
||||||
for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++)
|
for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++)
|
||||||
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 0, processIdx));
|
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 0, processIdx));
|
||||||
|
@ -291,7 +291,7 @@ cmdArchivePush(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop and wait for the WAL segment to be pushed
|
// Loop and wait for the WAL segment to be pushed
|
||||||
Wait *wait = waitNew((TimeMSec)(cfgOptionDbl(cfgOptArchiveTimeout) * MSEC_PER_SEC));
|
Wait *wait = waitNew(cfgOptionUInt64(cfgOptArchiveTimeout));
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -341,8 +341,8 @@ cmdArchivePush(void)
|
|||||||
if (!pushed)
|
if (!pushed)
|
||||||
{
|
{
|
||||||
THROW_FMT(
|
THROW_FMT(
|
||||||
ArchiveTimeoutError, "unable to push WAL file '%s' to the archive asynchronously after %lg second(s)",
|
ArchiveTimeoutError, "unable to push WAL file '%s' to the archive asynchronously after %s second(s)",
|
||||||
strZ(archiveFile), cfgOptionDbl(cfgOptArchiveTimeout));
|
strZ(archiveFile), strZ(cvtDoubleToStr((double)cfgOptionInt64(cfgOptArchiveTimeout) / MSEC_PER_SEC)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log success
|
// Log success
|
||||||
@ -503,7 +503,7 @@ cmdArchivePushAsync(void)
|
|||||||
|
|
||||||
// Create the parallel executor
|
// Create the parallel executor
|
||||||
ProtocolParallel *parallelExec = protocolParallelNew(
|
ProtocolParallel *parallelExec = protocolParallelNew(
|
||||||
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * MSEC_PER_SEC) / 2, archivePushAsyncCallback, &jobData);
|
cfgOptionUInt64(cfgOptProtocolTimeout) / 2, archivePushAsyncCallback, &jobData);
|
||||||
|
|
||||||
for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++)
|
for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++)
|
||||||
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 0, processIdx));
|
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 0, processIdx));
|
||||||
|
@ -904,7 +904,7 @@ backupStart(BackupData *backupData)
|
|||||||
if (cfgOptionBool(cfgOptBackupStandby))
|
if (cfgOptionBool(cfgOptBackupStandby))
|
||||||
{
|
{
|
||||||
LOG_INFO_FMT("wait for replay on the standby to reach %s", strZ(result.lsn));
|
LOG_INFO_FMT("wait for replay on the standby to reach %s", strZ(result.lsn));
|
||||||
dbReplayWait(backupData->dbStandby, result.lsn, (TimeMSec)(cfgOptionDbl(cfgOptArchiveTimeout) * MSEC_PER_SEC));
|
dbReplayWait(backupData->dbStandby, result.lsn, cfgOptionUInt64(cfgOptArchiveTimeout));
|
||||||
LOG_INFO_FMT("replay on the standby reached %s", strZ(result.lsn));
|
LOG_INFO_FMT("replay on the standby reached %s", strZ(result.lsn));
|
||||||
|
|
||||||
// The standby db object won't be used anymore so free it
|
// The standby db object won't be used anymore so free it
|
||||||
@ -1599,7 +1599,7 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
|
|||||||
|
|
||||||
// Create the parallel executor
|
// Create the parallel executor
|
||||||
ProtocolParallel *parallelExec = protocolParallelNew(
|
ProtocolParallel *parallelExec = protocolParallelNew(
|
||||||
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * MSEC_PER_SEC) / 2, backupJobCallback, &jobData);
|
cfgOptionUInt64(cfgOptProtocolTimeout) / 2, backupJobCallback, &jobData);
|
||||||
|
|
||||||
// First client is always on the primary
|
// First client is always on the primary
|
||||||
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypePg, backupData->pgIdxPrimary, 1));
|
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypePg, backupData->pgIdxPrimary, 1));
|
||||||
@ -1774,7 +1774,7 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
|
|||||||
|
|
||||||
// Find the actual wal segment file in the archive
|
// Find the actual wal segment file in the archive
|
||||||
const String *archiveFile = walSegmentFind(
|
const String *archiveFile = walSegmentFind(
|
||||||
storageRepo(), archiveId, walSegment, (TimeMSec)(cfgOptionDbl(cfgOptArchiveTimeout) * MSEC_PER_SEC));
|
storageRepo(), archiveId, walSegment, cfgOptionUInt64(cfgOptArchiveTimeout));
|
||||||
|
|
||||||
if (cfgOptionBool(cfgOptArchiveCopy))
|
if (cfgOptionBool(cfgOptArchiveCopy))
|
||||||
{
|
{
|
||||||
|
@ -129,7 +129,7 @@ checkPrimary(const DbGetResult dbGroup)
|
|||||||
dbFree(dbGroup.primary);
|
dbFree(dbGroup.primary);
|
||||||
|
|
||||||
// Wait for the WAL to appear in the repo
|
// Wait for the WAL to appear in the repo
|
||||||
TimeMSec archiveTimeout = (TimeMSec)(cfgOptionDbl(cfgOptArchiveTimeout) * MSEC_PER_SEC);
|
TimeMSec archiveTimeout = cfgOptionUInt64(cfgOptArchiveTimeout);
|
||||||
const String *walSegmentFile = walSegmentFind(storageRepo(), archiveId, walSegment, archiveTimeout);
|
const String *walSegmentFile = walSegmentFind(storageRepo(), archiveId, walSegment, archiveTimeout);
|
||||||
|
|
||||||
LOG_INFO_FMT(
|
LOG_INFO_FMT(
|
||||||
|
@ -126,6 +126,13 @@ cmdOption(void)
|
|||||||
{
|
{
|
||||||
valueList = strLstNewVarLst(cfgOptionIdxLst(optionId, optionIdx));
|
valueList = strLstNewVarLst(cfgOptionIdxLst(optionId, optionIdx));
|
||||||
}
|
}
|
||||||
|
// Generate time value
|
||||||
|
else if (cfgDefOptionType(optionId) == cfgDefOptTypeTime)
|
||||||
|
{
|
||||||
|
valueList = strLstNew();
|
||||||
|
strLstAdd(
|
||||||
|
valueList, cvtDoubleToStr((double)cfgOptionIdxInt64(optionId, optionIdx) / MSEC_PER_SEC));
|
||||||
|
}
|
||||||
// Else only one value
|
// Else only one value
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -75,10 +75,11 @@ helpRenderText(const String *text, size_t indent, bool indentFirst, size_t lengt
|
|||||||
Helper function for helpRender() to output values as strings
|
Helper function for helpRender() to output values as strings
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
static const String *
|
static const String *
|
||||||
helpRenderValue(const Variant *value)
|
helpRenderValue(const Variant *value, ConfigDefineOptionType type)
|
||||||
{
|
{
|
||||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||||
FUNCTION_LOG_PARAM(VARIANT, value);
|
FUNCTION_LOG_PARAM(VARIANT, value);
|
||||||
|
FUNCTION_LOG_PARAM(ENUM, type);
|
||||||
FUNCTION_LOG_END();
|
FUNCTION_LOG_END();
|
||||||
|
|
||||||
const String *result = NULL;
|
const String *result = NULL;
|
||||||
@ -127,6 +128,8 @@ helpRenderValue(const Variant *value)
|
|||||||
|
|
||||||
result = resultTemp;
|
result = resultTemp;
|
||||||
}
|
}
|
||||||
|
else if (type == cfgDefOptTypeTime)
|
||||||
|
result = cvtDoubleToStr((double)varInt64(value) / MSEC_PER_SEC);
|
||||||
else
|
else
|
||||||
result = varStrForce(value);
|
result = varStrForce(value);
|
||||||
}
|
}
|
||||||
@ -259,11 +262,11 @@ helpRender(void)
|
|||||||
strlen(cfgDefOptionHelpSummary(commandId, optionId)) - 1));
|
strlen(cfgDefOptionHelpSummary(commandId, optionId)) - 1));
|
||||||
|
|
||||||
// Ouput current and default values if they exist
|
// Ouput current and default values if they exist
|
||||||
const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId));
|
const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId), cfgDefOptionType(optionId));
|
||||||
const String *value = NULL;
|
const String *value = NULL;
|
||||||
|
|
||||||
if (cfgOptionSource(optionId) != cfgSourceDefault)
|
if (cfgOptionSource(optionId) != cfgSourceDefault)
|
||||||
value = helpRenderValue(cfgOption(optionId));
|
value = helpRenderValue(cfgOption(optionId), cfgDefOptionType(optionId));
|
||||||
|
|
||||||
if (value != NULL || defaultValue != NULL)
|
if (value != NULL || defaultValue != NULL)
|
||||||
{
|
{
|
||||||
@ -329,11 +332,11 @@ helpRender(void)
|
|||||||
strZ(helpRenderText(STR(cfgDefOptionHelpDescription(commandId, option.id)), 0, true, CONSOLE_WIDTH)));
|
strZ(helpRenderText(STR(cfgDefOptionHelpDescription(commandId, option.id)), 0, true, CONSOLE_WIDTH)));
|
||||||
|
|
||||||
// Ouput current and default values if they exist
|
// Ouput current and default values if they exist
|
||||||
const String *defaultValue = helpRenderValue(cfgOptionDefault(option.id));
|
const String *defaultValue = helpRenderValue(cfgOptionDefault(option.id), cfgDefOptionType(option.id));
|
||||||
const String *value = NULL;
|
const String *value = NULL;
|
||||||
|
|
||||||
if (cfgOptionSource(option.id) != cfgSourceDefault)
|
if (cfgOptionSource(option.id) != cfgSourceDefault)
|
||||||
value = helpRenderValue(cfgOption(option.id));
|
value = helpRenderValue(cfgOption(option.id), cfgDefOptionType(option.id));
|
||||||
|
|
||||||
if (value != NULL || defaultValue != NULL)
|
if (value != NULL || defaultValue != NULL)
|
||||||
{
|
{
|
||||||
|
@ -31,9 +31,9 @@ cmdLocal(int fdRead, int fdWrite)
|
|||||||
varLstAdd(retryInterval, varNewUInt64(15000));
|
varLstAdd(retryInterval, varNewUInt64(15000));
|
||||||
|
|
||||||
String *name = strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u", cfgOptionUInt(cfgOptProcess));
|
String *name = strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u", cfgOptionUInt(cfgOptProcess));
|
||||||
IoRead *read = ioFdReadNew(name, fdRead, (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
|
IoRead *read = ioFdReadNew(name, fdRead, cfgOptionUInt64(cfgOptProtocolTimeout));
|
||||||
ioReadOpen(read);
|
ioReadOpen(read);
|
||||||
IoWrite *write = ioFdWriteNew(name, fdWrite, (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
|
IoWrite *write = ioFdWriteNew(name, fdWrite, cfgOptionUInt64(cfgOptProtocolTimeout));
|
||||||
ioWriteOpen(write);
|
ioWriteOpen(write);
|
||||||
|
|
||||||
ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_LOCAL_STR, read, write);
|
ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_LOCAL_STR, read, write);
|
||||||
|
@ -26,9 +26,9 @@ cmdRemote(int fdRead, int fdWrite)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
String *name = strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u", cfgOptionUInt(cfgOptProcess));
|
String *name = strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u", cfgOptionUInt(cfgOptProcess));
|
||||||
IoRead *read = ioFdReadNew(name, fdRead, (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
|
IoRead *read = ioFdReadNew(name, fdRead, cfgOptionUInt64(cfgOptProtocolTimeout));
|
||||||
ioReadOpen(read);
|
ioReadOpen(read);
|
||||||
IoWrite *write = ioFdWriteNew(name, fdWrite, (TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
|
IoWrite *write = ioFdWriteNew(name, fdWrite, cfgOptionUInt64(cfgOptProtocolTimeout));
|
||||||
ioWriteOpen(write);
|
ioWriteOpen(write);
|
||||||
|
|
||||||
ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_REMOTE_STR, read, write);
|
ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_REMOTE_STR, read, write);
|
||||||
|
@ -193,8 +193,7 @@ cmdStorageGet(void)
|
|||||||
{
|
{
|
||||||
TRY_BEGIN()
|
TRY_BEGIN()
|
||||||
{
|
{
|
||||||
result = storageGetProcess(
|
result = storageGetProcess(ioFdWriteNew(STRDEF("stdout"), STDOUT_FILENO, cfgOptionUInt64(cfgOptIoTimeout)));
|
||||||
ioFdWriteNew(STRDEF("stdout"), STDOUT_FILENO, (TimeMSec)(cfgOptionDbl(cfgOptIoTimeout) * 1000)));
|
|
||||||
}
|
}
|
||||||
// Ignore write errors because it's possible (even likely) that this output is being piped to something like head which
|
// Ignore write errors because it's possible (even likely) that this output is being piped to something like head which
|
||||||
// will exit when it gets what it needs and leave us writing to a broken pipe. It would be better to just ignore the broken
|
// will exit when it gets what it needs and leave us writing to a broken pipe. It would be better to just ignore the broken
|
||||||
|
@ -194,8 +194,7 @@ cmdStorageList(void)
|
|||||||
{
|
{
|
||||||
TRY_BEGIN()
|
TRY_BEGIN()
|
||||||
{
|
{
|
||||||
storageListRender(
|
storageListRender(ioFdWriteNew(STRDEF("stdout"), STDOUT_FILENO, cfgOptionUInt64(cfgOptIoTimeout)));
|
||||||
ioFdWriteNew(STRDEF("stdout"), STDOUT_FILENO, (TimeMSec)(cfgOptionDbl(cfgOptIoTimeout) * 1000)));
|
|
||||||
}
|
}
|
||||||
// Ignore write errors because it's possible (even likely) that this output is being piped to something like head which
|
// Ignore write errors because it's possible (even likely) that this output is being piped to something like head which
|
||||||
// will exit when it gets what it needs and leave us writing to a broken pipe. It would be better to just ignore the broken
|
// will exit when it gets what it needs and leave us writing to a broken pipe. It would be better to just ignore the broken
|
||||||
|
@ -2096,7 +2096,7 @@ cmdRestore(void)
|
|||||||
|
|
||||||
// Create the parallel executor
|
// Create the parallel executor
|
||||||
ProtocolParallel *parallelExec = protocolParallelNew(
|
ProtocolParallel *parallelExec = protocolParallelNew(
|
||||||
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * MSEC_PER_SEC) / 2, restoreJobCallback, &jobData);
|
cfgOptionUInt64(cfgOptProtocolTimeout) / 2, restoreJobCallback, &jobData);
|
||||||
|
|
||||||
for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++)
|
for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++)
|
||||||
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 0, processIdx));
|
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 0, processIdx));
|
||||||
|
@ -977,7 +977,7 @@ verifyProcess(unsigned int *errorTotal)
|
|||||||
|
|
||||||
// Create the parallel executor
|
// Create the parallel executor
|
||||||
ProtocolParallel *parallelExec = protocolParallelNew(
|
ProtocolParallel *parallelExec = protocolParallelNew(
|
||||||
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * MSEC_PER_SEC) / 2, verifyJobCallback, &jobData);
|
cfgOptionUInt64(cfgOptProtocolTimeout) / 2, verifyJobCallback, &jobData);
|
||||||
|
|
||||||
for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++)
|
for (unsigned int processIdx = 1; processIdx <= cfgOptionUInt(cfgOptProcessMax); processIdx++)
|
||||||
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 0, processIdx));
|
protocolParallelClientAdd(parallelExec, protocolLocalGet(protocolStorageTypeRepo, 0, processIdx));
|
||||||
|
@ -180,6 +180,19 @@ cvtDoubleToZ(double value, char *buffer, size_t bufferSize)
|
|||||||
FUNCTION_TEST_RETURN((size_t)(end - buffer + 1));
|
FUNCTION_TEST_RETURN((size_t)(end - buffer + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String *cvtDoubleToStr(double value)
|
||||||
|
{
|
||||||
|
FUNCTION_TEST_BEGIN();
|
||||||
|
FUNCTION_TEST_PARAM(DOUBLE, value);
|
||||||
|
FUNCTION_TEST_END();
|
||||||
|
|
||||||
|
char working[CVT_BASE10_BUFFER_SIZE];
|
||||||
|
|
||||||
|
cvtDoubleToZ(value, working, sizeof(working));
|
||||||
|
|
||||||
|
FUNCTION_TEST_RETURN(strNew(working));
|
||||||
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
cvtZToDouble(const char *value)
|
cvtZToDouble(const char *value)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,8 @@ Convert Base Data Types
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include "common/type/string.h"
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Required buffer sizes
|
Required buffer sizes
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
@ -20,8 +22,9 @@ Functions
|
|||||||
// Convert char to zero-terminated string
|
// Convert char to zero-terminated string
|
||||||
size_t cvtCharToZ(char value, char *buffer, size_t bufferSize);
|
size_t cvtCharToZ(char value, char *buffer, size_t bufferSize);
|
||||||
|
|
||||||
// Convert double to zero-terminated string and vice versa
|
// Convert double to zero-terminated string (or String) and vice versa
|
||||||
size_t cvtDoubleToZ(double value, char *buffer, size_t bufferSize);
|
size_t cvtDoubleToZ(double value, char *buffer, size_t bufferSize);
|
||||||
|
String *cvtDoubleToStr(double value);
|
||||||
double cvtZToDouble(const char *value);
|
double cvtZToDouble(const char *value);
|
||||||
|
|
||||||
// Convert int to zero-terminated string and vice versa
|
// Convert int to zero-terminated string and vice versa
|
||||||
|
@ -41,13 +41,6 @@ typedef struct VariantBool
|
|||||||
MemContext *memContext;
|
MemContext *memContext;
|
||||||
} VariantBool;
|
} VariantBool;
|
||||||
|
|
||||||
typedef struct VariantDouble
|
|
||||||
{
|
|
||||||
VARIANT_COMMON
|
|
||||||
VARIANT_DOUBLE_COMMON
|
|
||||||
MemContext *memContext;
|
|
||||||
} VariantDouble;
|
|
||||||
|
|
||||||
typedef struct VariantInt
|
typedef struct VariantInt
|
||||||
{
|
{
|
||||||
VARIANT_COMMON
|
VARIANT_COMMON
|
||||||
@ -103,7 +96,6 @@ Variant type names
|
|||||||
static const char *const variantTypeName[] =
|
static const char *const variantTypeName[] =
|
||||||
{
|
{
|
||||||
"bool", // varTypeBool
|
"bool", // varTypeBool
|
||||||
"double", // varTypeDouble,
|
|
||||||
"int", // varTypeInt
|
"int", // varTypeInt
|
||||||
"int64", // varTypeInt64
|
"int64", // varTypeInt64
|
||||||
"KeyValue", // varTypeKeyValue
|
"KeyValue", // varTypeKeyValue
|
||||||
@ -133,12 +125,6 @@ varDup(const Variant *this)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case varTypeDouble:
|
|
||||||
{
|
|
||||||
result = varNewDbl(varDbl(this));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeInt:
|
case varTypeInt:
|
||||||
{
|
{
|
||||||
result = varNewInt(varInt(this));
|
result = varNewInt(varInt(this));
|
||||||
@ -220,12 +206,6 @@ varEq(const Variant *this1, const Variant *this2)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case varTypeDouble:
|
|
||||||
{
|
|
||||||
result = varDbl(this1) == varDbl(this2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeInt:
|
case varTypeInt:
|
||||||
{
|
{
|
||||||
result = varInt(this1) == varInt(this2);
|
result = varInt(this1) == varInt(this2);
|
||||||
@ -383,103 +363,6 @@ varBoolForce(const Variant *this)
|
|||||||
FUNCTION_TEST_RETURN(result);
|
FUNCTION_TEST_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************************************************************/
|
|
||||||
Variant *
|
|
||||||
varNewDbl(double data)
|
|
||||||
{
|
|
||||||
FUNCTION_TEST_BEGIN();
|
|
||||||
FUNCTION_TEST_PARAM(DOUBLE, data);
|
|
||||||
FUNCTION_TEST_END();
|
|
||||||
|
|
||||||
// Allocate memory for the variant and set the type and data
|
|
||||||
VariantDouble *this = memNew(sizeof(VariantDouble));
|
|
||||||
|
|
||||||
*this = (VariantDouble)
|
|
||||||
{
|
|
||||||
.memContext = memContextCurrent(),
|
|
||||||
.type = varTypeDouble,
|
|
||||||
.data = data,
|
|
||||||
};
|
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN((Variant *)this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************************************************************************/
|
|
||||||
double
|
|
||||||
varDbl(const Variant *this)
|
|
||||||
{
|
|
||||||
FUNCTION_TEST_BEGIN();
|
|
||||||
FUNCTION_TEST_PARAM(VARIANT, this);
|
|
||||||
FUNCTION_TEST_END();
|
|
||||||
|
|
||||||
ASSERT(this != NULL);
|
|
||||||
ASSERT(this->type == varTypeDouble);
|
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(((VariantDouble *)this)->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
|
||||||
varDblForce(const Variant *this)
|
|
||||||
{
|
|
||||||
FUNCTION_TEST_BEGIN();
|
|
||||||
FUNCTION_TEST_PARAM(VARIANT, this);
|
|
||||||
FUNCTION_TEST_END();
|
|
||||||
|
|
||||||
ASSERT(this != NULL);
|
|
||||||
|
|
||||||
double result = 0;
|
|
||||||
|
|
||||||
switch (this->type)
|
|
||||||
{
|
|
||||||
case varTypeBool:
|
|
||||||
{
|
|
||||||
result = varBool(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeDouble:
|
|
||||||
{
|
|
||||||
result = varDbl(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeInt:
|
|
||||||
{
|
|
||||||
result = varInt(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeInt64:
|
|
||||||
{
|
|
||||||
result = (double)varInt64(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeString:
|
|
||||||
{
|
|
||||||
result = cvtZToDouble(strZ(varStr(this)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeUInt:
|
|
||||||
{
|
|
||||||
result = (double)varUInt(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeUInt64:
|
|
||||||
{
|
|
||||||
result = (double)varUInt64(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
THROW_FMT(AssertError, "unable to force %s to %s", variantTypeName[this->type], variantTypeName[varTypeDouble]);
|
|
||||||
}
|
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************************************************************************/
|
/**********************************************************************************************************************************/
|
||||||
Variant *
|
Variant *
|
||||||
varNewInt(int data)
|
varNewInt(int data)
|
||||||
@ -1046,15 +929,6 @@ varStrForce(const Variant *this)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case varTypeDouble:
|
|
||||||
{
|
|
||||||
char working[CVT_BASE10_BUFFER_SIZE];
|
|
||||||
|
|
||||||
cvtDoubleToZ(varDbl(this), working, sizeof(working));
|
|
||||||
result = strNew(working);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeInt:
|
case varTypeInt:
|
||||||
{
|
{
|
||||||
char working[CVT_BASE10_BUFFER_SIZE];
|
char working[CVT_BASE10_BUFFER_SIZE];
|
||||||
@ -1177,7 +1051,6 @@ varToLog(const Variant *this)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case varTypeBool:
|
case varTypeBool:
|
||||||
case varTypeDouble:
|
|
||||||
case varTypeInt:
|
case varTypeInt:
|
||||||
case varTypeInt64:
|
case varTypeInt64:
|
||||||
case varTypeUInt:
|
case varTypeUInt:
|
||||||
@ -1212,12 +1085,6 @@ varFree(Variant *this)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case varTypeDouble:
|
|
||||||
{
|
|
||||||
memContext = ((VariantDouble *)this)->memContext;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case varTypeInt:
|
case varTypeInt:
|
||||||
{
|
{
|
||||||
memContext = ((VariantInt *)this)->memContext;
|
memContext = ((VariantInt *)this)->memContext;
|
||||||
|
@ -34,7 +34,6 @@ Variant type
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
varTypeBool,
|
varTypeBool,
|
||||||
varTypeDouble,
|
|
||||||
varTypeInt,
|
varTypeInt,
|
||||||
varTypeInt64,
|
varTypeInt64,
|
||||||
varTypeKeyValue,
|
varTypeKeyValue,
|
||||||
@ -52,7 +51,6 @@ typedef enum
|
|||||||
Constructors
|
Constructors
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
Variant *varNewBool(bool data);
|
Variant *varNewBool(bool data);
|
||||||
Variant *varNewDbl(double data);
|
|
||||||
Variant *varNewInt(int data);
|
Variant *varNewInt(int data);
|
||||||
Variant *varNewInt64(int64_t data);
|
Variant *varNewInt64(int64_t data);
|
||||||
|
|
||||||
@ -83,9 +81,6 @@ Getters/Setters
|
|||||||
bool varBool(const Variant *this);
|
bool varBool(const Variant *this);
|
||||||
bool varBoolForce(const Variant *this);
|
bool varBoolForce(const Variant *this);
|
||||||
|
|
||||||
double varDbl(const Variant *this);
|
|
||||||
double varDblForce(const Variant *this);
|
|
||||||
|
|
||||||
int varInt(const Variant *this);
|
int varInt(const Variant *this);
|
||||||
int varIntForce(const Variant *this);
|
int varIntForce(const Variant *this);
|
||||||
|
|
||||||
@ -128,15 +123,6 @@ typedef struct VariantBoolConst
|
|||||||
const VARIANT_BOOL_COMMON
|
const VARIANT_BOOL_COMMON
|
||||||
} VariantBoolConst;
|
} VariantBoolConst;
|
||||||
|
|
||||||
#define VARIANT_DOUBLE_COMMON \
|
|
||||||
double data; /* Double data */
|
|
||||||
|
|
||||||
typedef struct VariantDoubleConst
|
|
||||||
{
|
|
||||||
VARIANT_COMMON
|
|
||||||
const VARIANT_DOUBLE_COMMON
|
|
||||||
} VariantDoubleConst;
|
|
||||||
|
|
||||||
#define VARIANT_INT_COMMON \
|
#define VARIANT_INT_COMMON \
|
||||||
int data; /* Signed integer data */
|
int data; /* Signed integer data */
|
||||||
|
|
||||||
@ -196,10 +182,6 @@ By convention all variant constant identifiers are appended with _VAR.
|
|||||||
#define VARBOOL(dataParam) \
|
#define VARBOOL(dataParam) \
|
||||||
((const Variant *)&(const VariantBoolConst){.type = varTypeBool, .data = dataParam})
|
((const Variant *)&(const VariantBoolConst){.type = varTypeBool, .data = dataParam})
|
||||||
|
|
||||||
// Create a Double Variant constant inline from a double
|
|
||||||
#define VARDBL(dataParam) \
|
|
||||||
((const Variant *)&(const VariantDoubleConst){.type = varTypeDouble, .data = dataParam})
|
|
||||||
|
|
||||||
// Create an Int Variant constant inline from an int
|
// Create an Int Variant constant inline from an int
|
||||||
#define VARINT(dataParam) \
|
#define VARINT(dataParam) \
|
||||||
((const Variant *)&(const VariantIntConst){.type = varTypeInt, .data = dataParam})
|
((const Variant *)&(const VariantIntConst){.type = varTypeInt, .data = dataParam})
|
||||||
|
@ -564,14 +564,9 @@ cfgOptionDefaultValue(ConfigOption optionId)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cfgDefOptTypeFloat:
|
|
||||||
{
|
|
||||||
result = varNewDbl(varDblForce(defaultValue));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case cfgDefOptTypeInteger:
|
case cfgDefOptTypeInteger:
|
||||||
case cfgDefOptTypeSize:
|
case cfgDefOptTypeSize:
|
||||||
|
case cfgDefOptTypeTime:
|
||||||
{
|
{
|
||||||
result = varNewInt64(varInt64Force(defaultValue));
|
result = varNewInt64(varInt64Force(defaultValue));
|
||||||
break;
|
break;
|
||||||
@ -942,16 +937,6 @@ cfgOptionIdxBool(ConfigOption optionId, unsigned int optionIdx)
|
|||||||
FUNCTION_LOG_RETURN(BOOL, varBool(cfgOptionIdxInternal(optionId, optionIdx, varTypeBool, false)));
|
FUNCTION_LOG_RETURN(BOOL, varBool(cfgOptionIdxInternal(optionId, optionIdx, varTypeBool, false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
|
||||||
cfgOptionDbl(ConfigOption optionId)
|
|
||||||
{
|
|
||||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
|
||||||
FUNCTION_LOG_PARAM(ENUM, optionId);
|
|
||||||
FUNCTION_LOG_END();
|
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN(DOUBLE, varDbl(cfgOptionIdxInternal(optionId, cfgOptionIdxDefault(optionId), varTypeDouble, false)));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
cfgOptionInt(ConfigOption optionId)
|
cfgOptionInt(ConfigOption optionId)
|
||||||
{
|
{
|
||||||
@ -1185,18 +1170,9 @@ cfgOptionIdxSet(ConfigOption optionId, unsigned int optionIdx, ConfigSource sour
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cfgDefOptTypeFloat:
|
|
||||||
{
|
|
||||||
if (varType(value) == varTypeDouble)
|
|
||||||
configLocal->option[optionId].index[optionIdx].value = varDup(value);
|
|
||||||
else
|
|
||||||
configLocal->option[optionId].index[optionIdx].value = varNewDbl(varDblForce(value));
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case cfgDefOptTypeInteger:
|
case cfgDefOptTypeInteger:
|
||||||
case cfgDefOptTypeSize:
|
case cfgDefOptTypeSize:
|
||||||
|
case cfgDefOptTypeTime:
|
||||||
{
|
{
|
||||||
if (varType(value) == varTypeInt64)
|
if (varType(value) == varTypeInt64)
|
||||||
configLocal->option[optionId].index[optionIdx].value = varDup(value);
|
configLocal->option[optionId].index[optionIdx].value = varDup(value);
|
||||||
|
@ -122,7 +122,6 @@ const Variant *cfgOption(ConfigOption optionId);
|
|||||||
const Variant *cfgOptionIdx(ConfigOption optionId, unsigned int optionIdx);
|
const Variant *cfgOptionIdx(ConfigOption optionId, unsigned int optionIdx);
|
||||||
bool cfgOptionBool(ConfigOption optionId);
|
bool cfgOptionBool(ConfigOption optionId);
|
||||||
bool cfgOptionIdxBool(ConfigOption optionId, unsigned int optionIdx);
|
bool cfgOptionIdxBool(ConfigOption optionId, unsigned int optionIdx);
|
||||||
double cfgOptionDbl(ConfigOption optionId);
|
|
||||||
int cfgOptionInt(ConfigOption optionId);
|
int cfgOptionInt(ConfigOption optionId);
|
||||||
int cfgOptionIdxInt(ConfigOption optionId, unsigned int optionIdx);
|
int cfgOptionIdxInt(ConfigOption optionId, unsigned int optionIdx);
|
||||||
int64_t cfgOptionInt64(ConfigOption optionId);
|
int64_t cfgOptionInt64(ConfigOption optionId);
|
||||||
|
@ -563,7 +563,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
|||||||
CFGDEFDATA_OPTION_NAME("archive-timeout")
|
CFGDEFDATA_OPTION_NAME("archive-timeout")
|
||||||
CFGDEFDATA_OPTION_REQUIRED(true)
|
CFGDEFDATA_OPTION_REQUIRED(true)
|
||||||
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
||||||
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeFloat)
|
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeTime)
|
||||||
CFGDEFDATA_OPTION_INTERNAL(false)
|
CFGDEFDATA_OPTION_INTERNAL(false)
|
||||||
|
|
||||||
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
||||||
@ -588,8 +588,8 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
|||||||
|
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||||
(
|
(
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0.1, 86400)
|
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(100, 86400000)
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("60")
|
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("60000")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1127,7 +1127,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
|||||||
CFGDEFDATA_OPTION_NAME("db-timeout")
|
CFGDEFDATA_OPTION_NAME("db-timeout")
|
||||||
CFGDEFDATA_OPTION_REQUIRED(true)
|
CFGDEFDATA_OPTION_REQUIRED(true)
|
||||||
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
||||||
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeFloat)
|
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeTime)
|
||||||
CFGDEFDATA_OPTION_INTERNAL(false)
|
CFGDEFDATA_OPTION_INTERNAL(false)
|
||||||
|
|
||||||
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
||||||
@ -1162,8 +1162,8 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
|||||||
|
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||||
(
|
(
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0.1, 604800)
|
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(100, 604800000)
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("1800")
|
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("1800000")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1517,7 +1517,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
|||||||
CFGDEFDATA_OPTION_NAME("io-timeout")
|
CFGDEFDATA_OPTION_NAME("io-timeout")
|
||||||
CFGDEFDATA_OPTION_REQUIRED(true)
|
CFGDEFDATA_OPTION_REQUIRED(true)
|
||||||
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
||||||
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeFloat)
|
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeTime)
|
||||||
CFGDEFDATA_OPTION_INTERNAL(false)
|
CFGDEFDATA_OPTION_INTERNAL(false)
|
||||||
|
|
||||||
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
||||||
@ -1555,8 +1555,8 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
|||||||
|
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||||
(
|
(
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0.1, 3600)
|
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(100, 3600000)
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("60")
|
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("60000")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -2910,7 +2910,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
|||||||
CFGDEFDATA_OPTION_NAME("protocol-timeout")
|
CFGDEFDATA_OPTION_NAME("protocol-timeout")
|
||||||
CFGDEFDATA_OPTION_REQUIRED(true)
|
CFGDEFDATA_OPTION_REQUIRED(true)
|
||||||
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
||||||
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeFloat)
|
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeTime)
|
||||||
CFGDEFDATA_OPTION_INTERNAL(false)
|
CFGDEFDATA_OPTION_INTERNAL(false)
|
||||||
|
|
||||||
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
||||||
@ -2946,8 +2946,8 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
|||||||
|
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||||
(
|
(
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0.1, 604800)
|
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(100, 604800000)
|
||||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("1830")
|
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("1830000")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@ Option type define enum
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
cfgDefOptTypeBoolean,
|
cfgDefOptTypeBoolean,
|
||||||
cfgDefOptTypeFloat,
|
|
||||||
cfgDefOptTypeHash,
|
cfgDefOptTypeHash,
|
||||||
cfgDefOptTypeInteger,
|
cfgDefOptTypeInteger,
|
||||||
cfgDefOptTypeList,
|
cfgDefOptTypeList,
|
||||||
cfgDefOptTypePath,
|
cfgDefOptTypePath,
|
||||||
cfgDefOptTypeSize,
|
cfgDefOptTypeSize,
|
||||||
cfgDefOptTypeString,
|
cfgDefOptTypeString,
|
||||||
|
cfgDefOptTypeTime,
|
||||||
} ConfigDefineOptionType;
|
} ConfigDefineOptionType;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -138,10 +138,10 @@ typedef enum
|
|||||||
#define CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(rangeMinParam, rangeMaxParam) \
|
#define CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(rangeMinParam, rangeMaxParam) \
|
||||||
CFGDATA_OPTION_OPTIONAL_PUSH_LIST( \
|
CFGDATA_OPTION_OPTIONAL_PUSH_LIST( \
|
||||||
configDefDataTypeAllowRange, 4, 0, \
|
configDefDataTypeAllowRange, 4, 0, \
|
||||||
(const void *)(intptr_t)(int32_t)(((int64_t)((double)rangeMinParam * 100)) % 1000000000L), \
|
(const void *)(intptr_t)(int32_t)((int64_t)rangeMinParam >> 32), \
|
||||||
(const void *)(intptr_t)(int32_t)(((int64_t)((double)rangeMinParam * 100)) / 1000000000L), \
|
(const void *)(intptr_t)(int32_t)((int64_t)rangeMinParam & 0xFFFFFFFF), \
|
||||||
(const void *)(intptr_t)(int32_t)(((int64_t)((double)rangeMaxParam * 100)) % 1000000000L), \
|
(const void *)(intptr_t)(int32_t)((int64_t)rangeMaxParam >> 32), \
|
||||||
(const void *)(intptr_t)(int32_t)(((int64_t)((double)rangeMaxParam * 100)) / 1000000000L)),
|
(const void *)(intptr_t)(int32_t)((int64_t)rangeMaxParam & 0xFFFFFFFF)),
|
||||||
|
|
||||||
#define CFGDEFDATA_OPTION_OPTIONAL_DEPEND(optionDepend) \
|
#define CFGDEFDATA_OPTION_OPTIONAL_DEPEND(optionDepend) \
|
||||||
CFGDATA_OPTION_OPTIONAL_PUSH(configDefDataTypeDepend, 0, optionDepend),
|
CFGDATA_OPTION_OPTIONAL_PUSH(configDefDataTypeDepend, 0, optionDepend),
|
||||||
@ -391,7 +391,7 @@ cfgDefOptionAllowRange(ConfigCommand commandId, ConfigOption optionId)
|
|||||||
FUNCTION_TEST_RETURN(dataDefFound);
|
FUNCTION_TEST_RETURN(dataDefFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
int64_t
|
||||||
cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId)
|
cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId)
|
||||||
{
|
{
|
||||||
FUNCTION_TEST_BEGIN();
|
FUNCTION_TEST_BEGIN();
|
||||||
@ -404,11 +404,10 @@ cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId)
|
|||||||
|
|
||||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange);
|
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(
|
FUNCTION_TEST_RETURN((int64_t)(intptr_t)dataDefList[2] << 32 | (int64_t)(intptr_t)dataDefList[3]);
|
||||||
((double)(((int64_t)(intptr_t)dataDefList[2]) + (((int64_t)(intptr_t)dataDefList[3]) * 1000000000L))) / 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
int64_t
|
||||||
cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId)
|
cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId)
|
||||||
{
|
{
|
||||||
FUNCTION_TEST_BEGIN();
|
FUNCTION_TEST_BEGIN();
|
||||||
@ -421,8 +420,7 @@ cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId)
|
|||||||
|
|
||||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange);
|
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange);
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(
|
FUNCTION_TEST_RETURN((int64_t)(intptr_t)dataDefList[0] << 32 | (int64_t)(intptr_t)dataDefList[1]);
|
||||||
((double)(((int64_t)(intptr_t)dataDefList[0]) + (((int64_t)(intptr_t)dataDefList[1]) * 1000000000L))) / 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************************************************************/
|
/**********************************************************************************************************************************/
|
||||||
|
@ -42,8 +42,8 @@ bool cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigOption optio
|
|||||||
|
|
||||||
// Allow range
|
// Allow range
|
||||||
bool cfgDefOptionAllowRange(ConfigCommand commandId, ConfigOption optionId);
|
bool cfgDefOptionAllowRange(ConfigCommand commandId, ConfigOption optionId);
|
||||||
double cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId);
|
int64_t cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId);
|
||||||
double cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId);
|
int64_t cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId);
|
||||||
|
|
||||||
// Default value for the option
|
// Default value for the option
|
||||||
const char *cfgDefOptionDefault(ConfigCommand commandId, ConfigOption optionId);
|
const char *cfgDefOptionDefault(ConfigCommand commandId, ConfigOption optionId);
|
||||||
|
@ -109,6 +109,11 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key
|
|||||||
{
|
{
|
||||||
valueList = strLstNewVarLst(varVarLst(value));
|
valueList = strLstNewVarLst(varVarLst(value));
|
||||||
}
|
}
|
||||||
|
else if (cfgDefOptionType(optionId) == cfgDefOptTypeTime)
|
||||||
|
{
|
||||||
|
valueList = strLstNew();
|
||||||
|
strLstAdd(valueList, cvtDoubleToStr((double)varInt64(value) / MSEC_PER_SEC));
|
||||||
|
}
|
||||||
// Else only one value
|
// Else only one value
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -76,23 +76,26 @@ cfgLoadUpdateOption(void)
|
|||||||
|
|
||||||
// Protocol timeout should be greater than db timeout
|
// Protocol timeout should be greater than db timeout
|
||||||
if (cfgOptionTest(cfgOptDbTimeout) && cfgOptionTest(cfgOptProtocolTimeout) &&
|
if (cfgOptionTest(cfgOptDbTimeout) && cfgOptionTest(cfgOptProtocolTimeout) &&
|
||||||
cfgOptionDbl(cfgOptProtocolTimeout) <= cfgOptionDbl(cfgOptDbTimeout))
|
cfgOptionInt64(cfgOptProtocolTimeout) <= cfgOptionInt64(cfgOptDbTimeout))
|
||||||
{
|
{
|
||||||
// If protocol-timeout is default then increase it to be greater than db-timeout
|
// If protocol-timeout is default then increase it to be greater than db-timeout
|
||||||
if (cfgOptionSource(cfgOptProtocolTimeout) == cfgSourceDefault)
|
if (cfgOptionSource(cfgOptProtocolTimeout) == cfgSourceDefault)
|
||||||
cfgOptionSet(cfgOptProtocolTimeout, cfgSourceDefault, VARDBL(cfgOptionDbl(cfgOptDbTimeout) + 30));
|
{
|
||||||
|
cfgOptionSet(
|
||||||
|
cfgOptProtocolTimeout, cfgSourceDefault, VARINT64(cfgOptionInt64(cfgOptDbTimeout) + (int64_t)(30 * MSEC_PER_SEC)));
|
||||||
|
}
|
||||||
else if (cfgOptionSource(cfgOptDbTimeout) == cfgSourceDefault)
|
else if (cfgOptionSource(cfgOptDbTimeout) == cfgSourceDefault)
|
||||||
{
|
{
|
||||||
double dbTimeout = cfgOptionDbl(cfgOptProtocolTimeout) - 30;
|
int64_t dbTimeout = cfgOptionInt64(cfgOptProtocolTimeout) - (int64_t)(30 * MSEC_PER_SEC);
|
||||||
|
|
||||||
// Normally the protocol time will be greater than 45 seconds so db timeout can be at least 15 seconds
|
// Normally the protocol time will be greater than 45 seconds so db timeout can be at least 15 seconds
|
||||||
if (dbTimeout >= 15)
|
if (dbTimeout >= (int64_t)(15 * MSEC_PER_SEC))
|
||||||
{
|
{
|
||||||
cfgOptionSet(cfgOptDbTimeout, cfgSourceDefault, VARDBL(dbTimeout));
|
cfgOptionSet(cfgOptDbTimeout, cfgSourceDefault, VARINT64(dbTimeout));
|
||||||
}
|
}
|
||||||
// But in some test cases the protocol timeout will be very small so make db timeout half of protocol timeout
|
// But in some test cases the protocol timeout will be very small so make db timeout half of protocol timeout
|
||||||
else
|
else
|
||||||
cfgOptionSet(cfgOptDbTimeout, cfgSourceDefault, VARDBL(cfgOptionDbl(cfgOptProtocolTimeout) / 2));
|
cfgOptionSet(cfgOptDbTimeout, cfgSourceDefault, VARINT64(cfgOptionInt64(cfgOptProtocolTimeout) / 2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -355,7 +358,7 @@ cfgLoad(unsigned int argListSize, const char *argList[])
|
|||||||
|
|
||||||
// Set IO timeout
|
// Set IO timeout
|
||||||
if (cfgOptionValid(cfgOptIoTimeout))
|
if (cfgOptionValid(cfgOptIoTimeout))
|
||||||
ioTimeoutMsSet((TimeMSec)(cfgOptionDbl(cfgOptIoTimeout) * MSEC_PER_SEC));
|
ioTimeoutMsSet(cfgOptionUInt64(cfgOptIoTimeout));
|
||||||
|
|
||||||
// Open the log file if this command logs to a file
|
// Open the log file if this command logs to a file
|
||||||
cfgLoadLogFile();
|
cfgLoadLogFile();
|
||||||
|
@ -195,16 +195,16 @@ cfgParseOption(const String *optionName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Convert the value passed into bytes and update valueDbl for range checking
|
Generate multiplier based on character
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
static double
|
static uint64_t
|
||||||
sizeQualifierToMultiplier(char qualifier)
|
sizeQualifierToMultiplier(char qualifier)
|
||||||
{
|
{
|
||||||
FUNCTION_TEST_BEGIN();
|
FUNCTION_TEST_BEGIN();
|
||||||
FUNCTION_TEST_PARAM(CHAR, qualifier);
|
FUNCTION_TEST_PARAM(CHAR, qualifier);
|
||||||
FUNCTION_TEST_END();
|
FUNCTION_TEST_END();
|
||||||
|
|
||||||
double result;
|
uint64_t result;
|
||||||
|
|
||||||
switch (qualifier)
|
switch (qualifier)
|
||||||
{
|
{
|
||||||
@ -251,25 +251,24 @@ sizeQualifierToMultiplier(char qualifier)
|
|||||||
FUNCTION_TEST_RETURN(result);
|
FUNCTION_TEST_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static uint64_t
|
||||||
convertToByte(String **value, double *valueDbl)
|
convertToByte(const String *value)
|
||||||
{
|
{
|
||||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
FUNCTION_TEST_BEGIN();
|
||||||
FUNCTION_LOG_PARAM_P(STRING, value);
|
FUNCTION_TEST_PARAM(STRING, value);
|
||||||
FUNCTION_LOG_PARAM_P(DOUBLE, valueDbl);
|
FUNCTION_TEST_END();
|
||||||
FUNCTION_LOG_END();
|
|
||||||
|
|
||||||
ASSERT(valueDbl != NULL);
|
ASSERT(value != NULL);
|
||||||
|
|
||||||
// Make a copy of the value so it is not updated until we know the conversion will succeed
|
// Lowercase the value
|
||||||
String *result = strLower(strDup(*value));
|
String *valueLower = strLower(strDup(value));
|
||||||
|
|
||||||
// Match the value against possible values
|
// Match the value against possible values
|
||||||
if (regExpMatchOne(STRDEF("^[0-9]+(kb|k|mb|m|gb|g|tb|t|pb|p|b)*$"), result))
|
if (regExpMatchOne(STRDEF("^[0-9]+(kb|k|mb|m|gb|g|tb|t|pb|p|b)*$"), valueLower))
|
||||||
{
|
{
|
||||||
// Get the character array and size
|
// Get the character array and size
|
||||||
const char *strArray = strZ(result);
|
const char *strArray = strZ(valueLower);
|
||||||
size_t size = strSize(result);
|
size_t size = strSize(valueLower);
|
||||||
int chrPos = -1;
|
int chrPos = -1;
|
||||||
|
|
||||||
// If there is a 'b' on the end, then see if the previous character is a number
|
// If there is a 'b' on the end, then see if the previous character is a number
|
||||||
@ -287,7 +286,7 @@ convertToByte(String **value, double *valueDbl)
|
|||||||
else if (strArray[size - 1] > '9')
|
else if (strArray[size - 1] > '9')
|
||||||
chrPos = (int)(size - 1);
|
chrPos = (int)(size - 1);
|
||||||
|
|
||||||
double multiplier = 1;
|
uint64_t multiplier = 1;
|
||||||
|
|
||||||
// If a letter was found calculate multiplier, else do nothing since assumed value is already in bytes
|
// If a letter was found calculate multiplier, else do nothing since assumed value is already in bytes
|
||||||
if (chrPos != -1)
|
if (chrPos != -1)
|
||||||
@ -295,21 +294,14 @@ convertToByte(String **value, double *valueDbl)
|
|||||||
multiplier = sizeQualifierToMultiplier(strArray[chrPos]);
|
multiplier = sizeQualifierToMultiplier(strArray[chrPos]);
|
||||||
|
|
||||||
// Remove any letters
|
// Remove any letters
|
||||||
strTrunc(result, chrPos);
|
strTrunc(valueLower, chrPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert string to bytes
|
// Convert string to bytes
|
||||||
double newDbl = varDblForce(VARSTR(result)) * multiplier;
|
FUNCTION_TEST_RETURN(cvtZToUInt64(strZ(valueLower)) * multiplier);
|
||||||
result = varStrForce(VARDBL(newDbl));
|
|
||||||
|
|
||||||
// If nothing has blown up then safe to overwrite the original values
|
|
||||||
*valueDbl = newDbl;
|
|
||||||
*value = result;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
THROW_FMT(FormatError, "value '%s' is not valid", strZ(*value));
|
THROW_FMT(FormatError, "value '%s' is not valid", strZ(value));
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN_VOID();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
@ -1269,12 +1261,13 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
String *value = strLstGet(parseOptionValue->valueList, 0);
|
String *value = strLstGet(parseOptionValue->valueList, 0);
|
||||||
|
const String *valueAllow = value;
|
||||||
|
|
||||||
// If a numeric type check that the value is valid
|
// If a numeric type check that the value is valid
|
||||||
if (optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeFloat ||
|
if (optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeSize ||
|
||||||
optionDefType == cfgDefOptTypeSize)
|
optionDefType == cfgDefOptTypeTime)
|
||||||
{
|
{
|
||||||
double valueDbl = 0;
|
int64_t valueInt64 = 0;
|
||||||
|
|
||||||
// Check that the value can be converted
|
// Check that the value can be converted
|
||||||
TRY_BEGIN()
|
TRY_BEGIN()
|
||||||
@ -1287,27 +1280,31 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
|
|||||||
}
|
}
|
||||||
MEM_CONTEXT_END();
|
MEM_CONTEXT_END();
|
||||||
|
|
||||||
valueDbl = (double)varInt64(configOptionValue->value);
|
valueInt64 = varInt64(configOptionValue->value);
|
||||||
}
|
}
|
||||||
else if (optionDefType == cfgDefOptTypeSize)
|
else if (optionDefType == cfgDefOptTypeSize)
|
||||||
{
|
{
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
|
|
||||||
MEM_CONTEXT_BEGIN(config->memContext)
|
MEM_CONTEXT_BEGIN(config->memContext)
|
||||||
{
|
{
|
||||||
configOptionValue->value = varNewInt64((int64_t)valueDbl);
|
configOptionValue->value = varNewInt64((int64_t)convertToByte(value));
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_END();
|
MEM_CONTEXT_END();
|
||||||
|
|
||||||
|
valueInt64 = varInt64(configOptionValue->value);
|
||||||
|
valueAllow = varStrForce(configOptionValue->value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ASSERT(optionDefType == cfgDefOptTypeTime);
|
||||||
|
|
||||||
MEM_CONTEXT_BEGIN(config->memContext)
|
MEM_CONTEXT_BEGIN(config->memContext)
|
||||||
{
|
{
|
||||||
configOptionValue->value = varNewDbl(cvtZToDouble(strZ(value)));
|
configOptionValue->value = varNewInt64(
|
||||||
|
(int64_t)(cvtZToDouble(strZ(value)) * MSEC_PER_SEC));
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_END();
|
MEM_CONTEXT_END();
|
||||||
|
|
||||||
valueDbl = varDbl(configOptionValue->value);
|
valueInt64 = varInt64(configOptionValue->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CATCH_ANY()
|
CATCH_ANY()
|
||||||
@ -1320,8 +1317,8 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
|
|||||||
|
|
||||||
// Check value range
|
// Check value range
|
||||||
if (cfgDefOptionAllowRange(config->command, optionId) &&
|
if (cfgDefOptionAllowRange(config->command, optionId) &&
|
||||||
(valueDbl < cfgDefOptionAllowRangeMin(config->command, optionId) ||
|
(valueInt64 < cfgDefOptionAllowRangeMin(config->command, optionId) ||
|
||||||
valueDbl > cfgDefOptionAllowRangeMax(config->command, optionId)))
|
valueInt64 > cfgDefOptionAllowRangeMax(config->command, optionId)))
|
||||||
{
|
{
|
||||||
THROW_FMT(
|
THROW_FMT(
|
||||||
OptionInvalidValueError, "'%s' is out of range for '%s' option", strZ(value),
|
OptionInvalidValueError, "'%s' is out of range for '%s' option", strZ(value),
|
||||||
@ -1371,7 +1368,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
|
|||||||
|
|
||||||
// If the option has an allow list then check it
|
// If the option has an allow list then check it
|
||||||
if (cfgDefOptionAllowList(config->command, optionId) &&
|
if (cfgDefOptionAllowList(config->command, optionId) &&
|
||||||
!cfgDefOptionAllowListValueValid(config->command, optionId, strZ(value)))
|
!cfgDefOptionAllowListValueValid(config->command, optionId, strZ(valueAllow)))
|
||||||
{
|
{
|
||||||
THROW_FMT(
|
THROW_FMT(
|
||||||
OptionInvalidValueError, "'%s' is not allowed for '%s' option", strZ(value),
|
OptionInvalidValueError, "'%s' is not allowed for '%s' option", strZ(value),
|
||||||
@ -1397,15 +1394,15 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
|
|||||||
// represented as constants so they can be assigned directly without creating variants.
|
// represented as constants so they can be assigned directly without creating variants.
|
||||||
if (optionDefType == cfgDefOptTypeBoolean)
|
if (optionDefType == cfgDefOptTypeBoolean)
|
||||||
configOptionValue->value = strcmp(value, ONE_Z) == 0 ? BOOL_TRUE_VAR : BOOL_FALSE_VAR;
|
configOptionValue->value = strcmp(value, ONE_Z) == 0 ? BOOL_TRUE_VAR : BOOL_FALSE_VAR;
|
||||||
else if (optionDefType == cfgDefOptTypeFloat)
|
else if (optionDefType == cfgDefOptTypePath || optionDefType == cfgDefOptTypeString)
|
||||||
configOptionValue->value = varNewDbl(cvtZToDouble(value));
|
configOptionValue->value = varNewStrZ(value);
|
||||||
else if (optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeSize)
|
|
||||||
configOptionValue->value = varNewInt64(cvtZToInt64(value));
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(optionDefType == cfgDefOptTypePath || optionDefType == cfgDefOptTypeString);
|
ASSERT(
|
||||||
|
optionDefType == cfgDefOptTypeInteger || optionDefType == cfgDefOptTypeSize ||
|
||||||
|
optionDefType == cfgDefOptTypeTime);
|
||||||
|
|
||||||
configOptionValue->value = varNewStrZ(value);
|
configOptionValue->value = varNewInt64(cvtZToInt64(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MEM_CONTEXT_END();
|
MEM_CONTEXT_END();
|
||||||
|
@ -32,7 +32,7 @@ dbGetIdx(unsigned int pgIdx)
|
|||||||
pgClientNew(
|
pgClientNew(
|
||||||
cfgOptionIdxStrNull(cfgOptPgSocketPath, pgIdx), cfgOptionIdxUInt(cfgOptPgPort, pgIdx),
|
cfgOptionIdxStrNull(cfgOptPgSocketPath, pgIdx), cfgOptionIdxUInt(cfgOptPgPort, pgIdx),
|
||||||
cfgOptionIdxStr(cfgOptPgDatabase, pgIdx), cfgOptionIdxStrNull(cfgOptPgUser, pgIdx),
|
cfgOptionIdxStr(cfgOptPgDatabase, pgIdx), cfgOptionIdxStrNull(cfgOptPgUser, pgIdx),
|
||||||
(TimeMSec)(cfgOptionDbl(cfgOptDbTimeout) * MSEC_PER_SEC)),
|
cfgOptionUInt64(cfgOptDbTimeout)),
|
||||||
NULL, applicationName);
|
NULL, applicationName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -65,7 +65,7 @@ dbProtocol(const String *command, const VariantList *paramList, ProtocolServer *
|
|||||||
// Only a single db is passed to the remote
|
// Only a single db is passed to the remote
|
||||||
PgClient *pgClient = pgClientNew(
|
PgClient *pgClient = pgClientNew(
|
||||||
cfgOptionStrNull(cfgOptPgSocketPath), cfgOptionUInt(cfgOptPgPort), cfgOptionStr(cfgOptPgDatabase),
|
cfgOptionStrNull(cfgOptPgSocketPath), cfgOptionUInt(cfgOptPgPort), cfgOptionStr(cfgOptPgDatabase),
|
||||||
cfgOptionStrNull(cfgOptPgUser), (TimeMSec)(cfgOptionDbl(cfgOptDbTimeout) * MSEC_PER_SEC));
|
cfgOptionStrNull(cfgOptPgUser), cfgOptionUInt64(cfgOptDbTimeout));
|
||||||
pgClientOpen(pgClient);
|
pgClientOpen(pgClient);
|
||||||
|
|
||||||
lstAdd(dbProtocolLocal.pgClientList, &pgClient);
|
lstAdd(dbProtocolLocal.pgClientList, &pgClient);
|
||||||
|
@ -203,8 +203,7 @@ protocolLocalGet(ProtocolStorageType protocolStorageType, unsigned int hostIdx,
|
|||||||
// Execute the protocol command
|
// Execute the protocol command
|
||||||
protocolHelperClient->exec = execNew(
|
protocolHelperClient->exec = execNew(
|
||||||
cfgExe(), protocolLocalParam(protocolStorageType, hostIdx, processId),
|
cfgExe(), protocolLocalParam(protocolStorageType, hostIdx, processId),
|
||||||
strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u process", processId),
|
strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u process", processId), cfgOptionUInt64(cfgOptProtocolTimeout));
|
||||||
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
|
|
||||||
execOpen(protocolHelperClient->exec);
|
execOpen(protocolHelperClient->exec);
|
||||||
|
|
||||||
// Create protocol object
|
// Create protocol object
|
||||||
@ -517,7 +516,7 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostIdx)
|
|||||||
protocolHelperClient->exec = execNew(
|
protocolHelperClient->exec = execNew(
|
||||||
cfgOptionStr(cfgOptCmdSsh), protocolRemoteParam(protocolStorageType, hostIdx),
|
cfgOptionStr(cfgOptCmdSsh), protocolRemoteParam(protocolStorageType, hostIdx),
|
||||||
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u process on '%s'", processId, strZ(cfgOptionIdxStr(optHost, hostIdx))),
|
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u process on '%s'", processId, strZ(cfgOptionIdxStr(optHost, hostIdx))),
|
||||||
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
|
cfgOptionUInt64(cfgOptProtocolTimeout));
|
||||||
execOpen(protocolHelperClient->exec);
|
execOpen(protocolHelperClient->exec);
|
||||||
|
|
||||||
// Create protocol object
|
// Create protocol object
|
||||||
|
@ -178,7 +178,7 @@ unit:
|
|||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------------------------------
|
||||||
- name: type-variant
|
- name: type-variant
|
||||||
total: 13
|
total: 12
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
common/type/variant: full
|
common/type/variant: full
|
||||||
|
@ -264,7 +264,7 @@ testBackupPqScript(unsigned int pgVersion, time_t backupTimeStart, TestBackupPqS
|
|||||||
PgControl pgControl = pgControlFromFile(storagePg());
|
PgControl pgControl = pgControlFromFile(storagePg());
|
||||||
|
|
||||||
// Set archive timeout really small to save time on errors
|
// Set archive timeout really small to save time on errors
|
||||||
cfgOptionSet(cfgOptArchiveTimeout, cfgSourceParam, varNewDbl(.1));
|
cfgOptionSet(cfgOptArchiveTimeout, cfgSourceParam, varNewInt64(100));
|
||||||
|
|
||||||
uint64_t lsnStart = ((uint64_t)backupTimeStart & 0xFFFFFF00) << 28;
|
uint64_t lsnStart = ((uint64_t)backupTimeStart & 0xFFFFFF00) << 28;
|
||||||
uint64_t lsnStop =
|
uint64_t lsnStop =
|
||||||
|
@ -29,6 +29,7 @@ testRun(void)
|
|||||||
strLstAddZ(argList, PROJECT_BIN);
|
strLstAddZ(argList, PROJECT_BIN);
|
||||||
hrnCfgArgRawZ(argList, cfgOptStanza, "test");
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test");
|
||||||
hrnCfgArgRawBool(argList, cfgOptArchiveAsync, true);
|
hrnCfgArgRawBool(argList, cfgOptArchiveAsync, true);
|
||||||
|
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, "10");
|
||||||
hrnCfgArgRawZ(argList, cfgOptPgPath, "/pg1");
|
hrnCfgArgRawZ(argList, cfgOptPgPath, "/pg1");
|
||||||
strLstAddZ(argList, CFGCMD_ARCHIVE_GET);
|
strLstAddZ(argList, CFGCMD_ARCHIVE_GET);
|
||||||
strLstAddZ(argList, "param1");
|
strLstAddZ(argList, "param1");
|
||||||
@ -36,8 +37,8 @@ testRun(void)
|
|||||||
|
|
||||||
TEST_RESULT_VOID(cmdBegin(), "command begin with command parameter");
|
TEST_RESULT_VOID(cmdBegin(), "command begin with command parameter");
|
||||||
harnessLogResult(
|
harnessLogResult(
|
||||||
"P00 INFO: archive-get command begin " PROJECT_VERSION ": [param1] --archive-async --exec-id=1-test --pg1-path=/pg1"
|
"P00 INFO: archive-get command begin " PROJECT_VERSION ": [param1] --archive-async --archive-timeout=10"
|
||||||
" --stanza=test");
|
" --exec-id=1-test --pg1-path=/pg1 --stanza=test");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("multiple parameters");
|
TEST_TITLE("multiple parameters");
|
||||||
|
@ -71,11 +71,11 @@ testRun(void)
|
|||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
if (testBegin("helpRenderValue()"))
|
if (testBegin("helpRenderValue()"))
|
||||||
{
|
{
|
||||||
TEST_RESULT_STR_Z(helpRenderValue(varNewBool(true)), "y", "boolean y");
|
TEST_RESULT_STR_Z(helpRenderValue(varNewBool(true), cfgDefOptTypeBoolean), "y", "boolean y");
|
||||||
TEST_RESULT_STR_Z(helpRenderValue(varNewBool(false)), "n", "boolean n");
|
TEST_RESULT_STR_Z(helpRenderValue(varNewBool(false), cfgDefOptTypeBoolean), "n", "boolean n");
|
||||||
TEST_RESULT_STR_Z(helpRenderValue(varNewStrZ("test-string")), "test-string", "string");
|
TEST_RESULT_STR_Z(helpRenderValue(varNewStrZ("test-string"), cfgDefOptTypeString), "test-string", "string");
|
||||||
TEST_RESULT_STR_Z(helpRenderValue(varNewDbl(1.234)), "1.234", "double");
|
TEST_RESULT_STR_Z(helpRenderValue(varNewInt64(1234), cfgDefOptTypeInteger), "1234", "int");
|
||||||
TEST_RESULT_STR_Z(helpRenderValue(varNewInt(1234)), "1234", "int");
|
TEST_RESULT_STR_Z(helpRenderValue(varNewInt64(1234000), cfgDefOptTypeTime), "1234", "time");
|
||||||
}
|
}
|
||||||
|
|
||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
|
@ -45,6 +45,8 @@ testRun(void)
|
|||||||
TEST_RESULT_UINT(cvtDoubleToZ(999.1234, buffer, STACK_TRACE_PARAM_MAX), 8, "convert double to string");
|
TEST_RESULT_UINT(cvtDoubleToZ(999.1234, buffer, STACK_TRACE_PARAM_MAX), 8, "convert double to string");
|
||||||
TEST_RESULT_Z(buffer, "999.1234", " check buffer");
|
TEST_RESULT_Z(buffer, "999.1234", " check buffer");
|
||||||
|
|
||||||
|
TEST_RESULT_STR_Z(cvtDoubleToStr(999.1), "999.1", "convert double to string");
|
||||||
|
|
||||||
TEST_RESULT_UINT(cvtDoubleToZ(999999999.123456, buffer, STACK_TRACE_PARAM_MAX), 16, "convert double to string");
|
TEST_RESULT_UINT(cvtDoubleToZ(999999999.123456, buffer, STACK_TRACE_PARAM_MAX), 16, "convert double to string");
|
||||||
TEST_RESULT_Z(buffer, "999999999.123456", " check buffer");
|
TEST_RESULT_Z(buffer, "999999999.123456", " check buffer");
|
||||||
|
|
||||||
|
@ -52,43 +52,6 @@ testRun(void)
|
|||||||
TEST_RESULT_BOOL(varEq(BOOL_FALSE_VAR, BOOL_TRUE_VAR), false, "bool, bool not eq");
|
TEST_RESULT_BOOL(varEq(BOOL_FALSE_VAR, BOOL_TRUE_VAR), false, "bool, bool not eq");
|
||||||
}
|
}
|
||||||
|
|
||||||
// *****************************************************************************************************************************
|
|
||||||
if (testBegin("double"))
|
|
||||||
{
|
|
||||||
// Ensure type sizes are as expected
|
|
||||||
TEST_RESULT_UINT(sizeof(VariantDoubleConst), TEST_64BIT() ? 16 : 12, "check VariantDoubleConst size");
|
|
||||||
TEST_RESULT_UINT(sizeof(VariantDouble), TEST_64BIT() ? 24 : 16, "check VariantDouble size");
|
|
||||||
|
|
||||||
Variant *var = varNewDbl(44.44);
|
|
||||||
TEST_RESULT_DOUBLE(varDbl(var), 44.44, "double variant");
|
|
||||||
varFree(var);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
|
||||||
TEST_ERROR(varDbl(varNewStrZ("string")), AssertError, "assertion 'this->type == varTypeDouble' failed");
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
|
||||||
TEST_RESULT_DOUBLE(varDblForce(VARDBL(4.567)), 4.567, "force double to double");
|
|
||||||
TEST_RESULT_DOUBLE(varDblForce(varNewBool(false)), 0, "force bool to double");
|
|
||||||
TEST_RESULT_DOUBLE(varDblForce(VARINT(123)), 123, "force int to double");
|
|
||||||
TEST_RESULT_DOUBLE(varDblForce(VARINT64(999999999999)), 999999999999, "force int64 to double");
|
|
||||||
TEST_RESULT_DOUBLE(varDblForce(VARUINT64(9223372036854775807U)), 9223372036854775807.0, "force uint64 to double");
|
|
||||||
TEST_RESULT_DOUBLE(varDblForce(VARUINT(992)), 992, "force uint to double");
|
|
||||||
TEST_RESULT_DOUBLE(varDblForce(VARSTRDEF("879.01")), 879.01, "force String to double");
|
|
||||||
TEST_RESULT_DOUBLE(varDblForce(VARSTRDEF("0")), 0, "force String to double");
|
|
||||||
TEST_RESULT_DOUBLE(
|
|
||||||
varDblForce(VARUINT64(UINT64_MAX)), 18446744073709551616.0, "force max uint64 to double (it will be rounded)");
|
|
||||||
|
|
||||||
TEST_ERROR(varDblForce(VARSTRDEF("AAA")), FormatError, "unable to convert string 'AAA' to double");
|
|
||||||
TEST_ERROR(varDblForce(varNewVarLst(varLstNew())), AssertError, "unable to force VariantList to double");
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
|
||||||
TEST_RESULT_DOUBLE(varDbl(varDup(VARDBL(3.1415))), 3.1415, "dup double");
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
|
||||||
TEST_RESULT_BOOL(varEq(VARDBL(1.234), VARDBL(1.234)), true, "double, double eq");
|
|
||||||
TEST_RESULT_BOOL(varEq(VARDBL(4.321), VARDBL(1.234)), false, "double, double not eq");
|
|
||||||
}
|
|
||||||
|
|
||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
if (testBegin("int"))
|
if (testBegin("int"))
|
||||||
{
|
{
|
||||||
@ -324,7 +287,6 @@ testRun(void)
|
|||||||
TEST_RESULT_STR_Z(varStrForce(VARSTRDEF("teststring")), "teststring", "force string to string");
|
TEST_RESULT_STR_Z(varStrForce(VARSTRDEF("teststring")), "teststring", "force string to string");
|
||||||
TEST_RESULT_STR_Z(varStrForce(VARINT(999)), "999", "force int to string");
|
TEST_RESULT_STR_Z(varStrForce(VARINT(999)), "999", "force int to string");
|
||||||
TEST_RESULT_STR_Z(varStrForce(VARINT64(9223372036854775807L)), "9223372036854775807", "force int64 to string");
|
TEST_RESULT_STR_Z(varStrForce(VARINT64(9223372036854775807L)), "9223372036854775807", "force int64 to string");
|
||||||
TEST_RESULT_STR_Z(varStrForce(VARDBL((double)999999999.123456)), "999999999.123456", "force double to string");
|
|
||||||
TEST_RESULT_STR_Z(varStrForce(varNewBool(true)), "true", "force bool to string");
|
TEST_RESULT_STR_Z(varStrForce(varNewBool(true)), "true", "force bool to string");
|
||||||
TEST_RESULT_STR_Z(varStrForce(varNewBool(false)), "false", "force bool to string");
|
TEST_RESULT_STR_Z(varStrForce(varNewBool(false)), "false", "force bool to string");
|
||||||
TEST_RESULT_STR_Z(varStrForce(VARUINT64(18446744073709551615U)), "18446744073709551615", "force uint64 to string");
|
TEST_RESULT_STR_Z(varStrForce(VARUINT64(18446744073709551615U)), "18446744073709551615", "force uint64 to string");
|
||||||
|
@ -44,11 +44,10 @@ testRun(void)
|
|||||||
TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgOptCompressLevel), true, "range allowed");
|
TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgOptCompressLevel), true, "range allowed");
|
||||||
TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgOptRepoHost), false, "range not allowed");
|
TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgOptRepoHost), false, "range not allowed");
|
||||||
|
|
||||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdBackup, cfgOptDbTimeout), 0.1, "range min");
|
TEST_RESULT_INT(cfgDefOptionAllowRangeMin(cfgCmdBackup, cfgOptDbTimeout), 100, "range min");
|
||||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMax(cfgCmdBackup, cfgOptCompressLevel), 9, "range max");
|
TEST_RESULT_INT(cfgDefOptionAllowRangeMax(cfgCmdBackup, cfgOptCompressLevel), 9, "range max");
|
||||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdArchivePush, cfgOptArchivePushQueueMax), 0, "range min");
|
TEST_RESULT_INT(cfgDefOptionAllowRangeMin(cfgCmdArchivePush, cfgOptArchivePushQueueMax), 0, "range min");
|
||||||
TEST_RESULT_DOUBLE(
|
TEST_RESULT_INT(cfgDefOptionAllowRangeMax(cfgCmdArchivePush, cfgOptArchivePushQueueMax), 4503599627370496, "range max");
|
||||||
cfgDefOptionAllowRangeMax(cfgCmdArchivePush, cfgOptArchivePushQueueMax), 4503599627370496, "range max");
|
|
||||||
|
|
||||||
TEST_ERROR(
|
TEST_ERROR(
|
||||||
cfgDefOptionDefault(cfgDefCommandTotal(), cfgOptCompressLevel), AssertError,
|
cfgDefOptionDefault(cfgDefCommandTotal(), cfgOptCompressLevel), AssertError,
|
||||||
|
@ -17,6 +17,7 @@ testRun(void)
|
|||||||
StringList *argList = strLstNew();
|
StringList *argList = strLstNew();
|
||||||
strLstAddZ(argList, "pgbackrest");
|
strLstAddZ(argList, "pgbackrest");
|
||||||
strLstAddZ(argList, "--stanza=test1");
|
strLstAddZ(argList, "--stanza=test1");
|
||||||
|
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, "5");
|
||||||
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
|
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
|
||||||
strLstAdd(argList, strNewFmt("--pg1-path=%s/db path", testPath()));
|
strLstAdd(argList, strNewFmt("--pg1-path=%s/db path", testPath()));
|
||||||
strLstAddZ(argList, "--pg2-path=/db2");
|
strLstAddZ(argList, "--pg2-path=/db2");
|
||||||
@ -35,16 +36,16 @@ testRun(void)
|
|||||||
TEST_RESULT_STR(
|
TEST_RESULT_STR(
|
||||||
strLstJoin(cfgExecParam(cfgCmdArchiveGet, cfgCmdRoleAsync, NULL, false, true), "|"),
|
strLstJoin(cfgExecParam(cfgCmdArchiveGet, cfgCmdRoleAsync, NULL, false, true), "|"),
|
||||||
strNewFmt(
|
strNewFmt(
|
||||||
"--archive-async|--no-config|--exec-id=1-test|--log-subprocess|--reset-neutral-umask|--pg1-path=\"%s/db path\""
|
"--archive-async|--archive-timeout=5|--no-config|--exec-id=1-test|--log-subprocess|--reset-neutral-umask"
|
||||||
"|--pg2-path=/db2|--repo1-path=%s/repo|--stanza=test1|archive-get:async",
|
"|--pg1-path=\"%s/db path\"|--pg2-path=/db2|--repo1-path=%s/repo|--stanza=test1|archive-get:async",
|
||||||
testPath(), testPath()),
|
testPath(), testPath()),
|
||||||
"exec archive-get -> archive-get:async");
|
"exec archive-get -> archive-get:async");
|
||||||
|
|
||||||
TEST_RESULT_STR(
|
TEST_RESULT_STR(
|
||||||
strLstJoin(cfgExecParam(cfgCmdBackup, cfgCmdRoleDefault, NULL, false, false), "|"),
|
strLstJoin(cfgExecParam(cfgCmdBackup, cfgCmdRoleDefault, NULL, false, false), "|"),
|
||||||
strNewFmt(
|
strNewFmt(
|
||||||
"--no-config|--exec-id=1-test|--log-subprocess|--reset-neutral-umask|--pg1-path=%s/db path|--pg2-path=/db2"
|
"--archive-timeout=5|--no-config|--exec-id=1-test|--log-subprocess|--reset-neutral-umask|--pg1-path=%s/db path"
|
||||||
"|--repo1-path=%s/repo|--stanza=test1|backup",
|
"|--pg2-path=/db2|--repo1-path=%s/repo|--stanza=test1|backup",
|
||||||
testPath(), testPath()),
|
testPath(), testPath()),
|
||||||
"exec archive-get -> backup");
|
"exec archive-get -> backup");
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ testRun(void)
|
|||||||
cfgOptionInvalidate(cfgOptProtocolTimeout);
|
cfgOptionInvalidate(cfgOptProtocolTimeout);
|
||||||
cfgLoadUpdateOption();
|
cfgLoadUpdateOption();
|
||||||
|
|
||||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptDbTimeout), 100, "check db-timeout");
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptDbTimeout), 100000, "check db-timeout");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("protocol-timeout set but not db timeout");
|
TEST_TITLE("protocol-timeout set but not db timeout");
|
||||||
@ -90,7 +90,7 @@ testRun(void)
|
|||||||
cfgOptionInvalidate(cfgOptDbTimeout);
|
cfgOptionInvalidate(cfgOptDbTimeout);
|
||||||
cfgLoadUpdateOption();
|
cfgLoadUpdateOption();
|
||||||
|
|
||||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 100, "check protocol-timeout");
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptProtocolTimeout), 100000, "check protocol-timeout");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("protocol-timeout set automatically");
|
TEST_TITLE("protocol-timeout set automatically");
|
||||||
@ -101,7 +101,7 @@ testRun(void)
|
|||||||
hrnCfgArgRawZ(argList, cfgOptDbTimeout, "100000");
|
hrnCfgArgRawZ(argList, cfgOptDbTimeout, "100000");
|
||||||
harnessCfgLoad(cfgCmdCheck, argList);
|
harnessCfgLoad(cfgCmdCheck, argList);
|
||||||
|
|
||||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 100030, "check protocol-timeout");
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptProtocolTimeout), 100030000, "check protocol-timeout");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("error when db-timeout and protocol-timeout set but invalid");
|
TEST_TITLE("error when db-timeout and protocol-timeout set but invalid");
|
||||||
@ -113,8 +113,8 @@ testRun(void)
|
|||||||
hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, "50.5");
|
hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, "50.5");
|
||||||
TEST_ERROR(
|
TEST_ERROR(
|
||||||
harnessCfgLoad(cfgCmdCheck, argList), OptionInvalidValueError,
|
harnessCfgLoad(cfgCmdCheck, argList), OptionInvalidValueError,
|
||||||
"'50.5' is not valid for 'protocol-timeout' option\n"
|
"'50500' is not valid for 'protocol-timeout' option\n"
|
||||||
"HINT 'protocol-timeout' option (50.5) should be greater than 'db-timeout' option (100000).");
|
"HINT 'protocol-timeout' option (50500) should be greater than 'db-timeout' option (100000000).");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("very small protocol-timeout triggers db-timeout special handling");
|
TEST_TITLE("very small protocol-timeout triggers db-timeout special handling");
|
||||||
@ -125,8 +125,8 @@ testRun(void)
|
|||||||
hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, "11");
|
hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, "11");
|
||||||
harnessCfgLoad(cfgCmdCheck, argList);
|
harnessCfgLoad(cfgCmdCheck, argList);
|
||||||
|
|
||||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 11, "check protocol-timeout");
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptProtocolTimeout), 11000, "check protocol-timeout");
|
||||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptDbTimeout), 5.5, "check db-timeout");
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptDbTimeout), 5500, "check db-timeout");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("pg and repo cannot both be remote");
|
TEST_TITLE("pg and repo cannot both be remote");
|
||||||
|
@ -536,84 +536,14 @@ testRun(void)
|
|||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
if (testBegin("convertToByte()"))
|
if (testBegin("convertToByte()"))
|
||||||
{
|
{
|
||||||
double valueDbl = 0;
|
|
||||||
String *value = strNew("10.0");
|
|
||||||
|
|
||||||
TEST_ERROR(sizeQualifierToMultiplier('w'), AssertError, "'w' is not a valid size qualifier");
|
TEST_ERROR(sizeQualifierToMultiplier('w'), AssertError, "'w' is not a valid size qualifier");
|
||||||
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value '10.0' is not valid");
|
TEST_RESULT_UINT(convertToByte(STRDEF("10B")), 10, "10B");
|
||||||
strTrunc(value, strChr(value, '.'));
|
TEST_RESULT_UINT(convertToByte(STRDEF("1k")), 1024, "1k");
|
||||||
strCatZ(value, "K2");
|
TEST_RESULT_UINT(convertToByte(STRDEF("5G")), (uint64_t)5 * 1024 * 1024 * 1024, "5G");
|
||||||
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value '10K2' is not valid");
|
TEST_RESULT_UINT(convertToByte(STRDEF("3Tb")), (uint64_t)3 * 1024 * 1024 * 1024 * 1024, "3Tb");
|
||||||
strTrunc(value, strChr(value, '1'));
|
TEST_RESULT_UINT(convertToByte(STRDEF("11")), 11, "11 - no qualifier, default bytes");
|
||||||
strCatZ(value, "ab");
|
TEST_RESULT_UINT(convertToByte(STRDEF("4pB")), 4503599627370496, "4pB");
|
||||||
TEST_ERROR(convertToByte(&value, &valueDbl), FormatError, "value 'ab' is not valid");
|
TEST_RESULT_UINT(convertToByte(STRDEF("15MB")), (uint64_t)15 * 1024 * 1024, "15MB");
|
||||||
|
|
||||||
strTrunc(value, strChr(value, 'a'));
|
|
||||||
strCatZ(value, "10");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl no character identifier - straight to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "10", "value no character identifier - straight to bytes");
|
|
||||||
|
|
||||||
strCatZ(value, "B");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10, "valueDbl B to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "10", "value B to bytes");
|
|
||||||
|
|
||||||
strCatZ(value, "Kb");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl KB to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "10240", "value KB to bytes");
|
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '2'));
|
|
||||||
strCatZ(value, "k");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10240, "valueDbl k to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "10240", "value k to bytes");
|
|
||||||
|
|
||||||
strCatZ(value, "pB");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 11529215046068469760U, "valueDbl Pb to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "11529215046068469760", "value Pb to bytes");
|
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '5'));
|
|
||||||
strCatZ(value, "GB");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl GB to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "11811160064", "value GB to bytes");
|
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '8'));
|
|
||||||
strCatZ(value, "g");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 11811160064U, "valueDbl g to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "11811160064", "value g to bytes");
|
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '8'));
|
|
||||||
strCatZ(value, "T");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 12094627905536U, "valueDbl T to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "12094627905536", "value T to bytes");
|
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '0'));
|
|
||||||
strCatZ(value, "tb");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 13194139533312U, "valueDbl tb to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "13194139533312", "value tb to bytes");
|
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '3'));
|
|
||||||
strCatZ(value, "0m");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10485760, "valueDbl m to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "10485760", "value m to bytes");
|
|
||||||
|
|
||||||
strCatZ(value, "mb");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_DOUBLE(valueDbl, 10995116277760U, "valueDbl mb to bytes");
|
|
||||||
TEST_RESULT_STR_Z(value, "10995116277760", "value mb to bytes");
|
|
||||||
|
|
||||||
strTrunc(value, strChr(value, '0'));
|
|
||||||
strCatZ(value, "99999999999999999999p");
|
|
||||||
convertToByte(&value, &valueDbl);
|
|
||||||
TEST_RESULT_STR_Z(value, "225179981368524800000000000000000000", "value really large to bytes");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
@ -763,9 +693,9 @@ testRun(void)
|
|||||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||||
strLstAdd(argList, strNew("--stanza=db"));
|
strLstAdd(argList, strNew("--stanza=db"));
|
||||||
strLstAdd(argList, strNew("--manifest-save-threshold=199999999999999999999p"));
|
strLstAdd(argList, strNew("--manifest-save-threshold=9999999999999999999p"));
|
||||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||||
"'225179981368524800000000000000000000' is out of range for 'manifest-save-threshold' option");
|
"'9999999999999999999p' is out of range for 'manifest-save-threshold' option");
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------------------
|
||||||
argList = strLstNew();
|
argList = strLstNew();
|
||||||
@ -1299,6 +1229,7 @@ testRun(void)
|
|||||||
"pg1-path=/not/path/to/db\n"
|
"pg1-path=/not/path/to/db\n"
|
||||||
"backup-standby=y\n"
|
"backup-standby=y\n"
|
||||||
"buffer-size=65536\n"
|
"buffer-size=65536\n"
|
||||||
|
"protocol-timeout=3600\n"
|
||||||
"\n"
|
"\n"
|
||||||
"[db:backup]\n"
|
"[db:backup]\n"
|
||||||
"delta=n\n"
|
"delta=n\n"
|
||||||
@ -1361,7 +1292,8 @@ testRun(void)
|
|||||||
TEST_RESULT_INT(cfgOptionSource(cfgOptDelta), cfgSourceConfig, " delta is source config");
|
TEST_RESULT_INT(cfgOptionSource(cfgOptDelta), cfgSourceConfig, " delta is source config");
|
||||||
TEST_RESULT_INT(cfgOptionInt64(cfgOptBufferSize), 65536, " buffer-size is set");
|
TEST_RESULT_INT(cfgOptionInt64(cfgOptBufferSize), 65536, " buffer-size is set");
|
||||||
TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceConfig, " backup-standby is source config");
|
TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceConfig, " backup-standby is source config");
|
||||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptDbTimeout), 1800, " db-timeout is set");
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptDbTimeout), 1800000, " db-timeout is set");
|
||||||
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptProtocolTimeout), 3600000, " protocol-timeout is set");
|
||||||
TEST_RESULT_UINT(cfgOptionIdxUInt(cfgOptPgPort, 1), 5432, " pg2-port is set");
|
TEST_RESULT_UINT(cfgOptionIdxUInt(cfgOptPgPort, 1), 5432, " pg2-port is set");
|
||||||
TEST_RESULT_UINT(cfgOptionIdxUInt64(cfgOptPgPort, 1), 5432, " pg2-port is set");
|
TEST_RESULT_UINT(cfgOptionIdxUInt64(cfgOptPgPort, 1), 5432, " pg2-port is set");
|
||||||
TEST_RESULT_STR(cfgOptionIdxStrNull(cfgOptPgHost, 1), NULL, " pg2-host is NULL");
|
TEST_RESULT_STR(cfgOptionIdxStrNull(cfgOptPgHost, 1), NULL, " pg2-host is NULL");
|
||||||
@ -1373,15 +1305,15 @@ testRun(void)
|
|||||||
TEST_RESULT_PTR(cfgOptionDefault(cfgOptPgHost), NULL, " pg-host default is NULL");
|
TEST_RESULT_PTR(cfgOptionDefault(cfgOptPgHost), NULL, " pg-host default is NULL");
|
||||||
TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptLogLevelConsole)), "warn", " log-level-console default is warn");
|
TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptLogLevelConsole)), "warn", " log-level-console default is warn");
|
||||||
TEST_RESULT_INT(varInt64(cfgOptionDefault(cfgOptPgPort)), 5432, " pg-port default is 5432");
|
TEST_RESULT_INT(varInt64(cfgOptionDefault(cfgOptPgPort)), 5432, " pg-port default is 5432");
|
||||||
TEST_RESULT_DOUBLE(varDbl(cfgOptionDefault(cfgOptDbTimeout)), 1800, " db-timeout default is 1800");
|
TEST_RESULT_INT(varInt64(cfgOptionDefault(cfgOptDbTimeout)), 1800000, " db-timeout default is 1800000");
|
||||||
|
|
||||||
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, VARSTRDEF("/default")), " set pg-socket-path default");
|
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, VARSTRDEF("/default")), " set pg-socket-path default");
|
||||||
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgSocketPath, 0), "/path/to/socket", " pg1-socket-path unchanged");
|
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgSocketPath, 0), "/path/to/socket", " pg1-socket-path unchanged");
|
||||||
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgSocketPath, 1), "/default", " pg2-socket-path is new default");
|
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgSocketPath, 1), "/default", " pg2-socket-path is new default");
|
||||||
|
|
||||||
TEST_ERROR(cfgOptionDefaultValue(cfgOptDbInclude), AssertError, "default value not available for option type 4");
|
TEST_ERROR(cfgOptionDefaultValue(cfgOptDbInclude), AssertError, "default value not available for option type 3");
|
||||||
TEST_ERROR(cfgOptionLst(cfgOptDbInclude), AssertError, "option 'db-include' is not valid for the current command");
|
TEST_ERROR(cfgOptionLst(cfgOptDbInclude), AssertError, "option 'db-include' is not valid for the current command");
|
||||||
TEST_ERROR(cfgOptionKv(cfgOptPgPath), AssertError, "option 'pg2-path' is type 5 but 4 was requested");
|
TEST_ERROR(cfgOptionKv(cfgOptPgPath), AssertError, "option 'pg2-path' is type 4 but 3 was requested");
|
||||||
|
|
||||||
TEST_RESULT_VOID(cfgOptionInvalidate(cfgOptPgPath), " invalidate pg-path");
|
TEST_RESULT_VOID(cfgOptionInvalidate(cfgOptPgPath), " invalidate pg-path");
|
||||||
TEST_RESULT_BOOL(cfgOptionValid(cfgOptPgPath), false, " pg-path no longer valid");
|
TEST_RESULT_BOOL(cfgOptionValid(cfgOptPgPath), false, " pg-path no longer valid");
|
||||||
@ -1539,17 +1471,17 @@ testRun(void)
|
|||||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptForce, cfgSourceParam, VARBOOL(false)), "set force false");
|
TEST_RESULT_VOID(cfgOptionSet(cfgOptForce, cfgSourceParam, VARBOOL(false)), "set force false");
|
||||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptForce), false, "check force");
|
TEST_RESULT_BOOL(cfgOptionBool(cfgOptForce), false, "check force");
|
||||||
|
|
||||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, VARINT(1)), "set protocol-timeout to 1");
|
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, VARINT64(1000)), "set protocol-timeout to 1");
|
||||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 1, "check protocol-timeout");
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptProtocolTimeout), 1000, "check protocol-timeout");
|
||||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, VARDBL(2.2)), "set protocol-timeout to 2.2");
|
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, VARINT64(2200)), "set protocol-timeout to 2.2");
|
||||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 2.2, "check protocol-timeout");
|
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptProtocolTimeout), 2200, "check protocol-timeout");
|
||||||
|
|
||||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProcessMax, cfgSourceParam, VARINT(50)), "set process-max to 50");
|
TEST_RESULT_VOID(cfgOptionSet(cfgOptProcessMax, cfgSourceParam, VARINT(50)), "set process-max to 50");
|
||||||
TEST_RESULT_INT(cfgOptionInt(cfgOptProcessMax), 50, "check process-max");
|
TEST_RESULT_INT(cfgOptionInt(cfgOptProcessMax), 50, "check process-max");
|
||||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProcessMax, cfgSourceParam, VARINT64(51)), "set process-max to 51");
|
TEST_RESULT_VOID(cfgOptionSet(cfgOptProcessMax, cfgSourceParam, VARINT64(51)), "set process-max to 51");
|
||||||
TEST_RESULT_INT(cfgOptionInt(cfgOptProcessMax), 51, "check process-max");
|
TEST_RESULT_INT(cfgOptionInt(cfgOptProcessMax), 51, "check process-max");
|
||||||
|
|
||||||
TEST_ERROR(cfgOptionSet(cfgOptDbInclude, cfgSourceParam, VARINT(1)), AssertError, "set not available for option type 4");
|
TEST_ERROR(cfgOptionSet(cfgOptDbInclude, cfgSourceParam, VARINT(1)), AssertError, "set not available for option type 3");
|
||||||
|
|
||||||
TEST_ERROR(
|
TEST_ERROR(
|
||||||
cfgOptionIdxSet(cfgOptPgPath, 0, cfgSourceParam, VARINT(1)), AssertError,
|
cfgOptionIdxSet(cfgOptPgPath, 0, cfgSourceParam, VARINT(1)), AssertError,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user