2017-11-28 21:44:05 -05:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test Configuration Parse
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#define TEST_BACKREST_EXE "pgbackrest"
|
|
|
|
|
2017-12-05 10:09:07 -05:00
|
|
|
#define TEST_COMMAND_ARCHIVE_GET "archive-get"
|
|
|
|
#define TEST_COMMAND_BACKUP "backup"
|
2017-11-28 21:44:05 -05:00
|
|
|
#define TEST_COMMAND_HELP "help"
|
2017-12-05 10:09:07 -05:00
|
|
|
#define TEST_COMMAND_RESTORE "restore"
|
2017-11-28 21:44:05 -05:00
|
|
|
#define TEST_COMMAND_VERSION "version"
|
|
|
|
|
2018-02-03 18:27:38 -05:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Option find test -- this is done a lot in the deprecated tests
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
static void
|
2018-03-02 12:07:12 -05:00
|
|
|
testOptionFind(const char *option, unsigned int value)
|
2018-02-03 18:27:38 -05:00
|
|
|
{
|
|
|
|
// If not testing for a missing option, then add the option offset that is already added to each option in the list
|
|
|
|
if (value != 0)
|
|
|
|
value |= PARSE_OPTION_FLAG;
|
|
|
|
|
|
|
|
TEST_RESULT_INT(optionList[optionFind(strNew(option))].val, value, "check %s", option);
|
|
|
|
}
|
|
|
|
|
2017-11-28 21:44:05 -05:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test run
|
|
|
|
***********************************************************************************************************************************/
|
2018-01-31 18:22:25 -05:00
|
|
|
void
|
|
|
|
testRun()
|
2017-11-28 21:44:05 -05:00
|
|
|
{
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------------------
|
2017-12-22 23:27:49 -05:00
|
|
|
if (testBegin("configParse()"))
|
2017-11-28 21:44:05 -05:00
|
|
|
{
|
2017-12-22 23:27:49 -05:00
|
|
|
StringList *argList = NULL;
|
|
|
|
String *configFile = strNewFmt("%s/test.config", testPath());
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew(BOGUS_STR));
|
|
|
|
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)), CommandInvalidError, "invalid command 'BOGUS'");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--" BOGUS_STR));
|
|
|
|
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "invalid option '--BOGUS'");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-host"));
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_ERROR(
|
2018-02-03 18:27:38 -05:00
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option '--pg1-host' requires argument");
|
2017-12-22 23:27:49 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--no-online"));
|
|
|
|
strLstAdd(argList, strNew("--no-online"));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option 'online' is negated multiple times");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
2018-02-06 11:26:06 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--reset-pg1-host"));
|
|
|
|
strLstAdd(argList, strNew("--reset-pg1-host"));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option 'pg1-host' is reset multiple times");
|
|
|
|
|
2017-12-22 23:27:49 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
2017-11-28 21:44:05 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--no-config"));
|
2018-03-21 13:46:08 -04:00
|
|
|
strLstAdd(argList, strNew("--config=/etc/config"));
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option 'config' cannot be set and negated");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
2018-02-06 11:26:06 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--reset-log-path"));
|
2018-03-21 13:46:08 -04:00
|
|
|
strLstAdd(argList, strNew("--log-path=/var/log"));
|
2018-02-06 11:26:06 -05:00
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "option 'log-path' cannot be set and reset");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--no-compress"));
|
|
|
|
strLstAdd(argList, strNew("--reset-compress"));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"option 'compress' cannot be negated and reset");
|
|
|
|
|
2018-03-21 13:46:08 -04:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--reset-compress"));
|
|
|
|
strLstAdd(argList, strNew("--no-compress"));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"option 'compress' cannot be negated and reset");
|
|
|
|
|
2017-12-05 10:09:07 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2017-12-22 23:27:49 -05:00
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-03-08 14:15:05 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--compress-level=3"));
|
|
|
|
strLstAdd(argList, strNew("--compress-level=3"));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"option 'compress-level' cannot have multiple arguments");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2017-12-05 10:09:07 -05:00
|
|
|
strLstAdd(argList, strNew("--online"));
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)), CommandRequiredError, "no command found");
|
2017-11-28 21:44:05 -05:00
|
|
|
|
2018-03-21 13:46:08 -04:00
|
|
|
// Local and remove commands should not modify log levels during parsing
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew("pgbackrest"));
|
|
|
|
strLstAdd(argList, strNew("--host-id=1"));
|
|
|
|
strLstAdd(argList, strNew("--process=1"));
|
|
|
|
strLstAdd(argList, strNew("--command=backup"));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--type=backup"));
|
|
|
|
strLstAdd(argList, strNew("--log-level-stderr=info"));
|
|
|
|
strLstAdd(argList, strNew("local"));
|
|
|
|
|
|
|
|
logLevelStdOut = logLevelError;
|
|
|
|
logLevelStdErr = logLevelError;
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "load local config");
|
|
|
|
TEST_RESULT_INT(logLevelStdOut, logLevelError, "console logging is error");
|
|
|
|
TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error");
|
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew("pgbackrest"));
|
|
|
|
strLstAdd(argList, strNew("--process=1"));
|
|
|
|
strLstAdd(argList, strNew("--command=backup"));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--type=backup"));
|
|
|
|
strLstAdd(argList, strNew("--log-level-stderr=info"));
|
|
|
|
strLstAdd(argList, strNew("remote"));
|
|
|
|
|
|
|
|
logLevelStdOut = logLevelError;
|
|
|
|
logLevelStdErr = logLevelError;
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "load remote config");
|
|
|
|
TEST_RESULT_INT(logLevelStdOut, logLevelError, "console logging is error");
|
|
|
|
TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error");
|
|
|
|
|
2017-11-28 21:44:05 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2017-12-22 23:27:49 -05:00
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionRequiredError,
|
2018-02-03 18:27:38 -05:00
|
|
|
"backup command requires option: pg1-path\nHINT: does this stanza exist?");
|
2017-11-28 21:44:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2017-12-22 23:27:49 -05:00
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionRequiredError,
|
|
|
|
"backup command requires option: stanza");
|
2017-11-28 21:44:05 -05:00
|
|
|
|
2018-03-15 12:02:09 -04:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--repo1-type=s3"));
|
|
|
|
strLstAdd(argList, strNew("--repo1-s3-key=xxx"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), 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 '/etc/pgbackrest.conf' instead.");
|
|
|
|
|
2017-11-28 21:44:05 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2017-12-22 23:27:49 -05:00
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--no-config"));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
2018-03-15 11:09:46 -04:00
|
|
|
strLstAdd(argList, strNew("--repo1-s3-host=xxx"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
2018-03-15 11:09:46 -04:00
|
|
|
"option 'repo1-s3-host' not valid without option 'repo1-type' = 's3'");
|
2017-11-28 21:44:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2017-12-22 23:27:49 -05:00
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
|
|
|
strLstAdd(argList, strNew("--repo1-host-user=xxx"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
2018-02-05 11:50:09 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
2018-02-03 18:27:38 -05:00
|
|
|
"option 'repo1-host-user' not valid without option 'repo1-host'");
|
2017-11-28 21:44:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--force"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"option 'force' not valid without option 'no-online'");
|
2017-11-28 21:44:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--test-delay=1"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"option 'test-delay' not valid without option 'test'");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--recovery-option=a=b"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
2017-12-05 10:09:07 -05:00
|
|
|
TEST_ERROR(
|
2017-12-22 23:27:49 -05:00
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"option 'recovery-option' not valid for command 'backup'");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--target-exclusive"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
2017-12-05 10:09:07 -05:00
|
|
|
TEST_ERROR(
|
2017-12-22 23:27:49 -05:00
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"option 'target-exclusive' not valid without option 'type' in ('time', 'xid')");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--type=bogus"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
2017-12-05 10:09:07 -05:00
|
|
|
TEST_ERROR(
|
2017-12-22 23:27:49 -05:00
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
|
|
|
|
"'bogus' is not valid for 'type' option");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
2018-03-21 13:46:08 -04:00
|
|
|
// Lower and upper bounds for integer ranges
|
2017-12-05 10:09:07 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--process-max=0"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
2017-12-05 10:09:07 -05:00
|
|
|
TEST_ERROR(
|
2017-12-22 23:27:49 -05:00
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
|
|
|
|
"'0' is not valid for 'process-max' option");
|
|
|
|
|
2018-03-21 13:46:08 -04:00
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--process-max=65536"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
|
|
|
|
"'65536' is not valid for 'process-max' option");
|
|
|
|
|
2017-12-22 23:27:49 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--process-max=bogus"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
|
|
|
|
"'bogus' is not valid for 'process-max' option");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--protocol-timeout=.01"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
|
|
|
|
"'.01' is not valid for 'protocol-timeout' option");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew("--protocol-timeout=bogus"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
|
|
|
|
"'bogus' is not valid for 'protocol-timeout' option");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
|
2018-04-03 12:25:21 -04:00
|
|
|
storagePutNP(storageOpenWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew(
|
2017-12-22 23:27:49 -05:00
|
|
|
"[global]\n"
|
|
|
|
"compress=bogus\n"
|
|
|
|
)));
|
|
|
|
|
|
|
|
TEST_ERROR(configParse(
|
|
|
|
strLstSize(argList), strLstPtr(argList)), OptionInvalidError, "boolean option 'compress' must be 'y' or 'n'");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
|
2018-04-03 12:25:21 -04:00
|
|
|
storagePutNP(storageOpenWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew(
|
2017-12-22 23:27:49 -05:00
|
|
|
"[global]\n"
|
|
|
|
"compress=\n"
|
|
|
|
)));
|
|
|
|
|
|
|
|
TEST_ERROR(configParse(
|
|
|
|
strLstSize(argList), strLstPtr(argList)), OptionInvalidValueError,
|
|
|
|
"section 'global', key 'compress' must have a value");
|
|
|
|
|
2018-02-05 15:48:26 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
|
2018-04-03 12:25:21 -04:00
|
|
|
storagePutNP(storageOpenWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew(
|
2018-02-05 15:48:26 -05:00
|
|
|
"[db]\n"
|
|
|
|
"pg1-path=/path/to/db\n"
|
|
|
|
"db-path=/also/path/to/db\n"
|
|
|
|
)));
|
|
|
|
|
|
|
|
TEST_ERROR(configParse(
|
|
|
|
strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
strPtr(strNewFmt("'%s' contains duplicate options ('db-path', 'pg1-path') in section '[db]'", strPtr(configFile))));
|
|
|
|
|
2018-03-08 14:15:05 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
|
2018-04-03 12:25:21 -04:00
|
|
|
storagePutNP(storageOpenWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew(
|
2018-03-08 14:15:05 -05:00
|
|
|
"[db]\n"
|
|
|
|
"pg1-path=/path/to/db\n"
|
|
|
|
"pg1-path=/also/path/to/db\n"
|
|
|
|
)));
|
|
|
|
|
|
|
|
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList)),
|
|
|
|
OptionInvalidError,
|
|
|
|
"option 'pg1-path' cannot have multiple arguments");
|
|
|
|
|
2017-12-22 23:27:49 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "no command");
|
|
|
|
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
|
|
|
|
TEST_RESULT_INT(cfgCommand(), cfgCmdNone, " command is none");
|
2018-03-21 13:46:08 -04:00
|
|
|
TEST_RESULT_INT(logLevelStdOut, logLevelWarn, "console logging is warn");
|
|
|
|
TEST_RESULT_INT(logLevelStdErr, logLevelWarn, "stderr logging is warn");
|
2017-12-22 23:27:49 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("help"));
|
|
|
|
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help command");
|
|
|
|
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
|
|
|
|
TEST_RESULT_INT(cfgCommand(), cfgCmdHelp, " command is help");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("help"));
|
|
|
|
strLstAdd(argList, strNew("version"));
|
|
|
|
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "help for version command");
|
|
|
|
TEST_RESULT_BOOL(cfgCommandHelp(), true, " help is set");
|
|
|
|
TEST_RESULT_INT(cfgCommand(), cfgCmdVersion, " command is version");
|
|
|
|
|
2018-03-21 13:46:08 -04:00
|
|
|
// Help should not fail on missing options
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("help"));
|
|
|
|
strLstAdd(argList, strNew("backup"));
|
|
|
|
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "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");
|
|
|
|
TEST_RESULT_PTR(cfgOption(cfgOptPgPath), NULL, " pg1-path is not set");
|
|
|
|
|
2017-12-22 23:27:49 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
2017-12-05 10:09:07 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_ARCHIVE_GET));
|
|
|
|
strLstAdd(argList, strNew("000000010000000200000003"));
|
|
|
|
strLstAdd(argList, strNew("/path/to/wal/RECOVERYWAL"));
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "command arguments");
|
2017-12-05 10:09:07 -05:00
|
|
|
TEST_RESULT_STR(
|
2017-12-22 23:27:49 -05:00
|
|
|
strPtr(strLstJoin(cfgCommandParam(), "|")), "000000010000000200000003|/path/to/wal/RECOVERYWAL",
|
2017-12-05 10:09:07 -05:00
|
|
|
" check command arguments");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--no-online"));
|
2018-02-06 11:26:06 -05:00
|
|
|
strLstAdd(argList, strNew("--no-config"));
|
2017-12-05 10:09:07 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_BACKUP " command");
|
|
|
|
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, " command is " TEST_COMMAND_BACKUP);
|
|
|
|
|
|
|
|
TEST_RESULT_STR(strPtr(cfgExe()), TEST_BACKREST_EXE, " exe is set");
|
|
|
|
|
2018-03-05 18:51:48 -05:00
|
|
|
TEST_RESULT_BOOL(cfgOptionTest(cfgOptConfig), false, " config is not set");
|
2018-02-06 11:26:06 -05:00
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptConfig), cfgSourceParam, " config is source param");
|
|
|
|
TEST_RESULT_BOOL(cfgOptionNegate(cfgOptConfig), true, " config is negated");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptStanza), cfgSourceParam, " stanza is source param");
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptStanza)), "db", " stanza is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptStanza), cfgSourceParam, " stanza is source param");
|
2018-02-03 18:27:38 -05:00
|
|
|
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgPath)), "/path/to/db", " pg1-path is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceParam, " pg1-path is source param");
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_RESULT_BOOL(cfgOptionBool(cfgOptOnline), false, " online is not set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptOnline), cfgSourceParam, " online is source default");
|
|
|
|
TEST_RESULT_BOOL(cfgOptionBool(cfgOptCompress), true, " compress is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptCompress), cfgSourceDefault, " compress is source default");
|
2018-01-16 13:52:20 -05:00
|
|
|
TEST_RESULT_INT(cfgOptionInt(cfgOptBufferSize), 4194304, " buffer-size is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceDefault, " buffer-size is source default");
|
2017-12-22 23:27:49 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
|
|
|
|
strLstAdd(argList, strNew("--no-online"));
|
2018-02-06 11:26:06 -05:00
|
|
|
strLstAdd(argList, strNew("--reset-pg1-host"));
|
2018-02-13 15:58:14 -05:00
|
|
|
strLstAdd(argList, strNew("--reset-backup-standby"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
|
|
|
|
2018-04-03 12:25:21 -04:00
|
|
|
storagePutNP(storageOpenWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew(
|
2017-12-22 23:27:49 -05:00
|
|
|
"[global]\n"
|
|
|
|
"compress-level=3\n"
|
2018-03-21 13:46:08 -04:00
|
|
|
"spool-path=/path/to/spool\n"
|
2017-12-22 23:27:49 -05:00
|
|
|
"\n"
|
|
|
|
"[global:backup]\n"
|
2018-02-03 18:27:38 -05:00
|
|
|
"repo1-hardlink=y\n"
|
2017-12-22 23:27:49 -05:00
|
|
|
"bogus=bogus\n"
|
|
|
|
"no-compress=y\n"
|
2018-02-06 11:26:06 -05:00
|
|
|
"reset-compress=y\n"
|
2017-12-22 23:27:49 -05:00
|
|
|
"archive-copy=y\n"
|
|
|
|
"online=y\n"
|
2018-02-05 15:48:26 -05:00
|
|
|
"pg1-path=/not/path/to/db\n"
|
2018-02-13 15:58:14 -05:00
|
|
|
"backup-standby=y\n"
|
2018-03-21 13:46:08 -04:00
|
|
|
"buffer-size=65536\n"
|
2017-12-22 23:27:49 -05:00
|
|
|
"\n"
|
|
|
|
"[db:backup]\n"
|
|
|
|
"compress=n\n"
|
|
|
|
"recovery-option=a=b\n"
|
|
|
|
"\n"
|
|
|
|
"[db]\n"
|
2018-02-03 18:27:38 -05:00
|
|
|
"pg1-host=db\n"
|
|
|
|
"pg1-path=/path/to/db\n"
|
2017-12-22 23:27:49 -05:00
|
|
|
"recovery-option=c=d\n"
|
|
|
|
)));
|
|
|
|
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_BACKUP " command");
|
2018-01-28 21:37:09 -05:00
|
|
|
testLogErrResult(
|
|
|
|
strPtr(
|
|
|
|
strNewFmt(
|
|
|
|
"WARN: '%s' contains option 'recovery-option' invalid for section 'db:backup'\n"
|
|
|
|
"WARN: '%s' contains invalid option 'bogus'\n"
|
|
|
|
"WARN: '%s' contains negate option 'no-compress'\n"
|
2018-02-06 11:26:06 -05:00
|
|
|
"WARN: '%s' contains reset option 'reset-compress'\n"
|
2018-02-05 15:48:26 -05:00
|
|
|
"WARN: '%s' contains command-line only option 'online'\n"
|
|
|
|
"WARN: '%s' contains stanza-only option 'pg1-path' in global section 'global:backup'",
|
2018-02-06 11:26:06 -05:00
|
|
|
strPtr(configFile), strPtr(configFile), strPtr(configFile), strPtr(configFile), strPtr(configFile),
|
|
|
|
strPtr(configFile))));
|
2017-12-22 23:27:49 -05:00
|
|
|
|
2018-03-08 14:15:05 -05:00
|
|
|
TEST_RESULT_BOOL(cfgOptionTest(cfgOptPgHost), false, " pg1-host is not set (command line reset override)");
|
2018-02-03 18:27:38 -05:00
|
|
|
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptPgPath)), "/path/to/db", " pg1-path is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptPgPath), cfgSourceConfig, " pg1-path is source config");
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_RESULT_BOOL(cfgOptionBool(cfgOptCompress), false, " compress not is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptCompress), cfgSourceConfig, " compress is source config");
|
2018-03-05 18:51:48 -05:00
|
|
|
TEST_RESULT_BOOL(cfgOptionTest(cfgOptArchiveCheck), false, " archive-check is not set");
|
|
|
|
TEST_RESULT_BOOL(cfgOptionTest(cfgOptArchiveCopy), false, " archive-copy is not set");
|
2018-02-03 18:27:38 -05:00
|
|
|
TEST_RESULT_BOOL(cfgOptionBool(cfgOptRepoHardlink), true, " repo-hardlink is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptRepoHardlink), cfgSourceConfig, " repo-hardlink is source config");
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_RESULT_INT(cfgOptionInt(cfgOptCompressLevel), 3, " compress-level is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptCompressLevel), cfgSourceConfig, " compress-level is source config");
|
2018-02-13 15:58:14 -05:00
|
|
|
TEST_RESULT_BOOL(cfgOptionBool(cfgOptBackupStandby), false, " backup-standby not is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptBackupStandby), cfgSourceDefault, " backup-standby is source default");
|
2018-03-21 13:46:08 -04:00
|
|
|
TEST_RESULT_BOOL(cfgOptionInt64(cfgOptBufferSize), 65536, " buffer-size is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptBufferSize), cfgSourceConfig, " backup-standby is source config");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
2018-02-09 13:54:33 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-03-21 13:46:08 -04:00
|
|
|
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
|
2018-02-09 13:54:33 -05:00
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
2018-04-18 19:37:35 -04:00
|
|
|
strLstAdd(argList, strNew("--archive-push-queue-max=4503599627370496"));
|
2018-02-09 13:54:33 -05:00
|
|
|
strLstAdd(argList, strNew("archive-push"));
|
|
|
|
|
2018-04-03 12:25:21 -04:00
|
|
|
storagePutNP(storageOpenWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew(
|
2018-03-21 13:46:08 -04:00
|
|
|
"[global]\n"
|
|
|
|
"spool-path=/path/to/spool\n"
|
|
|
|
)));
|
|
|
|
|
2018-02-09 13:54:33 -05:00
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "archive-push command");
|
|
|
|
|
2018-04-18 19:37:35 -04:00
|
|
|
TEST_RESULT_INT(cfgOptionInt64(cfgOptArchivePushQueueMax), 4503599627370496, "archive-push-queue-max is set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptArchivePushQueueMax), cfgSourceParam, " archive-push-queue-max is source config");
|
2018-03-21 13:46:08 -04:00
|
|
|
TEST_RESULT_PTR(cfgOption(cfgOptSpoolPath), NULL, " spool-path is not set");
|
|
|
|
TEST_RESULT_INT(cfgOptionSource(cfgOptSpoolPath), cfgSourceDefault, " spool-path is source default");
|
2018-02-09 13:54:33 -05:00
|
|
|
|
2017-12-05 10:09:07 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--recovery-option=a"));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
2017-12-05 10:09:07 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
2017-12-22 23:27:49 -05:00
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"key/value 'a' not valid for 'recovery-option' option");
|
2017-12-05 10:09:07 -05:00
|
|
|
|
2017-12-22 23:27:49 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
2017-12-05 10:09:07 -05:00
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--recovery-option=a"));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
|
|
|
TEST_ERROR(
|
|
|
|
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
|
|
|
"key/value 'a' not valid for 'recovery-option' option");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--db-include=abc"));
|
|
|
|
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)), TEST_COMMAND_RESTORE " command");
|
|
|
|
|
|
|
|
const VariantList *includeList = NULL;
|
|
|
|
TEST_ASSIGN(includeList, cfgOptionLst(cfgOptDbInclude), "get db include options");
|
|
|
|
TEST_RESULT_STR(strPtr(varStr(varLstGet(includeList, 0))), "abc", "check db include option");
|
|
|
|
TEST_RESULT_STR(strPtr(varStr(varLstGet(includeList, 1))), "def", "check db include option");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
2017-12-22 23:27:49 -05:00
|
|
|
strLstAdd(argList, strNew("--recovery-option=a=b"));
|
|
|
|
strLstAdd(argList, strNew("--recovery-option=c=de=fg hi"));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_RESTORE " command");
|
|
|
|
|
|
|
|
const KeyValue *recoveryKv = NULL;
|
|
|
|
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
|
|
|
|
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("a"))))), "b", "check recovery option");
|
|
|
|
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("c"))))), "de=fg hi", "check recovery option");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
|
|
|
|
strLstAdd(argList, strNew("--stanza=db"));
|
|
|
|
strLstAdd(argList, strNew(TEST_COMMAND_RESTORE));
|
|
|
|
|
2018-04-03 12:25:21 -04:00
|
|
|
storagePutNP(storageOpenWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew(
|
2017-12-22 23:27:49 -05:00
|
|
|
"[global:restore]\n"
|
|
|
|
"recovery-option=f=g\n"
|
|
|
|
"recovery-option=hijk=l\n"
|
|
|
|
"\n"
|
|
|
|
"[db]\n"
|
2018-02-03 18:27:38 -05:00
|
|
|
"pg1-path=/path/to/db\n"
|
2017-12-22 23:27:49 -05:00
|
|
|
)));
|
|
|
|
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), TEST_COMMAND_RESTORE " command");
|
|
|
|
|
|
|
|
TEST_ASSIGN(recoveryKv, cfgOptionKv(cfgOptRecoveryOption), "get recovery options");
|
|
|
|
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("f"))))), "g", "check recovery option");
|
|
|
|
TEST_RESULT_STR(strPtr(varStr(kvGet(recoveryKv, varNewStr(strNew("hijk"))))), "l", "check recovery option");
|
2018-03-21 13:46:08 -04:00
|
|
|
|
|
|
|
// Stanza options should not be loaded for commands that don't take a stanza
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
|
|
|
strLstAdd(argList, strNewFmt("--config=%s", strPtr(configFile)));
|
|
|
|
strLstAdd(argList, strNew("info"));
|
|
|
|
|
2018-04-03 12:25:21 -04:00
|
|
|
storagePutNP(storageOpenWriteNP(storageLocalWrite(), configFile), bufNewStr(strNew(
|
2018-03-21 13:46:08 -04:00
|
|
|
"[global]\n"
|
|
|
|
"repo1-path=/path/to/repo\n"
|
|
|
|
"\n"
|
|
|
|
"[db]\n"
|
|
|
|
"repo1-path=/not/the/path\n"
|
|
|
|
)));
|
|
|
|
|
|
|
|
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList)), "info command");
|
|
|
|
TEST_RESULT_STR(strPtr(cfgOptionStr(cfgOptRepoPath)), "/path/to/repo", "check repo1-path option");
|
2017-11-28 21:44:05 -05:00
|
|
|
}
|
2018-02-03 18:27:38 -05:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------------------
|
|
|
|
if (testBegin("deprecated option names"))
|
|
|
|
{
|
|
|
|
// Repository options
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
testOptionFind("hardlink", PARSE_DEPRECATE_FLAG | cfgOptRepoHardlink);
|
|
|
|
testOptionFind("no-hardlink", PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoHardlink);
|
|
|
|
|
2018-04-18 19:37:35 -04:00
|
|
|
testOptionFind("archive-queue-max", PARSE_DEPRECATE_FLAG | cfgOptArchivePushQueueMax);
|
|
|
|
testOptionFind("reset-archive-queue-max", PARSE_DEPRECATE_FLAG | PARSE_RESET_FLAG | cfgOptArchivePushQueueMax);
|
|
|
|
|
2018-02-03 18:27:38 -05:00
|
|
|
testOptionFind("backup-cmd", PARSE_DEPRECATE_FLAG | cfgOptRepoHostCmd);
|
|
|
|
testOptionFind("backup-config", PARSE_DEPRECATE_FLAG | cfgOptRepoHostConfig);
|
|
|
|
testOptionFind("backup-host", PARSE_DEPRECATE_FLAG | cfgOptRepoHost);
|
|
|
|
testOptionFind("backup-ssh-port", PARSE_DEPRECATE_FLAG | cfgOptRepoHostPort);
|
|
|
|
testOptionFind("backup-user", PARSE_DEPRECATE_FLAG | cfgOptRepoHostUser);
|
|
|
|
|
|
|
|
testOptionFind("repo-cipher-pass", PARSE_DEPRECATE_FLAG | cfgOptRepoCipherPass);
|
|
|
|
testOptionFind("repo-cipher-type", PARSE_DEPRECATE_FLAG | cfgOptRepoCipherType);
|
|
|
|
testOptionFind("repo-path", PARSE_DEPRECATE_FLAG | cfgOptRepoPath);
|
|
|
|
testOptionFind("repo-type", PARSE_DEPRECATE_FLAG | cfgOptRepoType);
|
|
|
|
|
|
|
|
testOptionFind("repo-s3-bucket", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Bucket);
|
|
|
|
testOptionFind("repo-s3-ca-file", PARSE_DEPRECATE_FLAG | cfgOptRepoS3CaFile);
|
|
|
|
testOptionFind("repo-s3-ca-path", PARSE_DEPRECATE_FLAG | cfgOptRepoS3CaPath);
|
|
|
|
testOptionFind("repo-s3-endpoint", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Endpoint);
|
|
|
|
testOptionFind("repo-s3-host", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Host);
|
|
|
|
testOptionFind("repo-s3-key", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Key);
|
|
|
|
testOptionFind("repo-s3-key-secret", PARSE_DEPRECATE_FLAG | cfgOptRepoS3KeySecret);
|
|
|
|
testOptionFind("repo-s3-region", PARSE_DEPRECATE_FLAG | cfgOptRepoS3Region);
|
|
|
|
testOptionFind("repo-s3-verify-ssl", PARSE_DEPRECATE_FLAG | cfgOptRepoS3VerifySsl);
|
|
|
|
testOptionFind("no-repo-s3-verify-ssl", PARSE_DEPRECATE_FLAG | PARSE_NEGATE_FLAG | cfgOptRepoS3VerifySsl);
|
|
|
|
|
|
|
|
// PostreSQL options
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
testOptionFind("db-cmd", PARSE_DEPRECATE_FLAG | cfgOptPgHostCmd);
|
|
|
|
testOptionFind("db-config", PARSE_DEPRECATE_FLAG | cfgOptPgHostConfig);
|
|
|
|
testOptionFind("db-host", PARSE_DEPRECATE_FLAG | cfgOptPgHost);
|
|
|
|
testOptionFind("db-path", PARSE_DEPRECATE_FLAG | cfgOptPgPath);
|
|
|
|
testOptionFind("db-port", PARSE_DEPRECATE_FLAG | cfgOptPgPort);
|
|
|
|
testOptionFind("db-socket-path", PARSE_DEPRECATE_FLAG | cfgOptPgSocketPath);
|
|
|
|
testOptionFind("db-ssh-port", PARSE_DEPRECATE_FLAG | cfgOptPgHostPort);
|
|
|
|
testOptionFind("db-user", PARSE_DEPRECATE_FLAG | cfgOptPgHostUser);
|
|
|
|
|
|
|
|
testOptionFind("no-db-user", 0);
|
|
|
|
|
2018-03-02 12:07:12 -05:00
|
|
|
for (unsigned int optionIdx = 0; optionIdx < cfgDefOptionIndexTotal(cfgDefOptPgPath); optionIdx++)
|
2018-02-03 18:27:38 -05:00
|
|
|
{
|
|
|
|
testOptionFind(strPtr(strNewFmt("db%u-cmd", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostCmd + optionIdx));
|
|
|
|
testOptionFind(
|
|
|
|
strPtr(strNewFmt("db%u-config", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostConfig + optionIdx));
|
|
|
|
testOptionFind(strPtr(strNewFmt("db%u-host", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHost + optionIdx));
|
|
|
|
testOptionFind(strPtr(strNewFmt("db%u-path", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgPath + optionIdx));
|
|
|
|
testOptionFind(strPtr(strNewFmt("db%u-port", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgPort + optionIdx));
|
|
|
|
testOptionFind(
|
|
|
|
strPtr(strNewFmt("db%u-socket-path", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgSocketPath + optionIdx));
|
|
|
|
testOptionFind(
|
|
|
|
strPtr(strNewFmt("db%u-ssh-port", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostPort + optionIdx));
|
|
|
|
testOptionFind(strPtr(strNewFmt("db%u-user", optionIdx + 1)), PARSE_DEPRECATE_FLAG | (cfgOptPgHostUser + optionIdx));
|
|
|
|
}
|
|
|
|
}
|
2017-11-28 21:44:05 -05:00
|
|
|
}
|