mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-04 09:43:08 +02:00
Remove storageLocal() dependency from common/parse module.
storageLocal() requires the storage helper which is a huge dependency for this module. Pass in a storage object instead.
This commit is contained in:
parent
468507843f
commit
59e57c7231
@ -371,7 +371,7 @@ cfgLoad(unsigned int argListSize, const char *argList[])
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// Parse config from command line and config file
|
||||
configParse(argListSize, argList, true);
|
||||
configParse(storageLocal(), argListSize, argList, true);
|
||||
|
||||
// Check that only repo1 is configured. This is temporary until the multi-repo support is finalized.
|
||||
if (cfgCommandRole() == cfgCmdRoleDefault && cfgOptionGroupValid(cfgOptGrpRepo) &&
|
||||
|
@ -16,7 +16,6 @@ Command and Option Parse
|
||||
#include "common/regExp.h"
|
||||
#include "config/config.intern.h"
|
||||
#include "config/parse.h"
|
||||
#include "storage/helper.h"
|
||||
#include "version.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -743,12 +742,14 @@ cfgFileLoadPart(String **config, const Buffer *configPart)
|
||||
|
||||
static String *
|
||||
cfgFileLoad( // NOTE: Passing defaults to enable more complete test coverage
|
||||
const Storage *storage, // !!!
|
||||
const ParseOption *optionList, // All options and their current settings
|
||||
const String *optConfigDefault, // Current default for --config option
|
||||
const String *optConfigIncludePathDefault, // Current default for --config-include-path option
|
||||
const String *origConfigDefault) // Original --config option default (/etc/pgbackrest.conf)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(STORAGE, storage);
|
||||
FUNCTION_LOG_PARAM_P(PARSE_OPTION, optionList);
|
||||
FUNCTION_LOG_PARAM(STRING, optConfigDefault);
|
||||
FUNCTION_LOG_PARAM(STRING, optConfigIncludePathDefault);
|
||||
@ -813,7 +814,7 @@ cfgFileLoad( // NOTE: Pas
|
||||
configFileName = optConfigDefault;
|
||||
|
||||
// Load the config file
|
||||
Buffer *buffer = storageGetP(storageNewReadP(storageLocal(), configFileName, .ignoreMissing = !configRequired));
|
||||
Buffer *buffer = storageGetP(storageNewReadP(storage, configFileName, .ignoreMissing = !configRequired));
|
||||
|
||||
// Convert the contents of the file buffer to the config string object
|
||||
if (buffer != NULL)
|
||||
@ -821,7 +822,7 @@ cfgFileLoad( // NOTE: Pas
|
||||
else if (strEq(configFileName, optConfigDefaultCurrent))
|
||||
{
|
||||
// If config is current default and it was not found, attempt to load the config file from the old default location
|
||||
buffer = storageGetP(storageNewReadP(storageLocal(), origConfigDefault, .ignoreMissing = !configRequired));
|
||||
buffer = storageGetP(storageNewReadP(storage, origConfigDefault, .ignoreMissing = !configRequired));
|
||||
|
||||
if (buffer != NULL)
|
||||
result = strNewBuf(buffer);
|
||||
@ -848,7 +849,7 @@ cfgFileLoad( // NOTE: Pas
|
||||
|
||||
// Get a list of conf files from the specified path -error on missing directory if the option was passed on the command line
|
||||
StringList *list = storageListP(
|
||||
storageLocal(), configIncludePath, .expression = STRDEF(".+\\.conf$"), .errorOnMissing = configIncludeRequired,
|
||||
storage, configIncludePath, .expression = STRDEF(".+\\.conf$"), .errorOnMissing = configIncludeRequired,
|
||||
.nullOnMissing = !configIncludeRequired);
|
||||
|
||||
// If conf files are found, then add them to the config string
|
||||
@ -863,7 +864,7 @@ cfgFileLoad( // NOTE: Pas
|
||||
&result,
|
||||
storageGetP(
|
||||
storageNewReadP(
|
||||
storageLocal(), strNewFmt("%s/%s", strZ(configIncludePath), strZ(strLstGet(list, listIdx))),
|
||||
storage, strNewFmt("%s/%s", strZ(configIncludePath), strZ(strLstGet(list, listIdx))),
|
||||
.ignoreMissing = true)));
|
||||
}
|
||||
}
|
||||
@ -877,11 +878,13 @@ cfgFileLoad( // NOTE: Pas
|
||||
logic to this critical path code.
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
|
||||
configParse(const Storage *storage, unsigned int argListSize, const char *argList[], bool resetLogLevel)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(STORAGE, storage);
|
||||
FUNCTION_LOG_PARAM(UINT, argListSize);
|
||||
FUNCTION_LOG_PARAM(CHARPY, argList);
|
||||
FUNCTION_LOG_PARAM(BOOL, resetLogLevel);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
@ -1205,7 +1208,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Load the configuration file(s)
|
||||
String *configString = cfgFileLoad(
|
||||
parseOptionList, STR(cfgParseOptionDefault(config->command, cfgOptConfig)),
|
||||
storage, parseOptionList, STR(cfgParseOptionDefault(config->command, cfgOptConfig)),
|
||||
STR(cfgParseOptionDefault(config->command, cfgOptConfigIncludePath)), PGBACKREST_CONFIG_ORIG_PATH_FILE_STR);
|
||||
|
||||
if (configString != NULL)
|
||||
|
@ -6,12 +6,13 @@ Parse Configuration
|
||||
|
||||
#include "config/config.h"
|
||||
#include "config/parse.auto.h"
|
||||
#include "storage/storage.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
// Parse the command-line arguments and config file to produce final config data
|
||||
void configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel);
|
||||
void configParse(const Storage *storage, unsigned int argListSize, const char *argList[], bool resetLogLevel);
|
||||
|
||||
// Parse option name and return option info
|
||||
typedef struct CfgParseOptionResult
|
||||
|
@ -28,7 +28,7 @@ harnessCfgLoadRaw(unsigned int argListSize, const char *argList[])
|
||||
// Free objects in storage helper
|
||||
storageHelperFree();
|
||||
|
||||
configParse(argListSize, argList, false);
|
||||
configParse(storageLocal(), argListSize, argList, false);
|
||||
cfgLoadUpdateOption();
|
||||
|
||||
// Use a static exec-id for testing if it is not set explicitly
|
||||
|
@ -3,7 +3,7 @@ Test Configuration Parse
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/type/json.h"
|
||||
#include "protocol/helper.h"
|
||||
#include "storage/storage.intern.h"
|
||||
#include "storage/posix/storage.h"
|
||||
|
||||
#include "common/harnessConfig.h"
|
||||
|
||||
@ -39,6 +39,9 @@ testRun(void)
|
||||
{
|
||||
FUNCTION_HARNESS_VOID();
|
||||
|
||||
Storage *storageTest = storagePosixNewP(FSLASH_STR);
|
||||
Storage *storageTestWrite = storagePosixNewP(strNew(testPath()), .write = true);
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
if (testBegin("size"))
|
||||
{
|
||||
@ -89,14 +92,14 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
|
||||
storagePut(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n"));
|
||||
|
||||
storagePut(
|
||||
storageNewWriteP(storageLocalWrite(), strNewFmt("%s/global-backup.conf", strZ(configIncludePath))),
|
||||
storageNewWriteP(storageTestWrite, strNewFmt("%s/global-backup.conf", strZ(configIncludePath))),
|
||||
BUFSTRDEF(
|
||||
"[global:backup]\n"
|
||||
"repo1-hardlink=y\n"
|
||||
@ -110,14 +113,14 @@ testRun(void)
|
||||
"buffer-size=65536\n"));
|
||||
|
||||
storagePut(
|
||||
storageNewWriteP(storageLocalWrite(), strNewFmt("%s/db-backup.conf", strZ(configIncludePath))),
|
||||
storageNewWriteP(storageTestWrite, strNewFmt("%s/db-backup.conf", strZ(configIncludePath))),
|
||||
BUFSTRDEF(
|
||||
"[db:backup]\n"
|
||||
"delta=n\n"
|
||||
"recovery-option=a=b\n"));
|
||||
|
||||
storagePut(
|
||||
storageNewWriteP(storageLocalWrite(), strNewFmt("%s/stanza.db.conf", strZ(configIncludePath))),
|
||||
storageNewWriteP(storageTestWrite, strNewFmt("%s/stanza.db.conf", strZ(configIncludePath))),
|
||||
BUFSTRDEF(
|
||||
"[db]\n"
|
||||
"pg1-host=db\n"
|
||||
@ -125,7 +128,8 @@ testRun(void)
|
||||
"recovery-option=c=d\n"));
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command with config-include");
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false),
|
||||
TEST_COMMAND_BACKUP " command with config-include");
|
||||
harnessLogResult(
|
||||
strZ(
|
||||
strNew(
|
||||
@ -195,7 +199,7 @@ testRun(void)
|
||||
TEST_RESULT_VOID(cfgFileLoadPart(NULL, NULL), "check null part");
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n"
|
||||
@ -214,9 +218,8 @@ testRun(void)
|
||||
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
TEST_ERROR(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue,
|
||||
backupCmdDefConfigInclPathValue, oldConfigDefault), PathMissingError,
|
||||
"unable to list file info for missing path '/BOGUS'");
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
PathMissingError, "unable to list file info for missing path '/BOGUS'");
|
||||
|
||||
// --config-include-path valid, --config invalid (does not exist)
|
||||
value = strLstNew();
|
||||
@ -230,7 +233,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfig].indexList[0].valueList = value;
|
||||
|
||||
TEST_ERROR_FMT(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
FileMissingError, STORAGE_ERROR_READ_MISSING, strZ(strNewFmt("%s/BOGUS", testPath())));
|
||||
|
||||
strLstFree(parseOptionList[cfgOptConfig].indexList[0].valueList);
|
||||
@ -244,7 +247,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
NULL, "config default, config-include-path default but nothing to read");
|
||||
|
||||
// Config not passed as parameter - config does not exist. config-include-path passed as parameter - only include read
|
||||
@ -259,7 +262,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[db]\n"
|
||||
"pg1-host=db\n"
|
||||
"pg1-path=/path/to/db\n"
|
||||
@ -276,7 +279,7 @@ testRun(void)
|
||||
|
||||
mkdir(strZ(strPath(oldConfigDefault)), 0750);
|
||||
storagePut(
|
||||
storageNewWriteP(storageLocalWrite(), oldConfigDefault),
|
||||
storageNewWriteP(storageTestWrite, oldConfigDefault),
|
||||
BUFSTRDEF(
|
||||
"[global:backup]\n"
|
||||
"buffer-size=65536\n"));
|
||||
@ -284,7 +287,7 @@ testRun(void)
|
||||
// Pass actual location of config files as "default" - not setting valueList above, so these are the only possible values
|
||||
// to choose.
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, configFile, configIncludePath, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, configFile, configIncludePath, oldConfigDefault),
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n"
|
||||
@ -308,7 +311,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[global:backup]\n"
|
||||
"buffer-size=65536\n"
|
||||
"\n"
|
||||
@ -331,7 +334,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[db]\n"
|
||||
"pg1-host=db\n"
|
||||
"pg1-path=/path/to/db\n"
|
||||
@ -347,7 +350,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
|
||||
NULL, "--no-config, config-include-path default, nothing read");
|
||||
|
||||
// config passed and config-include-path default exists with files - only config read
|
||||
@ -363,7 +366,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].source = cfgSourceDefault;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n",
|
||||
@ -381,7 +384,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n"
|
||||
@ -401,7 +404,7 @@ testRun(void)
|
||||
|
||||
// File exists in old default config location but not in current default.
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, configIncludePath, oldConfigDefault),
|
||||
"[global:backup]\n"
|
||||
"buffer-size=65536\n"
|
||||
"\n"
|
||||
@ -427,7 +430,7 @@ testRun(void)
|
||||
// Override default paths for config and config-include-path - but no pgbackrest.conf file in override path only in old
|
||||
// default so ignored
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[db]\n"
|
||||
"pg1-host=db\n"
|
||||
"pg1-path=/path/to/db\n"
|
||||
@ -446,7 +449,7 @@ testRun(void)
|
||||
// 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
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n"
|
||||
@ -465,7 +468,7 @@ testRun(void)
|
||||
// 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
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n",
|
||||
@ -491,7 +494,7 @@ testRun(void)
|
||||
|
||||
// Override default paths for config and config-include-path with --config-path
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n"
|
||||
@ -521,7 +524,7 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
cfgFileLoad(storageTest, parseOptionList, configFile, backupCmdDefConfigInclPathValue, oldConfigDefault),
|
||||
"[global]\n"
|
||||
"compress-level=3\n"
|
||||
"spool-path=/path/to/spool\n",
|
||||
@ -543,7 +546,8 @@ testRun(void)
|
||||
parseOptionList[cfgOptConfigIncludePath].indexList[0].valueList = value;
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
cfgFileLoad(parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, backupCmdDefConfigValue),
|
||||
cfgFileLoad(
|
||||
storageTest, parseOptionList, backupCmdDefConfigValue, backupCmdDefConfigInclPathValue, backupCmdDefConfigValue),
|
||||
NULL, "config default does not exist, config-include-path passed but only empty conf file - nothing read");
|
||||
}
|
||||
|
||||
@ -574,7 +578,9 @@ testRun(void)
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew(BOGUS_STR));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), CommandInvalidError, "invalid command 'BOGUS'");
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandInvalidError,
|
||||
"invalid command 'BOGUS'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("invalid command/role combination");
|
||||
@ -584,7 +590,7 @@ testRun(void)
|
||||
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_ASYNC);
|
||||
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), CommandInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandInvalidError,
|
||||
"invalid command/role combination 'backup:async'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -592,20 +598,23 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew(BOGUS_STR ":" BOGUS_STR));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), CommandInvalidError, "invalid command 'BOGUS:BOGUS'");
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandInvalidError,
|
||||
"invalid command 'BOGUS:BOGUS'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew("--" BOGUS_STR));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError, "invalid option '--BOGUS'");
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"invalid option '--BOGUS'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew("--pg1-host"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option '--pg1-host' requires argument");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -614,7 +623,8 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("backup"));
|
||||
strLstAdd(argList, strNew("param1"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), ParamInvalidError, "command does not allow parameters");
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), ParamInvalidError,
|
||||
"command does not allow parameters");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
@ -622,7 +632,8 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("help"));
|
||||
strLstAdd(argList, strNew("backup"));
|
||||
strLstAdd(argList, strNew("param1"));
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "ignore params when help command");
|
||||
TEST_RESULT_VOID(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "ignore params when help command");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
@ -630,7 +641,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--no-online"));
|
||||
strLstAdd(argList, strNew("--no-online"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'online' is negated multiple times");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -639,7 +650,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--reset-pg1-host"));
|
||||
strLstAdd(argList, strNew("--reset-pg1-host"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'pg1-host' is reset multiple times");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -648,7 +659,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--no-config"));
|
||||
strLstAdd(argList, strNew("--config=/etc/config"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'config' cannot be set and negated");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -657,7 +668,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--reset-log-path"));
|
||||
strLstAdd(argList, strNew("--log-path=/var/log"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'log-path' cannot be set and reset");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -666,7 +677,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--no-delta"));
|
||||
strLstAdd(argList, strNew("--reset-delta"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'delta' cannot be negated and reset");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -675,7 +686,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--reset-delta"));
|
||||
strLstAdd(argList, strNew("--no-delta"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'delta' cannot be negated and reset");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -684,7 +695,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--delta"));
|
||||
strLstAdd(argList, strNew("--delta"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'delta' cannot be set multiple times");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -695,14 +706,15 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--compress-level=3"));
|
||||
strLstAdd(argList, strNew("--compress-level=3"));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'compress-level' cannot be set multiple times");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew("--online"));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), CommandRequiredError, "no command found");
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), CommandRequiredError, "no command found");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
@ -710,7 +722,8 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew("--manifest-save-threshold=123Q"));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'123Q' is not valid for 'manifest-save-threshold' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -719,7 +732,8 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew("--manifest-save-threshold=9999999999999999999p"));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'9999999999999999999p' is out of range for 'manifest-save-threshold' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -728,7 +742,8 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew("--pg1-path="));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'' must be >= 1 character for 'pg1-path' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -737,7 +752,8 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew("--pg1-path=bogus"));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'bogus' must begin with / for 'pg1-path' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -746,7 +762,8 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew("--pg1-path=/path1//path2"));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'/path1//path2' cannot contain // for 'pg1-path' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -755,7 +772,8 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew("--pg1-path=/path1/path2//"));
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'/path1/path2//' cannot contain // for 'pg1-path' option");
|
||||
|
||||
// Local and remove commands should not modify log levels during parsing
|
||||
@ -773,7 +791,7 @@ testRun(void)
|
||||
|
||||
logLevelStdOut = logLevelError;
|
||||
logLevelStdErr = logLevelError;
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load local config");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "load local config");
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptPgPath), "/path/to/2", "default pg-path");
|
||||
TEST_RESULT_INT(cfgCommandRole(), cfgCmdRoleLocal, " command role is local");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), false, " backup:local command does not require lock");
|
||||
@ -792,7 +810,7 @@ testRun(void)
|
||||
|
||||
logLevelStdOut = logLevelError;
|
||||
logLevelStdErr = logLevelError;
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "load remote config");
|
||||
TEST_RESULT_VOID(configParse(storageTest, 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");
|
||||
@ -805,7 +823,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
|
||||
"backup command requires option: pg1-path\nHINT: does this stanza exist?");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -813,7 +831,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionRequiredError,
|
||||
"backup command requires option: stanza");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -827,7 +845,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--repo1-s3-endpoint=xxx"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'repo1-s3-key' is not allowed on the command-line\n"
|
||||
"HINT: this option could expose secrets in the process list.\n"
|
||||
"HINT: specify the option in a configuration file or an environment variable instead.");
|
||||
@ -841,7 +859,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--repo1-s3-host=xxx"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'repo1-s3-host' not valid without option 'repo1-type' = 's3'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -852,7 +870,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'repo1-host-user' not valid without option 'repo1-host'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -863,7 +881,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--force"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'force' not valid without option 'no-online'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -874,7 +892,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--spool-path=/path/to/spool"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_ARCHIVE_GET));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'spool-path' not valid without option 'archive-async'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -885,7 +903,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--recovery-option=a=b"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'recovery-option' not valid for command 'backup'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -896,7 +914,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--target-exclusive"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'target-exclusive' not valid without option 'type' in ('time', 'xid')");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -907,7 +925,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--type=bogus"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'bogus' is not allowed for 'type' option");
|
||||
|
||||
// Lower and upper bounds for integer ranges
|
||||
@ -919,7 +937,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--process-max=0"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'0' is out of range for 'process-max' option");
|
||||
|
||||
argList = strLstNew();
|
||||
@ -929,7 +947,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--process-max=65536"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'65536' is out of range for 'process-max' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -940,7 +958,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--process-max=bogus"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'bogus' is not valid for 'process-max' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -951,7 +969,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--protocol-timeout=.01"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'.01' is out of range for 'protocol-timeout' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -962,7 +980,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--protocol-timeout=bogus"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"'bogus' is not valid for 'protocol-timeout' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -973,7 +991,7 @@ testRun(void)
|
||||
setenv("PGBACKREST_PROTOCOL_TIMEOUT", "", true);
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"environment variable 'protocol-timeout' must have a value");
|
||||
|
||||
unsetenv("PGBACKREST_PROTOCOL_TIMEOUT");
|
||||
@ -986,7 +1004,7 @@ testRun(void)
|
||||
setenv("PGBACKREST_DELTA", "x", true);
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"environment boolean option 'delta' must be 'y' or 'n'");
|
||||
|
||||
unsetenv("PGBACKREST_DELTA");
|
||||
@ -999,13 +1017,13 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[global]\n"
|
||||
"delta=bogus\n"));
|
||||
|
||||
TEST_ERROR(configParse(
|
||||
strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"boolean option 'delta' must be 'y' or 'n'");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1016,13 +1034,13 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[global]\n"
|
||||
"delta=\n"));
|
||||
|
||||
TEST_ERROR(configParse(
|
||||
strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidValueError,
|
||||
"section 'global', key 'delta' must have a value");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1033,14 +1051,14 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[db]\n"
|
||||
"pg1-path=/path/to/db\n"
|
||||
"db-path=/also/path/to/db\n"));
|
||||
|
||||
TEST_ERROR(configParse(
|
||||
strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
strZ(strNew("configuration file contains duplicate options ('db-path', 'pg1-path') in section '[db]'")));
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1051,26 +1069,26 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[db]\n"
|
||||
"pg1-path=/path/to/db\n"
|
||||
"pg1-path=/also/path/to/db\n"));
|
||||
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false),
|
||||
OptionInvalidError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'pg1-path' cannot be set multiple times");
|
||||
|
||||
// Also test with a boolean option since this gets converted immediately and will blow up if it is multi
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[db]\n"
|
||||
"start-fast=y\n"
|
||||
"start-fast=n\n"));
|
||||
|
||||
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false),
|
||||
OptionInvalidError,
|
||||
TEST_ERROR(
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"option 'start-fast' cannot be set multiple times");
|
||||
|
||||
// Test that log levels are set correctly when reset is enabled, then set them back to harness defaults
|
||||
@ -1080,7 +1098,7 @@ testRun(void)
|
||||
|
||||
logLevelStdOut = logLevelOff;
|
||||
logLevelStdErr = logLevelOff;
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), true), "no command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), true), "no command");
|
||||
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdNone, " command is none");
|
||||
TEST_RESULT_INT(logLevelStdOut, logLevelWarn, "console logging is warn");
|
||||
@ -1092,7 +1110,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew("help"));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "help command");
|
||||
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdHelp, " command is help");
|
||||
|
||||
@ -1102,7 +1120,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("help"));
|
||||
strLstAdd(argList, strNew("version"));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for version command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "help for version command");
|
||||
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdVersion, " command is version");
|
||||
|
||||
@ -1113,7 +1131,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("help"));
|
||||
strLstAdd(argList, strNew("backup"));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for backup command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "help for backup command");
|
||||
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, " command is backup");
|
||||
TEST_RESULT_BOOL(cfgOptionValid(cfgOptPgPath), true, " pg1-path is valid");
|
||||
@ -1127,7 +1145,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_ARCHIVE_GET));
|
||||
strLstAdd(argList, strNew("000000010000000200000003"));
|
||||
strLstAdd(argList, strNew("/path/to/wal/RECOVERYWAL"));
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "command arguments");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "command arguments");
|
||||
TEST_RESULT_STRLST_Z(
|
||||
cfgCommandParam(), "000000010000000200000003\n/path/to/wal/RECOVERYWAL\n", " check command arguments");
|
||||
|
||||
@ -1145,7 +1163,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
setenv("PGBACKREST_REPO1_S3_KEY", "xxx", true);
|
||||
setenv("PGBACKREST_REPO1_S3_KEY_SECRET", "xxx", true);
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
|
||||
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, " command is " TEST_COMMAND_BACKUP);
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), true, " backup command requires lock");
|
||||
TEST_RESULT_UINT(cfgLockType(), lockTypeBackup, " backup command requires backup lock type");
|
||||
@ -1234,7 +1252,7 @@ testRun(void)
|
||||
setenv("PGBACKREST_PG1_SOCKET_PATH", "/path/to/socket", true);
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTR(
|
||||
strNewFmt(
|
||||
"[global]\n"
|
||||
@ -1270,7 +1288,7 @@ testRun(void)
|
||||
"recovery-option=c=d\n",
|
||||
cfgParseOptionKeyIdxName(cfgOptPgHost, 1), cfgParseOptionKeyIdxName(cfgOptPgPath, 1))));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_BACKUP " command");
|
||||
harnessLogResult(
|
||||
strZ(
|
||||
strNew(
|
||||
@ -1373,12 +1391,12 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("archive-push:async"));
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[global]\n"
|
||||
"spool-path=/path/to/spool\n"));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "archive-push command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), "archive-push command");
|
||||
|
||||
TEST_RESULT_STR_Z(jsonFromVar(varNewVarLst(cfgCommandJobRetry())), "[0]", " default job retry");
|
||||
TEST_RESULT_BOOL(cfgLockRequired(), true, " archive-push:async command requires lock");
|
||||
@ -1399,7 +1417,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"key/value 'a' not valid for 'recovery-option' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1410,7 +1428,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), OptionInvalidError,
|
||||
"key/value 'a' not valid for 'recovery-option' option");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1421,7 +1439,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--db-include=def"));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
|
||||
|
||||
TEST_RESULT_STR_Z(jsonFromVar(varNewVarLst(cfgCommandJobRetry())), "[0,15000]", " default job retry");
|
||||
|
||||
@ -1439,7 +1457,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
hrnCfgArgRawZ(argList, cfgOptJobRetry, "0");
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
|
||||
|
||||
TEST_RESULT_PTR(cfgCommandJobRetry(), NULL, " no job retries");
|
||||
|
||||
@ -1458,7 +1476,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[global:restore]\n"
|
||||
"recovery-option=f=g\n"
|
||||
@ -1467,7 +1485,7 @@ testRun(void)
|
||||
"[db]\n"
|
||||
"pg1-path=/path/to/db\n"));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
|
||||
|
||||
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
|
||||
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("f")))), "g", "check recovery option");
|
||||
@ -1484,7 +1502,7 @@ testRun(void)
|
||||
setenv("PGBACKREST_RECOVERY_OPTION", "f=g:hijk=l", true);
|
||||
setenv("PGBACKREST_DB_INCLUDE", "77", true);
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, strLstSize(argList), strLstPtr(argList), false), TEST_COMMAND_RESTORE " command");
|
||||
|
||||
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
|
||||
TEST_RESULT_STR_Z(varStr(kvGet(recoveryKv, varNewStr(strNew("f")))), "g", "check recovery option");
|
||||
@ -1531,7 +1549,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("info"));
|
||||
|
||||
storagePutP(
|
||||
storageNewWriteP(storageLocalWrite(), configFile),
|
||||
storageNewWriteP(storageTestWrite, configFile),
|
||||
BUFSTRDEF(
|
||||
"[global]\n"
|
||||
"repo1-path=/path/to/repo\n"
|
||||
@ -1539,7 +1557,7 @@ testRun(void)
|
||||
"[db]\n"
|
||||
"repo1-path=/not/the/path\n"));
|
||||
|
||||
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "info command");
|
||||
TEST_RESULT_VOID(configParse(storageTest, 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");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user