You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-07 00:35:37 +02:00
Prepare configuration module for multi-repository support.
Refactor the code to allow a dynamic number of indexes for indexed options, e.g. pg-path. Our reliance on getopt_long() still limits the number of indexes we can have per group, but once this limitation is removed the rest of the code should be happy with dynamic numbers of indexes (with a reasonable maximum). Add an option to set a default in each group. This was previously handled by the host-id option but now there is a specific option for each group, pg and repo. These remain internal until they can be fully tested with multi-repo support. They are fully tested for internal usage. Remove the ConfigDefineOption enum and use the ConfigOption enum instead. They are now equal since the indexed options (e.g. cfgOptRepoHost2) have been removed from ConfigOption. Remove the config/config test module and add required tests to the config/parse test module. Parsing is now the only way to load a config so this removes some redundancy. Split new internal config structures and functions into a new header file, config.intern.h. More functions will need to be moved over from config.h but that will need to be done in a future commit to reduce churn. Add repoIdx to repoIsLocal() and storageRepo*(). Multi-repository support requires that repo locality and storage be accessible by index. This allows, for example, multiple repos to be iterated in a loop. This could be done in a separate commit but doesn't seem worth it since the code is related. Remove the type parameter from storageRepoGet(). This parameter existed solely to provide coverage for the case where the storage type was invalid. A better pattern is to check that the type is S3 once all other types have been ruled out.
This commit is contained in:
@ -19,7 +19,6 @@ use pgBackRestDoc::Common::String;
|
||||
use pgBackRestDoc::ProjectInfo;
|
||||
|
||||
use pgBackRestBuild::Build::Common;
|
||||
use pgBackRestBuild::Config::BuildDefine;
|
||||
use pgBackRestBuild::Config::Data;
|
||||
|
||||
####################################################################################################################################
|
||||
@ -36,8 +35,9 @@ use constant BLDLCL_CONSTANT_OPTION_TOTAL => 'CFG_OPTI
|
||||
|
||||
use constant BLDLCL_DATA_COMMAND_CONSTANT => '01-commandConstant';
|
||||
use constant BLDLCL_DATA_COMMAND => '02-command';
|
||||
use constant BLDLCL_DATA_OPTION_CONSTANT => '03-optionConstant';
|
||||
use constant BLDLCL_DATA_OPTION => '04-option';
|
||||
use constant BLDLCL_DATA_OPTION_GROUP => '03-optionGroup';
|
||||
use constant BLDLCL_DATA_OPTION_CONSTANT => '04-optionConstant';
|
||||
use constant BLDLCL_DATA_OPTION => '05-option';
|
||||
|
||||
use constant BLDLCL_ENUM_COMMAND => '01-enumCommand';
|
||||
use constant BLDLCL_ENUM_OPTION_GROUP => '02-enumOptionGroup';
|
||||
@ -107,6 +107,11 @@ my $rhBuild =
|
||||
&BLD_SUMMARY => 'Command data',
|
||||
},
|
||||
|
||||
&BLDLCL_DATA_OPTION_GROUP =>
|
||||
{
|
||||
&BLD_SUMMARY => 'Option group data',
|
||||
},
|
||||
|
||||
&BLDLCL_DATA_OPTION_CONSTANT =>
|
||||
{
|
||||
&BLD_SUMMARY => 'Option constants',
|
||||
@ -224,14 +229,31 @@ sub buildConfig
|
||||
$rhEnum = $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_ENUM}{&BLDLCL_ENUM_OPTION_GROUP};
|
||||
my $iGroupTotal = 0;
|
||||
|
||||
$strBuildSource =
|
||||
'static ConfigOptionGroupData configOptionGroupData[' . BLDLCL_CONSTANT_OPTION_GROUP_TOTAL . "] = \n" .
|
||||
"{";
|
||||
|
||||
foreach my $strGroup (sort(keys(%{$rhOptionGroupDefine})))
|
||||
{
|
||||
my $strGroupEnum = buildConfigOptionGroupEnum($strGroup);
|
||||
push(@{$rhEnum->{&BLD_LIST}}, $strGroupEnum);
|
||||
|
||||
$strBuildSource .=
|
||||
"\n" .
|
||||
" // ${strGroupEnum}\n" .
|
||||
" //" . (qw{-} x 126) . "\n" .
|
||||
" {\n" .
|
||||
" .name = \"" . $strGroup . "\"\n" .
|
||||
" },\n";
|
||||
|
||||
$iGroupTotal++;
|
||||
}
|
||||
|
||||
$strBuildSource .=
|
||||
"};\n";
|
||||
|
||||
$rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_DATA}{&BLDLCL_DATA_OPTION_GROUP}{&BLD_SOURCE} = $strBuildSource;
|
||||
|
||||
# Set option total constant
|
||||
$rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_CONSTANT_GROUP}{&BLDLCL_CONSTANT_OPTION_GROUP}{&BLD_CONSTANT}
|
||||
{&BLDLCL_CONSTANT_OPTION_GROUP_TOTAL}{&BLD_CONSTANT_VALUE} = $iGroupTotal;
|
||||
@ -253,20 +275,13 @@ sub buildConfig
|
||||
my $iOptionIndexTotal = $rhConfigDefine->{$strOption}{&CFGDEF_INDEX_TOTAL};
|
||||
my $strOptionPrefix = $rhConfigDefine->{$strOption}{&CFGDEF_PREFIX};
|
||||
|
||||
# Builds option data
|
||||
for (my $iOptionIndex = 1; $iOptionIndex <= $iOptionIndexTotal; $iOptionIndex++)
|
||||
{
|
||||
# Build C enum
|
||||
my $strOptionEnum = buildConfigOptionEnum($strOption) . ($iOptionIndex == 1 ? '' : $iOptionIndex);
|
||||
my $strOptionEnum = buildConfigOptionEnum($strOption);
|
||||
push(@{$rhEnum->{&BLD_LIST}}, $strOptionEnum);
|
||||
$rhEnum->{&BLD_VALUE}{$strOptionEnum} = $iOptionTotal;
|
||||
|
||||
# Create the indexed version of the option name
|
||||
my $strOptionIndex = defined($strOptionPrefix) ?
|
||||
"${strOptionPrefix}${iOptionIndex}-" . substr($strOption, length($strOptionPrefix) + 1) : $strOption;
|
||||
|
||||
# Build option constant name
|
||||
$strOptionConst = "CFGOPT_" . uc($strOptionIndex);
|
||||
$strOptionConst = "CFGOPT_" . uc($strOption);
|
||||
$strOptionConst =~ s/\-/_/g;
|
||||
|
||||
# Add option data
|
||||
@ -275,9 +290,7 @@ sub buildConfig
|
||||
" //" . (qw{-} x 126) . "\n" .
|
||||
" CONFIG_OPTION\n" .
|
||||
" (\n" .
|
||||
" CONFIG_OPTION_NAME(\"${strOptionIndex}\")\n" .
|
||||
" CONFIG_OPTION_INDEX(" . ($iOptionIndex - 1) . ")\n" .
|
||||
" CONFIG_OPTION_DEFINE_ID(" . buildConfigDefineOptionEnum($strOption) . ")\n";
|
||||
" CONFIG_OPTION_NAME(\"${strOption}\")\n";
|
||||
|
||||
if ($rhConfigDefine->{$strOption}{&CFGDEF_GROUP})
|
||||
{
|
||||
@ -286,11 +299,6 @@ sub buildConfig
|
||||
" CONFIG_OPTION_GROUP_ID(" . buildConfigOptionGroupEnum($rhConfigDefine->{$strOption}{&CFGDEF_GROUP}) .
|
||||
")\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$strBuildSource .=
|
||||
" CONFIG_OPTION_GROUP(false)\n";
|
||||
}
|
||||
|
||||
$strBuildSource .=
|
||||
" )\n";
|
||||
@ -299,7 +307,7 @@ sub buildConfig
|
||||
if (!$rhConfigDefine->{$strOption}{&CFGDEF_GROUP})
|
||||
{
|
||||
$rhBuild->{&BLD_FILE}{&BLDLCL_FILE_CONFIG}{&BLD_CONSTANT_GROUP}{&BLDLCL_CONSTANT_OPTION}{&BLD_CONSTANT}
|
||||
{$strOptionConst}{&BLD_CONSTANT_VALUE} = "\"${strOptionIndex}\"\n STRING_DECLARE(${strOptionConst}_STR);";
|
||||
{$strOptionConst}{&BLD_CONSTANT_VALUE} = "\"${strOption}\"\n STRING_DECLARE(${strOptionConst}_STR);";
|
||||
|
||||
$strBuildSourceConstant .=
|
||||
"STRING_EXTERN(${strOptionConst}_STR," . (' ' x (49 - length($strOptionConst))) . "${strOptionConst});\n";
|
||||
@ -307,7 +315,6 @@ sub buildConfig
|
||||
|
||||
$iOptionTotal += 1;
|
||||
}
|
||||
}
|
||||
|
||||
$strBuildSource .=
|
||||
")\n";
|
||||
|
@ -21,6 +21,7 @@ use pgBackRestDoc::Common::String;
|
||||
use pgBackRestDoc::ProjectInfo;
|
||||
|
||||
use pgBackRestBuild::Build::Common;
|
||||
use pgBackRestBuild::Config::Build;
|
||||
use pgBackRestBuild::Config::Data;
|
||||
|
||||
####################################################################################################################################
|
||||
@ -32,7 +33,6 @@ use constant BLDLCL_DATA_COMMAND => '01-dataC
|
||||
use constant BLDLCL_DATA_OPTION => '02-dataOption';
|
||||
|
||||
use constant BLDLCL_ENUM_OPTION_TYPE => '02-enumOptionType';
|
||||
use constant BLDLCL_ENUM_OPTION => '03-enumOption';
|
||||
|
||||
####################################################################################################################################
|
||||
# Definitions for constants and data to build
|
||||
@ -54,12 +54,6 @@ my $rhBuild =
|
||||
&BLD_SUMMARY => 'Option type define',
|
||||
&BLD_NAME => 'ConfigDefineOptionType',
|
||||
},
|
||||
|
||||
&BLDLCL_ENUM_OPTION =>
|
||||
{
|
||||
&BLD_SUMMARY => 'Option define',
|
||||
&BLD_NAME => 'ConfigDefineOption',
|
||||
},
|
||||
},
|
||||
|
||||
&BLD_DATA =>
|
||||
@ -81,11 +75,6 @@ my $rhBuild =
|
||||
####################################################################################################################################
|
||||
# Generate enum names
|
||||
####################################################################################################################################
|
||||
sub buildConfigCommandEnum
|
||||
{
|
||||
return bldEnum('cfgCmd', shift)
|
||||
}
|
||||
|
||||
sub buildConfigDefineOptionTypeEnum
|
||||
{
|
||||
return bldEnum('cfgDefOptType', shift);
|
||||
@ -93,13 +82,6 @@ sub buildConfigDefineOptionTypeEnum
|
||||
|
||||
push @EXPORT, qw(buildConfigDefineOptionTypeEnum);
|
||||
|
||||
sub buildConfigDefineOptionEnum
|
||||
{
|
||||
return bldEnum('cfgDefOpt', shift);
|
||||
}
|
||||
|
||||
push @EXPORT, qw(buildConfigDefineOptionEnum);
|
||||
|
||||
####################################################################################################################################
|
||||
# Helper function to format help text
|
||||
####################################################################################################################################
|
||||
@ -203,14 +185,14 @@ sub renderDepend
|
||||
return
|
||||
"${strIndent} CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST\n" .
|
||||
"${strIndent} (\n" .
|
||||
"${strIndent} " . buildConfigDefineOptionEnum($strDependOption) . ",\n" .
|
||||
"${strIndent} " . buildConfigOptionEnum($strDependOption) . ",\n" .
|
||||
"${strIndent} " . join(",\n${strIndent} ", bldQuoteList($ryDependList)) .
|
||||
"\n" .
|
||||
"${strIndent} )\n";
|
||||
}
|
||||
|
||||
return
|
||||
"${strIndent} CFGDEFDATA_OPTION_OPTIONAL_DEPEND(" . buildConfigDefineOptionEnum($strDependOption) . ")\n";
|
||||
"${strIndent} CFGDEFDATA_OPTION_OPTIONAL_DEPEND(" . buildConfigOptionEnum($strDependOption) . ")\n";
|
||||
}
|
||||
|
||||
sub renderOptional
|
||||
@ -410,7 +392,6 @@ sub buildConfigDefine
|
||||
# Build option constants and data
|
||||
#-------------------------------------------------------------------------------------------------------------------------------
|
||||
my $rhConfigDefine = cfgDefine();
|
||||
$rhEnum = $rhBuild->{&BLD_FILE}{&BLDLCL_FILE_DEFINE}{&BLD_ENUM}{&BLDLCL_ENUM_OPTION};
|
||||
|
||||
$strBuildSource =
|
||||
"static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST\n" .
|
||||
@ -421,10 +402,6 @@ sub buildConfigDefine
|
||||
# Get option help
|
||||
my $hOptionHelp = $hConfigHelp->{&CONFIG_HELP_OPTION}{$strOption};
|
||||
|
||||
# Build C enum
|
||||
my $strOptionEnum = buildConfigDefineOptionEnum($strOption);
|
||||
push(@{$rhEnum->{&BLD_LIST}}, $strOptionEnum);
|
||||
|
||||
# Build option data
|
||||
my $rhOption = $rhConfigDefine->{$strOption};
|
||||
|
||||
|
@ -240,12 +240,9 @@ sub buildConfigParse
|
||||
# Else add option to resolve order list
|
||||
elsif (!$rhResolved->{$strOption})
|
||||
{
|
||||
$rhResolved->{$strOption} = true;
|
||||
push(@stryResolveOrder, buildConfigOptionEnum($strOption));
|
||||
|
||||
for (my $iIndex = 0; $iIndex < $rhConfigDefine->{$strOption}{&CFGDEF_INDEX_TOTAL}; $iIndex++)
|
||||
{
|
||||
push(@stryResolveOrder, buildConfigOptionEnum($strOption) . ($iIndex == 0 ? '' : " + $iIndex"));
|
||||
}
|
||||
$rhResolved->{$strOption} = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,6 @@ use constant CFGOPT_OUTPUT => 'output';
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
use constant CFGOPT_EXEC_ID => 'exec-id';
|
||||
use constant CFGOPT_PROCESS => 'process';
|
||||
use constant CFGOPT_HOST_ID => 'host-id';
|
||||
use constant CFGOPT_REMOTE_TYPE => 'remote-type';
|
||||
|
||||
# Command-line only storage options
|
||||
@ -186,6 +185,9 @@ use constant CFGDEF_INDEX_REPO => 1;
|
||||
# Prefix that must be used by all repo options that allow multiple configurations
|
||||
use constant CFGDEF_PREFIX_REPO => 'repo';
|
||||
|
||||
# Set default repository
|
||||
use constant CFGOPT_REPO => CFGDEF_PREFIX_REPO;
|
||||
|
||||
# Repository General
|
||||
use constant CFGOPT_REPO_CIPHER_TYPE => CFGDEF_PREFIX_REPO . '-cipher-type';
|
||||
use constant CFGOPT_REPO_CIPHER_PASS => CFGDEF_PREFIX_REPO . '-cipher-pass';
|
||||
@ -282,6 +284,9 @@ use constant CFGDEF_INDEX_PG => 8;
|
||||
use constant CFGDEF_PREFIX_PG => 'pg';
|
||||
push @EXPORT, qw(CFGDEF_PREFIX_PG);
|
||||
|
||||
# Set default PostgreSQL cluster
|
||||
use constant CFGOPT_PG => CFGDEF_PREFIX_PG;
|
||||
|
||||
use constant CFGOPT_PG_LOCAL => CFGDEF_PREFIX_PG . '-local';
|
||||
|
||||
use constant CFGOPT_PG_HOST => CFGDEF_PREFIX_PG . '-host';
|
||||
@ -1003,22 +1008,6 @@ my %hConfigDefine =
|
||||
&CFGDEF_INTERNAL => true,
|
||||
},
|
||||
|
||||
&CFGOPT_HOST_ID =>
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_INTEGER,
|
||||
&CFGDEF_REQUIRED => false,
|
||||
&CFGDEF_INTERNAL => true,
|
||||
&CFGDEF_ALLOW_RANGE => [1, CFGDEF_INDEX_PG > CFGDEF_INDEX_REPO ? CFGDEF_INDEX_PG : CFGDEF_INDEX_REPO],
|
||||
&CFGDEF_COMMAND =>
|
||||
{
|
||||
&CFGCMD_ARCHIVE_GET => {},
|
||||
&CFGCMD_ARCHIVE_PUSH => {},
|
||||
&CFGCMD_BACKUP => {},
|
||||
&CFGCMD_RESTORE => {},
|
||||
&CFGCMD_VERIFY => {},
|
||||
},
|
||||
},
|
||||
|
||||
&CFGOPT_PROCESS =>
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_INTEGER,
|
||||
@ -1491,6 +1480,18 @@ my %hConfigDefine =
|
||||
}
|
||||
},
|
||||
|
||||
# Repository selector
|
||||
#-------------------------------------------------------------------------------------------------------------------------------
|
||||
&CFGOPT_REPO =>
|
||||
{
|
||||
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_INTEGER,
|
||||
&CFGDEF_INTERNAL => true,
|
||||
&CFGDEF_REQUIRED => false,
|
||||
&CFGDEF_ALLOW_RANGE => [1, CFGDEF_INDEX_REPO],
|
||||
&CFGDEF_COMMAND => CFGOPT_REPO_TYPE,
|
||||
},
|
||||
|
||||
# Repository options
|
||||
#-------------------------------------------------------------------------------------------------------------------------------
|
||||
&CFGOPT_REPO_CIPHER_PASS =>
|
||||
@ -2574,6 +2575,37 @@ my %hConfigDefine =
|
||||
|
||||
# Stanza options
|
||||
#-------------------------------------------------------------------------------------------------------------------------------
|
||||
&CFGOPT_PG =>
|
||||
{
|
||||
&CFGDEF_SECTION => CFGDEF_SECTION_STANZA,
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_INTEGER,
|
||||
&CFGDEF_INTERNAL => true,
|
||||
&CFGDEF_REQUIRED => false,
|
||||
&CFGDEF_ALLOW_RANGE => [1, CFGDEF_INDEX_PG],
|
||||
&CFGDEF_COMMAND =>
|
||||
{
|
||||
&CFGCMD_ARCHIVE_GET => {},
|
||||
&CFGCMD_ARCHIVE_PUSH => {},
|
||||
&CFGCMD_BACKUP =>
|
||||
{
|
||||
&CFGDEF_INTERNAL => true,
|
||||
},
|
||||
&CFGCMD_CHECK =>
|
||||
{
|
||||
&CFGDEF_INTERNAL => true,
|
||||
},
|
||||
&CFGCMD_RESTORE => {},
|
||||
&CFGCMD_STANZA_CREATE =>
|
||||
{
|
||||
&CFGDEF_INTERNAL => true,
|
||||
},
|
||||
&CFGCMD_STANZA_UPGRADE =>
|
||||
{
|
||||
&CFGDEF_INTERNAL => true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
&CFGOPT_PG_LOCAL =>
|
||||
{
|
||||
&CFGDEF_GROUP => CFGOPTGRP_PG,
|
||||
|
@ -481,6 +481,19 @@
|
||||
<example>y</example>
|
||||
</config-key>
|
||||
|
||||
<!-- ======================================================================================================= -->
|
||||
<config-key id="repo" name="Set Repository">
|
||||
<summary>Set default repository.</summary>
|
||||
|
||||
<text>Set the repository for a command to operate on.
|
||||
|
||||
For example, this option may be used to perform a restore from a specific repository, rather than letting <backrest/> choose.
|
||||
|
||||
Note that some commands, e.g. <cmd>archive-push</cmd>, are intended to operate on all repositories and will ignore this option.</text>
|
||||
|
||||
<example>1</example>
|
||||
</config-key>
|
||||
|
||||
<!-- CONFIG - REPO SECTION - REPO-PATH KEY -->
|
||||
<config-key id="repo-path" name="Repository Path">
|
||||
<summary>Path where backups and archive are stored.</summary>
|
||||
@ -1036,6 +1049,19 @@
|
||||
<example>db_owner</example>
|
||||
</config-key>
|
||||
|
||||
<!-- ======================================================================================================= -->
|
||||
<config-key id="pg" name="Set PostgreSQL Cluster">
|
||||
<summary>Set PostgreSQL cluster.</summary>
|
||||
|
||||
<text>Set the <postgres/> cluster for a command to operate on.
|
||||
|
||||
For example, this option may be used to perform a restore to a specific <postgres/> cluster, rather than using the first configured cluster.
|
||||
|
||||
Note that some commands, e.g. <cmd>backup</cmd>, are intended to operate on multiple <postgres/> clusters and will ignore this option.</text>
|
||||
|
||||
<example>1</example>
|
||||
</config-key>
|
||||
|
||||
<!-- CONFIG - STANZA SECTION - PG-PATH KEY -->
|
||||
<config-key id="pg-path" name="PostgreSQL Path">
|
||||
<summary><postgres/> data directory.</summary>
|
||||
|
@ -84,19 +84,32 @@
|
||||
|
||||
<release-development-list>
|
||||
<release-item>
|
||||
<commit subject="Declare cfgDefOptionAllowListValue/Total() static."/>
|
||||
<commit subject="Remove unused cfgDefOptionPrefix() function and data."/>
|
||||
<commit subject="Add option groups."/>
|
||||
<commit subject="Remove indexed option constants."/>
|
||||
<commit subject="Remove extraneous calls to cfgOptionValid() in unit tests."/>
|
||||
<commit subject="Use harnessCfgLoadRaw() in command/help unit test."/>
|
||||
<commit subject="Reset additional options in real/all integration test."/>
|
||||
<commit subject="Fix repo/pg-local option being overwritten."/>
|
||||
<commit subject="Remove ConfigDefineCommand enum."/>
|
||||
<commit subject="Remove cfgOptionId() and replace it with cfgParseOption()."/>
|
||||
<commit subject="Get target-action default from cfgOptionDefault() in restore command."/>
|
||||
<commit subject="Use harnessCfgLoadRaw() in command/command and common/exit unit tests."/>
|
||||
<commit subject="Add indexed option > 1 to config/exec unit test."/>
|
||||
<commit subject="Use zero-based indexes when referring to option indexes."/>
|
||||
<commit subject="Fix comment."/>
|
||||
<commit subject="Use harnessCfgLoad() in config/load unit tests."/>
|
||||
<commit subject="Use a constant to check restore target action."/>
|
||||
<commit subject="Fix override of user option reset."/>
|
||||
<commit subject="Rename hrnCfgEnvId*() to hrnCfgEnvKey*()."/>
|
||||
<commit subject="Prepare configuration module for multi-repository support."/>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-reviewer id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Add option groups.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-reviewer id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Use zero-based indexes when referring to option indexes.</p>
|
||||
<p>Prepare configuration module for multi-repository support.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
@ -116,6 +129,14 @@
|
||||
<p>Allow multiple remote locks from the same main process.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-reviewer id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Allow multiple remote locks from the same main process.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<commit subject="Reduce buffer used when size limit set."/>
|
||||
<commit subject="Assert when buffer used is greater than size limit."/>
|
||||
|
@ -238,13 +238,13 @@ backupInit(const InfoBackup *infoBackup)
|
||||
result->pgIdxStandby = dbInfo.standbyIdx;
|
||||
result->dbStandby = dbInfo.standby;
|
||||
result->storageStandby = storagePgIdx(result->pgIdxStandby);
|
||||
result->hostStandby = cfgOptionStrNull(cfgOptPgHost + result->pgIdxStandby);
|
||||
result->hostStandby = cfgOptionIdxStrNull(cfgOptPgHost, result->pgIdxStandby);
|
||||
}
|
||||
}
|
||||
|
||||
// Add primary info
|
||||
result->storagePrimary = storagePgIdx(result->pgIdxPrimary);
|
||||
result->hostPrimary = cfgOptionStrNull(cfgOptPgHost + result->pgIdxPrimary);
|
||||
result->hostPrimary = cfgOptionIdxStrNull(cfgOptPgHost, result->pgIdxPrimary);
|
||||
|
||||
// Get pg_control info from the primary
|
||||
PgControl pgControl = pgControlFromFile(result->storagePrimary);
|
||||
|
@ -31,13 +31,10 @@ checkManifest(void)
|
||||
{
|
||||
// Loop through all defined databases and attempt to build a manifest
|
||||
for (unsigned int pgIdx = 0; pgIdx < cfgOptionGroupIdxTotal(cfgOptGrpPg); pgIdx++)
|
||||
{
|
||||
if (cfgOptionGroupIdxTest(cfgOptGrpPg, pgIdx))
|
||||
{
|
||||
result++;
|
||||
// ??? Placeholder for manifest build
|
||||
storageListP(storagePgIdx(pgIdx), varStr(cfgOption(cfgOptPgPath + pgIdx)));
|
||||
}
|
||||
storageListP(storagePgIdx(pgIdx), cfgOptionIdxStr(cfgOptPgPath, pgIdx));
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
@ -60,7 +57,7 @@ checkStandby(const DbGetResult dbGroup, unsigned int pgPathDefinedTotal)
|
||||
if (dbGroup.primary == NULL)
|
||||
{
|
||||
// If the repo is local or more than one pg-path is found then a master should have been found so error
|
||||
if (repoIsLocal() || pgPathDefinedTotal > 1)
|
||||
if (repoIsLocal(cfgOptionGroupIdxDefault(cfgOptGrpRepo)) || pgPathDefinedTotal > 1)
|
||||
{
|
||||
THROW(
|
||||
ConfigError,
|
||||
|
@ -57,16 +57,16 @@ checkDbConfig(const unsigned int pgVersion, const unsigned int pgIdx, const Db *
|
||||
{
|
||||
unsigned int dbVersion = dbPgVersion(dbObject);
|
||||
const String *dbPath = dbPgDataPath(dbObject);
|
||||
unsigned int pgPath = cfgOptPgPath + pgIdx;
|
||||
|
||||
// Error if the version from the control file and the configured pg-path do not match the values obtained from the database
|
||||
if (pgVersion != dbVersion || strCmp(cfgOptionStr(pgPath), dbPath) != 0)
|
||||
if (pgVersion != dbVersion || strCmp(cfgOptionIdxStr(cfgOptPgPath, pgIdx), dbPath) != 0)
|
||||
{
|
||||
THROW_FMT(
|
||||
DbMismatchError, "version '%s' and path '%s' queried from cluster do not match version '%s' and '%s' read from '%s/"
|
||||
PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL "'\nHINT: the %s and %s settings likely reference different clusters.",
|
||||
strZ(pgVersionToStr(dbVersion)), strZ(dbPath), strZ(pgVersionToStr(pgVersion)), strZ(cfgOptionStr(pgPath)),
|
||||
strZ(cfgOptionStr(pgPath)), cfgOptionName(pgPath), cfgOptionName(cfgOptPgPort + pgIdx));
|
||||
strZ(pgVersionToStr(dbVersion)), strZ(dbPath), strZ(pgVersionToStr(pgVersion)),
|
||||
strZ(cfgOptionIdxStr(cfgOptPgPath, pgIdx)), strZ(cfgOptionIdxStr(cfgOptPgPath, pgIdx)),
|
||||
cfgOptionIdxName(cfgOptPgPath, pgIdx), cfgOptionIdxName(cfgOptPgPort, pgIdx));
|
||||
}
|
||||
|
||||
// Check archive configuration if option is valid for the command and set
|
||||
|
@ -12,7 +12,7 @@ Common Command Routines
|
||||
#include "common/stat.h"
|
||||
#include "common/time.h"
|
||||
#include "common/type/json.h"
|
||||
#include "config/config.h"
|
||||
#include "config/config.intern.h"
|
||||
#include "config/define.h"
|
||||
#include "version.h"
|
||||
|
||||
@ -76,37 +76,40 @@ cmdOption(void)
|
||||
// Skip the option if not valid for this command. Generally only one command runs at a time, but sometimes
|
||||
// commands are chained together (e.g. backup and expire) and the second command may not use all the options of
|
||||
// the first command. Displaying them is harmless but might cause confusion.
|
||||
if (!cfgDefOptionValid(cfgCommand(), cfgOptionDefIdFromId(optionId)))
|
||||
if (!cfgOptionValid(optionId) || !cfgDefOptionValid(cfgCommand(), optionId))
|
||||
continue;
|
||||
|
||||
// If option was negated
|
||||
if (cfgOptionNegate(optionId))
|
||||
strCatFmt(cmdOptionStr, " --no-%s", cfgOptionName(optionId));
|
||||
// If option was reset
|
||||
else if (cfgOptionReset(optionId))
|
||||
strCatFmt(cmdOptionStr, " --reset-%s", cfgOptionName(optionId));
|
||||
// Else not default
|
||||
else if (cfgOptionSource(optionId) != cfgSourceDefault)
|
||||
{
|
||||
ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId);
|
||||
// Loop through option indexes
|
||||
unsigned int optionIdxTotal = cfgOptionGroup(optionId) ? cfgOptionGroupIdxTotal(cfgOptionGroupId(optionId)) : 1;
|
||||
|
||||
for (unsigned int optionIdx = 0; optionIdx < optionIdxTotal; optionIdx++)
|
||||
{
|
||||
// If option was negated
|
||||
if (cfgOptionIdxNegate(optionId, optionIdx))
|
||||
strCatFmt(cmdOptionStr, " --no-%s", cfgOptionIdxName(optionId, optionIdx));
|
||||
// If option was reset
|
||||
else if (cfgOptionIdxReset(optionId, optionIdx))
|
||||
strCatFmt(cmdOptionStr, " --reset-%s", cfgOptionIdxName(optionId, optionIdx));
|
||||
// Else not default
|
||||
else if (cfgOptionIdxSource(optionId, optionIdx) != cfgSourceDefault)
|
||||
{
|
||||
// Don't show redacted options
|
||||
if (cfgDefOptionSecure(optionDefId))
|
||||
strCatFmt(cmdOptionStr, " --%s=<redacted>", cfgOptionName(optionId));
|
||||
if (cfgDefOptionSecure(optionId))
|
||||
strCatFmt(cmdOptionStr, " --%s=<redacted>", cfgOptionIdxName(optionId, optionIdx));
|
||||
// Output boolean option
|
||||
else if (cfgDefOptionType(optionDefId) == cfgDefOptTypeBoolean)
|
||||
strCatFmt(cmdOptionStr, " --%s", cfgOptionName(optionId));
|
||||
else if (cfgDefOptionType(optionId) == cfgDefOptTypeBoolean)
|
||||
strCatFmt(cmdOptionStr, " --%s", cfgOptionIdxName(optionId, optionIdx));
|
||||
// Output other options
|
||||
else
|
||||
{
|
||||
StringList *valueList = NULL;
|
||||
|
||||
// Generate the values of hash options
|
||||
if (cfgDefOptionType(optionDefId) == cfgDefOptTypeHash)
|
||||
if (cfgDefOptionType(optionId) == cfgDefOptTypeHash)
|
||||
{
|
||||
valueList = strLstNew();
|
||||
|
||||
const KeyValue *optionKv = cfgOptionKv(optionId);
|
||||
const KeyValue *optionKv = cfgOptionIdxKv(optionId, optionIdx);
|
||||
const VariantList *keyList = kvKeyList(optionKv);
|
||||
|
||||
for (unsigned int keyIdx = 0; keyIdx < varLstSize(keyList); keyIdx++)
|
||||
@ -119,15 +122,15 @@ cmdOption(void)
|
||||
}
|
||||
}
|
||||
// Generate values for list options
|
||||
else if (cfgDefOptionType(optionDefId) == cfgDefOptTypeList)
|
||||
else if (cfgDefOptionType(optionId) == cfgDefOptTypeList)
|
||||
{
|
||||
valueList = strLstNewVarLst(cfgOptionLst(optionId));
|
||||
valueList = strLstNewVarLst(cfgOptionIdxLst(optionId, optionIdx));
|
||||
}
|
||||
// Else only one value
|
||||
else
|
||||
{
|
||||
valueList = strLstNew();
|
||||
strLstAdd(valueList, varStrForce(cfgOption(optionId)));
|
||||
strLstAdd(valueList, varStrForce(cfgOptionIdx(optionId, optionIdx)));
|
||||
}
|
||||
|
||||
// Output options and values
|
||||
@ -135,7 +138,7 @@ cmdOption(void)
|
||||
{
|
||||
const String *value = strLstGet(valueList, valueListIdx);
|
||||
|
||||
strCatFmt(cmdOptionStr, " --%s", cfgOptionName(optionId));
|
||||
strCatFmt(cmdOptionStr, " --%s", cfgOptionIdxName(optionId, optionIdx));
|
||||
|
||||
if (strchr(strZ(value), ' ') != NULL)
|
||||
value = strNewFmt("\"%s\"", strZ(value));
|
||||
@ -146,6 +149,7 @@ cmdOption(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
|
@ -214,14 +214,14 @@ helpRender(void)
|
||||
KeyValue *optionKv = kvNew();
|
||||
size_t optionSizeMax = 0;
|
||||
|
||||
for (unsigned int optionDefId = 0; optionDefId < cfgDefOptionTotal(); optionDefId++)
|
||||
for (unsigned int optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++)
|
||||
{
|
||||
if (cfgDefOptionValid(commandId, optionDefId) && !cfgDefOptionInternal(commandId, optionDefId))
|
||||
if (cfgDefOptionValid(commandId, optionId) && !cfgDefOptionInternal(commandId, optionId))
|
||||
{
|
||||
const String *section = NULL;
|
||||
|
||||
if (cfgDefOptionHelpSection(optionDefId) != NULL)
|
||||
section = strNew(cfgDefOptionHelpSection(optionDefId));
|
||||
if (cfgDefOptionHelpSection(optionId) != NULL)
|
||||
section = strNew(cfgDefOptionHelpSection(optionId));
|
||||
|
||||
if (section == NULL ||
|
||||
(!strEqZ(section, "general") && !strEqZ(section, "log") && !strEqZ(section, "repository") &&
|
||||
@ -230,10 +230,10 @@ helpRender(void)
|
||||
section = strNew("command");
|
||||
}
|
||||
|
||||
kvAdd(optionKv, VARSTR(section), VARINT((int)optionDefId));
|
||||
kvAdd(optionKv, VARSTR(section), VARINT((int)optionId));
|
||||
|
||||
if (strlen(cfgDefOptionName(optionDefId)) > optionSizeMax)
|
||||
optionSizeMax = strlen(cfgDefOptionName(optionDefId));
|
||||
if (strlen(cfgDefOptionName(optionId)) > optionSizeMax)
|
||||
optionSizeMax = strlen(cfgDefOptionName(optionId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,13 +251,12 @@ helpRender(void)
|
||||
|
||||
for (unsigned int optionIdx = 0; optionIdx < varLstSize(optionList); optionIdx++)
|
||||
{
|
||||
ConfigDefineOption optionDefId = varInt(varLstGet(optionList, optionIdx));
|
||||
ConfigOption optionId = cfgOptionIdFromDefId(optionDefId, 0);
|
||||
ConfigOption optionId = varInt(varLstGet(optionList, optionIdx));
|
||||
|
||||
// Get option summary
|
||||
String *summary = strFirstLower(strNewN(
|
||||
cfgDefOptionHelpSummary(commandId, optionDefId),
|
||||
strlen(cfgDefOptionHelpSummary(commandId, optionDefId)) - 1));
|
||||
cfgDefOptionHelpSummary(commandId, optionId),
|
||||
strlen(cfgDefOptionHelpSummary(commandId, optionId)) - 1));
|
||||
|
||||
// Ouput current and default values if they exist
|
||||
const String *defaultValue = helpRenderValue(cfgOptionDefault(optionId));
|
||||
@ -271,7 +270,7 @@ helpRender(void)
|
||||
strCatZ(summary, " [");
|
||||
|
||||
if (value != NULL)
|
||||
strCatFmt(summary, "current=%s", cfgDefOptionSecure(optionDefId) ? "<redacted>" : strZ(value));
|
||||
strCatFmt(summary, "current=%s", cfgDefOptionSecure(optionId) ? "<redacted>" : strZ(value));
|
||||
|
||||
if (defaultValue != NULL)
|
||||
{
|
||||
@ -287,7 +286,7 @@ helpRender(void)
|
||||
// Output option help
|
||||
strCatFmt(
|
||||
result, " --%s%*s%s\n",
|
||||
cfgDefOptionName(optionDefId), (int)(optionSizeMax - strlen(cfgDefOptionName(optionDefId)) + 2), "",
|
||||
cfgDefOptionName(optionId), (int)(optionSizeMax - strlen(cfgDefOptionName(optionId)) + 2), "",
|
||||
strZ(helpRenderText(summary, optionSizeMax + 6, false, CONSOLE_WIDTH)));
|
||||
}
|
||||
}
|
||||
@ -314,12 +313,10 @@ helpRender(void)
|
||||
if (optionId == -1)
|
||||
THROW_FMT(OptionInvalidError, "option '%s' is not valid for command '%s'", strZ(optionName), commandName);
|
||||
else
|
||||
option.id = cfgOptionIdFromDefId((unsigned int)optionId, 0);
|
||||
option.id = (unsigned int)optionId;
|
||||
}
|
||||
|
||||
// Output option summary and description
|
||||
ConfigDefineOption optionDefId = cfgOptionDefIdFromId(option.id);
|
||||
|
||||
strCatFmt(
|
||||
result,
|
||||
" - '%s' option help\n"
|
||||
@ -327,9 +324,9 @@ helpRender(void)
|
||||
"%s\n"
|
||||
"\n"
|
||||
"%s\n",
|
||||
cfgDefOptionName(optionDefId),
|
||||
strZ(helpRenderText(STR(cfgDefOptionHelpSummary(commandId, optionDefId)), 0, true, CONSOLE_WIDTH)),
|
||||
strZ(helpRenderText(STR(cfgDefOptionHelpDescription(commandId, optionDefId)), 0, true, CONSOLE_WIDTH)));
|
||||
cfgDefOptionName(option.id),
|
||||
strZ(helpRenderText(STR(cfgDefOptionHelpSummary(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
|
||||
const String *defaultValue = helpRenderValue(cfgOptionDefault(option.id));
|
||||
@ -343,15 +340,15 @@ helpRender(void)
|
||||
strCat(result, LF_STR);
|
||||
|
||||
if (value != NULL)
|
||||
strCatFmt(result, "current: %s\n", cfgDefOptionSecure(optionDefId) ? "<redacted>" : strZ(value));
|
||||
strCatFmt(result, "current: %s\n", cfgDefOptionSecure(option.id) ? "<redacted>" : strZ(value));
|
||||
|
||||
if (defaultValue != NULL)
|
||||
strCatFmt(result, "default: %s\n", strZ(defaultValue));
|
||||
}
|
||||
|
||||
// Output alternate name (call it deprecated so the user will know not to use it)
|
||||
if (cfgDefOptionHelpNameAlt(optionDefId))
|
||||
strCatFmt(result, "\ndeprecated name: %s\n", cfgDefOptionHelpNameAltValue(optionDefId, 0));
|
||||
if (cfgDefOptionHelpNameAlt(option.id))
|
||||
strCatFmt(result, "\ndeprecated name: %s\n", cfgDefOptionHelpNameAltValue(option.id, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ Zero-terminated strings that are generally useful
|
||||
#define LF_Z "\n"
|
||||
#define N_Z "n"
|
||||
#define NULL_Z "null"
|
||||
#define ONE_Z "1"
|
||||
#define QUESTION_Z "?"
|
||||
#define QUOTED_Z "\""
|
||||
#define TRUE_Z "true"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -116,8 +116,6 @@ Option constants
|
||||
STRING_DECLARE(CFGOPT_FILTER_STR);
|
||||
#define CFGOPT_FORCE "force"
|
||||
STRING_DECLARE(CFGOPT_FORCE_STR);
|
||||
#define CFGOPT_HOST_ID "host-id"
|
||||
STRING_DECLARE(CFGOPT_HOST_ID_STR);
|
||||
#define CFGOPT_IGNORE_MISSING "ignore-missing"
|
||||
STRING_DECLARE(CFGOPT_IGNORE_MISSING_STR);
|
||||
#define CFGOPT_IO_TIMEOUT "io-timeout"
|
||||
@ -148,6 +146,8 @@ Option constants
|
||||
STRING_DECLARE(CFGOPT_ONLINE_STR);
|
||||
#define CFGOPT_OUTPUT "output"
|
||||
STRING_DECLARE(CFGOPT_OUTPUT_STR);
|
||||
#define CFGOPT_PG "pg"
|
||||
STRING_DECLARE(CFGOPT_PG_STR);
|
||||
#define CFGOPT_PROCESS "process"
|
||||
STRING_DECLARE(CFGOPT_PROCESS_STR);
|
||||
#define CFGOPT_PROCESS_MAX "process-max"
|
||||
@ -162,6 +162,8 @@ Option constants
|
||||
STRING_DECLARE(CFGOPT_RECURSE_STR);
|
||||
#define CFGOPT_REMOTE_TYPE "remote-type"
|
||||
STRING_DECLARE(CFGOPT_REMOTE_TYPE_STR);
|
||||
#define CFGOPT_REPO "repo"
|
||||
STRING_DECLARE(CFGOPT_REPO_STR);
|
||||
#define CFGOPT_RESUME "resume"
|
||||
STRING_DECLARE(CFGOPT_RESUME_STR);
|
||||
#define CFGOPT_SCK_BLOCK "sck-block"
|
||||
@ -201,7 +203,7 @@ Option constants
|
||||
#define CFGOPT_TYPE "type"
|
||||
STRING_DECLARE(CFGOPT_TYPE_STR);
|
||||
|
||||
#define CFG_OPTION_TOTAL 208
|
||||
#define CFG_OPTION_TOTAL 125
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Command enum
|
||||
@ -273,7 +275,6 @@ typedef enum
|
||||
cfgOptExpireAuto,
|
||||
cfgOptFilter,
|
||||
cfgOptForce,
|
||||
cfgOptHostId,
|
||||
cfgOptIgnoreMissing,
|
||||
cfgOptIoTimeout,
|
||||
cfgOptLinkAll,
|
||||
@ -289,102 +290,19 @@ typedef enum
|
||||
cfgOptNeutralUmask,
|
||||
cfgOptOnline,
|
||||
cfgOptOutput,
|
||||
cfgOptPg,
|
||||
cfgOptPgHost,
|
||||
cfgOptPgHost2,
|
||||
cfgOptPgHost3,
|
||||
cfgOptPgHost4,
|
||||
cfgOptPgHost5,
|
||||
cfgOptPgHost6,
|
||||
cfgOptPgHost7,
|
||||
cfgOptPgHost8,
|
||||
cfgOptPgHostCmd,
|
||||
cfgOptPgHostCmd2,
|
||||
cfgOptPgHostCmd3,
|
||||
cfgOptPgHostCmd4,
|
||||
cfgOptPgHostCmd5,
|
||||
cfgOptPgHostCmd6,
|
||||
cfgOptPgHostCmd7,
|
||||
cfgOptPgHostCmd8,
|
||||
cfgOptPgHostConfig,
|
||||
cfgOptPgHostConfig2,
|
||||
cfgOptPgHostConfig3,
|
||||
cfgOptPgHostConfig4,
|
||||
cfgOptPgHostConfig5,
|
||||
cfgOptPgHostConfig6,
|
||||
cfgOptPgHostConfig7,
|
||||
cfgOptPgHostConfig8,
|
||||
cfgOptPgHostConfigIncludePath,
|
||||
cfgOptPgHostConfigIncludePath2,
|
||||
cfgOptPgHostConfigIncludePath3,
|
||||
cfgOptPgHostConfigIncludePath4,
|
||||
cfgOptPgHostConfigIncludePath5,
|
||||
cfgOptPgHostConfigIncludePath6,
|
||||
cfgOptPgHostConfigIncludePath7,
|
||||
cfgOptPgHostConfigIncludePath8,
|
||||
cfgOptPgHostConfigPath,
|
||||
cfgOptPgHostConfigPath2,
|
||||
cfgOptPgHostConfigPath3,
|
||||
cfgOptPgHostConfigPath4,
|
||||
cfgOptPgHostConfigPath5,
|
||||
cfgOptPgHostConfigPath6,
|
||||
cfgOptPgHostConfigPath7,
|
||||
cfgOptPgHostConfigPath8,
|
||||
cfgOptPgHostPort,
|
||||
cfgOptPgHostPort2,
|
||||
cfgOptPgHostPort3,
|
||||
cfgOptPgHostPort4,
|
||||
cfgOptPgHostPort5,
|
||||
cfgOptPgHostPort6,
|
||||
cfgOptPgHostPort7,
|
||||
cfgOptPgHostPort8,
|
||||
cfgOptPgHostUser,
|
||||
cfgOptPgHostUser2,
|
||||
cfgOptPgHostUser3,
|
||||
cfgOptPgHostUser4,
|
||||
cfgOptPgHostUser5,
|
||||
cfgOptPgHostUser6,
|
||||
cfgOptPgHostUser7,
|
||||
cfgOptPgHostUser8,
|
||||
cfgOptPgLocal,
|
||||
cfgOptPgLocal2,
|
||||
cfgOptPgLocal3,
|
||||
cfgOptPgLocal4,
|
||||
cfgOptPgLocal5,
|
||||
cfgOptPgLocal6,
|
||||
cfgOptPgLocal7,
|
||||
cfgOptPgLocal8,
|
||||
cfgOptPgPath,
|
||||
cfgOptPgPath2,
|
||||
cfgOptPgPath3,
|
||||
cfgOptPgPath4,
|
||||
cfgOptPgPath5,
|
||||
cfgOptPgPath6,
|
||||
cfgOptPgPath7,
|
||||
cfgOptPgPath8,
|
||||
cfgOptPgPort,
|
||||
cfgOptPgPort2,
|
||||
cfgOptPgPort3,
|
||||
cfgOptPgPort4,
|
||||
cfgOptPgPort5,
|
||||
cfgOptPgPort6,
|
||||
cfgOptPgPort7,
|
||||
cfgOptPgPort8,
|
||||
cfgOptPgSocketPath,
|
||||
cfgOptPgSocketPath2,
|
||||
cfgOptPgSocketPath3,
|
||||
cfgOptPgSocketPath4,
|
||||
cfgOptPgSocketPath5,
|
||||
cfgOptPgSocketPath6,
|
||||
cfgOptPgSocketPath7,
|
||||
cfgOptPgSocketPath8,
|
||||
cfgOptPgUser,
|
||||
cfgOptPgUser2,
|
||||
cfgOptPgUser3,
|
||||
cfgOptPgUser4,
|
||||
cfgOptPgUser5,
|
||||
cfgOptPgUser6,
|
||||
cfgOptPgUser7,
|
||||
cfgOptPgUser8,
|
||||
cfgOptProcess,
|
||||
cfgOptProcessMax,
|
||||
cfgOptProtocolTimeout,
|
||||
@ -392,6 +310,7 @@ typedef enum
|
||||
cfgOptRecoveryOption,
|
||||
cfgOptRecurse,
|
||||
cfgOptRemoteType,
|
||||
cfgOptRepo,
|
||||
cfgOptRepoAzureAccount,
|
||||
cfgOptRepoAzureCaFile,
|
||||
cfgOptRepoAzureCaPath,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,6 @@ config/parse.c sets the command and options and determines which options are val
|
||||
#include "common/type/stringList.h"
|
||||
|
||||
#include "config/config.auto.h"
|
||||
#include "config/define.auto.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Command Role Enum
|
||||
@ -88,20 +87,25 @@ bool cfgLogFile(void);
|
||||
// Default log level -- used for log messages that are common to all commands
|
||||
LogLevel cfgLogLevelDefault(void);
|
||||
|
||||
// Does this command allow parameters?
|
||||
bool cfgParameterAllowed(void);
|
||||
|
||||
// Command parameters, if any
|
||||
const StringList *cfgCommandParam(void);
|
||||
|
||||
// Does this command allow parameters?
|
||||
bool cfgCommandParameterAllowed(ConfigCommand commandId);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Option Group Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Are any options in the group with the specified index valid for the command and set by the user (i.e. not default)?
|
||||
bool cfgOptionGroupIdxTest(ConfigOptionGroup groupId, unsigned int index);
|
||||
// Get the default index for this group, i.e. the index that will be used if a non-indexed function like cfgOptionTest() is called.
|
||||
unsigned int cfgOptionGroupIdxDefault(ConfigOptionGroup groupId);
|
||||
|
||||
// Total indexed groups, 0 if the group is not valid. Note that there may be gaps so each group index will need to be tested with
|
||||
// cfgOptionGroupIdxTest() to make sure it contains data.
|
||||
// Convert the group index to a key, i.e. the key that was used in the original configuration file, command-line, etc. Useful for
|
||||
// messages that do not show an option name but must use an index that the user will recognize. It is preferrable to generate an
|
||||
// option name with cfgOptionIdxName() when possible.
|
||||
unsigned int cfgOptionGroupIdxToKey(ConfigOptionGroup groupId, unsigned int groupIdx);
|
||||
|
||||
// Total indexes, 0 if the group is not valid. Will be the total configured indexes, no matter which raw indexes were used during
|
||||
// configuration. e.g., if pg1-path and pg8-path are configured then this function will return 2.
|
||||
unsigned int cfgOptionGroupIdxTotal(ConfigOptionGroup groupId);
|
||||
|
||||
// Are any options in the group valid for the command?
|
||||
@ -110,32 +114,42 @@ bool cfgOptionGroupValid(ConfigOptionGroup groupId);
|
||||
/***********************************************************************************************************************************
|
||||
Option Functions
|
||||
|
||||
Access option values, indexes, and determine if an option is valid for the current command.
|
||||
Access option values, indexes, and determine if an option is valid for the current command. Most functions have a variant that
|
||||
accepts an index, which currently work with non-indexed options (with optionIdx 0) but they may not always do so.
|
||||
***********************************************************************************************************************************/
|
||||
// Get config options for various types
|
||||
const Variant *cfgOption(ConfigOption optionId);
|
||||
const Variant *cfgOptionIdx(ConfigOption optionId, unsigned int optionIdx);
|
||||
bool cfgOptionBool(ConfigOption optionId);
|
||||
bool cfgOptionIdxBool(ConfigOption optionId, unsigned int optionIdx);
|
||||
double cfgOptionDbl(ConfigOption optionId);
|
||||
int cfgOptionInt(ConfigOption optionId);
|
||||
int cfgOptionIdxInt(ConfigOption optionId, unsigned int optionIdx);
|
||||
int64_t cfgOptionInt64(ConfigOption optionId);
|
||||
int64_t cfgOptionIdxInt64(ConfigOption optionId, unsigned int optionIdx);
|
||||
const KeyValue *cfgOptionKv(ConfigOption optionId);
|
||||
const KeyValue *cfgOptionIdxKv(ConfigOption optionId, unsigned int optionIdx);
|
||||
const VariantList *cfgOptionLst(ConfigOption optionId);
|
||||
const VariantList *cfgOptionIdxLst(ConfigOption optionId, unsigned int optionIdx);
|
||||
const String *cfgOptionStr(ConfigOption optionId);
|
||||
const String *cfgOptionIdxStr(ConfigOption optionId, unsigned int optionIdx);
|
||||
const String *cfgOptionStrNull(ConfigOption optionId);
|
||||
const String *cfgOptionIdxStrNull(ConfigOption optionId, unsigned int optionIdx);
|
||||
unsigned int cfgOptionUInt(ConfigOption optionId);
|
||||
unsigned int cfgOptionIdxUInt(ConfigOption optionId, unsigned int optionIdx);
|
||||
uint64_t cfgOptionUInt64(ConfigOption optionId);
|
||||
|
||||
// Get index for option
|
||||
unsigned int cfgOptionIndex(ConfigOption optionId);
|
||||
uint64_t cfgOptionIdxUInt64(ConfigOption optionId, unsigned int optionIdx);
|
||||
|
||||
// Option name by id
|
||||
const char *cfgOptionName(ConfigOption optionId);
|
||||
const char *cfgOptionIdxName(ConfigOption optionId, unsigned int optionIdx);
|
||||
|
||||
// Is the option valid for this command?
|
||||
bool cfgOptionValid(ConfigOption optionId);
|
||||
|
||||
// Is the option valid for the command and set?
|
||||
// Is the option valid for the command and also has a value?
|
||||
bool cfgOptionTest(ConfigOption optionId);
|
||||
bool cfgOptionIdxTest(ConfigOption optionId, unsigned int optionIdx);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Option Source Enum
|
||||
@ -156,17 +170,12 @@ Load Functions
|
||||
Used primarily by modules that need to manipulate the configuration. These modules include, but are not limited to, config/parse.c,
|
||||
config/load.c.
|
||||
***********************************************************************************************************************************/
|
||||
// Initialize or reinitialize the configuration data
|
||||
void cfgInit(void);
|
||||
|
||||
// Was help requested?
|
||||
bool cfgCommandHelp(void);
|
||||
void cfgCommandHelpSet(bool help);
|
||||
|
||||
// Get command id by name. If error is true then assert when the command does not exist.
|
||||
ConfigCommand cfgCommandId(const char *commandName, bool error);
|
||||
// Get command id by name
|
||||
ConfigCommand cfgCommandId(const char *commandName);
|
||||
|
||||
void cfgCommandParamSet(const StringList *param);
|
||||
void cfgCommandSet(ConfigCommand commandId, ConfigCommandRole commandRoleId);
|
||||
|
||||
// Get command/role name with custom separator
|
||||
@ -178,39 +187,32 @@ const String *cfgCommandRoleStr(ConfigCommandRole commandRole);
|
||||
|
||||
// pgBackRest exe
|
||||
const String *cfgExe(void);
|
||||
void cfgExeSet(const String *exe);
|
||||
|
||||
// Option default
|
||||
// Option default - should only be called by the help command
|
||||
const Variant *cfgOptionDefault(ConfigOption optionId);
|
||||
|
||||
// Set option default. Option defaults are generally not set in advance because the vast majority of them are never used. It is
|
||||
// more efficient to generate them when they are requested. Some defaults are (e.g. the exe path) are set at runtime.
|
||||
void cfgOptionDefaultSet(ConfigOption optionId, const Variant *defaultValue);
|
||||
|
||||
// Get the option define for this option
|
||||
ConfigDefineOption cfgOptionDefIdFromId(ConfigOption optionId);
|
||||
|
||||
// Parse a host option and extract the host and port (if it exists)
|
||||
String *cfgOptionHostPort(ConfigOption optionId, unsigned int *port);
|
||||
|
||||
// Get the id for this option define
|
||||
ConfigOption cfgOptionIdFromDefId(ConfigDefineOption optionDefId, unsigned int index);
|
||||
String *cfgOptionIdxHostPort(ConfigOption optionId, unsigned int optionIdx, unsigned int *port);
|
||||
|
||||
// Was the option negated?
|
||||
bool cfgOptionNegate(ConfigOption optionId);
|
||||
void cfgOptionNegateSet(ConfigOption optionId, bool negate);
|
||||
bool cfgOptionIdxNegate(ConfigOption optionId, unsigned int optionIdx);
|
||||
|
||||
// Was the option reset?
|
||||
bool cfgOptionReset(ConfigOption optionId);
|
||||
void cfgOptionResetSet(ConfigOption optionId, bool reset);
|
||||
bool cfgOptionIdxReset(ConfigOption optionId, unsigned int optionIdx);
|
||||
|
||||
// Set config option
|
||||
void cfgOptionSet(ConfigOption optionId, ConfigSource source, const Variant *value);
|
||||
void cfgOptionIdxSet(ConfigOption optionId, unsigned int optionIdx, ConfigSource source, const Variant *value);
|
||||
|
||||
// How was the option set (default, param, config)?
|
||||
ConfigSource cfgOptionSource(ConfigOption optionId);
|
||||
|
||||
// Set option valid
|
||||
void cfgOptionValidSet(ConfigOption optionId, bool valid);
|
||||
ConfigSource cfgOptionIdxSource(ConfigOption optionId, unsigned int optionIdx);
|
||||
|
||||
#endif
|
||||
|
94
src/config/config.intern.h
Normal file
94
src/config/config.intern.h
Normal file
@ -0,0 +1,94 @@
|
||||
/***********************************************************************************************************************************
|
||||
Command and Option Configuration Internals
|
||||
|
||||
These structures and functions are generally used by modules that create configurations, e.g. config/parse, or modules that
|
||||
manipulate the configuration as a whole, e.g. protocol/helper, in order to communicate with other processes.
|
||||
|
||||
The general-purpose functions for querying the current configuration are found in config.h.
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef CONFIG_CONFIG_INTERN_H
|
||||
#define CONFIG_CONFIG_INTERN_H
|
||||
|
||||
#include "config/config.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
The maximum number of keys that an indexed option can have, e.g. pg256-path would be the maximum pg-path option
|
||||
***********************************************************************************************************************************/
|
||||
#define CFG_OPTION_KEY_MAX 256
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Configuration data. These structures are not directly user-created or accessible. configParse() creates the structures and uses
|
||||
cfgInit() to load it as the current configuration. Various cfg*() functions provide access.
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct ConfigOptionValue
|
||||
{
|
||||
bool negate; // Is the option negated?
|
||||
bool reset; // Is the option reset?
|
||||
unsigned int source; // Where the option came from, i.e. ConfigSource enum
|
||||
const Variant *value; // Value
|
||||
} ConfigOptionValue;
|
||||
|
||||
typedef struct Config
|
||||
{
|
||||
MemContext *memContext; // Mem context for config data
|
||||
|
||||
// Generally set by the command parser but can also be set by during execute to change commands, i.e. backup -> expire
|
||||
ConfigCommand command; // Current command
|
||||
ConfigCommandRole commandRole; // Current command role
|
||||
|
||||
String *exe; // Location of the executable
|
||||
bool help; // Was help requested for the command?
|
||||
StringList *paramList; // Parameters passed to the command (if any)
|
||||
|
||||
// Group options that are related together to allow valid and test checks across all options in the group
|
||||
struct
|
||||
{
|
||||
bool valid; // Is option group valid for the current command?
|
||||
unsigned int indexTotal; // Total number of indexes with values in option group
|
||||
unsigned int indexDefault; // Default index (usually 0)
|
||||
unsigned int indexMap[CFG_OPTION_KEY_MAX]; // List of index to key index mappings
|
||||
} optionGroup[CFG_OPTION_GROUP_TOTAL];
|
||||
|
||||
// Option data
|
||||
struct
|
||||
{
|
||||
bool valid; // Is option valid for current command?
|
||||
const Variant *defaultValue; // Default value
|
||||
ConfigOptionValue *index; // List of indexed values (only 1 unless the option is indexed)
|
||||
} option[CFG_OPTION_TOTAL];
|
||||
} Config;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Init Function
|
||||
***********************************************************************************************************************************/
|
||||
// Init with new configuration
|
||||
void cfgInit(Config *config);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Option Group Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Is the option in a group?
|
||||
bool cfgOptionGroup(ConfigOption optionId);
|
||||
|
||||
// Group id if the option is in a group
|
||||
unsigned int cfgOptionGroupId(ConfigOption optionId);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Option Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Get the option name using the key index -- i.e. the key that was used during configuration - 1, e.g. to get pg2-host pass 1 to
|
||||
// keyIdx.
|
||||
const char *cfgOptionKeyIdxName(ConfigOption optionId, unsigned int keyIdx);
|
||||
|
||||
// Convert the key used in the original configuration to a group index. This is used when an option key must be translated into the
|
||||
// local group index, e.g. during parsing or when getting the value of specific options from a remote.
|
||||
unsigned int cfgOptionKeyToIdx(ConfigOption optionId, unsigned int key);
|
||||
|
||||
// Total indexes for the option if in a group, 1 otherwise.
|
||||
unsigned int cfgOptionIdxTotal(ConfigOption optionId);
|
||||
|
||||
// Invalidate an option so it will not be passed to other processes. This is used to manage deprecated options that have a newer
|
||||
// option that should be used when possible, e.g. compress and compress-type.
|
||||
void cfgOptionInvalidate(ConfigOption optionId);
|
||||
|
||||
#endif
|
@ -378,7 +378,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptOnline,
|
||||
cfgOptOnline,
|
||||
"1"
|
||||
)
|
||||
)
|
||||
@ -426,7 +426,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptArchiveCheck,
|
||||
cfgOptArchiveCheck,
|
||||
"1"
|
||||
)
|
||||
)
|
||||
@ -1403,7 +1403,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptOnline,
|
||||
cfgOptOnline,
|
||||
"0"
|
||||
)
|
||||
|
||||
@ -1477,33 +1477,6 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
)
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
CFGDEFDATA_OPTION
|
||||
(
|
||||
CFGDEFDATA_OPTION_NAME("host-id")
|
||||
CFGDEFDATA_OPTION_REQUIRED(false)
|
||||
CFGDEFDATA_OPTION_SECTION(cfgDefSectionCommandLine)
|
||||
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeInteger)
|
||||
CFGDEFDATA_OPTION_INTERNAL(true)
|
||||
|
||||
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
||||
CFGDEFDATA_OPTION_SECURE(false)
|
||||
|
||||
CFGDEFDATA_OPTION_COMMAND_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdArchiveGet)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdArchivePush)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdBackup)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdRestore)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdVerify)
|
||||
)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 8)
|
||||
)
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
CFGDEFDATA_OPTION
|
||||
(
|
||||
@ -2246,6 +2219,63 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
)
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
CFGDEFDATA_OPTION
|
||||
(
|
||||
CFGDEFDATA_OPTION_NAME("pg")
|
||||
CFGDEFDATA_OPTION_REQUIRED(false)
|
||||
CFGDEFDATA_OPTION_SECTION(cfgDefSectionStanza)
|
||||
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeInteger)
|
||||
CFGDEFDATA_OPTION_INTERNAL(true)
|
||||
|
||||
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
||||
CFGDEFDATA_OPTION_SECURE(false)
|
||||
|
||||
CFGDEFDATA_OPTION_COMMAND_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdArchiveGet)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdArchivePush)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdBackup)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdCheck)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdRestore)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaCreate)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaUpgrade)
|
||||
)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 8)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdBackup)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_INTERNAL(true)
|
||||
)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdCheck)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_INTERNAL(true)
|
||||
)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdStanzaCreate)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_INTERNAL(true)
|
||||
)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdStanzaUpgrade)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_INTERNAL(true)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
CFGDEFDATA_OPTION
|
||||
(
|
||||
@ -2284,7 +2314,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptPgLocal,
|
||||
cfgOptPgLocal,
|
||||
"0"
|
||||
)
|
||||
|
||||
@ -2347,7 +2377,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-cmd")
|
||||
)
|
||||
)
|
||||
@ -2386,7 +2416,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/pgbackrest.conf")
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-config")
|
||||
)
|
||||
@ -2426,7 +2456,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/conf.d")
|
||||
)
|
||||
)
|
||||
@ -2465,7 +2495,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest")
|
||||
)
|
||||
)
|
||||
@ -2504,7 +2534,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0, 65535)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-ssh-port")
|
||||
)
|
||||
)
|
||||
@ -2543,7 +2573,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("postgres")
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-user")
|
||||
)
|
||||
@ -2684,7 +2714,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0, 65535)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgPath)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgPath)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("5432")
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-port")
|
||||
)
|
||||
@ -2723,7 +2753,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0, 65535)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgPath)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgPath)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-socket-path")
|
||||
)
|
||||
)
|
||||
@ -2759,7 +2789,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptPgPath)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptPgPath)
|
||||
)
|
||||
)
|
||||
|
||||
@ -2950,7 +2980,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptType,
|
||||
cfgOptType,
|
||||
"default",
|
||||
"immediate",
|
||||
"name",
|
||||
@ -3048,6 +3078,46 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
)
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
CFGDEFDATA_OPTION
|
||||
(
|
||||
CFGDEFDATA_OPTION_NAME("repo")
|
||||
CFGDEFDATA_OPTION_REQUIRED(false)
|
||||
CFGDEFDATA_OPTION_SECTION(cfgDefSectionGlobal)
|
||||
CFGDEFDATA_OPTION_TYPE(cfgDefOptTypeInteger)
|
||||
CFGDEFDATA_OPTION_INTERNAL(true)
|
||||
|
||||
CFGDEFDATA_OPTION_INDEX_TOTAL(1)
|
||||
CFGDEFDATA_OPTION_SECURE(false)
|
||||
|
||||
CFGDEFDATA_OPTION_COMMAND_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdArchiveGet)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdArchivePush)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdBackup)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdCheck)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdExpire)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdInfo)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoCreate)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoGet)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoLs)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoPut)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdRepoRm)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdRestore)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaCreate)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaDelete)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdStanzaUpgrade)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdStart)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdStop)
|
||||
CFGDEFDATA_OPTION_COMMAND(cfgCmdVerify)
|
||||
)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 1)
|
||||
)
|
||||
)
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
CFGDEFDATA_OPTION
|
||||
(
|
||||
@ -3093,7 +3163,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
)
|
||||
@ -3144,7 +3214,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
)
|
||||
@ -3195,7 +3265,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
)
|
||||
@ -3249,7 +3319,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
)
|
||||
@ -3300,7 +3370,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
|
||||
@ -3353,7 +3423,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
)
|
||||
@ -3404,7 +3474,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
)
|
||||
@ -3464,7 +3534,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
|
||||
@ -3518,7 +3588,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 65535)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
|
||||
@ -3572,7 +3642,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"azure"
|
||||
)
|
||||
|
||||
@ -3625,7 +3695,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoCipherType,
|
||||
cfgOptRepoCipherType,
|
||||
"aes-256-cbc"
|
||||
)
|
||||
)
|
||||
@ -3769,7 +3839,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoLocal,
|
||||
cfgOptRepoLocal,
|
||||
"0"
|
||||
)
|
||||
|
||||
@ -3851,7 +3921,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("backup-cmd")
|
||||
)
|
||||
)
|
||||
@ -3895,7 +3965,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/pgbackrest.conf")
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("backup-config")
|
||||
)
|
||||
@ -3940,7 +4010,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/conf.d")
|
||||
)
|
||||
)
|
||||
@ -3984,7 +4054,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest")
|
||||
)
|
||||
)
|
||||
@ -4028,7 +4098,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(0, 65535)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("backup-ssh-port")
|
||||
)
|
||||
)
|
||||
@ -4074,7 +4144,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEFAULT("pgbackrest")
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("backup-user")
|
||||
)
|
||||
@ -4455,7 +4525,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
)
|
||||
@ -4506,7 +4576,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
)
|
||||
@ -4557,7 +4627,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
)
|
||||
@ -4608,7 +4678,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
)
|
||||
@ -4659,7 +4729,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
)
|
||||
@ -4710,7 +4780,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoS3KeyType,
|
||||
cfgOptRepoS3KeyType,
|
||||
"shared"
|
||||
)
|
||||
)
|
||||
@ -4761,7 +4831,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoS3KeyType,
|
||||
cfgOptRepoS3KeyType,
|
||||
"shared"
|
||||
)
|
||||
)
|
||||
@ -4821,7 +4891,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
|
||||
@ -4875,7 +4945,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 65535)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
|
||||
@ -4928,7 +4998,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
)
|
||||
@ -4979,7 +5049,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoS3KeyType,
|
||||
cfgOptRepoS3KeyType,
|
||||
"auto"
|
||||
)
|
||||
)
|
||||
@ -5030,7 +5100,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoS3KeyType,
|
||||
cfgOptRepoS3KeyType,
|
||||
"shared"
|
||||
)
|
||||
)
|
||||
@ -5090,7 +5160,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
|
||||
@ -5144,7 +5214,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptRepoType,
|
||||
cfgOptRepoType,
|
||||
"s3"
|
||||
)
|
||||
|
||||
@ -5374,7 +5444,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgCmdInfo)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgDefOptStanza)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND(cfgOptStanza)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_REQUIRED(false)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_SUMMARY("Backup set to detail.")
|
||||
@ -5505,7 +5575,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptArchiveAsync,
|
||||
cfgOptArchiveAsync,
|
||||
"1"
|
||||
)
|
||||
)
|
||||
@ -5516,7 +5586,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptArchiveAsync,
|
||||
cfgOptArchiveAsync,
|
||||
"1"
|
||||
)
|
||||
)
|
||||
@ -5789,7 +5859,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptType,
|
||||
cfgOptType,
|
||||
"name",
|
||||
"time",
|
||||
"xid"
|
||||
@ -5836,7 +5906,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptType,
|
||||
cfgOptType,
|
||||
"immediate",
|
||||
"name",
|
||||
"time",
|
||||
@ -5886,7 +5956,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptType,
|
||||
cfgOptType,
|
||||
"time",
|
||||
"xid"
|
||||
)
|
||||
@ -5930,7 +6000,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptType,
|
||||
cfgOptType,
|
||||
"default",
|
||||
"name",
|
||||
"standby",
|
||||
@ -5995,7 +6065,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 32)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptSckKeepAlive,
|
||||
cfgOptSckKeepAlive,
|
||||
"1"
|
||||
)
|
||||
)
|
||||
@ -6048,7 +6118,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 3600)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptSckKeepAlive,
|
||||
cfgOptSckKeepAlive,
|
||||
"1"
|
||||
)
|
||||
)
|
||||
@ -6101,7 +6171,7 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_ALLOW_RANGE(1, 900)
|
||||
CFGDEFDATA_OPTION_OPTIONAL_DEPEND_LIST
|
||||
(
|
||||
cfgDefOptSckKeepAlive,
|
||||
cfgOptSckKeepAlive,
|
||||
"1"
|
||||
)
|
||||
)
|
||||
|
@ -21,135 +21,4 @@ typedef enum
|
||||
cfgDefOptTypeString,
|
||||
} ConfigDefineOptionType;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Option define enum
|
||||
***********************************************************************************************************************************/
|
||||
typedef enum
|
||||
{
|
||||
cfgDefOptArchiveAsync,
|
||||
cfgDefOptArchiveCheck,
|
||||
cfgDefOptArchiveCopy,
|
||||
cfgDefOptArchiveGetQueueMax,
|
||||
cfgDefOptArchiveMode,
|
||||
cfgDefOptArchivePushQueueMax,
|
||||
cfgDefOptArchiveTimeout,
|
||||
cfgDefOptBackupStandby,
|
||||
cfgDefOptBufferSize,
|
||||
cfgDefOptChecksumPage,
|
||||
cfgDefOptCipherPass,
|
||||
cfgDefOptCmdSsh,
|
||||
cfgDefOptCompress,
|
||||
cfgDefOptCompressLevel,
|
||||
cfgDefOptCompressLevelNetwork,
|
||||
cfgDefOptCompressType,
|
||||
cfgDefOptConfig,
|
||||
cfgDefOptConfigIncludePath,
|
||||
cfgDefOptConfigPath,
|
||||
cfgDefOptDbInclude,
|
||||
cfgDefOptDbTimeout,
|
||||
cfgDefOptDelta,
|
||||
cfgDefOptDryRun,
|
||||
cfgDefOptExclude,
|
||||
cfgDefOptExecId,
|
||||
cfgDefOptExpireAuto,
|
||||
cfgDefOptFilter,
|
||||
cfgDefOptForce,
|
||||
cfgDefOptHostId,
|
||||
cfgDefOptIgnoreMissing,
|
||||
cfgDefOptIoTimeout,
|
||||
cfgDefOptLinkAll,
|
||||
cfgDefOptLinkMap,
|
||||
cfgDefOptLockPath,
|
||||
cfgDefOptLogLevelConsole,
|
||||
cfgDefOptLogLevelFile,
|
||||
cfgDefOptLogLevelStderr,
|
||||
cfgDefOptLogPath,
|
||||
cfgDefOptLogSubprocess,
|
||||
cfgDefOptLogTimestamp,
|
||||
cfgDefOptManifestSaveThreshold,
|
||||
cfgDefOptNeutralUmask,
|
||||
cfgDefOptOnline,
|
||||
cfgDefOptOutput,
|
||||
cfgDefOptPgHost,
|
||||
cfgDefOptPgHostCmd,
|
||||
cfgDefOptPgHostConfig,
|
||||
cfgDefOptPgHostConfigIncludePath,
|
||||
cfgDefOptPgHostConfigPath,
|
||||
cfgDefOptPgHostPort,
|
||||
cfgDefOptPgHostUser,
|
||||
cfgDefOptPgLocal,
|
||||
cfgDefOptPgPath,
|
||||
cfgDefOptPgPort,
|
||||
cfgDefOptPgSocketPath,
|
||||
cfgDefOptPgUser,
|
||||
cfgDefOptProcess,
|
||||
cfgDefOptProcessMax,
|
||||
cfgDefOptProtocolTimeout,
|
||||
cfgDefOptRaw,
|
||||
cfgDefOptRecoveryOption,
|
||||
cfgDefOptRecurse,
|
||||
cfgDefOptRemoteType,
|
||||
cfgDefOptRepoAzureAccount,
|
||||
cfgDefOptRepoAzureCaFile,
|
||||
cfgDefOptRepoAzureCaPath,
|
||||
cfgDefOptRepoAzureContainer,
|
||||
cfgDefOptRepoAzureEndpoint,
|
||||
cfgDefOptRepoAzureHost,
|
||||
cfgDefOptRepoAzureKey,
|
||||
cfgDefOptRepoAzureKeyType,
|
||||
cfgDefOptRepoAzurePort,
|
||||
cfgDefOptRepoAzureVerifyTls,
|
||||
cfgDefOptRepoCipherPass,
|
||||
cfgDefOptRepoCipherType,
|
||||
cfgDefOptRepoHardlink,
|
||||
cfgDefOptRepoHost,
|
||||
cfgDefOptRepoHostCmd,
|
||||
cfgDefOptRepoHostConfig,
|
||||
cfgDefOptRepoHostConfigIncludePath,
|
||||
cfgDefOptRepoHostConfigPath,
|
||||
cfgDefOptRepoHostPort,
|
||||
cfgDefOptRepoHostUser,
|
||||
cfgDefOptRepoLocal,
|
||||
cfgDefOptRepoPath,
|
||||
cfgDefOptRepoRetentionArchive,
|
||||
cfgDefOptRepoRetentionArchiveType,
|
||||
cfgDefOptRepoRetentionDiff,
|
||||
cfgDefOptRepoRetentionFull,
|
||||
cfgDefOptRepoRetentionFullType,
|
||||
cfgDefOptRepoS3Bucket,
|
||||
cfgDefOptRepoS3CaFile,
|
||||
cfgDefOptRepoS3CaPath,
|
||||
cfgDefOptRepoS3Endpoint,
|
||||
cfgDefOptRepoS3Host,
|
||||
cfgDefOptRepoS3Key,
|
||||
cfgDefOptRepoS3KeySecret,
|
||||
cfgDefOptRepoS3KeyType,
|
||||
cfgDefOptRepoS3Port,
|
||||
cfgDefOptRepoS3Region,
|
||||
cfgDefOptRepoS3Role,
|
||||
cfgDefOptRepoS3Token,
|
||||
cfgDefOptRepoS3UriStyle,
|
||||
cfgDefOptRepoS3VerifyTls,
|
||||
cfgDefOptRepoType,
|
||||
cfgDefOptResume,
|
||||
cfgDefOptSckBlock,
|
||||
cfgDefOptSckKeepAlive,
|
||||
cfgDefOptSet,
|
||||
cfgDefOptSort,
|
||||
cfgDefOptSpoolPath,
|
||||
cfgDefOptStanza,
|
||||
cfgDefOptStartFast,
|
||||
cfgDefOptStopAuto,
|
||||
cfgDefOptTablespaceMap,
|
||||
cfgDefOptTablespaceMapAll,
|
||||
cfgDefOptTarget,
|
||||
cfgDefOptTargetAction,
|
||||
cfgDefOptTargetExclusive,
|
||||
cfgDefOptTargetTimeline,
|
||||
cfgDefOptTcpKeepAliveCount,
|
||||
cfgDefOptTcpKeepAliveIdle,
|
||||
cfgDefOptTcpKeepAliveInterval,
|
||||
cfgDefOptType,
|
||||
} ConfigDefineOption;
|
||||
|
||||
#endif
|
||||
|
@ -249,14 +249,14 @@ cfgDefDataFind(
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
}
|
||||
|
||||
#define CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, type) \
|
||||
#define CONFIG_DEFINE_DATA_FIND(commandId, optionId, type) \
|
||||
bool dataDefFound = false; \
|
||||
int dataDef = 0; \
|
||||
unsigned int dataDefListSize = 0; \
|
||||
const void **dataDefList = NULL; \
|
||||
\
|
||||
cfgDefDataFind( \
|
||||
type, commandId, configDefineOptionData[optionDefId].data, &dataDefFound, &dataDef, &dataDefList, &dataDefListSize);
|
||||
type, commandId, configDefineOptionData[optionId].data, &dataDefFound, &dataDef, &dataDefList, &dataDefListSize);
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
unsigned int
|
||||
@ -300,74 +300,74 @@ cfgDefCommandHelpSummary(ConfigCommand commandId)
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionAllowList(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionAllowList(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowList);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowList);
|
||||
|
||||
FUNCTION_TEST_RETURN(dataDefFound);
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
cfgDefOptionAllowListValueTotal(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionAllowListValueTotal(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowList);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowList);
|
||||
|
||||
FUNCTION_TEST_RETURN(dataDefListSize);
|
||||
}
|
||||
|
||||
static const char *
|
||||
cfgDefOptionAllowListValue(ConfigCommand commandId, ConfigDefineOption optionDefId, unsigned int valueId)
|
||||
cfgDefOptionAllowListValue(ConfigCommand commandId, ConfigOption optionId, unsigned int valueId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_PARAM(UINT, valueId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(valueId < cfgDefOptionAllowListValueTotal(commandId, optionDefId));
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
ASSERT(valueId < cfgDefOptionAllowListValueTotal(commandId, optionId));
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowList);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowList);
|
||||
|
||||
FUNCTION_TEST_RETURN((char *)dataDefList[valueId]);
|
||||
}
|
||||
|
||||
// Check if the value matches a value in the allow list
|
||||
bool
|
||||
cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigDefineOption optionDefId, const char *value)
|
||||
cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigOption optionId, const char *value)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_PARAM(STRINGZ, value);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
ASSERT(value != NULL);
|
||||
|
||||
bool result = false;
|
||||
|
||||
for (unsigned int valueIdx = 0; valueIdx < cfgDefOptionAllowListValueTotal(commandId, optionDefId); valueIdx++)
|
||||
for (unsigned int valueIdx = 0; valueIdx < cfgDefOptionAllowListValueTotal(commandId, optionId); valueIdx++)
|
||||
{
|
||||
if (strcmp(value, cfgDefOptionAllowListValue(commandId, optionDefId, valueIdx)) == 0)
|
||||
if (strcmp(value, cfgDefOptionAllowListValue(commandId, optionId, valueIdx)) == 0)
|
||||
result = true;
|
||||
}
|
||||
|
||||
@ -376,50 +376,50 @@ cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigDefineOption opti
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionAllowRange(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionAllowRange(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowRange);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange);
|
||||
|
||||
FUNCTION_TEST_RETURN(dataDefFound);
|
||||
}
|
||||
|
||||
double
|
||||
cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowRange);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange);
|
||||
|
||||
FUNCTION_TEST_RETURN(
|
||||
((double)(((int64_t)(intptr_t)dataDefList[2]) + (((int64_t)(intptr_t)dataDefList[3]) * 1000000000L))) / 100);
|
||||
}
|
||||
|
||||
double
|
||||
cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeAllowRange);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeAllowRange);
|
||||
|
||||
FUNCTION_TEST_RETURN(
|
||||
((double)(((int64_t)(intptr_t)dataDefList[0]) + (((int64_t)(intptr_t)dataDefList[1]) * 1000000000L))) / 100);
|
||||
@ -427,17 +427,17 @@ cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigDefineOption optionDefI
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
const char *
|
||||
cfgDefOptionDefault(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionDefault(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDefault);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDefault);
|
||||
|
||||
char *result = NULL;
|
||||
|
||||
@ -449,90 +449,90 @@ cfgDefOptionDefault(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionDepend(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionDepend(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDepend);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDepend);
|
||||
|
||||
FUNCTION_TEST_RETURN(dataDefFound);
|
||||
}
|
||||
|
||||
ConfigDefineOption
|
||||
cfgDefOptionDependOption(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
ConfigOption
|
||||
cfgDefOptionDependOption(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDepend);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDepend);
|
||||
|
||||
FUNCTION_TEST_RETURN((ConfigDefineOption)dataDef);
|
||||
FUNCTION_TEST_RETURN((ConfigOption)dataDef);
|
||||
}
|
||||
|
||||
const char *
|
||||
cfgDefOptionDependValue(ConfigCommand commandId, ConfigDefineOption optionDefId, unsigned int valueId)
|
||||
cfgDefOptionDependValue(ConfigCommand commandId, ConfigOption optionId, unsigned int valueId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_PARAM(UINT, valueId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(valueId < cfgDefOptionDependValueTotal(commandId, optionDefId));
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
ASSERT(valueId < cfgDefOptionDependValueTotal(commandId, optionId));
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDepend);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDepend);
|
||||
|
||||
FUNCTION_TEST_RETURN((char *)dataDefList[valueId]);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
cfgDefOptionDependValueTotal(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionDependValueTotal(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeDepend);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeDepend);
|
||||
|
||||
FUNCTION_TEST_RETURN(dataDefListSize);
|
||||
}
|
||||
|
||||
// Check if the value matches a value in the allow list
|
||||
bool
|
||||
cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigDefineOption optionDefId, const char *value)
|
||||
cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigOption optionId, const char *value)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_PARAM(STRINGZ, value);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
ASSERT(value != NULL);
|
||||
|
||||
bool result = false;
|
||||
|
||||
for (unsigned int valueIdx = 0; valueIdx < cfgDefOptionDependValueTotal(commandId, optionDefId); valueIdx++)
|
||||
for (unsigned int valueIdx = 0; valueIdx < cfgDefOptionDependValueTotal(commandId, optionId); valueIdx++)
|
||||
{
|
||||
if (strcmp(value, cfgDefOptionDependValue(commandId, optionDefId, valueIdx)) == 0)
|
||||
if (strcmp(value, cfgDefOptionDependValue(commandId, optionId, valueIdx)) == 0)
|
||||
result = true;
|
||||
}
|
||||
|
||||
@ -541,19 +541,19 @@ cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigDefineOption optionD
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
const char *
|
||||
cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeHelpDescription);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeHelpDescription);
|
||||
|
||||
const char *result = configDefineOptionData[optionDefId].helpDescription;
|
||||
const char *result = configDefineOptionData[optionId].helpDescription;
|
||||
|
||||
if (dataDefFound)
|
||||
result = (char *)dataDefList[0];
|
||||
@ -563,77 +563,77 @@ cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigDefineOption optionDe
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionHelpNameAlt(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionHelpNameAlt(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(-1, optionDefId, configDefDataTypeHelpNameAlt);
|
||||
CONFIG_DEFINE_DATA_FIND(-1, optionId, configDefDataTypeHelpNameAlt);
|
||||
|
||||
FUNCTION_TEST_RETURN(dataDefFound);
|
||||
}
|
||||
|
||||
const char *
|
||||
cfgDefOptionHelpNameAltValue(ConfigDefineOption optionDefId, unsigned int valueId)
|
||||
cfgDefOptionHelpNameAltValue(ConfigOption optionId, unsigned int valueId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_PARAM(UINT, valueId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(valueId < cfgDefOptionHelpNameAltValueTotal(optionDefId));
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
ASSERT(valueId < cfgDefOptionHelpNameAltValueTotal(optionId));
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(-1, optionDefId, configDefDataTypeHelpNameAlt);
|
||||
CONFIG_DEFINE_DATA_FIND(-1, optionId, configDefDataTypeHelpNameAlt);
|
||||
|
||||
FUNCTION_TEST_RETURN((char *)dataDefList[valueId]);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
cfgDefOptionHelpNameAltValueTotal(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionHelpNameAltValueTotal(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(-1, optionDefId, configDefDataTypeHelpNameAlt);
|
||||
CONFIG_DEFINE_DATA_FIND(-1, optionId, configDefDataTypeHelpNameAlt);
|
||||
|
||||
FUNCTION_TEST_RETURN(dataDefListSize);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
const char *
|
||||
cfgDefOptionHelpSection(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionHelpSection(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].helpSection);
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionId].helpSection);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
const char *
|
||||
cfgDefOptionHelpSummary(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionHelpSummary(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeHelpSummary);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeHelpSummary);
|
||||
|
||||
const char *result = configDefineOptionData[optionDefId].helpSummary;
|
||||
const char *result = configDefineOptionData[optionId].helpSummary;
|
||||
|
||||
if (dataDefFound)
|
||||
result = (char *)dataDefList[0];
|
||||
@ -653,41 +653,41 @@ cfgDefOptionId(const char *optionName)
|
||||
|
||||
int result = -1;
|
||||
|
||||
for (ConfigDefineOption optionDefId = 0; optionDefId < cfgDefOptionTotal(); optionDefId++)
|
||||
if (strcmp(optionName, configDefineOptionData[optionDefId].name) == 0)
|
||||
result = optionDefId;
|
||||
for (ConfigOption optionId = 0; optionId < cfgDefOptionTotal(); optionId++)
|
||||
if (strcmp(optionName, configDefineOptionData[optionId].name) == 0)
|
||||
result = optionId;
|
||||
|
||||
FUNCTION_TEST_RETURN(result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
unsigned int
|
||||
cfgDefOptionIndexTotal(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionIndexTotal(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].indexTotal);
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionId].indexTotal);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionInternal(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionInternal(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeInternal);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeInternal);
|
||||
|
||||
bool result = configDefineOptionData[optionDefId].internal;
|
||||
bool result = configDefineOptionData[optionId].internal;
|
||||
|
||||
if (dataDefFound)
|
||||
result = (bool)dataDef;
|
||||
@ -697,60 +697,60 @@ cfgDefOptionInternal(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionMulti(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionMulti(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
FUNCTION_TEST_RETURN(
|
||||
configDefineOptionData[optionDefId].type == cfgDefOptTypeHash ||
|
||||
configDefineOptionData[optionDefId].type == cfgDefOptTypeList);
|
||||
configDefineOptionData[optionId].type == cfgDefOptTypeHash ||
|
||||
configDefineOptionData[optionId].type == cfgDefOptTypeList);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
const char *
|
||||
cfgDefOptionName(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionName(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].name);
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionId].name);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionSecure(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionSecure(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].secure);
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionId].secure);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionRequired(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionRequired(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionDefId, configDefDataTypeRequired);
|
||||
CONFIG_DEFINE_DATA_FIND(commandId, optionId, configDefDataTypeRequired);
|
||||
|
||||
bool result = configDefineOptionData[optionDefId].required;
|
||||
bool result = configDefineOptionData[optionId].required;
|
||||
|
||||
if (dataDefFound)
|
||||
result = (bool)dataDef;
|
||||
@ -760,41 +760,41 @@ cfgDefOptionRequired(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
ConfigDefSection
|
||||
cfgDefOptionSection(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionSection(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].section);
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionId].section);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
int
|
||||
cfgDefOptionType(ConfigDefineOption optionDefId)
|
||||
cfgDefOptionType(ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].type);
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionId].type);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
cfgDefOptionValid(ConfigCommand commandId, ConfigDefineOption optionDefId)
|
||||
cfgDefOptionValid(ConfigCommand commandId, ConfigOption optionId)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(ENUM, commandId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionDefId);
|
||||
FUNCTION_TEST_PARAM(ENUM, optionId);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(commandId < cfgDefCommandTotal());
|
||||
ASSERT(optionDefId < cfgDefOptionTotal());
|
||||
ASSERT(optionId < cfgDefOptionTotal());
|
||||
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionDefId].commandValid & (1 << commandId));
|
||||
FUNCTION_TEST_RETURN(configDefineOptionData[optionId].commandValid & (1 << commandId));
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ typedef enum
|
||||
cfgDefSectionStanza, // command-line or in any config stanza section
|
||||
} ConfigDefSection;
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/define.auto.h"
|
||||
#include "common/type/string.h"
|
||||
#include "config/config.auto.h"
|
||||
#include "config/define.auto.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Define global section name
|
||||
@ -37,67 +37,67 @@ const char *cfgDefCommandHelpDescription(ConfigCommand commandId);
|
||||
const char *cfgDefCommandHelpSummary(ConfigCommand commandId);
|
||||
|
||||
// Option allow lists
|
||||
bool cfgDefOptionAllowList(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigDefineOption optionDefId, const char *value);
|
||||
bool cfgDefOptionAllowList(ConfigCommand commandId, ConfigOption optionId);
|
||||
bool cfgDefOptionAllowListValueValid(ConfigCommand commandId, ConfigOption optionId, const char *value);
|
||||
|
||||
// Allow range
|
||||
bool cfgDefOptionAllowRange(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
double cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
double cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionAllowRange(ConfigCommand commandId, ConfigOption optionId);
|
||||
double cfgDefOptionAllowRangeMax(ConfigCommand commandId, ConfigOption optionId);
|
||||
double cfgDefOptionAllowRangeMin(ConfigCommand commandId, ConfigOption optionId);
|
||||
|
||||
// Default value for the option
|
||||
const char *cfgDefOptionDefault(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionDefault(ConfigCommand commandId, ConfigOption optionId);
|
||||
|
||||
// Dependencies and depend lists
|
||||
bool cfgDefOptionDepend(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
ConfigDefineOption cfgDefOptionDependOption(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
unsigned int cfgDefOptionDependValueTotal(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigDefineOption optionDefId, const char *value);
|
||||
const char *cfgDefOptionDependValue(ConfigCommand commandId, ConfigDefineOption optionDefId, unsigned int valueId);
|
||||
bool cfgDefOptionDepend(ConfigCommand commandId, ConfigOption optionId);
|
||||
ConfigOption cfgDefOptionDependOption(ConfigCommand commandId, ConfigOption optionId);
|
||||
unsigned int cfgDefOptionDependValueTotal(ConfigCommand commandId, ConfigOption optionId);
|
||||
bool cfgDefOptionDependValueValid(ConfigCommand commandId, ConfigOption optionId, const char *value);
|
||||
const char *cfgDefOptionDependValue(ConfigCommand commandId, ConfigOption optionId, unsigned int valueId);
|
||||
|
||||
// Option help
|
||||
const char *cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionHelpSummary(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionHelpDescription(ConfigCommand commandId, ConfigOption optionId);
|
||||
const char *cfgDefOptionHelpSummary(ConfigCommand commandId, ConfigOption optionId);
|
||||
|
||||
// Option help name alt
|
||||
bool cfgDefOptionHelpNameAlt(ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionHelpNameAltValue(ConfigDefineOption optionDefId, unsigned int valueId);
|
||||
unsigned int cfgDefOptionHelpNameAltValueTotal(ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionHelpNameAlt(ConfigOption optionId);
|
||||
const char *cfgDefOptionHelpNameAltValue(ConfigOption optionId, unsigned int valueId);
|
||||
unsigned int cfgDefOptionHelpNameAltValueTotal(ConfigOption optionId);
|
||||
|
||||
// Option help section
|
||||
const char *cfgDefOptionHelpSection(ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionHelpSection(ConfigOption optionId);
|
||||
|
||||
// Option id by name
|
||||
int cfgDefOptionId(const char *optionName);
|
||||
|
||||
// Total indexed values for option
|
||||
unsigned int cfgDefOptionIndexTotal(ConfigDefineOption optionDefId);
|
||||
unsigned int cfgDefOptionIndexTotal(ConfigOption optionId);
|
||||
|
||||
// Is the option for internal use only?
|
||||
bool cfgDefOptionInternal(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionInternal(ConfigCommand commandId, ConfigOption optionId);
|
||||
|
||||
// Does the option accept multiple values?
|
||||
bool cfgDefOptionMulti(ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionMulti(ConfigOption optionId);
|
||||
|
||||
// Name of the option
|
||||
const char *cfgDefOptionName(ConfigDefineOption optionDefId);
|
||||
const char *cfgDefOptionName(ConfigOption optionId);
|
||||
|
||||
// Is the option required
|
||||
bool cfgDefOptionRequired(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionRequired(ConfigCommand commandId, ConfigOption optionId);
|
||||
|
||||
// Get option section
|
||||
ConfigDefSection cfgDefOptionSection(ConfigDefineOption optionDefId);
|
||||
ConfigDefSection cfgDefOptionSection(ConfigOption optionId);
|
||||
|
||||
// Does the option need to be protected from showing up in logs, command lines, etc?
|
||||
bool cfgDefOptionSecure(ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionSecure(ConfigOption optionId);
|
||||
|
||||
// Option total
|
||||
unsigned int cfgDefOptionTotal(void);
|
||||
|
||||
// Get option data type
|
||||
int cfgDefOptionType(ConfigDefineOption optionDefId);
|
||||
int cfgDefOptionType(ConfigOption optionId);
|
||||
|
||||
// Is the option valid for the command?
|
||||
bool cfgDefOptionValid(ConfigCommand commandId, ConfigDefineOption optionDefId);
|
||||
bool cfgDefOptionValid(ConfigCommand commandId, ConfigOption optionId);
|
||||
|
||||
#endif
|
||||
|
@ -8,6 +8,7 @@ Exec Configuration
|
||||
#include "common/debug.h"
|
||||
#include "common/log.h"
|
||||
#include "config/define.h"
|
||||
#include "config/config.intern.h"
|
||||
#include "config/exec.h"
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -31,22 +32,26 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key
|
||||
|
||||
for (ConfigOption optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++)
|
||||
{
|
||||
ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId);
|
||||
|
||||
// Skip the option if it is not valid for the specified command or if is secure. Also skip repo1-cipher-type because
|
||||
// there's no point of passing it if the other process doesn't have access to repo1-cipher-pass. There is probably a
|
||||
// better way to do this...
|
||||
if (!cfgDefOptionValid(commandId, optionDefId) || cfgDefOptionSecure(optionDefId) ||
|
||||
optionDefId == cfgDefOptRepoCipherType)
|
||||
// Skip the option if it is not valid for the original/specified command or if is secure. Also skip repo1-cipher-type
|
||||
// because there's no point of passing it if the other process doesn't have access to repo1-cipher-pass. There is
|
||||
// probably a better way to do this last part...
|
||||
if (!cfgDefOptionValid(commandId, optionId) || cfgDefOptionSecure(optionId) || optionId == cfgOptRepoCipherType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Loop through option indexes
|
||||
unsigned int optionIdxTotal = cfgOptionGroup(optionId) ? cfgOptionGroupIdxTotal(cfgOptionGroupId(optionId)) : 1;
|
||||
|
||||
for (unsigned int optionIdx = 0; optionIdx < optionIdxTotal; optionIdx++)
|
||||
{
|
||||
// First check for a replacement
|
||||
const Variant *key = VARSTRZ(cfgOptionName(optionId));
|
||||
const Variant *key = VARSTRZ(cfgOptionIdxName(optionId, optionIdx));
|
||||
const Variant *value = NULL;
|
||||
bool exists = false;
|
||||
|
||||
// If an option is requested to be replaced (usually because remote processes do not have access to the config)
|
||||
// then if the option exists, get the new value for replacement
|
||||
if (optionReplace != NULL)
|
||||
{
|
||||
exists = kvKeyExists(optionReplace, key);
|
||||
@ -55,30 +60,30 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key
|
||||
value = kvGet(optionReplace, key);
|
||||
}
|
||||
|
||||
// If the key exists but is NULL then skip this option
|
||||
// If the key exists but its value is NULL then skip this option
|
||||
if (exists && value == NULL)
|
||||
continue;
|
||||
|
||||
// If no replacement then see if this option is valid for the current command and is not default
|
||||
// If no replacement then see if this option is not default
|
||||
if (value == NULL && cfgOptionValid(optionId))
|
||||
{
|
||||
if (cfgOptionNegate(optionId))
|
||||
if (cfgOptionIdxNegate(optionId, optionIdx))
|
||||
value = BOOL_FALSE_VAR;
|
||||
else if (cfgOptionSource(optionId) != cfgSourceDefault)
|
||||
value = cfgOption(optionId);
|
||||
else if (cfgOptionIdxSource(optionId, optionIdx) != cfgSourceDefault)
|
||||
value = cfgOptionIdx(optionId, optionIdx);
|
||||
}
|
||||
|
||||
// If the option was reset
|
||||
if (value == NULL && cfgOptionReset(optionId))
|
||||
if (value == NULL && cfgOptionValid(optionId) && cfgOptionIdxReset(optionId, optionIdx))
|
||||
{
|
||||
strLstAdd(result, strNewFmt("--reset-%s", cfgOptionName(optionId)));
|
||||
strLstAdd(result, strNewFmt("--reset-%s", cfgOptionIdxName(optionId, optionIdx)));
|
||||
}
|
||||
// Else format the value if found
|
||||
else if (value != NULL && (!local || exists || cfgOptionSource(optionId) == cfgSourceParam))
|
||||
// Else format the value if found, even if the option is not valid for the command
|
||||
else if (value != NULL && (!local || exists || cfgOptionIdxSource(optionId, optionIdx) == cfgSourceParam))
|
||||
{
|
||||
if (varType(value) == varTypeBool)
|
||||
{
|
||||
strLstAdd(result, strNewFmt("--%s%s", varBool(value) ? "" : "no-", cfgOptionName(optionId)));
|
||||
strLstAdd(result, strNewFmt("--%s%s", varBool(value) ? "" : "no-", cfgOptionIdxName(optionId, optionIdx)));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -119,7 +124,8 @@ cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const Key
|
||||
if (quote && strchr(strZ(value), ' ') != NULL)
|
||||
value = strNewFmt("\"%s\"", strZ(value));
|
||||
|
||||
strLstAdd(result, strNewFmt("--%s=%s", cfgOptionName(optionId), strZ(value)));
|
||||
strLstAdd(result, strNewFmt("--%s=%s", cfgOptionIdxName(optionId, optionIdx), strZ(value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,7 @@ Configuration Load
|
||||
#include "common/io/socket/common.h"
|
||||
#include "common/lock.h"
|
||||
#include "common/log.h"
|
||||
#include "config/config.h"
|
||||
#include "config/define.h"
|
||||
#include "config/config.intern.h"
|
||||
#include "config/load.h"
|
||||
#include "config/parse.h"
|
||||
#include "storage/helper.h"
|
||||
@ -68,18 +67,12 @@ cfgLoadUpdateOption(void)
|
||||
FUNCTION_LOG_VOID(logLevelTrace);
|
||||
|
||||
// Set default for repo-host-cmd
|
||||
if (cfgOptionTest(cfgOptRepoHost) && cfgOptionSource(cfgOptRepoHostCmd) == cfgSourceDefault)
|
||||
if (cfgOptionValid(cfgOptRepoHostCmd))
|
||||
cfgOptionDefaultSet(cfgOptRepoHostCmd, VARSTR(cfgExe()));
|
||||
|
||||
// Set default for pg-host-cmd
|
||||
if (cfgOptionValid(cfgOptPgHostCmd))
|
||||
{
|
||||
for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpPg); optionIdx++)
|
||||
{
|
||||
if (cfgOptionTest(cfgOptPgHost + optionIdx) && cfgOptionSource(cfgOptPgHostCmd + optionIdx) == cfgSourceDefault)
|
||||
cfgOptionDefaultSet(cfgOptPgHostCmd + optionIdx, VARSTR(cfgExe()));
|
||||
}
|
||||
}
|
||||
cfgOptionDefaultSet(cfgOptPgHostCmd, VARSTR(cfgExe()));
|
||||
|
||||
// Protocol timeout should be greater than db timeout
|
||||
if (cfgOptionTest(cfgOptDbTimeout) && cfgOptionTest(cfgOptProtocolTimeout) &&
|
||||
@ -119,7 +112,7 @@ cfgLoadUpdateOption(void)
|
||||
|
||||
for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpPg); optionIdx++)
|
||||
{
|
||||
if (cfgOptionTest(cfgOptPgHost + optionIdx))
|
||||
if (cfgOptionIdxTest(cfgOptPgHost, optionIdx))
|
||||
{
|
||||
pgHostFound = true;
|
||||
break;
|
||||
@ -131,7 +124,7 @@ cfgLoadUpdateOption(void)
|
||||
{
|
||||
for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpRepo); optionIdx++)
|
||||
{
|
||||
if (cfgOptionTest(cfgOptRepoHost + optionIdx))
|
||||
if (cfgOptionIdxTest(cfgOptRepoHost, optionIdx))
|
||||
THROW_FMT(ConfigError, "pg and repo hosts cannot both be configured as remote");
|
||||
}
|
||||
}
|
||||
@ -142,15 +135,14 @@ cfgLoadUpdateOption(void)
|
||||
{
|
||||
for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpRepo); optionIdx++)
|
||||
{
|
||||
// If the repo-type is defined, then see if corresponding retention-full is set
|
||||
if (cfgOptionTest(cfgOptRepoType + optionIdx) && !(cfgOptionTest(cfgOptRepoRetentionFull + optionIdx)))
|
||||
if (!(cfgOptionIdxTest(cfgOptRepoRetentionFull, optionIdx)))
|
||||
{
|
||||
LOG_WARN_FMT(
|
||||
"option '%s' is not set for '%s=%s', the repository may run out of space"
|
||||
"\nHINT: to retain full backups indefinitely (without warning), set option '%s' to the maximum.",
|
||||
cfgOptionName(cfgOptRepoRetentionFull + optionIdx), cfgOptionName(cfgOptRepoRetentionFullType + optionIdx),
|
||||
strZ(cfgOptionStr(cfgOptRepoRetentionFullType + optionIdx)),
|
||||
cfgOptionName(cfgOptRepoRetentionFull + optionIdx));
|
||||
cfgOptionIdxName(cfgOptRepoRetentionFull, optionIdx), cfgOptionIdxName(cfgOptRepoRetentionFullType, optionIdx),
|
||||
strZ(cfgOptionIdxStr(cfgOptRepoRetentionFullType, optionIdx)),
|
||||
cfgOptionIdxName(cfgOptRepoRetentionFull, optionIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -161,41 +153,43 @@ cfgLoadUpdateOption(void)
|
||||
// For each possible repo, check and adjust the settings as appropriate
|
||||
for (unsigned int optionIdx = 0; optionIdx < cfgOptionGroupIdxTotal(cfgOptGrpRepo); optionIdx++)
|
||||
{
|
||||
const String *archiveRetentionType = cfgOptionStr(cfgOptRepoRetentionArchiveType + optionIdx);
|
||||
const String *archiveRetentionType = cfgOptionIdxStr(cfgOptRepoRetentionArchiveType, optionIdx);
|
||||
|
||||
const String *msgArchiveOff = strNewFmt(
|
||||
"WAL segments will not be expired: option '%s=%s' but", cfgOptionName(cfgOptRepoRetentionArchiveType + optionIdx),
|
||||
"WAL segments will not be expired: option '%s=%s' but", cfgOptionIdxName(cfgOptRepoRetentionArchiveType, optionIdx),
|
||||
strZ(archiveRetentionType));
|
||||
|
||||
// If the archive retention is not explicitly set then determine what it should be defaulted to
|
||||
if (!cfgOptionTest(cfgOptRepoRetentionArchive + optionIdx))
|
||||
if (!cfgOptionIdxTest(cfgOptRepoRetentionArchive, optionIdx))
|
||||
{
|
||||
// If repo-retention-archive-type is default (full), then if repo-retention-full is set, set the
|
||||
// repo-retention-archive to this value when retention-full-type is 'count', else ignore archiving. If
|
||||
// retention-full-type is 'time' then the the expire command will default the archive retention accordingly.
|
||||
if (strEqZ(archiveRetentionType, CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_FULL))
|
||||
{
|
||||
if (strEqZ(cfgOptionStr(cfgOptRepoRetentionFullType + optionIdx), CFGOPTVAL_TMP_REPO_RETENTION_FULL_TYPE_COUNT)
|
||||
&& cfgOptionTest(cfgOptRepoRetentionFull + optionIdx))
|
||||
if (strEqZ(
|
||||
cfgOptionIdxStr(cfgOptRepoRetentionFullType, optionIdx),
|
||||
CFGOPTVAL_TMP_REPO_RETENTION_FULL_TYPE_COUNT) &&
|
||||
cfgOptionIdxTest(cfgOptRepoRetentionFull, optionIdx))
|
||||
{
|
||||
cfgOptionSet(cfgOptRepoRetentionArchive + optionIdx, cfgSourceDefault,
|
||||
VARUINT(cfgOptionUInt(cfgOptRepoRetentionFull + optionIdx)));
|
||||
cfgOptionIdxSet(cfgOptRepoRetentionArchive, optionIdx, cfgSourceDefault,
|
||||
VARUINT(cfgOptionIdxUInt(cfgOptRepoRetentionFull, optionIdx)));
|
||||
}
|
||||
}
|
||||
else if (strEqZ(archiveRetentionType, CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_DIFF))
|
||||
{
|
||||
// if repo-retention-diff is set then user must have set it
|
||||
if (cfgOptionTest(cfgOptRepoRetentionDiff + optionIdx))
|
||||
if (cfgOptionIdxTest(cfgOptRepoRetentionDiff, optionIdx))
|
||||
{
|
||||
cfgOptionSet(cfgOptRepoRetentionArchive + optionIdx, cfgSourceDefault,
|
||||
VARUINT(cfgOptionUInt(cfgOptRepoRetentionDiff + optionIdx)));
|
||||
cfgOptionIdxSet(cfgOptRepoRetentionArchive, optionIdx, cfgSourceDefault,
|
||||
VARUINT(cfgOptionIdxUInt(cfgOptRepoRetentionDiff, optionIdx)));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARN_FMT(
|
||||
"%s neither option '%s' nor option '%s' is set", strZ(msgArchiveOff),
|
||||
cfgOptionName(cfgOptRepoRetentionArchive + optionIdx),
|
||||
cfgOptionName(cfgOptRepoRetentionDiff + optionIdx));
|
||||
cfgOptionIdxName(cfgOptRepoRetentionArchive, optionIdx),
|
||||
cfgOptionIdxName(cfgOptRepoRetentionDiff, optionIdx));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -204,7 +198,7 @@ cfgLoadUpdateOption(void)
|
||||
|
||||
LOG_WARN_FMT(
|
||||
"%s option '%s' is not set", strZ(msgArchiveOff),
|
||||
cfgOptionName(cfgOptRepoRetentionArchive + optionIdx));
|
||||
cfgOptionIdxName(cfgOptRepoRetentionArchive, optionIdx));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -213,21 +207,21 @@ cfgLoadUpdateOption(void)
|
||||
// corresponding setting is UNDEF since UNDEF means backups will not be expired but they should be in the
|
||||
// practice of setting this value even though expiring the archive itself is OK and will be performed.
|
||||
if ((strEqZ(archiveRetentionType, CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_DIFF)) &&
|
||||
(!cfgOptionTest(cfgOptRepoRetentionDiff + optionIdx)))
|
||||
(!cfgOptionIdxTest(cfgOptRepoRetentionDiff, optionIdx)))
|
||||
{
|
||||
LOG_WARN_FMT("option '%s' is not set for '%s=%s'\n"
|
||||
"HINT: to retain differential backups indefinitely (without warning), set option '%s' to the maximum.",
|
||||
cfgOptionName(cfgOptRepoRetentionDiff + optionIdx),
|
||||
cfgOptionName(cfgOptRepoRetentionArchiveType + optionIdx),
|
||||
cfgOptionIdxName(cfgOptRepoRetentionDiff, optionIdx),
|
||||
cfgOptionIdxName(cfgOptRepoRetentionArchiveType, optionIdx),
|
||||
CFGOPTVAL_TMP_REPO_RETENTION_ARCHIVE_TYPE_DIFF,
|
||||
cfgOptionName(cfgOptRepoRetentionDiff + optionIdx));
|
||||
cfgOptionIdxName(cfgOptRepoRetentionDiff, optionIdx));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Error if an S3 bucket name contains dots
|
||||
if (cfgOptionTest(cfgOptRepoS3Bucket) && cfgOptionBool(cfgOptRepoS3VerifyTls) &&
|
||||
if (cfgOptionGroupValid(cfgOptGrpRepo) && cfgOptionTest(cfgOptRepoS3Bucket) && cfgOptionBool(cfgOptRepoS3VerifyTls) &&
|
||||
strChr(cfgOptionStr(cfgOptRepoS3Bucket), '.') != -1)
|
||||
{
|
||||
THROW_FMT(
|
||||
@ -258,7 +252,7 @@ cfgLoadUpdateOption(void)
|
||||
}
|
||||
|
||||
// Now invalidate compress so it can't be used and won't be passed to child processes
|
||||
cfgOptionValidSet(cfgOptCompress, false);
|
||||
cfgOptionInvalidate(cfgOptCompress);
|
||||
cfgOptionSet(cfgOptCompress, cfgSourceDefault, NULL);
|
||||
}
|
||||
|
||||
|
@ -348,14 +348,6 @@ static const struct option optionList[] =
|
||||
.val = PARSE_OPTION_FLAG | cfgOptForce,
|
||||
},
|
||||
|
||||
// host-id option
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
{
|
||||
.name = "host-id",
|
||||
.has_arg = required_argument,
|
||||
.val = PARSE_OPTION_FLAG | cfgOptHostId,
|
||||
},
|
||||
|
||||
// ignore-missing option
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
{
|
||||
@ -538,6 +530,18 @@ static const struct option optionList[] =
|
||||
.val = PARSE_OPTION_FLAG | cfgOptOutput,
|
||||
},
|
||||
|
||||
// pg option
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
{
|
||||
.name = "pg",
|
||||
.has_arg = required_argument,
|
||||
.val = PARSE_OPTION_FLAG | cfgOptPg,
|
||||
},
|
||||
{
|
||||
.name = "reset-pg",
|
||||
.val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptPg,
|
||||
},
|
||||
|
||||
// pg-host option and deprecations
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
{
|
||||
@ -1888,6 +1892,18 @@ static const struct option optionList[] =
|
||||
.val = PARSE_OPTION_FLAG | cfgOptRemoteType,
|
||||
},
|
||||
|
||||
// repo option
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
{
|
||||
.name = "repo",
|
||||
.has_arg = required_argument,
|
||||
.val = PARSE_OPTION_FLAG | cfgOptRepo,
|
||||
},
|
||||
{
|
||||
.name = "reset-repo",
|
||||
.val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptRepo,
|
||||
},
|
||||
|
||||
// repo-azure-account option
|
||||
// -----------------------------------------------------------------------------------------------------------------------------
|
||||
{
|
||||
@ -2779,7 +2795,6 @@ static const ConfigOption optionResolveOrder[] =
|
||||
cfgOptExecId,
|
||||
cfgOptExpireAuto,
|
||||
cfgOptFilter,
|
||||
cfgOptHostId,
|
||||
cfgOptIgnoreMissing,
|
||||
cfgOptIoTimeout,
|
||||
cfgOptLinkAll,
|
||||
@ -2795,52 +2810,19 @@ static const ConfigOption optionResolveOrder[] =
|
||||
cfgOptNeutralUmask,
|
||||
cfgOptOnline,
|
||||
cfgOptOutput,
|
||||
cfgOptPg,
|
||||
cfgOptPgLocal,
|
||||
cfgOptPgLocal + 1,
|
||||
cfgOptPgLocal + 2,
|
||||
cfgOptPgLocal + 3,
|
||||
cfgOptPgLocal + 4,
|
||||
cfgOptPgLocal + 5,
|
||||
cfgOptPgLocal + 6,
|
||||
cfgOptPgLocal + 7,
|
||||
cfgOptPgPath,
|
||||
cfgOptPgPath + 1,
|
||||
cfgOptPgPath + 2,
|
||||
cfgOptPgPath + 3,
|
||||
cfgOptPgPath + 4,
|
||||
cfgOptPgPath + 5,
|
||||
cfgOptPgPath + 6,
|
||||
cfgOptPgPath + 7,
|
||||
cfgOptPgPort,
|
||||
cfgOptPgPort + 1,
|
||||
cfgOptPgPort + 2,
|
||||
cfgOptPgPort + 3,
|
||||
cfgOptPgPort + 4,
|
||||
cfgOptPgPort + 5,
|
||||
cfgOptPgPort + 6,
|
||||
cfgOptPgPort + 7,
|
||||
cfgOptPgSocketPath,
|
||||
cfgOptPgSocketPath + 1,
|
||||
cfgOptPgSocketPath + 2,
|
||||
cfgOptPgSocketPath + 3,
|
||||
cfgOptPgSocketPath + 4,
|
||||
cfgOptPgSocketPath + 5,
|
||||
cfgOptPgSocketPath + 6,
|
||||
cfgOptPgSocketPath + 7,
|
||||
cfgOptPgUser,
|
||||
cfgOptPgUser + 1,
|
||||
cfgOptPgUser + 2,
|
||||
cfgOptPgUser + 3,
|
||||
cfgOptPgUser + 4,
|
||||
cfgOptPgUser + 5,
|
||||
cfgOptPgUser + 6,
|
||||
cfgOptPgUser + 7,
|
||||
cfgOptProcess,
|
||||
cfgOptProcessMax,
|
||||
cfgOptProtocolTimeout,
|
||||
cfgOptRaw,
|
||||
cfgOptRecurse,
|
||||
cfgOptRemoteType,
|
||||
cfgOptRepo,
|
||||
cfgOptRepoCipherType,
|
||||
cfgOptRepoHardlink,
|
||||
cfgOptRepoLocal,
|
||||
@ -2869,61 +2851,12 @@ static const ConfigOption optionResolveOrder[] =
|
||||
cfgOptArchiveCopy,
|
||||
cfgOptForce,
|
||||
cfgOptPgHost,
|
||||
cfgOptPgHost + 1,
|
||||
cfgOptPgHost + 2,
|
||||
cfgOptPgHost + 3,
|
||||
cfgOptPgHost + 4,
|
||||
cfgOptPgHost + 5,
|
||||
cfgOptPgHost + 6,
|
||||
cfgOptPgHost + 7,
|
||||
cfgOptPgHostCmd,
|
||||
cfgOptPgHostCmd + 1,
|
||||
cfgOptPgHostCmd + 2,
|
||||
cfgOptPgHostCmd + 3,
|
||||
cfgOptPgHostCmd + 4,
|
||||
cfgOptPgHostCmd + 5,
|
||||
cfgOptPgHostCmd + 6,
|
||||
cfgOptPgHostCmd + 7,
|
||||
cfgOptPgHostConfig,
|
||||
cfgOptPgHostConfig + 1,
|
||||
cfgOptPgHostConfig + 2,
|
||||
cfgOptPgHostConfig + 3,
|
||||
cfgOptPgHostConfig + 4,
|
||||
cfgOptPgHostConfig + 5,
|
||||
cfgOptPgHostConfig + 6,
|
||||
cfgOptPgHostConfig + 7,
|
||||
cfgOptPgHostConfigIncludePath,
|
||||
cfgOptPgHostConfigIncludePath + 1,
|
||||
cfgOptPgHostConfigIncludePath + 2,
|
||||
cfgOptPgHostConfigIncludePath + 3,
|
||||
cfgOptPgHostConfigIncludePath + 4,
|
||||
cfgOptPgHostConfigIncludePath + 5,
|
||||
cfgOptPgHostConfigIncludePath + 6,
|
||||
cfgOptPgHostConfigIncludePath + 7,
|
||||
cfgOptPgHostConfigPath,
|
||||
cfgOptPgHostConfigPath + 1,
|
||||
cfgOptPgHostConfigPath + 2,
|
||||
cfgOptPgHostConfigPath + 3,
|
||||
cfgOptPgHostConfigPath + 4,
|
||||
cfgOptPgHostConfigPath + 5,
|
||||
cfgOptPgHostConfigPath + 6,
|
||||
cfgOptPgHostConfigPath + 7,
|
||||
cfgOptPgHostPort,
|
||||
cfgOptPgHostPort + 1,
|
||||
cfgOptPgHostPort + 2,
|
||||
cfgOptPgHostPort + 3,
|
||||
cfgOptPgHostPort + 4,
|
||||
cfgOptPgHostPort + 5,
|
||||
cfgOptPgHostPort + 6,
|
||||
cfgOptPgHostPort + 7,
|
||||
cfgOptPgHostUser,
|
||||
cfgOptPgHostUser + 1,
|
||||
cfgOptPgHostUser + 2,
|
||||
cfgOptPgHostUser + 3,
|
||||
cfgOptPgHostUser + 4,
|
||||
cfgOptPgHostUser + 5,
|
||||
cfgOptPgHostUser + 6,
|
||||
cfgOptPgHostUser + 7,
|
||||
cfgOptRecoveryOption,
|
||||
cfgOptRepoAzureAccount,
|
||||
cfgOptRepoAzureCaFile,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,7 @@ typedef struct CfgParseOptionResult
|
||||
{
|
||||
bool found; // Was the option found?
|
||||
ConfigOption id; // Option ID
|
||||
unsigned int keyIdx; // Option key index, i.e. option key - 1
|
||||
bool negate; // Was the option negated?
|
||||
bool reset; // Was the option reset?
|
||||
bool deprecated; // Is the option deprecated?
|
||||
|
@ -7,7 +7,7 @@ Configuration Protocol Handler
|
||||
#include "common/io/io.h"
|
||||
#include "common/log.h"
|
||||
#include "common/memContext.h"
|
||||
#include "config/config.h"
|
||||
#include "config/config.intern.h"
|
||||
#include "config/parse.h"
|
||||
#include "config/protocol.h"
|
||||
|
||||
@ -42,7 +42,7 @@ configProtocol(const String *command, const VariantList *paramList, ProtocolServ
|
||||
CfgParseOptionResult option = cfgParseOption(varStr(varLstGet(paramList, optionIdx)));
|
||||
CHECK(option.found);
|
||||
|
||||
varLstAdd(optionList, varDup(cfgOption(option.id)));
|
||||
varLstAdd(optionList, varDup(cfgOptionIdx(option.id, cfgOptionKeyToIdx(option.id, option.keyIdx + 1))));
|
||||
}
|
||||
|
||||
protocolServerResponse(server, varNewVarLst(optionList));
|
||||
|
@ -30,8 +30,8 @@ dbGetIdx(unsigned int pgIdx)
|
||||
{
|
||||
result = dbNew(
|
||||
pgClientNew(
|
||||
cfgOptionStrNull(cfgOptPgSocketPath + pgIdx), cfgOptionUInt(cfgOptPgPort + pgIdx), PG_DB_POSTGRES_STR,
|
||||
cfgOptionStrNull(cfgOptPgUser + pgIdx), (TimeMSec)(cfgOptionDbl(cfgOptDbTimeout) * MSEC_PER_SEC)),
|
||||
cfgOptionIdxStrNull(cfgOptPgSocketPath, pgIdx), cfgOptionIdxUInt(cfgOptPgPort, pgIdx), PG_DB_POSTGRES_STR,
|
||||
cfgOptionIdxStrNull(cfgOptPgUser, pgIdx), (TimeMSec)(cfgOptionDbl(cfgOptDbTimeout) * MSEC_PER_SEC)),
|
||||
NULL, applicationName);
|
||||
}
|
||||
else
|
||||
@ -64,8 +64,6 @@ dbGet(bool primaryOnly, bool primaryRequired, bool standbyRequired)
|
||||
{
|
||||
// Loop through to look for primary and standby (if required)
|
||||
for (unsigned int pgIdx = 0; pgIdx < cfgOptionGroupIdxTotal(cfgOptGrpPg); pgIdx++)
|
||||
{
|
||||
if (cfgOptionGroupIdxTest(cfgOptGrpPg, pgIdx))
|
||||
{
|
||||
Db *db = NULL;
|
||||
bool standby = false;
|
||||
@ -90,7 +88,9 @@ dbGet(bool primaryOnly, bool primaryRequired, bool standbyRequired)
|
||||
}
|
||||
CATCH_ANY()
|
||||
{
|
||||
LOG_WARN_FMT("unable to check pg-%u: [%s] %s", pgIdx + 1, errorTypeName(errorType()), errorMessage());
|
||||
LOG_WARN_FMT(
|
||||
"unable to check pg-%u: [%s] %s", cfgOptionGroupIdxToKey(cfgOptGrpPg, pgIdx), errorTypeName(errorType()),
|
||||
errorMessage());
|
||||
db = NULL;
|
||||
}
|
||||
TRY_END();
|
||||
@ -123,7 +123,6 @@ dbGet(bool primaryOnly, bool primaryRequired, bool standbyRequired)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Error if no primary was found
|
||||
if (result.primary == NULL && primaryRequired)
|
||||
|
@ -9,7 +9,7 @@ Protocol Helper
|
||||
#include "common/debug.h"
|
||||
#include "common/exec.h"
|
||||
#include "common/memContext.h"
|
||||
#include "config/config.h"
|
||||
#include "config/config.intern.h"
|
||||
#include "config/define.h"
|
||||
#include "config/exec.h"
|
||||
#include "config/protocol.h"
|
||||
@ -70,10 +70,13 @@ protocolHelperInit(void)
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
bool
|
||||
repoIsLocal(void)
|
||||
repoIsLocal(unsigned int repoIdx)
|
||||
{
|
||||
FUNCTION_TEST_VOID();
|
||||
FUNCTION_TEST_RETURN(!cfgOptionTest(cfgOptRepoHost));
|
||||
FUNCTION_LOG_BEGIN(logLevelDebug);
|
||||
FUNCTION_LOG_PARAM(UINT, repoIdx);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
FUNCTION_LOG_RETURN(BOOL, !cfgOptionIdxTest(cfgOptRepoHost, repoIdx));
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -82,7 +85,7 @@ repoIsLocalVerify(void)
|
||||
{
|
||||
FUNCTION_TEST_VOID();
|
||||
|
||||
if (!repoIsLocal())
|
||||
if (!repoIsLocal(cfgOptionGroupIdxDefault(cfgOptGrpRepo)))
|
||||
THROW_FMT(HostInvalidError, "%s command must be run on the repository host", cfgCommandName(cfgCommand()));
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
@ -96,7 +99,7 @@ pgIsLocal(unsigned int pgIdx)
|
||||
FUNCTION_LOG_PARAM(UINT, pgIdx);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
FUNCTION_LOG_RETURN(BOOL, !cfgOptionTest(cfgOptPgHost + pgIdx));
|
||||
FUNCTION_LOG_RETURN(BOOL, !cfgOptionIdxTest(cfgOptPgHost, pgIdx));
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -105,7 +108,7 @@ pgIsLocalVerify(void)
|
||||
{
|
||||
FUNCTION_TEST_VOID();
|
||||
|
||||
if (!pgIsLocal(0))
|
||||
if (!pgIsLocal(cfgOptionGroupIdxDefault(cfgOptGrpPg)))
|
||||
THROW_FMT(HostInvalidError, "%s command must be run on the " PG_NAME " host", cfgCommandName(cfgCommand()));
|
||||
|
||||
FUNCTION_TEST_RETURN_VOID();
|
||||
@ -133,8 +136,13 @@ protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int hostIdx
|
||||
// Add the process id -- used when more than one process will be called
|
||||
kvPut(optionReplace, VARSTR(CFGOPT_PROCESS_STR), VARUINT(processId));
|
||||
|
||||
// Add the host id
|
||||
kvPut(optionReplace, VARSTR(CFGOPT_HOST_ID_STR), VARUINT(hostIdx + 1));
|
||||
// Add the group default id
|
||||
kvPut(
|
||||
optionReplace,
|
||||
VARSTRZ(cfgOptionName(protocolStorageType == protocolStorageTypeRepo ? cfgOptRepo : cfgOptPg)),
|
||||
VARUINT(
|
||||
cfgOptionGroupIdxToKey(
|
||||
protocolStorageType == protocolStorageTypeRepo ? cfgOptGrpRepo : cfgOptGrpPg, hostIdx)));
|
||||
|
||||
// Add the remote type
|
||||
kvPut(optionReplace, VARSTR(CFGOPT_REMOTE_TYPE_STR), VARSTR(protocolStorageTypeStr(protocolStorageType)));
|
||||
@ -295,111 +303,122 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int hostId
|
||||
strLstAddZ(result, "PasswordAuthentication=no");
|
||||
|
||||
// Append port if specified
|
||||
ConfigOption optHostPort = isRepo ? cfgOptRepoHostPort : cfgOptPgHostPort + hostIdx;
|
||||
ConfigOption optHostPort = isRepo ? cfgOptRepoHostPort : cfgOptPgHostPort;
|
||||
|
||||
if (cfgOptionTest(optHostPort))
|
||||
if (cfgOptionIdxTest(optHostPort, hostIdx))
|
||||
{
|
||||
strLstAddZ(result, "-p");
|
||||
strLstAdd(result, strNewFmt("%u", cfgOptionUInt(optHostPort)));
|
||||
strLstAdd(result, strNewFmt("%u", cfgOptionIdxUInt(optHostPort, hostIdx)));
|
||||
}
|
||||
|
||||
// Append user/host
|
||||
strLstAdd(
|
||||
result,
|
||||
strNewFmt(
|
||||
"%s@%s", strZ(cfgOptionStr(isRepo ? cfgOptRepoHostUser : cfgOptPgHostUser + hostIdx)),
|
||||
strZ(cfgOptionStr(isRepo ? cfgOptRepoHost : cfgOptPgHost + hostIdx))));
|
||||
"%s@%s", strZ(cfgOptionIdxStr(isRepo ? cfgOptRepoHostUser : cfgOptPgHostUser, hostIdx)),
|
||||
strZ(cfgOptionIdxStr(isRepo ? cfgOptRepoHost : cfgOptPgHost, hostIdx))));
|
||||
|
||||
// Option replacements
|
||||
KeyValue *optionReplace = kvNew();
|
||||
|
||||
// Replace config options with the host versions
|
||||
unsigned int optConfig = isRepo ? cfgOptRepoHostConfig : cfgOptPgHostConfig + hostIdx;
|
||||
unsigned int optConfig = isRepo ? cfgOptRepoHostConfig : cfgOptPgHostConfig;
|
||||
|
||||
kvPut(optionReplace, VARSTR(CFGOPT_CONFIG_STR), cfgOptionSource(optConfig) != cfgSourceDefault ? cfgOption(optConfig) : NULL);
|
||||
kvPut(
|
||||
optionReplace, VARSTR(CFGOPT_CONFIG_STR),
|
||||
cfgOptionIdxSource(optConfig, hostIdx) != cfgSourceDefault ? VARSTR(cfgOptionIdxStr(optConfig, hostIdx)) : NULL);
|
||||
|
||||
unsigned int optConfigIncludePath = isRepo ? cfgOptRepoHostConfigIncludePath : cfgOptPgHostConfigIncludePath + hostIdx;
|
||||
unsigned int optConfigIncludePath = isRepo ? cfgOptRepoHostConfigIncludePath : cfgOptPgHostConfigIncludePath;
|
||||
|
||||
kvPut(
|
||||
optionReplace, VARSTR(CFGOPT_CONFIG_INCLUDE_PATH_STR),
|
||||
cfgOptionSource(optConfigIncludePath) != cfgSourceDefault ? cfgOption(optConfigIncludePath) : NULL);
|
||||
cfgOptionIdxSource(optConfigIncludePath, hostIdx) != cfgSourceDefault ?
|
||||
VARSTR(cfgOptionIdxStr(optConfigIncludePath, hostIdx)) : NULL);
|
||||
|
||||
unsigned int optConfigPath = isRepo ? cfgOptRepoHostConfigPath : cfgOptPgHostConfigPath + hostIdx;
|
||||
unsigned int optConfigPath = isRepo ? cfgOptRepoHostConfigPath : cfgOptPgHostConfigPath;
|
||||
|
||||
kvPut(
|
||||
optionReplace, VARSTR(CFGOPT_CONFIG_PATH_STR),
|
||||
cfgOptionSource(optConfigPath) != cfgSourceDefault ? cfgOption(optConfigPath) : NULL);
|
||||
cfgOptionIdxSource(optConfigPath, hostIdx) != cfgSourceDefault ? VARSTR(cfgOptionIdxStr(optConfigPath, hostIdx)) : NULL);
|
||||
|
||||
// Update/remove repo/pg options that are sent to the remote
|
||||
const String *repoHostPrefix = STR(cfgDefOptionName(cfgDefOptRepoHost));
|
||||
const String *repoPrefix = strNewFmt("%s-", PROTOCOL_REMOTE_TYPE_REPO);
|
||||
const String *pgHostPrefix = STR(cfgDefOptionName(cfgDefOptPgHost));
|
||||
const String *pgPrefix = strNewFmt("%s-", PROTOCOL_REMOTE_TYPE_PG);
|
||||
const String *repoHostPrefix = STR(cfgDefOptionName(cfgOptRepoHost));
|
||||
const String *pgHostPrefix = STR(cfgDefOptionName(cfgOptPgHost));
|
||||
|
||||
for (ConfigOption optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++)
|
||||
{
|
||||
ConfigDefineOption optionDefId = cfgOptionDefIdFromId(optionId);
|
||||
const String *optionDefName = STR(cfgDefOptionName(optionDefId));
|
||||
bool remove = false;
|
||||
// Skip options that are not part of a group
|
||||
if (!cfgOptionGroup(optionId))
|
||||
continue;
|
||||
|
||||
// Remove repo host options that are not needed on the remote. The remote is not expecting to see host settings and it
|
||||
// could get confused about the locality of the repo, i.e. local or remote.
|
||||
if (strBeginsWith(optionDefName, repoHostPrefix))
|
||||
const String *optionDefName = STR(cfgDefOptionName(optionId));
|
||||
unsigned int groupId = cfgOptionGroupId(optionId);
|
||||
bool remove = false;
|
||||
bool skipHostZero = false;
|
||||
|
||||
// Remove repo host options that are not needed on the remote. The remote is not expecting to see host settings so it could
|
||||
// get confused about the locality of the repo, i.e. local or remote. Also remove repo options when the remote type is pg
|
||||
// since they won't be used.
|
||||
if (groupId == cfgOptGrpRepo)
|
||||
{
|
||||
remove = true;
|
||||
remove = protocolStorageType == protocolStorageTypePg || strBeginsWith(optionDefName, repoHostPrefix);
|
||||
}
|
||||
// Remove repo options when the remote type is pg since they won't be used
|
||||
else if (strBeginsWith(optionDefName, repoPrefix))
|
||||
// Remove pg host options that are not needed on the remote
|
||||
else
|
||||
{
|
||||
if (protocolStorageType == protocolStorageTypePg)
|
||||
remove = true;
|
||||
ASSERT(groupId == cfgOptGrpPg);
|
||||
|
||||
// Remove unrequired/defaulted pg options when the remote type is repo since they won't be used
|
||||
if (protocolStorageType == protocolStorageTypeRepo)
|
||||
{
|
||||
remove = !cfgDefOptionRequired(cfgCommand(), optionId) || cfgDefOptionDefault(cfgCommand(), optionId) != NULL;
|
||||
}
|
||||
// Remove pg host options that are not needed on the remote. The remote is not expecting to see host settings and it could
|
||||
// get confused about the locality of pg, i.e. local or remote.
|
||||
// The remote is not expecting to see host settings so it could get confused about the locality of pg, i.e. local or
|
||||
// remote.
|
||||
else if (strBeginsWith(optionDefName, pgHostPrefix))
|
||||
{
|
||||
remove = true;
|
||||
}
|
||||
else if (strBeginsWith(optionDefName, pgPrefix))
|
||||
// Move pg options to host index 0 (key 1) so they will be in the default index on the remote host
|
||||
else
|
||||
{
|
||||
// Remove unrequired/defaulted pg options when the remote type is repo since they won't be used
|
||||
if (protocolStorageType == protocolStorageTypeRepo)
|
||||
{
|
||||
remove = !cfgDefOptionRequired(cfgCommand(), optionDefId) || cfgDefOptionDefault(cfgCommand(), optionDefId) != NULL;
|
||||
}
|
||||
// Else move/remove pg options with index > 0 since they won't be used
|
||||
else if (cfgOptionIndex(optionId) > 0)
|
||||
{
|
||||
// If the option index matches the host-id then this is a pg option that the remote needs. Since the remote expects
|
||||
// to find pg options in index 0, copy the option to index 0.
|
||||
if (cfgOptionIndex(optionId) == hostIdx)
|
||||
if (hostIdx != 0)
|
||||
{
|
||||
kvPut(
|
||||
optionReplace, VARSTRZ(cfgOptionName(optionId - hostIdx)),
|
||||
cfgOptionSource(optionId) != cfgSourceDefault ? cfgOption(optionId) : NULL);
|
||||
optionReplace, VARSTRZ(cfgOptionIdxName(optionId, 0)),
|
||||
cfgOptionIdxSource(optionId, hostIdx) != cfgSourceDefault ? cfgOptionIdx(optionId, hostIdx) : NULL);
|
||||
}
|
||||
|
||||
// Remove pg options that are not needed on the remote. The remote is only going to look at index 0 so the options
|
||||
// in higher indexes will not be used and just add clutter which makes debugging harder.
|
||||
remove = true;
|
||||
skipHostZero = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove options that have been marked for removal if they are not already null or invalid. This is more efficient because
|
||||
// cfgExecParam() won't have to search through as large a list looking for overrides.
|
||||
if (remove && cfgOptionTest(optionId))
|
||||
kvPut(optionReplace, VARSTRZ(cfgOptionName(optionId)), NULL);
|
||||
if (remove)
|
||||
{
|
||||
// Loop through option indexes
|
||||
for (unsigned int optionIdx = 0; optionIdx < cfgOptionIdxTotal(optionId); optionIdx++)
|
||||
{
|
||||
if (cfgOptionIdxTest(optionId, optionIdx) && !(skipHostZero && optionIdx == 0))
|
||||
kvPut(optionReplace, VARSTRZ(cfgOptionIdxName(optionId, optionIdx)), NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set local so host settings configured on the remote will not accidentally be picked up
|
||||
kvPut(
|
||||
optionReplace,
|
||||
protocolStorageType == protocolStorageTypeRepo ?
|
||||
VARSTRZ(cfgOptionName(cfgOptRepoLocal)) : VARSTRZ(cfgOptionName(cfgOptPgLocal)),
|
||||
VARSTRZ(cfgOptionIdxName(cfgOptRepoLocal, hostIdx)) : VARSTRZ(cfgOptionKeyIdxName(cfgOptPgLocal, 0)),
|
||||
BOOL_TRUE_VAR);
|
||||
|
||||
// Don't pass host-id to the remote. The host will always be in index 0.
|
||||
kvPut(optionReplace, VARSTR(CFGOPT_HOST_ID_STR), NULL);
|
||||
// Set default to make it explicit which host will be used on the remote
|
||||
kvPut(
|
||||
optionReplace,
|
||||
VARSTRZ(cfgOptionName(protocolStorageType == protocolStorageTypeRepo ? cfgOptRepo : cfgOptPg)),
|
||||
VARUINT(protocolStorageType == protocolStorageTypeRepo ? cfgOptionGroupIdxToKey(cfgOptGrpRepo, hostIdx) : 1));
|
||||
|
||||
// Add the process id if not set. This means that the remote is being started from the main process and should always get a
|
||||
// process id of 0.
|
||||
@ -436,7 +455,7 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int hostId
|
||||
kvPut(optionReplace, VARSTR(CFGOPT_REMOTE_TYPE_STR), VARSTR(protocolStorageTypeStr(protocolStorageType)));
|
||||
|
||||
StringList *commandExec = cfgExecParam(cfgCommand(), cfgCmdRoleRemote, optionReplace, false, true);
|
||||
strLstInsert(commandExec, 0, cfgOptionStr(isRepo ? cfgOptRepoHostCmd : cfgOptPgHostCmd + hostIdx));
|
||||
strLstInsert(commandExec, 0, cfgOptionIdxStr(isRepo ? cfgOptRepoHostCmd : cfgOptPgHostCmd, hostIdx));
|
||||
strLstAdd(result, strLstJoin(commandExec, " "));
|
||||
|
||||
FUNCTION_LOG_RETURN(STRING_LIST, result);
|
||||
@ -464,9 +483,9 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostIdx)
|
||||
// The number of remotes allowed is the greater of allowed repo or pg configs + 1 (0 is reserved for connections from
|
||||
// the main process). Since these are static and only one will be true it presents a problem for coverage. We think
|
||||
// that pg remotes will always be greater but we'll protect that assumption with an assertion.
|
||||
ASSERT(cfgDefOptionIndexTotal(cfgDefOptPgPath) >= cfgDefOptionIndexTotal(cfgDefOptRepoPath));
|
||||
ASSERT(cfgDefOptionIndexTotal(cfgOptPgPath) >= cfgDefOptionIndexTotal(cfgOptRepoPath));
|
||||
|
||||
protocolHelper.clientRemoteSize = cfgDefOptionIndexTotal(cfgDefOptPgPath) + 1;
|
||||
protocolHelper.clientRemoteSize = cfgDefOptionIndexTotal(cfgOptPgPath) + 1;
|
||||
protocolHelper.clientRemote = memNew(protocolHelper.clientRemoteSize * sizeof(ProtocolHelperClient));
|
||||
|
||||
for (unsigned int clientIdx = 0; clientIdx < protocolHelper.clientRemoteSize; clientIdx++)
|
||||
@ -492,18 +511,18 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostIdx)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(protocolHelper.memContext)
|
||||
{
|
||||
unsigned int optHost = isRepo ? cfgOptRepoHost : cfgOptPgHost + hostIdx;
|
||||
unsigned int optHost = isRepo ? cfgOptRepoHost : cfgOptPgHost;
|
||||
|
||||
// Execute the protocol command
|
||||
protocolHelperClient->exec = execNew(
|
||||
cfgOptionStr(cfgOptCmdSsh), protocolRemoteParam(protocolStorageType, hostIdx),
|
||||
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u process on '%s'", processId, strZ(cfgOptionStr(optHost))),
|
||||
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u process on '%s'", processId, strZ(cfgOptionIdxStr(optHost, hostIdx))),
|
||||
(TimeMSec)(cfgOptionDbl(cfgOptProtocolTimeout) * 1000));
|
||||
execOpen(protocolHelperClient->exec);
|
||||
|
||||
// Create protocol object
|
||||
protocolHelperClient->client = protocolClientNew(
|
||||
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u protocol on '%s'", processId, strZ(cfgOptionStr(optHost))),
|
||||
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u protocol on '%s'", processId, strZ(cfgOptionIdxStr(optHost, hostIdx))),
|
||||
PROTOCOL_SERVICE_REMOTE_STR, execIoRead(protocolHelperClient->exec), execIoWrite(protocolHelperClient->exec));
|
||||
|
||||
// Get cipher options from the remote if none are locally configured
|
||||
|
@ -54,7 +54,7 @@ bool pgIsLocal(unsigned int pgIdx);
|
||||
void pgIsLocalVerify(void);
|
||||
|
||||
// Is the repository local?
|
||||
bool repoIsLocal(void);
|
||||
bool repoIsLocal(unsigned int repoIdx);
|
||||
|
||||
// Error if the repository is not local
|
||||
void repoIsLocalVerify(void);
|
||||
|
@ -48,8 +48,8 @@ static struct StorageHelper
|
||||
Storage *storageLocalWrite; // Local write storage
|
||||
Storage **storagePg; // PostgreSQL read-only storage
|
||||
Storage **storagePgWrite; // PostgreSQL write storage
|
||||
Storage *storageRepo; // Repository read-only storage
|
||||
Storage *storageRepoWrite; // Repository write storage
|
||||
Storage **storageRepo; // Repository read-only storage
|
||||
Storage **storageRepoWrite; // Repository write storage
|
||||
Storage *storageSpool; // Spool read-only storage
|
||||
Storage *storageSpoolWrite; // Spool write storage
|
||||
|
||||
@ -183,7 +183,7 @@ storagePgGet(unsigned int pgIdx, bool write)
|
||||
// Use Posix storage
|
||||
else
|
||||
{
|
||||
result = storagePosixNewP(cfgOptionStr(cfgOptPgPath + pgIdx), .write = write);
|
||||
result = storagePosixNewP(cfgOptionIdxStr(cfgOptPgPath, pgIdx), .write = write);
|
||||
}
|
||||
|
||||
FUNCTION_TEST_RETURN(result);
|
||||
@ -204,7 +204,7 @@ storagePgIdx(unsigned int pgIdx)
|
||||
MEM_CONTEXT_BEGIN(storageHelper.memContext)
|
||||
{
|
||||
if (storageHelper.storagePg == NULL)
|
||||
storageHelper.storagePg = memNewPtrArray(cfgDefOptionIndexTotal(cfgDefOptPgPath));
|
||||
storageHelper.storagePg = memNewPtrArray(cfgOptionGroupIdxTotal(cfgOptGrpPg));
|
||||
|
||||
storageHelper.storagePg[pgIdx] = storagePgGet(pgIdx, false);
|
||||
}
|
||||
@ -218,7 +218,7 @@ const Storage *
|
||||
storagePg(void)
|
||||
{
|
||||
FUNCTION_TEST_VOID();
|
||||
FUNCTION_TEST_RETURN(storagePgIdx(cfgOptionTest(cfgOptHostId) ? cfgOptionUInt(cfgOptHostId) - 1 : 0));
|
||||
FUNCTION_TEST_RETURN(storagePgIdx(cfgOptionGroupIdxDefault(cfgOptGrpPg)));
|
||||
}
|
||||
|
||||
const Storage *
|
||||
@ -239,7 +239,7 @@ storagePgIdxWrite(unsigned int pgIdx)
|
||||
MEM_CONTEXT_BEGIN(storageHelper.memContext)
|
||||
{
|
||||
if (storageHelper.storagePgWrite == NULL)
|
||||
storageHelper.storagePgWrite = memNewPtrArray(cfgDefOptionIndexTotal(cfgDefOptPgPath));
|
||||
storageHelper.storagePgWrite = memNewPtrArray(cfgOptionGroupIdxTotal(cfgOptGrpPg));
|
||||
|
||||
storageHelper.storagePgWrite[pgIdx] = storagePgGet(pgIdx, true);
|
||||
}
|
||||
@ -253,7 +253,7 @@ const Storage *
|
||||
storagePgWrite(void)
|
||||
{
|
||||
FUNCTION_TEST_VOID();
|
||||
FUNCTION_TEST_RETURN(storagePgIdxWrite(cfgOptionTest(cfgOptHostId) ? cfgOptionUInt(cfgOptHostId) - 1 : 0));
|
||||
FUNCTION_TEST_RETURN(storagePgIdxWrite(cfgOptionGroupIdxDefault(cfgOptGrpPg)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -333,83 +333,95 @@ storageRepoPathExpression(const String *expression, const String *path)
|
||||
Get the repo storage
|
||||
***********************************************************************************************************************************/
|
||||
static Storage *
|
||||
storageRepoGet(const String *type, bool write)
|
||||
storageRepoGet(unsigned int repoIdx, bool write)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(STRING, type);
|
||||
FUNCTION_TEST_PARAM(UINT, repoIdx);
|
||||
FUNCTION_TEST_PARAM(BOOL, write);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ASSERT(type != NULL);
|
||||
|
||||
Storage *result = NULL;
|
||||
|
||||
// Use remote storage
|
||||
if (!repoIsLocal())
|
||||
if (!repoIsLocal(repoIdx))
|
||||
{
|
||||
result = storageRemoteNew(
|
||||
STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write, storageRepoPathExpression,
|
||||
protocolRemoteGet(protocolStorageTypeRepo, 0), cfgOptionUInt(cfgOptCompressLevelNetwork));
|
||||
protocolRemoteGet(protocolStorageTypeRepo, repoIdx), cfgOptionIdxUInt(cfgOptCompressLevelNetwork, repoIdx));
|
||||
}
|
||||
// Use Azure storage
|
||||
else if (strEqZ(type, STORAGE_AZURE_TYPE))
|
||||
else
|
||||
{
|
||||
const String *type = cfgOptionIdxStr(cfgOptRepoType, repoIdx);
|
||||
|
||||
if (strEqZ(type, STORAGE_AZURE_TYPE))
|
||||
{
|
||||
result = storageAzureNew(
|
||||
cfgOptionStr(cfgOptRepoPath), write, storageRepoPathExpression, cfgOptionStr(cfgOptRepoAzureContainer),
|
||||
cfgOptionStr(cfgOptRepoAzureAccount),
|
||||
strEqZ(cfgOptionStr(cfgOptRepoAzureKeyType), STORAGE_AZURE_KEY_TYPE_SHARED) ?
|
||||
cfgOptionIdxStr(cfgOptRepoPath, repoIdx), write, storageRepoPathExpression,
|
||||
cfgOptionIdxStr(cfgOptRepoAzureContainer, repoIdx), cfgOptionIdxStr(cfgOptRepoAzureAccount, repoIdx),
|
||||
strEqZ(cfgOptionIdxStr(cfgOptRepoAzureKeyType, repoIdx), STORAGE_AZURE_KEY_TYPE_SHARED) ?
|
||||
storageAzureKeyTypeShared : storageAzureKeyTypeSas,
|
||||
cfgOptionStr(cfgOptRepoAzureKey), STORAGE_AZURE_BLOCKSIZE_MIN, cfgOptionStrNull(cfgOptRepoAzureHost),
|
||||
cfgOptionStr(cfgOptRepoAzureEndpoint), cfgOptionUInt(cfgOptRepoAzurePort), ioTimeoutMs(),
|
||||
cfgOptionBool(cfgOptRepoAzureVerifyTls), cfgOptionStrNull(cfgOptRepoAzureCaFile),
|
||||
cfgOptionStrNull(cfgOptRepoAzureCaPath));
|
||||
cfgOptionIdxStr(cfgOptRepoAzureKey, repoIdx), STORAGE_AZURE_BLOCKSIZE_MIN,
|
||||
cfgOptionIdxStrNull(cfgOptRepoAzureHost, repoIdx), cfgOptionIdxStr(cfgOptRepoAzureEndpoint, repoIdx),
|
||||
cfgOptionIdxUInt(cfgOptRepoAzurePort, repoIdx), ioTimeoutMs(), cfgOptionIdxBool(cfgOptRepoAzureVerifyTls, repoIdx),
|
||||
cfgOptionIdxStrNull(cfgOptRepoAzureCaFile, repoIdx),
|
||||
cfgOptionIdxStrNull(cfgOptRepoAzureCaPath, repoIdx));
|
||||
}
|
||||
// Use CIFS storage
|
||||
else if (strEqZ(type, STORAGE_CIFS_TYPE))
|
||||
{
|
||||
result = storageCifsNew(
|
||||
cfgOptionStr(cfgOptRepoPath), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write, storageRepoPathExpression);
|
||||
cfgOptionIdxStr(cfgOptRepoPath, repoIdx), STORAGE_MODE_FILE_DEFAULT, STORAGE_MODE_PATH_DEFAULT, write,
|
||||
storageRepoPathExpression);
|
||||
}
|
||||
// Use Posix storage
|
||||
else if (strEqZ(type, STORAGE_POSIX_TYPE))
|
||||
{
|
||||
result = storagePosixNewP(
|
||||
cfgOptionStr(cfgOptRepoPath), .write = write, .pathExpressionFunction = storageRepoPathExpression);
|
||||
cfgOptionIdxStr(cfgOptRepoPath, repoIdx), .write = write, .pathExpressionFunction = storageRepoPathExpression);
|
||||
}
|
||||
// Use S3 storage
|
||||
else if (strEqZ(type, STORAGE_S3_TYPE))
|
||||
else
|
||||
{
|
||||
// Storage must be S3
|
||||
CHECK(strEqZ(type, STORAGE_S3_TYPE));
|
||||
|
||||
// Set the default port
|
||||
unsigned int port = cfgOptionUInt(cfgOptRepoS3Port);
|
||||
unsigned int port = cfgOptionIdxUInt(cfgOptRepoS3Port, repoIdx);
|
||||
|
||||
// Extract port from the endpoint and host if it is present
|
||||
const String *endPoint = cfgOptionHostPort(cfgOptRepoS3Endpoint, &port);
|
||||
const String *host = cfgOptionHostPort(cfgOptRepoS3Host, &port);
|
||||
const String *endPoint = cfgOptionIdxHostPort(cfgOptRepoS3Endpoint, repoIdx, &port);
|
||||
const String *host = cfgOptionIdxHostPort(cfgOptRepoS3Host, repoIdx, &port);
|
||||
|
||||
// If the port option was set explicitly then use it in preference to appended ports
|
||||
if (cfgOptionSource(cfgOptRepoS3Port) != cfgSourceDefault)
|
||||
port = cfgOptionUInt(cfgOptRepoS3Port);
|
||||
if (cfgOptionIdxSource(cfgOptRepoS3Port, repoIdx) != cfgSourceDefault)
|
||||
port = cfgOptionIdxUInt(cfgOptRepoS3Port, repoIdx);
|
||||
|
||||
result = storageS3New(
|
||||
cfgOptionStr(cfgOptRepoPath), write, storageRepoPathExpression, cfgOptionStr(cfgOptRepoS3Bucket), endPoint,
|
||||
strEqZ(cfgOptionStr(cfgOptRepoS3UriStyle), STORAGE_S3_URI_STYLE_HOST) ? storageS3UriStyleHost : storageS3UriStylePath,
|
||||
cfgOptionStr(cfgOptRepoS3Region),
|
||||
strEqZ(cfgOptionStr(cfgOptRepoS3KeyType), STORAGE_S3_KEY_TYPE_SHARED) ? storageS3KeyTypeShared : storageS3KeyTypeAuto,
|
||||
cfgOptionStrNull(cfgOptRepoS3Key), cfgOptionStrNull(cfgOptRepoS3KeySecret), cfgOptionStrNull(cfgOptRepoS3Token),
|
||||
cfgOptionStrNull(cfgOptRepoS3Role), STORAGE_S3_PARTSIZE_MIN, host, port, ioTimeoutMs(),
|
||||
cfgOptionBool(cfgOptRepoS3VerifyTls), cfgOptionStrNull(cfgOptRepoS3CaFile), cfgOptionStrNull(cfgOptRepoS3CaPath));
|
||||
cfgOptionIdxStr(cfgOptRepoPath, repoIdx), write, storageRepoPathExpression,
|
||||
cfgOptionIdxStr(cfgOptRepoS3Bucket, repoIdx), endPoint,
|
||||
strEqZ(cfgOptionIdxStr(cfgOptRepoS3UriStyle, repoIdx), STORAGE_S3_URI_STYLE_HOST) ?
|
||||
storageS3UriStyleHost : storageS3UriStylePath,
|
||||
cfgOptionIdxStr(cfgOptRepoS3Region, repoIdx),
|
||||
strEqZ(cfgOptionIdxStr(cfgOptRepoS3KeyType, repoIdx), STORAGE_S3_KEY_TYPE_SHARED) ?
|
||||
storageS3KeyTypeShared : storageS3KeyTypeAuto,
|
||||
cfgOptionIdxStrNull(cfgOptRepoS3Key, repoIdx), cfgOptionIdxStrNull(cfgOptRepoS3KeySecret, repoIdx),
|
||||
cfgOptionIdxStrNull(cfgOptRepoS3Token, repoIdx), cfgOptionIdxStrNull(cfgOptRepoS3Role, repoIdx),
|
||||
STORAGE_S3_PARTSIZE_MIN, host, port, ioTimeoutMs(), cfgOptionIdxBool(cfgOptRepoS3VerifyTls, repoIdx),
|
||||
cfgOptionIdxStrNull(cfgOptRepoS3CaFile, repoIdx), cfgOptionIdxStrNull(cfgOptRepoS3CaPath, repoIdx));
|
||||
}
|
||||
}
|
||||
else
|
||||
THROW_FMT(AssertError, "invalid storage type '%s'", strZ(type));
|
||||
|
||||
FUNCTION_TEST_RETURN(result);
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
const Storage *
|
||||
storageRepo(void)
|
||||
storageRepoIdx(unsigned int repoIdx)
|
||||
{
|
||||
FUNCTION_TEST_VOID();
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, repoIdx);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
if (storageHelper.storageRepo == NULL)
|
||||
{
|
||||
@ -419,18 +431,36 @@ storageRepo(void)
|
||||
|
||||
MEM_CONTEXT_BEGIN(storageHelper.memContext)
|
||||
{
|
||||
storageHelper.storageRepo = storageRepoGet(cfgOptionStr(cfgOptRepoType), false);
|
||||
storageHelper.storageRepo = memNewPtrArray(cfgOptionGroupIdxTotal(cfgOptGrpRepo));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
|
||||
FUNCTION_TEST_RETURN(storageHelper.storageRepo);
|
||||
if (storageHelper.storageRepo[repoIdx] == NULL)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(storageHelper.memContext)
|
||||
{
|
||||
storageHelper.storageRepo[repoIdx] = storageRepoGet(repoIdx, false);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
|
||||
FUNCTION_TEST_RETURN(storageHelper.storageRepo[repoIdx]);
|
||||
}
|
||||
|
||||
const Storage *
|
||||
storageRepoWrite(void)
|
||||
storageRepo(void)
|
||||
{
|
||||
FUNCTION_TEST_VOID();
|
||||
FUNCTION_TEST_RETURN(storageRepoIdx(cfgOptionGroupIdxDefault(cfgOptGrpRepo)));
|
||||
}
|
||||
|
||||
const Storage *
|
||||
storageRepoIdxWrite(unsigned int repoIdx)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, repoIdx);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
// Writes not allowed in dry-run mode
|
||||
if (!storageHelper.dryRunInit || storageHelper.dryRun)
|
||||
@ -444,12 +474,28 @@ storageRepoWrite(void)
|
||||
|
||||
MEM_CONTEXT_BEGIN(storageHelper.memContext)
|
||||
{
|
||||
storageHelper.storageRepoWrite = storageRepoGet(cfgOptionStr(cfgOptRepoType), true);
|
||||
storageHelper.storageRepoWrite = memNewPtrArray(cfgOptionGroupIdxTotal(cfgOptGrpRepo));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
|
||||
FUNCTION_TEST_RETURN(storageHelper.storageRepoWrite);
|
||||
if (storageHelper.storageRepoWrite[repoIdx] == NULL)
|
||||
{
|
||||
MEM_CONTEXT_BEGIN(storageHelper.memContext)
|
||||
{
|
||||
storageHelper.storageRepoWrite[repoIdx] = storageRepoGet(repoIdx, true);
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
}
|
||||
|
||||
FUNCTION_TEST_RETURN(storageHelper.storageRepoWrite[repoIdx]);
|
||||
}
|
||||
|
||||
const Storage *
|
||||
storageRepoWrite(void)
|
||||
{
|
||||
FUNCTION_TEST_VOID();
|
||||
FUNCTION_TEST_RETURN(storageRepoIdxWrite(cfgOptionGroupIdxDefault(cfgOptGrpRepo)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
|
@ -41,11 +41,15 @@ const Storage *storageLocalWrite(void);
|
||||
const Storage *storagePgIdx(unsigned int pgIdx);
|
||||
const Storage *storagePgIdxWrite(unsigned int pgIdx);
|
||||
|
||||
// PostgreSQL storage default (calculated from host-id, when set, or the first cfgOptGrpPg index)
|
||||
// PostgreSQL storage default (calculated from the pg option, when set, or the first cfgOptGrpPg index)
|
||||
const Storage *storagePg(void);
|
||||
const Storage *storagePgWrite(void);
|
||||
|
||||
// Repository storage
|
||||
// Repository storage by cfgOptGrpRepo index
|
||||
const Storage *storageRepoIdx(unsigned int repoIdx);
|
||||
const Storage *storageRepoIdxWrite(unsigned int repoIdx);
|
||||
|
||||
// Repository storage default (calculated from the repo option, when set, or the first cfgOptGrpPg index)
|
||||
const Storage *storageRepo(void);
|
||||
const Storage *storageRepoWrite(void);
|
||||
|
||||
|
@ -365,18 +365,11 @@ unit:
|
||||
config/define.auto: noCode
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------
|
||||
- name: config
|
||||
total: 4
|
||||
- name: parse
|
||||
total: 5
|
||||
|
||||
coverage:
|
||||
config/config: full
|
||||
config/config.auto: noCode
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------------
|
||||
- name: parse
|
||||
total: 4
|
||||
|
||||
coverage:
|
||||
config/parse: full
|
||||
config/parse.auto: noCode
|
||||
|
||||
|
@ -10,6 +10,7 @@ Harness for Loading Test Configurations
|
||||
#include "common/harnessLog.h"
|
||||
#include "common/harnessTest.h"
|
||||
|
||||
#include "config/config.intern.h"
|
||||
#include "config/define.h"
|
||||
#include "config/load.h"
|
||||
#include "config/parse.h"
|
||||
@ -58,11 +59,11 @@ harnessCfgLoadRole(ConfigCommand commandId, ConfigCommandRole commandRoleId, con
|
||||
StringList *argList = strLstDup(argListParam);
|
||||
|
||||
// Set log path if valid
|
||||
if (cfgDefOptionValid(commandId, cfgDefOptLogPath))
|
||||
if (cfgDefOptionValid(commandId, cfgOptLogPath))
|
||||
strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOG_PATH "=%s", testDataPath()));
|
||||
|
||||
// Set lock path if valid
|
||||
if (cfgDefOptionValid(commandId, cfgDefOptLockPath))
|
||||
if (cfgDefOptionValid(commandId, cfgOptLockPath))
|
||||
strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOCK_PATH "=%s/lock", testDataPath()));
|
||||
|
||||
// Insert the command so it does not interfere with parameters
|
||||
@ -138,7 +139,7 @@ hrnCfgArgRawZ(StringList *argList, ConfigOption optionId, const char *value)
|
||||
void
|
||||
hrnCfgArgKeyRawZ(StringList *argList, ConfigOption optionId, unsigned optionKey, const char *value)
|
||||
{
|
||||
strLstAdd(argList, strNewFmt("--%s=%s", cfgOptionName(optionId + optionKey - 1), value));
|
||||
strLstAdd(argList, strNewFmt("--%s=%s", cfgOptionKeyIdxName(optionId, optionKey - 1), value));
|
||||
}
|
||||
|
||||
void
|
||||
@ -150,7 +151,7 @@ hrnCfgArgRawBool(StringList *argList, ConfigOption optionId, bool value)
|
||||
void
|
||||
hrnCfgArgKeyRawBool(StringList *argList, ConfigOption optionId, unsigned optionKey, bool value)
|
||||
{
|
||||
strLstAdd(argList, strNewFmt("--%s%s", value ? "" : "no-", cfgOptionName(optionId + optionKey - 1)));
|
||||
strLstAdd(argList, strNewFmt("--%s%s", value ? "" : "no-", cfgOptionKeyIdxName(optionId, optionKey - 1)));
|
||||
}
|
||||
|
||||
void
|
||||
@ -162,7 +163,7 @@ hrnCfgArgRawNegate(StringList *argList, ConfigOption optionId)
|
||||
void
|
||||
hrnCfgArgKeyRawNegate(StringList *argList, ConfigOption optionId, unsigned optionKey)
|
||||
{
|
||||
strLstAdd(argList, strNewFmt("--no-%s", cfgOptionName(optionId + optionKey - 1)));
|
||||
strLstAdd(argList, strNewFmt("--no-%s", cfgOptionKeyIdxName(optionId, optionKey - 1)));
|
||||
}
|
||||
|
||||
void
|
||||
@ -174,7 +175,7 @@ hrnCfgArgRawReset(StringList *argList, ConfigOption optionId)
|
||||
void
|
||||
hrnCfgArgKeyRawReset(StringList *argList, ConfigOption optionId, unsigned optionKey)
|
||||
{
|
||||
strLstAdd(argList, strNewFmt("--reset-%s", cfgOptionName(optionId + optionKey - 1)));
|
||||
strLstAdd(argList, strNewFmt("--reset-%s", cfgOptionKeyIdxName(optionId, optionKey - 1)));
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
@ -199,7 +200,7 @@ hrnCfgEnvRawZ(ConfigOption optionId, const char *value)
|
||||
void
|
||||
hrnCfgEnvKeyRawZ(ConfigOption optionId, unsigned optionKey, const char *value)
|
||||
{
|
||||
setenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgOptionName(optionId + optionKey - 1))), value, true);
|
||||
setenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgOptionKeyIdxName(optionId, optionKey - 1))), value, true);
|
||||
}
|
||||
|
||||
void
|
||||
@ -211,5 +212,5 @@ hrnCfgEnvRemoveRaw(ConfigOption optionId)
|
||||
void
|
||||
hrnCfgEnvKeyRemoveRaw(ConfigOption optionId, unsigned optionKey)
|
||||
{
|
||||
unsetenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgOptionName(optionId + optionKey - 1))));
|
||||
unsetenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgOptionKeyIdxName(optionId, optionKey - 1))));
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ testRun(void)
|
||||
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
|
||||
strLstAddZ(argList, "--process=1");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
|
||||
strLstAddZ(argList, "--host-id=1");
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "1");
|
||||
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList);
|
||||
|
||||
cmdLocal(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE());
|
||||
|
@ -1,294 +0,0 @@
|
||||
/***********************************************************************************************************************************
|
||||
Test Configuration Commands and Options
|
||||
***********************************************************************************************************************************/
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test run
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
testRun(void)
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Static tests against known values -- these may break as options change so will need to be kept up to date. The tests have
|
||||
// generally been selected to favor values that are not expected to change but adjustments are welcome as long as the type of
|
||||
// test is not drastically changed.
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("check known values"))
|
||||
{
|
||||
TEST_ERROR(cfgCommandId(BOGUS_STR, true), AssertError, "invalid command 'BOGUS'");
|
||||
TEST_RESULT_INT(cfgCommandId(BOGUS_STR, false), cfgCmdNone, "command none id from bogus");
|
||||
TEST_RESULT_INT(cfgCommandId("archive-push", true), cfgCmdArchivePush, "command id from name");
|
||||
|
||||
TEST_RESULT_Z(cfgCommandName(cfgCmdBackup), "backup", "command name from id");
|
||||
|
||||
TEST_RESULT_INT(cfgOptionDefIdFromId(cfgOptPgHost + 6), cfgDefOptPgHost, "option id to def id");
|
||||
|
||||
TEST_ERROR(
|
||||
cfgOptionIdFromDefId(999999, 6), AssertError,
|
||||
"assertion 'optionId != CFG_OPTION_TOTAL' failed");
|
||||
TEST_ERROR(
|
||||
cfgOptionIdFromDefId(0, 999999), AssertError,
|
||||
"assertion 'index < cfgDefOptionIndexTotal(optionDefId)' failed");
|
||||
TEST_RESULT_INT(cfgOptionIdFromDefId(cfgDefOptPgHost, 6), cfgOptPgHost + 6, "option def id to id");
|
||||
|
||||
TEST_ERROR(cfgOptionIndex(CFG_OPTION_TOTAL), AssertError, "assertion 'optionId < CFG_OPTION_TOTAL' failed");
|
||||
TEST_RESULT_INT(cfgOptionIndex(cfgOptPgHostCmd + 6), 6, "option index");
|
||||
TEST_RESULT_INT(cfgOptionIndex(cfgOptCompressLevel), 0, "option index");
|
||||
|
||||
TEST_RESULT_Z(cfgOptionName(cfgOptBackupStandby), "backup-standby", "option id from name");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("configuration"))
|
||||
{
|
||||
TEST_RESULT_VOID(cfgInit(), "config init");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdNone, "command begins as none");
|
||||
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault), "command set to backup");
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, "command is backup");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup", "command:role is backup");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleLocal), "command set to backup:local");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup:local", "command:role is backup:local");
|
||||
TEST_RESULT_INT(cfgCommandInternal(cfgCmdBackup), false, "backup is external");
|
||||
TEST_RESULT_INT(cfgLogLevelDefault(), logLevelInfo, "default log level is info");
|
||||
TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), false, "lock is not required");
|
||||
TEST_RESULT_BOOL(cfgLockRemoteRequired(), true, "remote lock is required");
|
||||
TEST_RESULT_INT(cfgLockType(), lockTypeBackup, "lock is type backup");
|
||||
TEST_RESULT_BOOL(cfgParameterAllowed(), false, "parameters not allowed");
|
||||
|
||||
TEST_RESULT_VOID(cfgCommandSet(cfgCmdInfo, cfgCmdRoleDefault), "command set to info");
|
||||
TEST_RESULT_INT(cfgLogLevelDefault(), logLevelDebug, "default log level is debug");
|
||||
TEST_RESULT_BOOL(cfgLogFile(), false, "log file is off");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), false, "lock is not required");
|
||||
TEST_RESULT_BOOL(cfgLockRemoteRequired(), false, "remote lock is not required");
|
||||
TEST_RESULT_INT(cfgLockType(), lockTypeNone, "lock is type none");
|
||||
|
||||
TEST_RESULT_VOID(cfgCommandSet(cfgCmdStanzaCreate, cfgCmdRoleDefault), "command set to stanza-create");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), true, "lock is required");
|
||||
TEST_RESULT_INT(cfgLockType(), lockTypeAll, "lock is type all");
|
||||
|
||||
TEST_RESULT_VOID(cfgCommandSet(cfgCmdArchiveGet, cfgCmdRoleAsync), "command set to archive-get:async");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), true, "lock is required");
|
||||
TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on");
|
||||
|
||||
TEST_RESULT_VOID(cfgCommandSet(cfgCmdInfo, cfgCmdRoleDefault), "command set to info");
|
||||
|
||||
cfgOptionSet(cfgOptLogLevelFile, cfgSourceParam, VARSTRDEF("info"));
|
||||
cfgOptionValidSet(cfgOptLogLevelFile, true);
|
||||
|
||||
TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("command roles");
|
||||
|
||||
TEST_ERROR(cfgCommandRoleEnum(strNew(BOGUS_STR)), CommandInvalidError, "invalid command role 'BOGUS'");
|
||||
TEST_RESULT_UINT(cfgCommandRoleEnum(NULL), cfgCmdRoleDefault, "command default role enum");
|
||||
TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("async")), cfgCmdRoleAsync, "command async role enum");
|
||||
TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("local")), cfgCmdRoleLocal, "command local role enum");
|
||||
TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("remote")), cfgCmdRoleRemote, "command remote role enum");
|
||||
|
||||
TEST_RESULT_STR(cfgCommandRoleStr(cfgCmdRoleDefault), NULL, "command default role str");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleAsync), "async", "command async role str");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleLocal), "local", "command local role str");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleRemote), "remote", "command remote role str");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_BOOL(cfgCommandHelp(), false, "command help defaults to false");
|
||||
TEST_RESULT_VOID(cfgCommandHelpSet(true), "set command help");
|
||||
TEST_RESULT_BOOL(cfgCommandHelp(), true, "command help is set");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
StringList *param = strLstNew();
|
||||
strLstAddZ(param, "param");
|
||||
|
||||
TEST_RESULT_INT(strLstSize(cfgCommandParam()), 0, "command param list defaults to empty");
|
||||
TEST_RESULT_VOID(cfgCommandParamSet(param), "set command param list");
|
||||
TEST_RESULT_INT(strLstSize(cfgCommandParam()), 1, "command param list is set");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_STR(cfgExe(), NULL, "exe defaults to null");
|
||||
TEST_RESULT_VOID(cfgExeSet(strNew("/path/to/exe")), "set exe");
|
||||
TEST_RESULT_Z(strZ(cfgExe()), "/path/to/exe", "exe is set");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_BOOL(cfgOptionNegate(cfgOptConfig), false, "negate defaults to false");
|
||||
TEST_RESULT_VOID(cfgOptionNegateSet(cfgOptConfig, true), "set negate");
|
||||
TEST_RESULT_BOOL(cfgOptionNegate(cfgOptConfig), true, "negate is set");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_BOOL(cfgOptionReset(cfgOptConfig), false, "reset defaults to false");
|
||||
TEST_RESULT_VOID(cfgOptionResetSet(cfgOptConfig, true), "set reset");
|
||||
TEST_RESULT_BOOL(cfgOptionReset(cfgOptConfig), true, "reset is set");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_BOOL(cfgOptionValid(cfgOptConfig), false, "valid defaults to false");
|
||||
TEST_RESULT_BOOL(cfgOptionTest(cfgOptConfig), false, "option not valid for the command");
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptConfig, true), "set valid");
|
||||
TEST_RESULT_BOOL(cfgOptionValid(cfgOptConfig), true, "valid is set");
|
||||
TEST_RESULT_BOOL(cfgOptionTest(cfgOptConfig), false, "option valid but value is null");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptConfig, cfgSourceParam, varNewStrZ("cfg")), "set option config");
|
||||
TEST_RESULT_BOOL(cfgOptionTest(cfgOptConfig), true, "option valid and value not null");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("option groups");
|
||||
|
||||
TEST_RESULT_BOOL(cfgOptionGroupValid(cfgOptGrpPg), false, "pg option group is not valid");
|
||||
TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 0), false, "pg option group index 0 is not set");
|
||||
TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 0, "pg option group index total is 0");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptPgPath + 1, true), "set pg1-path valid");
|
||||
TEST_RESULT_BOOL(cfgOptionGroupValid(cfgOptGrpPg), true, "pg option group is valid");
|
||||
TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 0), true, "pg option group index 0 is set");
|
||||
TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 1), false, "pg option group index 1 is not set");
|
||||
TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 1, "pg option group index total is 1");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptPgPath + 7, true), "set pg7-path valid");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptPgPath + 7, cfgSourceParam, VARSTRDEF("/path")), "set pg7-path");
|
||||
TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 1), false, "pg option group index 1 is not set");
|
||||
TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 7), true, "pg option group index 7 is set");
|
||||
TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 8, "pg option group index total is 8");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptPgPath + 5, true), "set pg5-path valid");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptPgPath + 5, cfgSourceDefault, VARSTRDEF("/path")), "set pg5-path");
|
||||
TEST_RESULT_BOOL(cfgOptionGroupIdxTest(cfgOptGrpPg, 5), false, "pg option group index 5 is not set");
|
||||
TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 8, "pg option group index total is 8");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_PTR(cfgOption(cfgOptOnline), NULL, "online is null");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptOnline, cfgSourceParam, varNewBool(false)), "set online");
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptOnline, true), "set online valid");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, "online is set");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptOnline, cfgSourceParam, varNewStrZ("1")), "set online");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), true, "online is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, "online source is set");
|
||||
TEST_ERROR(cfgOptionDbl(cfgOptOnline), AssertError, "option 'online' is type 0 but 1 was requested");
|
||||
TEST_ERROR(cfgOptionInt64(cfgOptOnline), AssertError, "option 'online' is type 0 but 3 was requested");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptCompressLevel, cfgSourceParam, varNewInt64(1)), "set compress-level");
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptCompressLevel, true), "set compress-level valid");
|
||||
TEST_RESULT_INT(cfgOptionInt(cfgOptCompressLevel), 1, "compress-level is set");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptCompressLevel, cfgSourceDefault, varNewStrZ("3")), "set compress-level");
|
||||
TEST_RESULT_INT(cfgOptionUInt(cfgOptCompressLevel), 3, "compress-level is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptCompressLevel), cfgSourceDefault, "compress source is set");
|
||||
TEST_ERROR(cfgOptionBool(cfgOptCompressLevel), AssertError, "option 'compress-level' is type 3 but 0 was requested");
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
cfgOptionSet(cfgOptArchivePushQueueMax, cfgSourceParam, varNewInt64(999999999999)), "set archive-push-queue-max");
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptArchivePushQueueMax, true), "set archive-push-queue-max valid");
|
||||
TEST_RESULT_INT(cfgOptionInt64(cfgOptArchivePushQueueMax), 999999999999, "archive-push-queue-max is set");
|
||||
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptArchivePushQueueMax), 999999999999, "archive-push-queue-max is set");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, varNewDbl(1.1)), "set protocol-timeout");
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptProtocolTimeout, true), "set protocol-timeout valid");
|
||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 1.1, "protocol-timeout is set");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceConfig, varNewStrZ("3.3")), "set protocol-timeout");
|
||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 3.3, "protocol-timeout is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptProtocolTimeout), cfgSourceConfig, "protocol-timeout source is set");
|
||||
TEST_ERROR(cfgOptionKv(cfgOptProtocolTimeout), AssertError, "option 'protocol-timeout' is type 1 but 4 was requested");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceConfig, NULL), "set protocol-timeout to NULL");
|
||||
TEST_RESULT_PTR(cfgOption(cfgOptProtocolTimeout), NULL, "protocol-timeout is not set");
|
||||
|
||||
TEST_ERROR(
|
||||
cfgOptionSet(cfgOptRecoveryOption, cfgSourceParam, varNewDbl(1.1)), AssertError,
|
||||
"option 'recovery-option' must be set with KeyValue variant");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptRecoveryOption, cfgSourceConfig, varNewKv(kvNew())), "set recovery-option");
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptRecoveryOption, true), "set recovery-option valid");
|
||||
TEST_RESULT_INT(varLstSize(kvKeyList(cfgOptionKv(cfgOptRecoveryOption))), 0, "recovery-option is set");
|
||||
TEST_ERROR(cfgOptionLst(cfgOptRecoveryOption), AssertError, "option 'recovery-option' is type 4 but 8 was requested");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptDbInclude, true), "set db-include valid");
|
||||
TEST_RESULT_INT(varLstSize(cfgOptionLst(cfgOptDbInclude)), 0, "db-include defaults to empty");
|
||||
TEST_ERROR(
|
||||
cfgOptionSet(cfgOptDbInclude, cfgSourceParam, varNewDbl(1.1)), AssertError,
|
||||
"option 'db-include' must be set with VariantList variant");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptDbInclude, cfgSourceConfig, varNewVarLst(varLstNew())), "set db-include");
|
||||
TEST_RESULT_INT(varLstSize(cfgOptionLst(cfgOptDbInclude)), 0, "db-include is set");
|
||||
TEST_ERROR(cfgOptionStr(cfgOptDbInclude), AssertError, "option 'db-include' is type 8 but 5 was requested");
|
||||
|
||||
TEST_ERROR(cfgOptionStr(cfgOptStanza), AssertError, "option 'stanza' is not valid for the current command");
|
||||
TEST_RESULT_VOID(cfgOptionValidSet(cfgOptStanza, true), "set stanza valid");
|
||||
TEST_ERROR(cfgOptionStr(cfgOptStanza), AssertError, "option 'stanza' is null but non-null was requested");
|
||||
TEST_RESULT_STR(cfgOptionStrNull(cfgOptStanza), NULL, "stanza defaults to null");
|
||||
TEST_ERROR(
|
||||
cfgOptionSet(cfgOptStanza, cfgSourceParam, varNewDbl(1.1)), AssertError,
|
||||
"option 'stanza' must be set with String variant");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptStanza, cfgSourceConfig, varNewStrZ("db")), "set stanza");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptStanza), "db", "stanza is set");
|
||||
TEST_ERROR(cfgOptionInt(cfgOptStanza), AssertError, "option 'stanza' is type 5 but 3 was requested");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_VOID(cfgInit(), "config init resets value");
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdNone, "command begins as none");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("cfgOptionHostPort()"))
|
||||
{
|
||||
unsigned int port = 55555;
|
||||
|
||||
cfgInit();
|
||||
cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault);
|
||||
|
||||
cfgOptionValidSet(cfgOptRepoS3Host, true);
|
||||
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("host.com")) ;
|
||||
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "host.com", "check plain host");
|
||||
TEST_RESULT_UINT(port, 55555, "check that port was not updated");
|
||||
|
||||
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777")) ;
|
||||
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "myhost.com", "check host with port");
|
||||
TEST_RESULT_UINT(port, 777, "check that port was updated");
|
||||
|
||||
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), NULL, "check null host");
|
||||
TEST_RESULT_UINT(port, 777, "check that port was not updated");
|
||||
|
||||
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777:888")) ;
|
||||
TEST_ERROR(
|
||||
cfgOptionHostPort(cfgOptRepoS3Host, &port), OptionInvalidError,
|
||||
"'myhost.com:777:888' is not valid for option 'repo1-s3-host'"
|
||||
"\nHINT: is more than one port specified?");
|
||||
TEST_RESULT_UINT(port, 777, "check that port was not updated");
|
||||
|
||||
cfgOptionValidSet(cfgOptRepoS3Endpoint, true);
|
||||
cfgOptionSet(cfgOptRepoS3Endpoint, cfgSourceConfig, varNewStrZ("myendpoint.com:ZZZ")) ;
|
||||
TEST_ERROR(
|
||||
cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), OptionInvalidError,
|
||||
"'myendpoint.com:ZZZ' is not valid for option 'repo1-s3-endpoint'"
|
||||
"\nHINT: port is not a positive integer.");
|
||||
TEST_RESULT_UINT(port, 777, "check that port was not updated");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("cfgOptionDefault() and cfgOptionDefaultSet()"))
|
||||
{
|
||||
TEST_RESULT_VOID(cfgInit(), "config init");
|
||||
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault), "backup command");
|
||||
|
||||
TEST_ERROR(
|
||||
strZ(varStr(cfgOptionDefaultValue(cfgDefOptDbInclude))), AssertError, "default value not available for option type 4");
|
||||
TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptType)), "incr", "backup type default");
|
||||
TEST_RESULT_BOOL(varBool(cfgOptionDefault(cfgOptArchiveAsync)), false, "archive async default");
|
||||
TEST_RESULT_DOUBLE(varDbl(cfgOptionDefault(cfgOptProtocolTimeout)), 1830, "backup protocol-timeout default");
|
||||
TEST_RESULT_INT(varIntForce(cfgOptionDefault(cfgOptProcessMax)), 1, "backup process-max default");
|
||||
TEST_RESULT_PTR(cfgOptionDefault(cfgOptDbInclude), NULL, "backup db-include default is null");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptPgHost, cfgSourceParam, varNewStrZ("backup")), "backup host set");
|
||||
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgHost, varNewStrZ("backup-default")), "backup host default");
|
||||
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgHost, varNewStrZ("backup-default2")), "reset backup host default");
|
||||
TEST_RESULT_STR_Z(varStr(cfgOption(cfgOptPgHost)), "backup", "backup host value");
|
||||
TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptPgHost)), "backup-default2", "backup host default");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptPgSocketPath, cfgSourceDefault, NULL), "backup pg-socket-path set");
|
||||
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, varNewStrZ("/to/socket")), "backup pg-socket-path default");
|
||||
TEST_RESULT_VOID(cfgOptionDefaultSet(cfgOptPgSocketPath, varNewStrZ("/to/socket2")), "reset backup pg-socket-path default");
|
||||
TEST_RESULT_STR_Z(varStr(cfgOption(cfgOptPgSocketPath)), "/to/socket2", "backup pg-socket-path value");
|
||||
TEST_RESULT_STR_Z(varStr(cfgOptionDefault(cfgOptPgSocketPath)), "/to/socket2", "backup pg-socket-path value default");
|
||||
}
|
||||
|
||||
FUNCTION_HARNESS_RESULT_VOID();
|
||||
}
|
@ -16,112 +16,112 @@ testRun(void)
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("check known values"))
|
||||
{
|
||||
TEST_RESULT_Z(cfgDefOptionName(cfgDefOptConfig), "config", "option name");
|
||||
TEST_RESULT_Z(cfgDefOptionName(cfgOptConfig), "config", "option name");
|
||||
|
||||
TEST_RESULT_INT(cfgDefOptionId("repo-host"), cfgDefOptRepoHost, "define id");
|
||||
TEST_RESULT_INT(cfgDefOptionId("repo-host"), cfgOptRepoHost, "define id");
|
||||
TEST_RESULT_INT(cfgDefOptionId(BOGUS_STR), -1, "invalid define id");
|
||||
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgDefOptLogLevelConsole), true, "allow list valid");
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgDefOptPgHost), false, "allow list not valid");
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgDefOptType), true, "command allow list valid");
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgOptLogLevelConsole), true, "allow list valid");
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgOptPgHost), false, "allow list not valid");
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowList(cfgCmdBackup, cfgOptType), true, "command allow list valid");
|
||||
|
||||
TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgCmdBackup, cfgDefOptChecksumPage), 0, "allow list total = 0");
|
||||
TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgCmdBackup, cfgOptChecksumPage), 0, "allow list total = 0");
|
||||
|
||||
TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgCmdBackup, cfgDefOptType), 3, "allow list total");
|
||||
TEST_RESULT_INT(cfgDefOptionAllowListValueTotal(cfgCmdBackup, cfgOptType), 3, "allow list total");
|
||||
|
||||
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgDefOptType, 0), "full", "allow list value 0");
|
||||
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgDefOptType, 1), "diff", "allow list value 1");
|
||||
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgDefOptType, 2), "incr", "allow list value 2");
|
||||
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgOptType, 0), "full", "allow list value 0");
|
||||
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgOptType, 1), "diff", "allow list value 1");
|
||||
TEST_RESULT_Z(cfgDefOptionAllowListValue(cfgCmdBackup, cfgOptType, 2), "incr", "allow list value 2");
|
||||
TEST_ERROR(
|
||||
cfgDefOptionAllowListValue(cfgCmdBackup, cfgDefOptType, 3), AssertError,
|
||||
"assertion 'valueId < cfgDefOptionAllowListValueTotal(commandId, optionDefId)' failed");
|
||||
cfgDefOptionAllowListValue(cfgCmdBackup, cfgOptType, 3), AssertError,
|
||||
"assertion 'valueId < cfgDefOptionAllowListValueTotal(commandId, optionId)' failed");
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
cfgDefOptionAllowListValueValid(cfgCmdBackup, cfgDefOptType, "diff"), true, "allow list value valid");
|
||||
cfgDefOptionAllowListValueValid(cfgCmdBackup, cfgOptType, "diff"), true, "allow list value valid");
|
||||
TEST_RESULT_BOOL(
|
||||
cfgDefOptionAllowListValueValid(cfgCmdBackup, cfgDefOptType, BOGUS_STR), false, "allow list value not valid");
|
||||
cfgDefOptionAllowListValueValid(cfgCmdBackup, cfgOptType, BOGUS_STR), false, "allow list value not valid");
|
||||
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgDefOptCompressLevel), true, "range allowed");
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgDefOptRepoHost), false, "range not allowed");
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgOptCompressLevel), true, "range allowed");
|
||||
TEST_RESULT_BOOL(cfgDefOptionAllowRange(cfgCmdBackup, cfgOptRepoHost), false, "range not allowed");
|
||||
|
||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdBackup, cfgDefOptDbTimeout), 0.1, "range min");
|
||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMax(cfgCmdBackup, cfgDefOptCompressLevel), 9, "range max");
|
||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdArchivePush, cfgDefOptArchivePushQueueMax), 0, "range min");
|
||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdBackup, cfgOptDbTimeout), 0.1, "range min");
|
||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMax(cfgCmdBackup, cfgOptCompressLevel), 9, "range max");
|
||||
TEST_RESULT_DOUBLE(cfgDefOptionAllowRangeMin(cfgCmdArchivePush, cfgOptArchivePushQueueMax), 0, "range min");
|
||||
TEST_RESULT_DOUBLE(
|
||||
cfgDefOptionAllowRangeMax(cfgCmdArchivePush, cfgDefOptArchivePushQueueMax), 4503599627370496, "range max");
|
||||
cfgDefOptionAllowRangeMax(cfgCmdArchivePush, cfgOptArchivePushQueueMax), 4503599627370496, "range max");
|
||||
|
||||
TEST_ERROR(
|
||||
cfgDefOptionDefault(cfgDefCommandTotal(), cfgDefOptCompressLevel), AssertError,
|
||||
cfgDefOptionDefault(cfgDefCommandTotal(), cfgOptCompressLevel), AssertError,
|
||||
"assertion 'commandId < cfgDefCommandTotal()' failed");
|
||||
TEST_ERROR(cfgDefOptionDefault(
|
||||
cfgCmdBackup, cfgDefOptionTotal()), AssertError,
|
||||
"assertion 'optionDefId < cfgDefOptionTotal()' failed");
|
||||
TEST_RESULT_Z(cfgDefOptionDefault(cfgCmdRestore, cfgDefOptType), "default", "command default exists");
|
||||
TEST_RESULT_Z(cfgDefOptionDefault(cfgCmdBackup, cfgDefOptRepoHost), NULL, "default does not exist");
|
||||
"assertion 'optionId < cfgDefOptionTotal()' failed");
|
||||
TEST_RESULT_Z(cfgDefOptionDefault(cfgCmdRestore, cfgOptType), "default", "command default exists");
|
||||
TEST_RESULT_Z(cfgDefOptionDefault(cfgCmdBackup, cfgOptRepoHost), NULL, "default does not exist");
|
||||
|
||||
TEST_RESULT_BOOL(cfgDefOptionDepend(cfgCmdRestore, cfgDefOptRepoS3Key), true, "has depend option");
|
||||
TEST_RESULT_BOOL(cfgDefOptionDepend(cfgCmdRestore, cfgDefOptType), false, "does not have depend option");
|
||||
TEST_RESULT_BOOL(cfgDefOptionDepend(cfgCmdRestore, cfgOptRepoS3Key), true, "has depend option");
|
||||
TEST_RESULT_BOOL(cfgDefOptionDepend(cfgCmdRestore, cfgOptType), false, "does not have depend option");
|
||||
|
||||
TEST_RESULT_INT(cfgDefOptionDependOption(cfgCmdBackup, cfgDefOptPgHostUser), cfgDefOptPgHost, "depend option id");
|
||||
TEST_RESULT_INT(cfgDefOptionDependOption(cfgCmdBackup, cfgDefOptRepoHostCmd), cfgDefOptRepoHost, "depend option id");
|
||||
TEST_RESULT_INT(cfgDefOptionDependOption(cfgCmdBackup, cfgOptPgHostUser), cfgOptPgHost, "depend option id");
|
||||
TEST_RESULT_INT(cfgDefOptionDependOption(cfgCmdBackup, cfgOptRepoHostCmd), cfgOptRepoHost, "depend option id");
|
||||
|
||||
TEST_RESULT_INT(cfgDefOptionDependValueTotal(cfgCmdRestore, cfgDefOptTarget), 3, "depend option value total");
|
||||
TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgDefOptTarget, 0), "name", "depend option value 0");
|
||||
TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgDefOptTarget, 1), "time", "depend option value 1");
|
||||
TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgDefOptTarget, 2), "xid", "depend option value 2");
|
||||
TEST_RESULT_INT(cfgDefOptionDependValueTotal(cfgCmdRestore, cfgOptTarget), 3, "depend option value total");
|
||||
TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgOptTarget, 0), "name", "depend option value 0");
|
||||
TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgOptTarget, 1), "time", "depend option value 1");
|
||||
TEST_RESULT_Z(cfgDefOptionDependValue(cfgCmdRestore, cfgOptTarget, 2), "xid", "depend option value 2");
|
||||
TEST_ERROR(
|
||||
cfgDefOptionDependValue(cfgCmdRestore, cfgDefOptTarget, 3), AssertError,
|
||||
"assertion 'valueId < cfgDefOptionDependValueTotal(commandId, optionDefId)' failed");
|
||||
cfgDefOptionDependValue(cfgCmdRestore, cfgOptTarget, 3), AssertError,
|
||||
"assertion 'valueId < cfgDefOptionDependValueTotal(commandId, optionId)' failed");
|
||||
|
||||
TEST_RESULT_BOOL(
|
||||
cfgDefOptionDependValueValid(cfgCmdRestore, cfgDefOptTarget, "time"), true, "depend option value valid");
|
||||
cfgDefOptionDependValueValid(cfgCmdRestore, cfgOptTarget, "time"), true, "depend option value valid");
|
||||
TEST_RESULT_BOOL(
|
||||
cfgDefOptionDependValueValid(cfgCmdRestore, cfgDefOptTarget, BOGUS_STR), false, "depend option value not valid");
|
||||
cfgDefOptionDependValueValid(cfgCmdRestore, cfgOptTarget, BOGUS_STR), false, "depend option value not valid");
|
||||
|
||||
TEST_ERROR(
|
||||
cfgDefOptionIndexTotal(cfgDefOptionTotal()), AssertError,
|
||||
"assertion 'optionDefId < cfgDefOptionTotal()' failed");
|
||||
TEST_RESULT_INT(cfgDefOptionIndexTotal(cfgDefOptPgPath), 8, "index total > 1");
|
||||
TEST_RESULT_INT(cfgDefOptionIndexTotal(cfgDefOptRepoPath), 1, "index total == 1");
|
||||
"assertion 'optionId < cfgDefOptionTotal()' failed");
|
||||
TEST_RESULT_INT(cfgDefOptionIndexTotal(cfgOptPgPath), 8, "index total > 1");
|
||||
TEST_RESULT_INT(cfgDefOptionIndexTotal(cfgOptRepoPath), 1, "index total == 1");
|
||||
|
||||
TEST_RESULT_BOOL(cfgDefOptionInternal(cfgCmdRestore, cfgDefOptSet), false, "option set is not internal");
|
||||
TEST_RESULT_BOOL(cfgDefOptionInternal(cfgCmdRestore, cfgDefOptPgHost), true, "option pg-host is internal");
|
||||
TEST_RESULT_BOOL(cfgDefOptionInternal(cfgCmdRestore, cfgOptSet), false, "option set is not internal");
|
||||
TEST_RESULT_BOOL(cfgDefOptionInternal(cfgCmdRestore, cfgOptPgHost), true, "option pg-host is internal");
|
||||
|
||||
TEST_RESULT_BOOL(cfgDefOptionMulti(cfgDefOptRecoveryOption), true, "recovery-option is multi");
|
||||
TEST_RESULT_BOOL(cfgDefOptionMulti(cfgDefOptDbInclude), true, "db-include is multi");
|
||||
TEST_RESULT_BOOL(cfgDefOptionMulti(cfgDefOptStartFast), false, "start-fast is not multi");
|
||||
TEST_RESULT_BOOL(cfgDefOptionMulti(cfgOptRecoveryOption), true, "recovery-option is multi");
|
||||
TEST_RESULT_BOOL(cfgDefOptionMulti(cfgOptDbInclude), true, "db-include is multi");
|
||||
TEST_RESULT_BOOL(cfgDefOptionMulti(cfgOptStartFast), false, "start-fast is not multi");
|
||||
|
||||
TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdBackup, cfgDefOptConfig), true, "option required");
|
||||
TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdRestore, cfgDefOptRepoHost), false, "option not required");
|
||||
TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdInfo, cfgDefOptStanza), false, "command option not required");
|
||||
TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdBackup, cfgOptConfig), true, "option required");
|
||||
TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdRestore, cfgOptRepoHost), false, "option not required");
|
||||
TEST_RESULT_BOOL(cfgDefOptionRequired(cfgCmdInfo, cfgOptStanza), false, "command option not required");
|
||||
|
||||
TEST_RESULT_INT(cfgDefOptionSection(cfgDefOptRepoS3Key), cfgDefSectionGlobal, "global section");
|
||||
TEST_RESULT_INT(cfgDefOptionSection(cfgDefOptPgPath), cfgDefSectionStanza, "stanza section");
|
||||
TEST_RESULT_INT(cfgDefOptionSection(cfgDefOptType), cfgDefSectionCommandLine, "command line only");
|
||||
TEST_RESULT_INT(cfgDefOptionSection(cfgOptRepoS3Key), cfgDefSectionGlobal, "global section");
|
||||
TEST_RESULT_INT(cfgDefOptionSection(cfgOptPgPath), cfgDefSectionStanza, "stanza section");
|
||||
TEST_RESULT_INT(cfgDefOptionSection(cfgOptType), cfgDefSectionCommandLine, "command line only");
|
||||
|
||||
TEST_RESULT_BOOL(cfgDefOptionSecure(cfgDefOptRepoS3Key), true, "option secure");
|
||||
TEST_RESULT_BOOL(cfgDefOptionSecure(cfgDefOptRepoHost), false, "option not secure");
|
||||
TEST_RESULT_BOOL(cfgDefOptionSecure(cfgOptRepoS3Key), true, "option secure");
|
||||
TEST_RESULT_BOOL(cfgDefOptionSecure(cfgOptRepoHost), false, "option not secure");
|
||||
|
||||
TEST_RESULT_INT(cfgDefOptionType(cfgDefOptType), cfgDefOptTypeString, "string type");
|
||||
TEST_RESULT_INT(cfgDefOptionType(cfgDefOptDelta), cfgDefOptTypeBoolean, "boolean type");
|
||||
TEST_RESULT_INT(cfgDefOptionType(cfgOptType), cfgDefOptTypeString, "string type");
|
||||
TEST_RESULT_INT(cfgDefOptionType(cfgOptDelta), cfgDefOptTypeBoolean, "boolean type");
|
||||
|
||||
TEST_ERROR(
|
||||
cfgDefOptionValid(cfgCmdInfo, cfgDefOptionTotal()), AssertError,
|
||||
"assertion 'optionDefId < cfgDefOptionTotal()' failed");
|
||||
TEST_RESULT_BOOL(cfgDefOptionValid(cfgCmdBackup, cfgDefOptType), true, "option valid");
|
||||
TEST_RESULT_BOOL(cfgDefOptionValid(cfgCmdInfo, cfgDefOptType), false, "option not valid");
|
||||
"assertion 'optionId < cfgDefOptionTotal()' failed");
|
||||
TEST_RESULT_BOOL(cfgDefOptionValid(cfgCmdBackup, cfgOptType), true, "option valid");
|
||||
TEST_RESULT_BOOL(cfgDefOptionValid(cfgCmdInfo, cfgOptType), false, "option not valid");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("cfgDefCommandHelp*() and cfgDefOptionHelp*()"))
|
||||
{
|
||||
TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgDefOptRepoHost), true, "name alt exists");
|
||||
TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgDefOptSet), false, "name alt not exists");
|
||||
TEST_RESULT_INT(cfgDefOptionHelpNameAltValueTotal(cfgDefOptRepoHost), 1, "name alt value total");
|
||||
TEST_RESULT_Z(cfgDefOptionHelpNameAltValue(cfgDefOptRepoHost, 0), "backup-host", "name alt value 0");
|
||||
TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgOptRepoHost), true, "name alt exists");
|
||||
TEST_RESULT_BOOL(cfgDefOptionHelpNameAlt(cfgOptSet), false, "name alt not exists");
|
||||
TEST_RESULT_INT(cfgDefOptionHelpNameAltValueTotal(cfgOptRepoHost), 1, "name alt value total");
|
||||
TEST_RESULT_Z(cfgDefOptionHelpNameAltValue(cfgOptRepoHost, 0), "backup-host", "name alt value 0");
|
||||
TEST_ERROR(
|
||||
cfgDefOptionHelpNameAltValue(cfgDefOptRepoHost, 1), AssertError,
|
||||
"assertion 'valueId < cfgDefOptionHelpNameAltValueTotal(optionDefId)' failed");
|
||||
cfgDefOptionHelpNameAltValue(cfgOptRepoHost, 1), AssertError,
|
||||
"assertion 'valueId < cfgDefOptionHelpNameAltValueTotal(optionId)' failed");
|
||||
|
||||
TEST_RESULT_Z(cfgDefCommandHelpSummary(cfgCmdBackup), "Backup a database cluster.", "backup command help summary");
|
||||
TEST_RESULT_Z(
|
||||
@ -129,18 +129,18 @@ testRun(void)
|
||||
"pgBackRest does not have a built-in scheduler so it's best to run it from cron or some other scheduling mechanism.",
|
||||
"backup command help description");
|
||||
|
||||
TEST_RESULT_Z(cfgDefOptionHelpSection(cfgDefOptDelta), "general", "delta option help section");
|
||||
TEST_RESULT_Z(cfgDefOptionHelpSection(cfgOptDelta), "general", "delta option help section");
|
||||
TEST_RESULT_Z(
|
||||
cfgDefOptionHelpSummary(cfgCmdBackup, cfgDefOptBufferSize), "Buffer size for file operations.",
|
||||
cfgDefOptionHelpSummary(cfgCmdBackup, cfgOptBufferSize), "Buffer size for file operations.",
|
||||
"backup command, delta option help summary");
|
||||
TEST_RESULT_Z(
|
||||
cfgDefOptionHelpSummary(cfgCmdBackup, cfgDefOptType), "Backup type.", "backup command, type option help summary");
|
||||
cfgDefOptionHelpSummary(cfgCmdBackup, cfgOptType), "Backup type.", "backup command, type option help summary");
|
||||
TEST_RESULT_Z(
|
||||
cfgDefOptionHelpDescription(cfgCmdBackup, cfgDefOptLogSubprocess),
|
||||
cfgDefOptionHelpDescription(cfgCmdBackup, cfgOptLogSubprocess),
|
||||
"Enable file logging for any subprocesses created by this process using the log level specified by log-level-file.",
|
||||
"backup command, log-subprocess option help description");
|
||||
TEST_RESULT_Z(
|
||||
cfgDefOptionHelpDescription(cfgCmdBackup, cfgDefOptType),
|
||||
cfgDefOptionHelpDescription(cfgCmdBackup, cfgOptType),
|
||||
"The following backup types are supported:\n"
|
||||
"\n"
|
||||
"* full - all database cluster files will be copied and there will be no dependencies on previous backups.\n"
|
||||
|
@ -61,8 +61,8 @@ testRun(void)
|
||||
hrnCfgArgKeyRawZ(argList, cfgOptPgHostCmd, 2, "pg2-exe");
|
||||
harnessCfgLoad(cfgCmdCheck, argList);
|
||||
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgHostCmd + 0), testProjectExe(), " check pg1-host-cmd");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgHostCmd + 1), "pg2-exe", " check pg2-host-cmd");
|
||||
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgHostCmd, 0), testProjectExe(), " check pg1-host-cmd");
|
||||
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgHostCmd, 1), "pg2-exe", " check pg2-host-cmd");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("db-timeout set but not protocol timeout");
|
||||
@ -73,7 +73,7 @@ testRun(void)
|
||||
hrnCfgArgRawZ(argList, cfgOptDbTimeout, "100");
|
||||
harnessCfgLoad(cfgCmdCheck, argList);
|
||||
|
||||
cfgOptionValidSet(cfgOptProtocolTimeout, false);
|
||||
cfgOptionInvalidate(cfgOptProtocolTimeout);
|
||||
cfgLoadUpdateOption();
|
||||
|
||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptDbTimeout), 100, "check db-timeout");
|
||||
@ -87,7 +87,7 @@ testRun(void)
|
||||
hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, "100");
|
||||
harnessCfgLoad(cfgCmdCheck, argList);
|
||||
|
||||
cfgOptionValidSet(cfgOptDbTimeout, false);
|
||||
cfgOptionInvalidate(cfgOptDbTimeout);
|
||||
cfgLoadUpdateOption();
|
||||
|
||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 100, "check protocol-timeout");
|
||||
@ -143,7 +143,7 @@ testRun(void)
|
||||
TEST_TITLE("only pg can be remote");
|
||||
|
||||
// We'll have to cheat here and invalidate the repo-host option since there are currently no pg-only commands
|
||||
cfgOptionValidSet(cfgOptRepoHost, false);
|
||||
cfgOptionInvalidate(cfgOptRepoHost);
|
||||
cfgLoadUpdateOption();
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -519,7 +519,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
|
||||
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to");
|
||||
strLstAdd(argList, strNew("--process=1"));
|
||||
strLstAdd(argList, strNew("--host-id=1"));
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "1");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
|
||||
strLstAdd(argList, strNew("--log-level-file=warn"));
|
||||
hrnCfgArgRawZ(argList, cfgOptExecId, "1111-fe70d611");
|
||||
|
@ -23,7 +23,8 @@ testOptionFind(const char *optionName, unsigned int optionId, unsigned int optio
|
||||
CfgParseOptionResult option = cfgParseOption(STR(optionName));
|
||||
|
||||
TEST_RESULT_BOOL(option.found, true, "check %s found", optionName);
|
||||
TEST_RESULT_UINT(option.id, optionId + optionKeyIdx, "check %s id %u", optionName, optionId + optionKeyIdx);
|
||||
TEST_RESULT_UINT(option.id, optionId, "check %s id %u", optionName, optionId);
|
||||
TEST_RESULT_UINT(option.keyIdx, optionKeyIdx, "check %s key idx %u", optionName, optionKeyIdx);
|
||||
TEST_RESULT_BOOL(option.negate, negate, "check %s negate %d", optionName, negate);
|
||||
TEST_RESULT_BOOL(option.reset, reset, "check %s reset %d", optionName, reset);
|
||||
TEST_RESULT_BOOL(option.deprecated, deprecated, "check %s deprecated %d", optionName, deprecated);
|
||||
@ -37,6 +38,15 @@ testRun(void)
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
// Config functions that are not tested with parse
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("cfg*()"))
|
||||
{
|
||||
TEST_TITLE("config command defaults to none before cfgInit()");
|
||||
|
||||
TEST_RESULT_UINT(cfgCommand(), cfgCmdNone, "command is none");
|
||||
}
|
||||
|
||||
// config and config-include-path options
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("cfgFileLoad()"))
|
||||
@ -136,28 +146,37 @@ testRun(void)
|
||||
strZ(strNewFmt("%s/global-backup.confsave", strZ(configIncludePath))));
|
||||
|
||||
// Set up defaults
|
||||
String *backupCmdDefConfigValue = strNew(cfgDefOptionDefault(
|
||||
cfgCommandId(TEST_COMMAND_BACKUP, true), cfgOptionDefIdFromId(cfgOptConfig)));
|
||||
String *backupCmdDefConfigInclPathValue = strNew(cfgDefOptionDefault(
|
||||
cfgCommandId(TEST_COMMAND_BACKUP, true), cfgOptionDefIdFromId(cfgOptConfigIncludePath)));
|
||||
String *backupCmdDefConfigValue = strNew(cfgDefOptionDefault(cfgCommandId(TEST_COMMAND_BACKUP), cfgOptConfig));
|
||||
String *backupCmdDefConfigInclPathValue = strNew(
|
||||
cfgDefOptionDefault(cfgCommandId(TEST_COMMAND_BACKUP), cfgOptConfigIncludePath));
|
||||
String *oldConfigDefault = strNewFmt("%s%s", testPath(), PGBACKREST_CONFIG_ORIG_PATH_FILE);
|
||||
|
||||
// Create the option structure and initialize with 0
|
||||
ParseOption parseOptionList[CFG_OPTION_TOTAL] = {{.found = false}};
|
||||
ParseOption parseOptionList[CFG_OPTION_TOTAL] = {{0}};
|
||||
|
||||
StringList *value = strLstNew();
|
||||
strLstAdd(value, configFile);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = true;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexListTotal = 1;
|
||||
parseOptionList[cfgOptConfig].indexList = memNew(sizeof(ParseOptionValue));
|
||||
parseOptionList[cfgOptConfig].indexList[0] = (ParseOptionValue)
|
||||
{
|
||||
.found = true,
|
||||
.source = cfgSourceParam,
|
||||
.valueList = value,
|
||||
};
|
||||
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configIncludePath);
|
||||
|
||||
parseOptionList[cfgOptConfigIncludePath].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexListTotal = 1;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList = memNew(sizeof(ParseOptionValue));
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0] = (ParseOptionValue)
|
||||
{
|
||||
.found = true,
|
||||
.source = cfgSourceParam,
|
||||
.valueList = value,
|
||||
};
|
||||
|
||||
TEST_RESULT_VOID(cfgFileLoadPart(NULL, NULL), "check null part");
|
||||
|
||||
@ -179,7 +198,7 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAddZ(value, BOGUS_STR);
|
||||
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
TEST_ERROR(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
|
||||
backupCmdDefConfigInclPathValue, oldConfigDefault), PathMissingError,
|
||||
@ -189,26 +208,26 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configIncludePath);
|
||||
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
value = strLstNew();
|
||||
strLstAdd(value, strNewFmt("%s/%s", testPath(), BOGUS_STR));
|
||||
|
||||
parseOptionList[cfgOptConfig].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexList[0].valueList = value;
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
FileMissingError, STORAGE_ERROR_READ_MISSING, strZ(strNewFmt("%s/BOGUS", testPath())));
|
||||
|
||||
strLstFree(parseOptionList[cfgOptConfig].valueList);
|
||||
strLstFree(parseOptionList[cfgOptConfigIncludePath].valueList);
|
||||
strLstFree(parseOptionList[cfgOptConfig].indexList[0].valueList);
|
||||
strLstFree(parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList);
|
||||
|
||||
// Neither config nor config-include-path passed as parameter (defaults but none exist)
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
@ -219,11 +238,11 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configIncludePath);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
@ -236,10 +255,10 @@ testRun(void)
|
||||
// config and config-include-path are "default" with files existing. Config file exists in both current default and old
|
||||
// default location - old location ignored.
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
mkdir(strZ(strPath(oldConfigDefault)), 0750);
|
||||
storagePut(
|
||||
@ -268,11 +287,11 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configIncludePath);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
@ -290,12 +309,12 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configIncludePath);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = true;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].negate = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].indexList[0].negate = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
@ -307,11 +326,11 @@ testRun(void)
|
||||
|
||||
// --no-config and config-include-path default exists with files - nothing to read
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
parseOptionList[cfgOptConfig].found = true;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].negate = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].indexList[0].negate = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
|
||||
@ -322,12 +341,12 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configFile);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = true;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].negate = false;
|
||||
parseOptionList[cfgOptConfig].valueList = value;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].indexList[0].negate = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].valueList = value;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
|
||||
@ -341,11 +360,11 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configIncludePath);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
@ -361,10 +380,10 @@ testRun(void)
|
||||
|
||||
// config and config-include-path are "default".
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
// File exists in old default config location but not in current default.
|
||||
TEST_RESULT_STR_Z(
|
||||
@ -382,9 +401,14 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAddZ(value, testPath());
|
||||
|
||||
parseOptionList[cfgOptConfigPath].found = true;
|
||||
parseOptionList[cfgOptConfigPath].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigPath].valueList = value;
|
||||
parseOptionList[cfgOptConfigPath].indexListTotal = 1;
|
||||
parseOptionList[cfgOptConfigPath].indexList = memNew(sizeof(ParseOptionValue));
|
||||
parseOptionList[cfgOptConfigPath].indexList[0] = (ParseOptionValue)
|
||||
{
|
||||
.found = true,
|
||||
.source = cfgSourceParam,
|
||||
.valueList = value,
|
||||
};
|
||||
|
||||
// Override default paths for config and config-include-path - but no pgbackrest.conf file in override path only in old
|
||||
// default so ignored
|
||||
@ -400,10 +424,10 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configFile);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = true;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].negate = false;
|
||||
parseOptionList[cfgOptConfig].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfig].indexList[0].negate = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].valueList = value;
|
||||
|
||||
// Passing --config and --config-path - default config-include-path overwritten and config is required and is loaded and
|
||||
// config-include-path files will attempt to be loaded but not required
|
||||
@ -422,7 +446,7 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAddZ(value, BOGUS_STR);
|
||||
|
||||
parseOptionList[cfgOptConfigPath].valueList = value;
|
||||
parseOptionList[cfgOptConfigPath].indexList[0].valueList = value;
|
||||
|
||||
// Passing --config and bogus --config-path - default config-include-path overwritten, config is required and is loaded and
|
||||
// config-include-path files will attempt to be loaded but doesn't exist - no error since not required
|
||||
@ -440,16 +464,16 @@ testRun(void)
|
||||
strZ(strNewFmt("cp %s %s", strZ(configFile), strZ(strNewFmt("%s/pgbackrest.conf", testPath()))))), 0,
|
||||
"copy configFile to pgbackrest.conf");
|
||||
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfig].negate = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfig].indexList[0].negate = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
value = strLstNew();
|
||||
strLstAddZ(value, testPath());
|
||||
|
||||
parseOptionList[cfgOptConfigPath].valueList = value;
|
||||
parseOptionList[cfgOptConfigPath].indexList[0].valueList = value;
|
||||
|
||||
// Override default paths for config and config-include-path with --config-path
|
||||
TEST_RESULT_STR_Z(
|
||||
@ -465,8 +489,8 @@ testRun(void)
|
||||
"config-path override: config-include-path and config file read");
|
||||
|
||||
// Clear config-path
|
||||
parseOptionList[cfgOptConfigPath].found = false;
|
||||
parseOptionList[cfgOptConfigPath].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigPath].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfigPath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
// config default and config-include-path passed - but no config files in the include path - only in the default path
|
||||
// rm command is split below because code counter is confused by what looks like a comment.
|
||||
@ -476,11 +500,11 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configIncludePath);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
@ -498,11 +522,11 @@ testRun(void)
|
||||
value = strLstNew();
|
||||
strLstAdd(value, configIncludePath);
|
||||
|
||||
parseOptionList[cfgOptConfig].found = false;
|
||||
parseOptionList[cfgOptConfig].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].valueList = value;
|
||||
parseOptionList[cfgOptConfig].indexList[0].found = false;
|
||||
parseOptionList[cfgOptConfig].indexList[0].source = cfgSourceDefault;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].found = true;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceParam;
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, backupCmdDefConfigValue),
|
||||
@ -783,7 +807,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew("pgbackrest"));
|
||||
strLstAdd(argList, strNew("--host-id=1"));
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "1");
|
||||
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to");
|
||||
strLstAdd(argList, strNew("--process=1"));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
@ -794,6 +818,9 @@ testRun(void)
|
||||
logLevelStdOut = logLevelError;
|
||||
logLevelStdErr = logLevelError;
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load local config");
|
||||
TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleLocal, " command role is local");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), false, " backup:local command does not require lock");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup:local", " command/role name is backup:local");
|
||||
TEST_RESULT_INT(logLevelStdOut, logLevelError, "console logging is error");
|
||||
TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error");
|
||||
|
||||
@ -809,6 +836,8 @@ testRun(void)
|
||||
logLevelStdOut = logLevelError;
|
||||
logLevelStdErr = logLevelError;
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load remote config");
|
||||
TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleRemote, " command role is remote");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleRemote), "remote", " remote role name");
|
||||
TEST_RESULT_INT(logLevelStdOut, logLevelError, "console logging is error");
|
||||
TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error");
|
||||
harnessLogLevelReset();
|
||||
@ -1162,6 +1191,18 @@ testRun(void)
|
||||
setenv("PGBACKREST_REPO1_S3_KEY_SECRET", "xxx", true);
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, " command is " TEST_COMMAND_BACKUP);
|
||||
TEST_RESULT_BOOL(cfgCommandInternal(cfgCmdBackup), false, " backup command is not internal");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), true, " backup command requires lock");
|
||||
TEST_RESULT_UINT(cfgLockType(), lockTypeBackup, " backup command requires backup lock type");
|
||||
TEST_RESULT_UINT(cfgLogLevelDefault(), logLevelInfo, " backup defaults to log level warn");
|
||||
TEST_RESULT_BOOL(cfgLogFile(), true, " backup command does file logging");
|
||||
TEST_RESULT_BOOL(cfgLockRemoteRequired(), true, " backup command requires remote lock");
|
||||
TEST_RESULT_STR_Z(strLstJoin(cfgCommandParam(), "|"), "", " check command arguments");
|
||||
TEST_RESULT_UINT(cfgCommandRoleEnum(NULL), cfgCmdRoleDefault, "command role default enum");
|
||||
TEST_ERROR(cfgCommandRoleEnum(STRDEF("bogus")), CommandInvalidError, "invalid command role 'bogus'");
|
||||
TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleDefault, " command role is default");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup", " command/role name is backup");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleDefault), NULL, " default role name is NULL");
|
||||
|
||||
TEST_RESULT_STR_Z(cfgExe(), TEST_BACKREST_EXE, " exe is set");
|
||||
|
||||
@ -1171,18 +1212,50 @@ testRun(void)
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptStanza), cfgSourceParam, " stanza is source param");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptStanza), "db", " stanza is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptStanza), cfgSourceParam, " stanza is source param");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db", " pg1-path is set");
|
||||
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, 0), "/path/to/db", " pg1-path is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceParam, " pg1-path is source param");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoS3KeySecret), "xxx", " repo1-s3-secret is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptRepoS3KeySecret), cfgSourceConfig, " repo1-s3-secret is source env");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, " online is not set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, " online is source default");
|
||||
TEST_RESULT_INT(cfgOptionInt(cfgOptBufferSize), 1048576, " buffer-size is set");
|
||||
TEST_RESULT_INT(cfgOptionIdxInt(cfgOptBufferSize, 0), 1048576, " buffer-size is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceDefault, " buffer-size is source default");
|
||||
TEST_RESULT_Z(cfgOptionName(cfgOptBufferSize), "buffer-size", " buffer-size name");
|
||||
|
||||
unsetenv("PGBACKREST_REPO1_S3_KEY");
|
||||
unsetenv("PGBACKREST_REPO1_S3_KEY_SECRET");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("port can be parsed from hostname");
|
||||
|
||||
unsigned int port = 55555;
|
||||
|
||||
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("host.com")) ;
|
||||
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "host.com", "check plain host");
|
||||
TEST_RESULT_UINT(port, 55555, "check that port was not updated");
|
||||
|
||||
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777")) ;
|
||||
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Host, &port), "myhost.com", "check host with port");
|
||||
TEST_RESULT_UINT(port, 777, "check that port was updated");
|
||||
|
||||
cfgOptionSet(cfgOptRepoS3Endpoint, cfgSourceConfig, NULL);
|
||||
TEST_RESULT_STR_Z(cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), NULL, "check null host");
|
||||
TEST_RESULT_UINT(port, 777, "check that port was not updated");
|
||||
|
||||
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("myhost.com:777:888")) ;
|
||||
TEST_ERROR(
|
||||
cfgOptionHostPort(cfgOptRepoS3Host, &port), OptionInvalidError,
|
||||
"'myhost.com:777:888' is not valid for option 'repo1-s3-host'"
|
||||
"\nHINT: is more than one port specified?");
|
||||
TEST_RESULT_UINT(port, 777, "check that port was not updated");
|
||||
|
||||
cfgOptionSet(cfgOptRepoS3Endpoint, cfgSourceConfig, varNewStrZ("myendpoint.com:ZZZ"));
|
||||
TEST_ERROR(
|
||||
cfgOptionHostPort(cfgOptRepoS3Endpoint, &port), OptionInvalidError,
|
||||
"'myendpoint.com:ZZZ' is not valid for option 'repo1-s3-endpoint'"
|
||||
"\nHINT: port is not a positive integer.");
|
||||
TEST_RESULT_UINT(port, 777, "check that port was not updated");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
@ -1190,7 +1263,9 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--config=%s", strZ(configFile)));
|
||||
strLstAdd(argList, strNew("--no-online"));
|
||||
hrnCfgArgKeyRawBool(argList, cfgOptPgLocal, 2, true);
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "2");
|
||||
strLstAdd(argList, strNew("--reset-pg1-host"));
|
||||
strLstAdd(argList, strNew("--reset-pg3-host"));
|
||||
strLstAdd(argList, strNew("--reset-backup-standby"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
|
||||
@ -1234,8 +1309,9 @@ testRun(void)
|
||||
"pg1-path=/path/to/db\n"
|
||||
"%s=ignore\n"
|
||||
"%s=/path/to/db2\n"
|
||||
"pg3-host=ignore\n"
|
||||
"recovery-option=c=d\n",
|
||||
cfgOptionName(cfgOptPgHost + 1), cfgOptionName(cfgOptPgPath + 1))));
|
||||
cfgOptionKeyIdxName(cfgOptPgHost, 1), cfgOptionKeyIdxName(cfgOptPgPath, 1))));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
|
||||
harnessLogResult(
|
||||
@ -1251,20 +1327,25 @@ testRun(void)
|
||||
"P00 WARN: configuration file contains command-line only option 'online'\n"
|
||||
"P00 WARN: configuration file contains stanza-only option 'pg1-path' in global section 'global:backup'")));
|
||||
|
||||
TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost), false, " pg1-host is not set (command line reset override)");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db", " pg1-path is set");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptPgLocal + 1), true, " pg2-local is set");
|
||||
TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost + 1), false, " pg2-host is not set (pg2-local override)");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath + 1), "/path/to/db2", " pg2-path is set");
|
||||
TEST_RESULT_BOOL(cfgOptionIdxTest(cfgOptPgHost, 0), false, " pg1-host is not set (command line reset override)");
|
||||
TEST_RESULT_BOOL(cfgOptionIdxReset(cfgOptPgHost, 0), true, " pg1-host was reset");
|
||||
TEST_RESULT_UINT(cfgOptionGroupIdxDefault(cfgOptGrpPg), 1, " pg2 is default");
|
||||
TEST_RESULT_UINT(cfgOptionGroupIdxToKey(cfgOptGrpPg, 1), 2, " pg2 is index 1");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/db2", " default pg-path");
|
||||
TEST_RESULT_UINT(cfgOptionGroupIdxTotal(cfgOptGrpPg), 2, " pg1 and pg2 are set");
|
||||
TEST_RESULT_BOOL(cfgOptionIdxBool(cfgOptPgLocal, 1), true, " pg2-local is set");
|
||||
TEST_RESULT_BOOL(cfgOptionIdxTest(cfgOptPgHost, 1), false, " pg2-host is not set (pg2-local override)");
|
||||
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, cfgOptionKeyToIdx(cfgOptPgPath, 2)), "/path/to/db2", " pg2-path is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceConfig, " pg1-path is source config");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptLockPath), "/", " lock-path is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptLockPath), cfgSourceConfig, " lock-path is source config");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgSocketPath), "/path/to/socket", " pg1-socket-path is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptPgSocketPath), cfgSourceConfig, " pg1-socket-path is config param");
|
||||
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgSocketPath, 0), "/path/to/socket", " pg1-socket-path is set");
|
||||
TEST_RESULT_INT(cfgOptionIdxSource(cfgOptPgSocketPath, 0), cfgSourceConfig, " pg1-socket-path is config param");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, " online not is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, " online is source param");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptStartFast), false, " start-fast not is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptStartFast), cfgSourceConfig, " start-fast is config param");
|
||||
TEST_RESULT_UINT(cfgOptionIdxTotal(cfgOptDelta), 1, " delta not indexed");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptDelta), true, " delta not set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptDelta), cfgSourceConfig, " delta is source config");
|
||||
TEST_RESULT_BOOL(cfgOptionTest(cfgOptArchiveCheck), false, " archive-check is not set");
|
||||
@ -1275,10 +1356,38 @@ testRun(void)
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptCompressLevel), cfgSourceConfig, " compress-level is source config");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptBackupStandby), false, " backup-standby not is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptBackupStandby), cfgSourceDefault, " backup-standby is source default");
|
||||
TEST_RESULT_BOOL(cfgOptionReset(cfgOptBackupStandby), true, " backup-standby was reset");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptDelta), true, " delta is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptDelta), cfgSourceConfig, " delta is source config");
|
||||
TEST_RESULT_INT(cfgOptionInt64(cfgOptBufferSize), 65536, " buffer-size is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceConfig, " backup-standby is source config");
|
||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptDbTimeout), 1800, " db-timeout 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_STR(cfgOptionIdxStrNull(cfgOptPgHost, 1), NULL, " pg2-host is NULL");
|
||||
TEST_RESULT_STR(cfgOptionStrNull(cfgOptPgHost), NULL, " pg2-host is NULL");
|
||||
TEST_ERROR(cfgOptionStr(cfgOptPgHost), AssertError, "option 'pg2-host' is null but non-null was requested");
|
||||
|
||||
TEST_RESULT_BOOL(varBool(cfgOptionDefault(cfgOptBackupStandby)), false, " backup-standby default is false");
|
||||
TEST_RESULT_BOOL(varBool(cfgOptionDefault(cfgOptBackupStandby)), false, " backup-standby default is false (again)");
|
||||
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_INT(varInt64(cfgOptionDefault(cfgOptPgPort)), 5432, " pg-port default is 5432");
|
||||
TEST_RESULT_DOUBLE(varDbl(cfgOptionDefault(cfgOptDbTimeout)), 1800, " db-timeout default is 1800");
|
||||
|
||||
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, 1), "/default", " pg2-socket-path is new default");
|
||||
|
||||
TEST_ERROR(cfgOptionDefaultValue(cfgOptDbInclude), AssertError, "default value not available for option type 4");
|
||||
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_RESULT_VOID(cfgOptionInvalidate(cfgOptPgPath), " invalidate pg-path");
|
||||
TEST_RESULT_BOOL(cfgOptionValid(cfgOptPgPath), false, " pg-path no longer valid");
|
||||
|
||||
TEST_RESULT_UINT(cfgOptionKeyToIdx(cfgOptArchiveTimeout, 1), 0, "check archive-timeout");
|
||||
TEST_ERROR(cfgOptionKeyToIdx(cfgOptPgPath, 4), AssertError, "key '4' is not valid for 'pg-path' option");
|
||||
|
||||
unsetenv("PGBACKREST_BOGUS");
|
||||
unsetenv("PGBACKREST_NO_DELTA");
|
||||
@ -1288,6 +1397,12 @@ testRun(void)
|
||||
unsetenv("PGBACKREST_START_FAST");
|
||||
unsetenv("PGBACKREST_PG1_SOCKET_PATH");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("set command to expire");
|
||||
|
||||
TEST_RESULT_VOID(cfgCommandSet(cfgCmdExpire, cfgCommandRoleEnum(STRDEF("async"))), "set command");
|
||||
TEST_RESULT_STR_Z(cfgCommandRoleName(), "expire:async", "command/role name is expire:async");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
@ -1295,7 +1410,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew("--archive-push-queue-max=4503599627370496"));
|
||||
strLstAdd(argList, strNew("--buffer-size=2MB"));
|
||||
strLstAdd(argList, strNew("archive-push"));
|
||||
strLstAdd(argList, strNew("archive-push:async"));
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
@ -1305,9 +1420,12 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "archive-push command");
|
||||
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), true, " archive-push:async command requires lock");
|
||||
TEST_RESULT_BOOL(cfgLogFile(), true, " archive-push:async command does file logging");
|
||||
TEST_RESULT_INT(cfgOptionInt64(cfgOptArchivePushQueueMax), 4503599627370496, "archive-push-queue-max is set");
|
||||
TEST_RESULT_UINT(cfgOptionUInt64(cfgOptArchivePushQueueMax), 4503599627370496, "archive-push-queue-max is set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptArchivePushQueueMax), cfgSourceParam, " archive-push-queue-max is source config");
|
||||
TEST_RESULT_INT(cfgOptionInt64(cfgOptBufferSize), 2097152, "buffer-size is set to bytes from MB");
|
||||
TEST_RESULT_INT(cfgOptionIdxInt64(cfgOptBufferSize, 0), 2097152, "buffer-size is set to bytes from MB");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceParam, " buffer-size is source config");
|
||||
TEST_RESULT_PTR(cfgOption(cfgOptSpoolPath), NULL, " spool-path is not set");
|
||||
TEST_RESULT_INT(cfgOptionSource(cfgOptSpoolPath), cfgSourceDefault, " spool-path is source default");
|
||||
@ -1362,7 +1480,9 @@ testRun(void)
|
||||
const KeyValue *recoveryKv = NULL;
|
||||
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
|
||||
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("a")))), "b", "check recovery option");
|
||||
TEST_ASSIGN(recoveryKv, cfgOptionIdxKv(cfgOptRecoveryOption, 0), "get recovery options");
|
||||
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("c")))), "de=fg hi", "check recovery option");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), false, " restore command does not require lock");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
@ -1386,6 +1506,7 @@ testRun(void)
|
||||
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
|
||||
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("f")))), "g", "check recovery option");
|
||||
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("hijk")))), "l", "check recovery option");
|
||||
TEST_RESULT_UINT(varLstSize(cfgOptionLst(cfgOptDbInclude)), 0, "check db include option size");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
@ -1410,6 +1531,32 @@ testRun(void)
|
||||
unsetenv("PGBACKREST_RECOVERY_OPTION");
|
||||
unsetenv("PGBACKREST_DB_INCLUDE");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("cfgOptionSet() and cfgOptionIdxSet()");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptForce, cfgSourceParam, VARINT(1)), "set force true");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptForce), true, "check force");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptForce, cfgSourceParam, VARBOOL(false)), "set force false");
|
||||
TEST_RESULT_BOOL(cfgOptionBool(cfgOptForce), false, "check force");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, VARINT(1)), "set protocol-timeout to 1");
|
||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 1, "check protocol-timeout");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, VARDBL(2.2)), "set protocol-timeout to 2.2");
|
||||
TEST_RESULT_DOUBLE(cfgOptionDbl(cfgOptProtocolTimeout), 2.2, "check protocol-timeout");
|
||||
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProcessMax, cfgSourceParam, VARINT(50)), "set process-max to 50");
|
||||
TEST_RESULT_INT(cfgOptionInt(cfgOptProcessMax), 50, "check process-max");
|
||||
TEST_RESULT_VOID(cfgOptionSet(cfgOptProcessMax, cfgSourceParam, VARINT64(51)), "set process-max to 51");
|
||||
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(
|
||||
cfgOptionIdxSet(cfgOptPgPath, 0, cfgSourceParam, VARINT(1)), AssertError,
|
||||
"option 'pg1-path' must be set with String variant");
|
||||
TEST_RESULT_VOID(cfgOptionIdxSet(cfgOptPgPath, 0, cfgSourceParam, VARSTRDEF("/new")), "set pg1-path");
|
||||
TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, 0), "/new", "check pg1-path");
|
||||
|
||||
// Stanza options should not be loaded for commands that don't take a stanza
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
@ -1427,7 +1574,45 @@ testRun(void)
|
||||
"repo1-path=/not/the/path\n"));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "info command");
|
||||
TEST_RESULT_BOOL(cfgLogFile(), false, " info command does not do file logging");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoPath), "/path/to/repo", "check repo1-path option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("info command can be forced to do file logging");
|
||||
|
||||
argList = strLstNew();
|
||||
hrnCfgArgRawZ(argList, cfgOptLogLevelFile, "detail");
|
||||
TEST_RESULT_VOID(harnessCfgLoad(cfgCmdInfo, argList), "info command");
|
||||
|
||||
TEST_RESULT_BOOL(cfgLogFile(), true, " check logging");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("version command does not do file logging");
|
||||
|
||||
TEST_RESULT_VOID(harnessCfgLoad(cfgCmdVersion, strLstNew()), "version command");
|
||||
TEST_RESULT_BOOL(cfgLogFile(), false, " check logging");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
// TEST_TITLE("option key 1 is not required");
|
||||
//
|
||||
// argList = strLstNew();
|
||||
// hrnCfgArgRawZ(argList, cfgOptStanza, "test");
|
||||
// hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 2, "/pg2");
|
||||
// hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, "/pg8");
|
||||
// TEST_RESULT_VOID(harnessCfgLoad(cfgCmdCheck, argList), "check command");
|
||||
//
|
||||
// TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, 0), "/pg2", "check pg1-path");
|
||||
// TEST_RESULT_STR_Z(cfgOptionIdxStr(cfgOptPgPath, cfgOptionKeyToIdx(cfgOptPgPath, 8)), "/pg8", "check pg8-path");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("invalid pg option");
|
||||
|
||||
argList = strLstNew();
|
||||
hrnCfgArgRawZ(argList, cfgOptStanza, "test");
|
||||
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, "/pg1");
|
||||
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, "/pg8");
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "4");
|
||||
TEST_ERROR(harnessCfgLoad(cfgCmdCheck, argList), OptionInvalidValueError, "key '4' is not valid for 'pg' option");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
@ -671,7 +671,7 @@ testRun(void)
|
||||
"P00 WARN: unable to check pg-5: [DbConnectError] raised from remote-0 protocol on 'localhost':"
|
||||
" unable to connect to 'dbname='postgres' port=5432': could not connect to server: [NO SUCH FILE OR DIRECTORY]");
|
||||
|
||||
TEST_RESULT_INT(result.primaryIdx, 7, " check primary id");
|
||||
TEST_RESULT_INT(result.primaryIdx, 3, " check primary idx");
|
||||
TEST_RESULT_BOOL(result.primary != NULL, true, " check primary");
|
||||
TEST_RESULT_STR_Z(dbArchiveMode(result.primary), "on", " dbArchiveMode");
|
||||
TEST_RESULT_STR_Z(dbArchiveCommand(result.primary), PROJECT_BIN, " dbArchiveCommand");
|
||||
|
@ -167,7 +167,9 @@ testRun(void)
|
||||
|
||||
driver.interface.infoList = storageTestPerfInfoList;
|
||||
|
||||
storageHelper.storageRepo = storageNew(STRDEF("TEST"), STRDEF("/"), 0, 0, false, NULL, &driver, driver.interface);
|
||||
storageHelper.storageRepo = memNew(sizeof(Storage *));
|
||||
storageHelper.storageRepo[0] = storageNew(
|
||||
STRDEF("TEST"), STRDEF("/"), 0, 0, false, NULL, &driver, driver.interface);
|
||||
|
||||
// Setup handler for remote storage protocol
|
||||
IoRead *read = ioFdReadNew(strNew("storage server read"), HARNESS_FORK_CHILD_READ(), 60000);
|
||||
|
@ -133,7 +133,7 @@ testRun(void)
|
||||
strLstAddZ(argList, "archive-get");
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_BOOL(repoIsLocal(), true, "repo is local");
|
||||
TEST_RESULT_BOOL(repoIsLocal(0), true, "repo is local");
|
||||
TEST_RESULT_VOID(repoIsLocalVerify(), " local verified");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -145,7 +145,7 @@ testRun(void)
|
||||
strLstAddZ(argList, "archive-get");
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_BOOL(repoIsLocal(), false, "repo is remote");
|
||||
TEST_RESULT_BOOL(repoIsLocal(0), false, "repo is remote");
|
||||
TEST_ERROR_FMT(repoIsLocalVerify(), HostInvalidError, "archive-get command must be run on the repository host");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -185,14 +185,14 @@ testRun(void)
|
||||
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/bogus");
|
||||
strLstAddZ(argList, "--pg7-path=/path/to");
|
||||
strLstAddZ(argList, "--pg7-host=test1");
|
||||
strLstAddZ(argList, "--host-id=7");
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "7");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
|
||||
strLstAddZ(argList, "--process=0");
|
||||
hrnCfgArgRawZ(argList, cfgOptRepoRetentionFull, "1");
|
||||
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_BOOL(pgIsLocal(6), false, "pg7 is remote");
|
||||
TEST_RESULT_BOOL(pgIsLocal(1), false, "pg7 is remote");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
@ -228,8 +228,8 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 0, 0), "|"),
|
||||
"--exec-id=1-test|--host-id=1|--log-level-console=off|--log-level-file=off|--log-level-stderr=error"
|
||||
"|--pg1-path=/path/to/pg|--process=0|--remote-type=repo|--stanza=test1|archive-get:local",
|
||||
"--exec-id=1-test|--log-level-console=off|--log-level-file=off|--log-level-stderr=error|--pg1-path=/path/to/pg"
|
||||
"|--process=0|--remote-type=repo|--repo=1|--stanza=test1|archive-get:local",
|
||||
"local repo protocol params");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -237,6 +237,7 @@ testRun(void)
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--pg1-path=/pg");
|
||||
hrnCfgArgRawReset(argList, cfgOptPg);
|
||||
strLstAddZ(argList, "--repo1-retention-full=1");
|
||||
strLstAddZ(argList, "--log-subprocess");
|
||||
strLstAddZ(argList, "backup");
|
||||
@ -244,8 +245,8 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolLocalParam(protocolStorageTypePg, 0, 1), "|"),
|
||||
"--exec-id=1-test|--host-id=1|--log-level-console=off|--log-level-file=info|--log-level-stderr=error|--log-subprocess|"
|
||||
"--pg1-path=/pg|--process=1|--remote-type=pg|--repo1-retention-full=1|--stanza=test1|backup:local",
|
||||
"--exec-id=1-test|--log-level-console=off|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg=1"
|
||||
"|--pg1-path=/pg|--process=1|--remote-type=pg|--repo1-retention-full=1|--stanza=test1|backup:local",
|
||||
"local pg protocol params");
|
||||
}
|
||||
|
||||
@ -271,7 +272,7 @@ testRun(void)
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 0), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|repo-host-user@repo-host"
|
||||
"|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error"
|
||||
" --pg1-path=/path/to/pg --process=0 --remote-type=repo --repo1-local --stanza=test1 archive-get:remote",
|
||||
" --pg1-path=/path/to/pg --process=0 --remote-type=repo --repo=1 --repo1-local --stanza=test1 archive-get:remote",
|
||||
"remote protocol params");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -295,7 +296,7 @@ testRun(void)
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|-p|444|repo-host-user@repo-host"
|
||||
"|pgbackrest --config=/path/pgbackrest.conf --config-include-path=/path/include --config-path=/path/config"
|
||||
" --exec-id=1-test --log-level-console=off --log-level-file=info --log-level-stderr=error --log-subprocess"
|
||||
" --pg1-path=/unused --process=0 --remote-type=repo --repo1-local --stanza=test1 check:remote",
|
||||
" --pg1-path=/unused --process=0 --remote-type=repo --repo=1 --repo1-local --stanza=test1 check:remote",
|
||||
"remote protocol params with replacements");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -304,7 +305,7 @@ testRun(void)
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
|
||||
strLstAddZ(argList, "--process=3");
|
||||
strLstAddZ(argList, "--host-id=1");
|
||||
hrnCfgArgRawZ(argList, cfgOptRepo, "1");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
|
||||
strLstAddZ(argList, "--repo1-host=repo-host");
|
||||
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_LOCAL);
|
||||
@ -314,7 +315,7 @@ testRun(void)
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 0), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|pgbackrest@repo-host"
|
||||
"|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error"
|
||||
" --pg1-path=/path/to/pg --process=3 --remote-type=repo --repo1-local --stanza=test1 archive-get:remote",
|
||||
" --pg1-path=/path/to/pg --process=3 --remote-type=repo --repo=1 --repo1-local --stanza=test1 archive-get:remote",
|
||||
"remote protocol params for backup local");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -330,8 +331,8 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 0), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg1-host"
|
||||
"|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-local"
|
||||
" --pg1-path=/path/to/1 --process=0 --remote-type=pg --stanza=test1 backup:remote",
|
||||
"|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1"
|
||||
" --pg1-local --pg1-path=/path/to/1 --process=0 --remote-type=pg --stanza=test1 backup:remote",
|
||||
"remote protocol params for db backup");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -339,7 +340,7 @@ testRun(void)
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--process=4");
|
||||
strLstAddZ(argList, "--host-id=2");
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "2");
|
||||
strLstAddZ(argList, "--pg1-path=/path/to/1");
|
||||
strLstAddZ(argList, "--pg1-socket-path=/socket3");
|
||||
strLstAddZ(argList, "--pg1-port=1111");
|
||||
@ -353,8 +354,8 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg2-host"
|
||||
"|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-local"
|
||||
" --pg1-path=/path/to/2 --process=4 --remote-type=pg --stanza=test1 backup:remote",
|
||||
"|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1"
|
||||
" --pg1-local --pg1-path=/path/to/2 --process=4 --remote-type=pg --stanza=test1 backup:remote",
|
||||
"remote protocol params for db local");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -362,7 +363,7 @@ testRun(void)
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--process=4");
|
||||
strLstAddZ(argList, "--host-id=3");
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "3");
|
||||
strLstAddZ(argList, "--pg1-path=/path/to/1");
|
||||
strLstAddZ(argList, "--pg3-path=/path/to/3");
|
||||
strLstAddZ(argList, "--pg3-host=pg3-host");
|
||||
@ -374,11 +375,11 @@ testRun(void)
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 2), "|"),
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg3-host"
|
||||
"|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-local"
|
||||
" --pg1-path=/path/to/3 --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg --stanza=test1"
|
||||
" backup:remote",
|
||||
"|pgbackrest --exec-id=1-test --log-level-console=off --log-level-file=off --log-level-stderr=error --pg=1"
|
||||
" --pg1-local --pg1-path=/path/to/3 --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg"
|
||||
" --stanza=test1 backup:remote",
|
||||
"remote protocol params for db local");
|
||||
}
|
||||
|
||||
@ -978,7 +979,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser()));
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath()));
|
||||
strLstAddZ(argList, "--process=999");
|
||||
strLstAddZ(argList, "--host-id=1");
|
||||
hrnCfgArgRawZ(argList, cfgOptPg, "1");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
|
||||
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList);
|
||||
|
||||
|
@ -190,7 +190,7 @@ testRun(void)
|
||||
harnessCfgLoad(cfgCmdArchivePush, argList);
|
||||
|
||||
Storage *storage = NULL;
|
||||
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_AZURE_TYPE), false), "get repo storage");
|
||||
TEST_ASSIGN(storage, storageRepoGet(0, false), "get repo storage");
|
||||
TEST_RESULT_STR_Z(storage->path, "/repo", " check path");
|
||||
TEST_RESULT_STR(((StorageAzure *)storage->driver)->account, TEST_ACCOUNT_STR, " check account");
|
||||
TEST_RESULT_STR(((StorageAzure *)storage->driver)->container, TEST_CONTAINER_STR, " check container");
|
||||
@ -299,7 +299,7 @@ testRun(void)
|
||||
harnessCfgLoad(cfgCmdArchivePush, argList);
|
||||
|
||||
Storage *storage = NULL;
|
||||
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_AZURE_TYPE), true), "get repo storage");
|
||||
TEST_ASSIGN(storage, storageRepoGet(0, true), "get repo storage");
|
||||
|
||||
driver = (StorageAzure *)storage->driver;
|
||||
TEST_RESULT_STR(driver->host, hrnServerHost(), " check host");
|
||||
@ -731,7 +731,7 @@ testRun(void)
|
||||
hrnCfgEnvRawZ(cfgOptRepoAzureKey, TEST_KEY_SAS);
|
||||
harnessCfgLoad(cfgCmdArchivePush, argList);
|
||||
|
||||
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_AZURE_TYPE), true), "get repo storage");
|
||||
TEST_ASSIGN(storage, storageRepoGet(0, true), "get repo storage");
|
||||
|
||||
driver = (StorageAzure *)storage->driver;
|
||||
TEST_RESULT_PTR_NE(driver->sasKey, NULL, "check sas key");
|
||||
|
@ -23,7 +23,7 @@ testRun(void)
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
||||
const Storage *storage = NULL;
|
||||
TEST_ASSIGN(storage, storageRepoGet(strNew(STORAGE_CIFS_TYPE), true), "get cifs repo storage");
|
||||
TEST_ASSIGN(storage, storageRepoGet(0, true), "get cifs repo storage");
|
||||
TEST_RESULT_STR_Z(storage->type, "cifs", "check storage type");
|
||||
TEST_RESULT_BOOL(storageFeature(storage, storageFeaturePath), true, " check path feature");
|
||||
TEST_RESULT_BOOL(storageFeature(storage, storageFeatureCompress), true, " check compress feature");
|
||||
|
@ -69,7 +69,7 @@ testRun(void)
|
||||
TEST_TITLE("writable storage fails when dry-run is not initialized");
|
||||
|
||||
TEST_ERROR(storagePgIdxWrite(0), AssertError, WRITABLE_WHILE_DRYRUN);
|
||||
TEST_ERROR(storageRepoWrite(), AssertError, WRITABLE_WHILE_DRYRUN);
|
||||
TEST_ERROR(storageRepoIdxWrite(0), AssertError, WRITABLE_WHILE_DRYRUN);
|
||||
TEST_ERROR(storageSpoolWrite(), AssertError, WRITABLE_WHILE_DRYRUN);
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -78,7 +78,7 @@ testRun(void)
|
||||
storageHelperDryRunInit(true);
|
||||
|
||||
TEST_ERROR(storagePgIdxWrite(0), AssertError, WRITABLE_WHILE_DRYRUN);
|
||||
TEST_ERROR(storageRepoWrite(), AssertError, WRITABLE_WHILE_DRYRUN);
|
||||
TEST_ERROR(storageRepoIdxWrite(0), AssertError, WRITABLE_WHILE_DRYRUN);
|
||||
TEST_ERROR(storageSpoolWrite(), AssertError, WRITABLE_WHILE_DRYRUN);
|
||||
}
|
||||
|
||||
@ -1163,14 +1163,11 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
||||
TEST_ERROR(storageRepoGet(strNew(BOGUS_STR), false), AssertError, "invalid storage type 'BOGUS'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
const Storage *storage = NULL;
|
||||
|
||||
TEST_RESULT_PTR(storageHelper.storageRepo, NULL, "repo storage not cached");
|
||||
TEST_ASSIGN(storage, storageRepo(), "new storage");
|
||||
TEST_RESULT_PTR(storageHelper.storageRepo, storage, "repo storage cached");
|
||||
TEST_RESULT_PTR(storageHelper.storageRepo[0], storage, "repo storage cached");
|
||||
TEST_RESULT_PTR(storageRepo(), storage, "get cached storage");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1221,7 +1218,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_RESULT_PTR(storageHelper.storageRepoWrite, NULL, "repo write storage not cached");
|
||||
TEST_ASSIGN(storage, storageRepoWrite(), "new write storage");
|
||||
TEST_RESULT_PTR(storageHelper.storageRepoWrite, storage, "repo write storage cached");
|
||||
TEST_RESULT_PTR(storageHelper.storageRepoWrite[0], storage, "repo write storage cached");
|
||||
TEST_RESULT_PTR(storageRepoWrite(), storage, "get cached storage");
|
||||
|
||||
TEST_RESULT_BOOL(storage->write, true, "get write enabled");
|
||||
|
@ -57,7 +57,7 @@ testRun(void)
|
||||
if (testBegin("storageNew()"))
|
||||
{
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), false), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, false), "get remote repo storage");
|
||||
TEST_RESULT_UINT(storageInterface(storageRemote).feature, storageInterface(storageTest).feature, " check features");
|
||||
TEST_RESULT_BOOL(storageFeature(storageRemote, storageFeaturePath), true, " check path feature");
|
||||
TEST_RESULT_BOOL(storageFeature(storageRemote, storageFeatureCompress), true, " check compress feature");
|
||||
@ -83,7 +83,7 @@ testRun(void)
|
||||
if (testBegin("storageInfo()"))
|
||||
{
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("missing file/path");
|
||||
@ -253,7 +253,7 @@ testRun(void)
|
||||
if (testBegin("storageInfoList()"))
|
||||
{
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("path not found");
|
||||
@ -314,7 +314,7 @@ testRun(void)
|
||||
if (testBegin("storageNewRead()"))
|
||||
{
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), false), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, false), "get remote repo storage");
|
||||
storagePathCreateP(storageTest, strNew("repo"));
|
||||
|
||||
Buffer *contentBuf = bufNew(32768);
|
||||
@ -463,7 +463,7 @@ testRun(void)
|
||||
storagePathCreateP(storageTest, strNew("repo"));
|
||||
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage");
|
||||
|
||||
// Create buffer with plenty of data
|
||||
Buffer *contentBuf = bufNew(32768);
|
||||
@ -603,7 +603,7 @@ testRun(void)
|
||||
storagePathCreateP(storageTest, strNew("repo"));
|
||||
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage");
|
||||
|
||||
// Create a path via the remote. Check the repo via the local test storage to ensure the remote created it.
|
||||
TEST_RESULT_VOID(storagePathCreateP(storageRemote, path), "new path");
|
||||
@ -661,7 +661,7 @@ testRun(void)
|
||||
storagePathCreateP(storageTest, strNew("repo"));
|
||||
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage");
|
||||
TEST_RESULT_VOID(storagePathCreateP(storageRemote, path), "new path");
|
||||
|
||||
// Check the repo via the local test storage to ensure the remote wrote it, then remove via the remote and confirm removed
|
||||
@ -701,7 +701,7 @@ testRun(void)
|
||||
storagePathCreateP(storageTest, strNew("repo"));
|
||||
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage");
|
||||
String *file = strNew("file.txt");
|
||||
|
||||
// Write the file to the repo via the remote so owner is pgbackrest
|
||||
@ -749,7 +749,7 @@ testRun(void)
|
||||
storagePathCreateP(storageTest, strNew("repo"));
|
||||
|
||||
Storage *storageRemote = NULL;
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(strNew(STORAGE_POSIX_TYPE), true), "get remote repo storage");
|
||||
TEST_ASSIGN(storageRemote, storageRepoGet(0, true), "get remote repo storage");
|
||||
|
||||
String *path = strNew("testpath");
|
||||
TEST_RESULT_VOID(storagePathCreateP(storageRemote, path), "new path");
|
||||
|
@ -257,7 +257,7 @@ testRun(void)
|
||||
StringList *argList = strLstDup(commonArgList);
|
||||
harnessCfgLoad(cfgCmdArchivePush, argList);
|
||||
|
||||
StorageS3 *driver = (StorageS3 *)storageDriver(storageRepoGet(STORAGE_S3_TYPE_STR, false));
|
||||
StorageS3 *driver = (StorageS3 *)storageDriver(storageRepoGet(0, false));
|
||||
|
||||
TEST_RESULT_STR(driver->bucket, bucket, "check bucket");
|
||||
TEST_RESULT_STR(driver->region, region, "check region");
|
||||
@ -328,7 +328,7 @@ testRun(void)
|
||||
hrnCfgEnvRaw(cfgOptRepoS3Token, securityToken);
|
||||
harnessCfgLoad(cfgCmdArchivePush, argList);
|
||||
|
||||
driver = (StorageS3 *)storageDriver(storageRepoGet(STORAGE_S3_TYPE_STR, false));
|
||||
driver = (StorageS3 *)storageDriver(storageRepoGet(0, false));
|
||||
|
||||
TEST_RESULT_STR(driver->securityToken, securityToken, "check security token");
|
||||
TEST_RESULT_STR(
|
||||
@ -392,7 +392,7 @@ testRun(void)
|
||||
hrnCfgEnvRaw(cfgOptRepoS3Token, securityToken);
|
||||
harnessCfgLoad(cfgCmdArchivePush, argList);
|
||||
|
||||
Storage *s3 = storageRepoGet(STORAGE_S3_TYPE_STR, true);
|
||||
Storage *s3 = storageRepoGet(0, true);
|
||||
StorageS3 *driver = (StorageS3 *)s3->driver;
|
||||
|
||||
TEST_RESULT_STR(s3->path, path, "check path");
|
||||
@ -450,7 +450,7 @@ testRun(void)
|
||||
hrnCfgArgRawZ(argList, cfgOptRepoS3KeyType, STORAGE_S3_KEY_TYPE_AUTO);
|
||||
harnessCfgLoad(cfgCmdArchivePush, argList);
|
||||
|
||||
s3 = storageRepoGet(STORAGE_S3_TYPE_STR, true);
|
||||
s3 = storageRepoGet(0, true);
|
||||
driver = (StorageS3 *)s3->driver;
|
||||
|
||||
TEST_RESULT_STR(s3->path, path, "check path");
|
||||
@ -1019,7 +1019,7 @@ testRun(void)
|
||||
hrnCfgEnvRemoveRaw(cfgOptRepoS3Token);
|
||||
harnessCfgLoad(cfgCmdArchivePush, argList);
|
||||
|
||||
s3 = storageRepoGet(STORAGE_S3_TYPE_STR, true);
|
||||
s3 = storageRepoGet(0, true);
|
||||
driver = (StorageS3 *)s3->driver;
|
||||
|
||||
// Set deleteMax to a small value for testing
|
||||
|
Reference in New Issue
Block a user