1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-29 22:28:02 +02:00

Configuration rules are now pulled from the C library when present.

This commit is contained in:
David Steele
2017-08-25 16:47:47 -04:00
parent 8d3436bce7
commit 1e0ed07455
118 changed files with 8911 additions and 4522 deletions

View File

@@ -25,328 +25,331 @@ sub run
{
my $self = shift;
my $oOption = {};
my $oConfig = {};
my $strConfigFile = $self->testPath() . '/pgbackrest.conf';
if ($self->begin('set and negate option ' . OPTION_CONFIG))
if ($self->begin('set and negate option ' . cfgOptionName(CFGOPT_CONFIG)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, '/dude/dude.conf');
$self->optionBoolSetTest($oOption, OPTION_CONFIG, false);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, '/dude/dude.conf');
$self->optionTestSetBool(CFGOPT_CONFIG, false);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_NEGATE, OPTION_CONFIG);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_NEGATE, cfgOptionName(CFGOPT_CONFIG));
}
if ($self->begin('option ' . OPTION_CONFIG))
if ($self->begin('option ' . cfgOptionName(CFGOPT_CONFIG)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionBoolSetTest($oOption, OPTION_CONFIG, false);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSetBool(CFGOPT_CONFIG, false);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_CONFIG);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_CONFIG);
}
if ($self->begin('default option ' . OPTION_CONFIG))
if ($self->begin('default option ' . cfgOptionName(CFGOPT_CONFIG)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_CONFIG, OPTION_DEFAULT_CONFIG);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_CONFIG, cfgRuleOptionDefault(CFGCMD_BACKUP, CFGOPT_CONFIG));
}
if ($self->begin('config file is a path'))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $self->testPath());
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $self->testPath());
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_FILE_INVALID, $self->testPath());
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP), ERROR_FILE_INVALID, $self->testPath());
}
if ($self->begin('load from config stanza command section - option ' . OPTION_PROCESS_MAX))
if ($self->begin('load from config stanza command section - option ' . cfgOptionName(CFGOPT_PROCESS_MAX)))
{
$oConfig = {};
$$oConfig{$self->stanza() . ':' . &CMD_BACKUP}{&OPTION_PROCESS_MAX} = 2;
$$oConfig{$self->stanza() . ':' . cfgCommandName(CFGCMD_BACKUP)}{cfgOptionName(CFGOPT_PROCESS_MAX)} = 2;
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_PROCESS_MAX, 2);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_PROCESS_MAX, 2);
}
if ($self->begin('load from config stanza section - option ' . OPTION_PROCESS_MAX))
if ($self->begin('load from config stanza section - option ' . cfgOptionName(CFGOPT_PROCESS_MAX)))
{
$oConfig = {};
$$oConfig{$self->stanza()}{&OPTION_PROCESS_MAX} = 3;
$$oConfig{$self->stanza()}{cfgOptionName(CFGOPT_PROCESS_MAX)} = 3;
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_PROCESS_MAX, 3);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_PROCESS_MAX, 3);
}
if ($self->begin('load from config global command section - option thread-max'))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_BACKUP}{'thread-max'} = 2;
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_BACKUP)}{'thread-max'} = 2;
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_PROCESS_MAX, 2);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_PROCESS_MAX, 2);
}
if ($self->begin('load from config global section - option ' . OPTION_PROCESS_MAX))
if ($self->begin('load from config global section - option ' . cfgOptionName(CFGOPT_PROCESS_MAX)))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_PROCESS_MAX} = 5;
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_PROCESS_MAX)} = 5;
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_PROCESS_MAX, 5);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_PROCESS_MAX, 5);
}
if ($self->begin('default - option ' . OPTION_PROCESS_MAX))
if ($self->begin('default - option ' . cfgOptionName(CFGOPT_PROCESS_MAX)))
{
$oConfig = {};
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_PROCESS_MAX, 1);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_PROCESS_MAX, 1);
}
if ($self->begin('command-line override - option ' . OPTION_PROCESS_MAX))
if ($self->begin('command-line override - option ' . cfgOptionName(CFGOPT_PROCESS_MAX)))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_PROCESS_MAX} = 9;
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_PROCESS_MAX)} = 9;
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_PROCESS_MAX, 7);
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_PROCESS_MAX, 7);
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_PROCESS_MAX, 7);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_PROCESS_MAX, 7);
}
if ($self->begin('invalid boolean - option ' . OPTION_HARDLINK))
if ($self->begin('invalid boolean - option ' . cfgOptionName(CFGOPT_HARDLINK)))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_BACKUP}{&OPTION_HARDLINK} = 'Y';
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_BACKUP)}{cfgOptionName(CFGOPT_HARDLINK)} = 'Y';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, 'Y', OPTION_HARDLINK);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID_VALUE, 'Y', cfgOptionName(CFGOPT_HARDLINK));
}
if ($self->begin('invalid value - option ' . OPTION_LOG_LEVEL_CONSOLE))
if ($self->begin('invalid value - option ' . cfgOptionName(CFGOPT_LOG_LEVEL_CONSOLE)))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_LOG_LEVEL_CONSOLE} = BOGUS;
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_LOG_LEVEL_CONSOLE)} = BOGUS;
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_LOG_LEVEL_CONSOLE);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID_VALUE, BOGUS, cfgOptionName(CFGOPT_LOG_LEVEL_CONSOLE));
}
if ($self->begin('valid value - option ' . OPTION_LOG_LEVEL_CONSOLE))
if ($self->begin('valid value - option ' . cfgOptionName(CFGOPT_LOG_LEVEL_CONSOLE)))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_LOG_LEVEL_CONSOLE} = lc(INFO);
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_LOG_LEVEL_CONSOLE)} = lc(INFO);
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_RESTORE);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_RESTORE));
}
if ($self->begin('archive-push - option ' . OPTION_LOG_LEVEL_CONSOLE))
if ($self->begin('archive-push - option ' . cfgOptionName(CFGOPT_LOG_LEVEL_CONSOLE)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_ARCHIVE_PUSH);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_ARCHIVE_PUSH));
}
if ($self->begin(CMD_EXPIRE . ' ' . OPTION_RETENTION_FULL))
if ($self->begin(cfgCommandName(CFGCMD_EXPIRE) . ' ' . cfgOptionName(CFGOPT_RETENTION_FULL)))
{
$oConfig = {};
$$oConfig{$self->stanza() . ':' . &CMD_EXPIRE}{&OPTION_RETENTION_FULL} = 2;
$$oConfig{$self->stanza() . ':' . cfgCommandName(CFGCMD_EXPIRE)}{cfgOptionName(CFGOPT_RETENTION_FULL)} = 2;
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_EXPIRE);
$self->optionTestExpect(OPTION_RETENTION_FULL, 2);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_EXPIRE));
$self->optionTestExpect(CFGOPT_RETENTION_FULL, 2);
}
if ($self->begin(CMD_BACKUP . ' option ' . OPTION_COMPRESS))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' option ' . cfgOptionName(CFGOPT_COMPRESS)))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_BACKUP}{&OPTION_COMPRESS} = 'n';
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_BACKUP)}{cfgOptionName(CFGOPT_COMPRESS)} = 'n';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_COMPRESS, false);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_COMPRESS, false);
}
if ($self->begin(CMD_RESTORE . ' global option ' . OPTION_RESTORE_RECOVERY_OPTION . ' error'))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' global option ' . cfgOptionName(CFGOPT_RECOVERY_OPTION) . ' error'))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_RESTORE}{&OPTION_RESTORE_RECOVERY_OPTION} = 'bogus=';
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_RESTORE)}{cfgOptionName(CFGOPT_RECOVERY_OPTION)} = 'bogus=';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_VALUE, 'bogus=', OPTION_RESTORE_RECOVERY_OPTION);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_RESTORE), ERROR_OPTION_INVALID_VALUE, 'bogus=', cfgOptionName(CFGOPT_RECOVERY_OPTION));
}
if ($self->begin(CMD_RESTORE . ' global option ' . OPTION_RESTORE_RECOVERY_OPTION . ' error'))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' global option ' . cfgOptionName(CFGOPT_RECOVERY_OPTION) . ' error'))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_RESTORE}{&OPTION_RESTORE_RECOVERY_OPTION} = '=bogus';
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_RESTORE)}{cfgOptionName(CFGOPT_RECOVERY_OPTION)} = '=bogus';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_VALUE, '=bogus', OPTION_RESTORE_RECOVERY_OPTION);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_RESTORE), ERROR_OPTION_INVALID_VALUE, '=bogus', cfgOptionName(CFGOPT_RECOVERY_OPTION));
}
if ($self->begin(CMD_RESTORE . ' global option ' . OPTION_RESTORE_RECOVERY_OPTION))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' global option ' . cfgOptionName(CFGOPT_RECOVERY_OPTION)))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_RESTORE}{&OPTION_RESTORE_RECOVERY_OPTION} =
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_RESTORE)}{cfgOptionName(CFGOPT_RECOVERY_OPTION)} =
'archive-command=/path/to/pgbackrest';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_RESTORE);
$self->optionTestExpect(OPTION_RESTORE_RECOVERY_OPTION, '/path/to/pgbackrest', 'archive-command');
$self->configTestLoadExpect(cfgCommandName(CFGCMD_RESTORE));
$self->optionTestExpect(CFGOPT_RECOVERY_OPTION, '/path/to/pgbackrest', 'archive-command');
}
if ($self->begin(CMD_RESTORE . ' stanza option ' . OPTION_RESTORE_RECOVERY_OPTION))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' stanza option ' . cfgOptionName(CFGOPT_RECOVERY_OPTION)))
{
$oConfig = {};
$$oConfig{$self->stanza()}{&OPTION_RESTORE_RECOVERY_OPTION} = ['standby-mode=on', 'a=b'];
$$oConfig{$self->stanza()}{cfgOptionName(CFGOPT_RECOVERY_OPTION)} = ['standby-mode=on', 'a=b'];
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_RESTORE);
$self->optionTestExpect(OPTION_RESTORE_RECOVERY_OPTION, 'b', 'a');
$self->optionTestExpect(OPTION_RESTORE_RECOVERY_OPTION, 'on', 'standby-mode');
$self->configTestLoadExpect(cfgCommandName(CFGCMD_RESTORE));
$self->optionTestExpect(CFGOPT_RECOVERY_OPTION, 'b', 'a');
$self->optionTestExpect(CFGOPT_RECOVERY_OPTION, 'on', 'standby-mode');
}
if ($self->begin(CMD_BACKUP . ' option ' . OPTION_DB_PATH))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' option ' . cfgOptionName(CFGOPT_DB_PATH)))
{
$oConfig = {};
$$oConfig{$self->stanza()}{&OPTION_DB_PATH} = '/path/to/db';
$$oConfig{$self->stanza()}{cfgOptionName(CFGOPT_DB_PATH)} = '/path/to/db';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_DB_PATH, '/path/to/db');
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_DB_PATH, '/path/to/db');
}
if ($self->begin(CMD_BACKUP . ' option ' . OPTION_BACKUP_ARCHIVE_CHECK))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' option ' . cfgOptionName(CFGOPT_ARCHIVE_CHECK)))
{
$oConfig = {};
$$oConfig{$self->stanza()}{&OPTION_DB_PATH} = '/path/to/db';
$$oConfig{$self->stanza()}{cfgOptionName(CFGOPT_DB_PATH)} = '/path/to/db';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionBoolSetTest($oOption, OPTION_BACKUP_ARCHIVE_CHECK, false);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->optionTestSetBool(CFGOPT_ARCHIVE_CHECK, false);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_ONLINE, true);
$self->optionTestExpect(OPTION_BACKUP_ARCHIVE_CHECK, false);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_ONLINE, true);
$self->optionTestExpect(CFGOPT_ARCHIVE_CHECK, false);
}
if ($self->begin(CMD_ARCHIVE_PUSH . ' option ' . OPTION_DB_PATH))
if ($self->begin(cfgCommandName(CFGCMD_ARCHIVE_PUSH) . ' option ' . cfgOptionName(CFGOPT_DB_PATH)))
{
$oConfig = {};
$$oConfig{$self->stanza()}{&OPTION_DB_PATH} = '/path/to/db';
$$oConfig{$self->stanza()}{cfgOptionName(CFGOPT_DB_PATH)} = '/path/to/db';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_ARCHIVE_PUSH);
$self->optionTestExpect(OPTION_DB_PATH, '/path/to/db');
$self->configTestLoadExpect(cfgCommandName(CFGCMD_ARCHIVE_PUSH));
$self->optionTestExpect(CFGOPT_DB_PATH, '/path/to/db');
}
if ($self->begin(CMD_BACKUP . ' option ' . OPTION_REPO_PATH))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' option ' . cfgOptionName(CFGOPT_REPO_PATH)))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_REPO_PATH} = '/repo';
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_REPO_PATH)} = '/repo';
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_REPO_PATH, '/repo');
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_REPO_PATH, '/repo');
}
if ($self->begin(CMD_BACKUP . ' option ' . OPTION_REPO_PATH . ' multiple times'))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' option ' . cfgOptionName(CFGOPT_REPO_PATH) . ' multiple times'))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_REPO_PATH} = ['/repo', '/repo2'];
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_REPO_PATH)} = ['/repo', '/repo2'];
storageTest()->put($strConfigFile, iniRender($oConfig, true));
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_CONFIG, $strConfigFile);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_MULTIPLE_VALUE, OPTION_REPO_PATH);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_MULTIPLE_VALUE, cfgOptionName(CFGOPT_REPO_PATH));
}
}

View File

@@ -26,325 +26,337 @@ sub run
{
my $self = shift;
my $oOption = {};
my @oyArray;
if ($self->begin('backup with no stanza'))
{
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_REQUIRED, OPTION_STANZA);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_REQUIRED, cfgOptionName(CFGOPT_STANZA));
}
if ($self->begin('backup with boolean stanza'))
{
$self->optionBoolSetTest($oOption, OPTION_STANZA);
$self->optionTestSetBool(CFGOPT_STANZA);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_COMMAND_REQUIRED);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP), ERROR_COMMAND_REQUIRED);
}
if ($self->begin('backup type defaults to ' . BACKUP_TYPE_INCR))
if ($self->begin('backup type defaults to ' . CFGOPTVAL_BACKUP_TYPE_INCR))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_TYPE, BACKUP_TYPE_INCR);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_TYPE, CFGOPTVAL_BACKUP_TYPE_INCR);
}
if ($self->begin(CMD_BACKUP . ' invalid option ' . OPTION_ARCHIVE_ASYNC))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' invalid option ' . cfgOptionName(CFGOPT_ARCHIVE_ASYNC)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionBoolSetTest($oOption, OPTION_ARCHIVE_ASYNC);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSetBool(CFGOPT_ARCHIVE_ASYNC);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_COMMAND, OPTION_ARCHIVE_ASYNC, CMD_BACKUP);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_COMMAND, cfgOptionName(CFGOPT_ARCHIVE_ASYNC),
cfgCommandName(CFGCMD_BACKUP));
}
if ($self->begin('backup type set to ' . BACKUP_TYPE_FULL))
if ($self->begin('backup type set to ' . CFGOPTVAL_BACKUP_TYPE_FULL))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_TYPE, BACKUP_TYPE_FULL);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_TYPE, CFGOPTVAL_BACKUP_TYPE_FULL);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_TYPE, BACKUP_TYPE_FULL);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_TYPE, CFGOPTVAL_BACKUP_TYPE_FULL);
}
if ($self->begin('backup type invalid'))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_TYPE, BOGUS);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_TYPE, BOGUS);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_TYPE);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID_VALUE, BOGUS, cfgOptionName(CFGOPT_TYPE));
}
if ($self->begin('backup invalid force'))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionBoolSetTest($oOption, OPTION_FORCE);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSetBool(CFGOPT_FORCE);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID, OPTION_FORCE, 'no-' . OPTION_ONLINE);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID, cfgOptionName(CFGOPT_FORCE), 'no-' . cfgOptionName(CFGOPT_ONLINE));
}
if ($self->begin('backup valid force'))
{
# $oOption = {};
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionBoolSetTest($oOption, OPTION_ONLINE, false);
$self->optionBoolSetTest($oOption, OPTION_FORCE);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSetBool(CFGOPT_ONLINE, false);
$self->optionTestSetBool(CFGOPT_FORCE);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_ONLINE, false);
$self->optionTestExpect(OPTION_FORCE, true);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_ONLINE, false);
$self->optionTestExpect(CFGOPT_FORCE, true);
}
if ($self->begin('backup invalid value for ' . OPTION_TEST_DELAY))
if ($self->begin('backup invalid value for ' . cfgOptionName(CFGOPT_TEST_DELAY)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionBoolSetTest($oOption, OPTION_TEST);
$self->optionSetTest($oOption, OPTION_TEST_DELAY, BOGUS);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSetBool(CFGOPT_TEST);
$self->optionTestSet(CFGOPT_TEST_DELAY, BOGUS);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_TEST_DELAY);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID_VALUE, BOGUS, cfgOptionName(CFGOPT_TEST_DELAY));
}
if ($self->begin('backup invalid ' . OPTION_TEST_DELAY))
if ($self->begin('backup invalid ' . cfgOptionName(CFGOPT_TEST_DELAY)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_TEST_DELAY, 5);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_TEST_DELAY, 5);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID, OPTION_TEST_DELAY, OPTION_TEST);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID, cfgOptionName(CFGOPT_TEST_DELAY), cfgOptionName(CFGOPT_TEST));
}
if ($self->begin('backup check ' . OPTION_TEST_DELAY . ' undef'))
if ($self->begin('backup check ' . cfgOptionName(CFGOPT_TEST_DELAY) . ' undef'))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_TEST_DELAY);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_TEST_DELAY);
}
if ($self->begin('restore invalid ' . OPTION_TARGET))
if ($self->begin('restore invalid ' . cfgOptionName(CFGOPT_TARGET)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_TYPE, RECOVERY_TYPE_DEFAULT);
$self->optionSetTest($oOption, OPTION_TARGET, BOGUS);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_TYPE, cfgRuleOptionDefault(CFGCMD_RESTORE, CFGOPT_TYPE));
$self->optionTestSet(CFGOPT_TARGET, BOGUS);
@oyArray = (RECOVERY_TYPE_NAME, RECOVERY_TYPE_TIME, RECOVERY_TYPE_XID);
$self->configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID, OPTION_TARGET, OPTION_TYPE, \@oyArray);
@oyArray = (CFGOPTVAL_RESTORE_TYPE_NAME, CFGOPTVAL_RESTORE_TYPE_TIME, CFGOPTVAL_RESTORE_TYPE_XID);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_RESTORE), ERROR_OPTION_INVALID, cfgOptionName(CFGOPT_TARGET),
cfgOptionName(CFGOPT_TYPE), \@oyArray);
}
if ($self->begin('restore ' . OPTION_TARGET))
if ($self->begin('restore ' . cfgOptionName(CFGOPT_TARGET)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_TYPE, RECOVERY_TYPE_NAME);
$self->optionSetTest($oOption, OPTION_TARGET, BOGUS);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_TYPE, CFGOPTVAL_RESTORE_TYPE_NAME);
$self->optionTestSet(CFGOPT_TARGET, BOGUS);
$self->configLoadExpect($oOption, CMD_RESTORE);
$self->optionTestExpect(OPTION_TYPE, RECOVERY_TYPE_NAME);
$self->optionTestExpect(OPTION_TARGET, BOGUS);
$self->optionTestExpect(OPTION_TARGET_TIMELINE);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_RESTORE));
$self->optionTestExpect(CFGOPT_TYPE, CFGOPTVAL_RESTORE_TYPE_NAME);
$self->optionTestExpect(CFGOPT_TARGET, BOGUS);
$self->optionTestExpect(CFGOPT_TARGET_TIMELINE);
}
if ($self->begin('invalid string ' . OPTION_PROCESS_MAX))
if ($self->begin('invalid string ' . cfgOptionName(CFGOPT_PROCESS_MAX)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_PROCESS_MAX, BOGUS);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_PROCESS_MAX, BOGUS);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_PROCESS_MAX);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID_VALUE, BOGUS, cfgOptionName(CFGOPT_PROCESS_MAX));
}
if ($self->begin('invalid float ' . OPTION_PROCESS_MAX))
if ($self->begin('invalid float ' . cfgOptionName(CFGOPT_PROCESS_MAX)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_PROCESS_MAX, '0.0');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_PROCESS_MAX, '0.0');
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, '0.0', OPTION_PROCESS_MAX);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID_VALUE, '0.0', cfgOptionName(CFGOPT_PROCESS_MAX));
}
if ($self->begin('valid ' . OPTION_PROCESS_MAX))
if ($self->begin('valid ' . cfgOptionName(CFGOPT_PROCESS_MAX)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_PROCESS_MAX, '2');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_PROCESS_MAX, '2');
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
}
if ($self->begin('valid thread-max'))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, 'thread-max', '2');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSetByName('thread-max', '2');
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_PROCESS_MAX, 2);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_PROCESS_MAX, 2);
}
if ($self->begin('valid float ' . OPTION_TEST_DELAY))
if ($self->begin('valid float ' . cfgOptionName(CFGOPT_TEST_DELAY)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionBoolSetTest($oOption, OPTION_TEST);
$self->optionSetTest($oOption, OPTION_TEST_DELAY, '0.25');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSetBool(CFGOPT_TEST);
$self->optionTestSet(CFGOPT_TEST_DELAY, '0.25');
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
}
if ($self->begin('valid int ' . OPTION_TEST_DELAY))
if ($self->begin('valid int ' . cfgOptionName(CFGOPT_TEST_DELAY)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionBoolSetTest($oOption, OPTION_TEST);
$self->optionSetTest($oOption, OPTION_TEST_DELAY, 3);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSetBool(CFGOPT_TEST);
$self->optionTestSet(CFGOPT_TEST_DELAY, 3);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
}
if ($self->begin('restore valid ' . OPTION_TARGET_TIMELINE))
if ($self->begin('restore valid ' . cfgOptionName(CFGOPT_TARGET_TIMELINE)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_TARGET_TIMELINE, 2);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_TARGET_TIMELINE, 2);
$self->configLoadExpect($oOption, CMD_RESTORE);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_RESTORE));
}
if ($self->begin('invalid ' . OPTION_COMPRESS_LEVEL))
if ($self->begin('invalid ' . cfgOptionName(CFGOPT_COMPRESS_LEVEL)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_COMPRESS_LEVEL, '12');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_COMPRESS_LEVEL, '12');
$self->configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_RANGE, '12', OPTION_COMPRESS_LEVEL);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_RESTORE), ERROR_OPTION_INVALID_RANGE, '12', cfgOptionName(CFGOPT_COMPRESS_LEVEL));
}
if ($self->begin(CMD_BACKUP . ' invalid value ' . OPTION_RETENTION_ARCHIVE_TYPE))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' invalid value ' . cfgOptionName(CFGOPT_RETENTION_ARCHIVE_TYPE)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_RETENTION_ARCHIVE_TYPE, BOGUS);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_RETENTION_ARCHIVE_TYPE, BOGUS);
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_RETENTION_ARCHIVE_TYPE);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID_VALUE, BOGUS, cfgOptionName(CFGOPT_RETENTION_ARCHIVE_TYPE));
}
if ($self->begin(
CMD_BACKUP . ' default value ' . OPTION_DEFAULT_RETENTION_ARCHIVE_TYPE . ' for ' . OPTION_RETENTION_ARCHIVE_TYPE .
' with valid ' . OPTION_RETENTION_FULL))
cfgCommandName(CFGCMD_BACKUP) . ' default value ' . cfgRuleOptionDefault(CFGCMD_BACKUP, CFGOPT_RETENTION_ARCHIVE_TYPE) .
' for ' . cfgOptionName(CFGOPT_RETENTION_ARCHIVE_TYPE) . ' with valid ' . cfgOptionName(CFGOPT_RETENTION_FULL)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_RETENTION_FULL, 1);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_RETENTION_FULL, 1);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_RETENTION_ARCHIVE, 1);
$self->optionTestExpect(OPTION_RETENTION_FULL, 1);
$self->optionTestExpect(OPTION_RETENTION_DIFF, undef);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_RETENTION_ARCHIVE, 1);
$self->optionTestExpect(CFGOPT_RETENTION_FULL, 1);
$self->optionTestExpect(CFGOPT_RETENTION_DIFF, undef);
# Default is FULL so this test will fail if the default is changed, alerting to the need to update configLoad.
$self->optionTestExpect(OPTION_RETENTION_ARCHIVE_TYPE, BACKUP_TYPE_FULL);
$self->optionTestExpect(CFGOPT_RETENTION_ARCHIVE_TYPE, CFGOPTVAL_BACKUP_TYPE_FULL);
}
if ($self->begin(
CMD_BACKUP . ' valid value ' . OPTION_RETENTION_ARCHIVE . ' for ' . OPTION_RETENTION_ARCHIVE_TYPE . ' ' .
BACKUP_TYPE_DIFF))
cfgCommandName(CFGCMD_BACKUP) . ' valid value ' . cfgOptionName(CFGOPT_RETENTION_ARCHIVE) . ' for ' .
cfgOptionName(CFGOPT_RETENTION_ARCHIVE_TYPE) . ' ' . CFGOPTVAL_BACKUP_TYPE_DIFF))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_RETENTION_DIFF, 1);
$self->optionSetTest($oOption, OPTION_RETENTION_ARCHIVE_TYPE, BACKUP_TYPE_DIFF);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_RETENTION_DIFF, 1);
$self->optionTestSet(CFGOPT_RETENTION_ARCHIVE_TYPE, CFGOPTVAL_BACKUP_TYPE_DIFF);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_RETENTION_ARCHIVE, 1);
$self->optionTestExpect(OPTION_RETENTION_DIFF, 1);
$self->optionTestExpect(OPTION_RETENTION_FULL, undef);
$self->optionTestExpect(OPTION_RETENTION_ARCHIVE_TYPE, BACKUP_TYPE_DIFF);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_RETENTION_ARCHIVE, 1);
$self->optionTestExpect(CFGOPT_RETENTION_DIFF, 1);
$self->optionTestExpect(CFGOPT_RETENTION_FULL, undef);
$self->optionTestExpect(CFGOPT_RETENTION_ARCHIVE_TYPE, CFGOPTVAL_BACKUP_TYPE_DIFF);
}
if ($self->begin(
CMD_BACKUP . ' warn no valid value ' . OPTION_RETENTION_ARCHIVE . ' for ' . OPTION_RETENTION_ARCHIVE_TYPE . ' ' .
BACKUP_TYPE_INCR))
cfgCommandName(CFGCMD_BACKUP) . ' warn no valid value ' . cfgOptionName(CFGOPT_RETENTION_ARCHIVE) . ' for ' .
cfgOptionName(CFGOPT_RETENTION_ARCHIVE_TYPE) . ' ' . CFGOPTVAL_BACKUP_TYPE_INCR))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_RETENTION_FULL, 2);
$self->optionSetTest($oOption, OPTION_RETENTION_DIFF, 1);
$self->optionSetTest($oOption, OPTION_RETENTION_ARCHIVE_TYPE, BACKUP_TYPE_INCR);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_RETENTION_FULL, 2);
$self->optionTestSet(CFGOPT_RETENTION_DIFF, 1);
$self->optionTestSet(CFGOPT_RETENTION_ARCHIVE_TYPE, CFGOPTVAL_BACKUP_TYPE_INCR);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_RETENTION_ARCHIVE, undef);
$self->optionTestExpect(OPTION_RETENTION_ARCHIVE_TYPE, BACKUP_TYPE_INCR);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_RETENTION_ARCHIVE, undef);
$self->optionTestExpect(CFGOPT_RETENTION_ARCHIVE_TYPE, CFGOPTVAL_BACKUP_TYPE_INCR);
}
if ($self->begin(CMD_BACKUP . ' invalid value ' . OPTION_PROTOCOL_TIMEOUT))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' invalid value ' . cfgOptionName(CFGOPT_PROTOCOL_TIMEOUT)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_DB_TIMEOUT, 5);
$self->optionSetTest($oOption, OPTION_PROTOCOL_TIMEOUT, 4);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_DB_TIMEOUT, 5);
$self->optionTestSet(CFGOPT_PROTOCOL_TIMEOUT, 4);
$self->configLoadExpect(
$oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, 4, OPTION_PROTOCOL_TIMEOUT,
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_INVALID_VALUE, 4, cfgOptionName(CFGOPT_PROTOCOL_TIMEOUT),
"'protocol-timeout' option should be greater than 'db-timeout' option");
}
if ($self->begin(CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' invalid value ' . cfgOptionName(CFGOPT_RECOVERY_OPTION)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, '=');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_RECOVERY_OPTION, '=');
$self->configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, '=', OPTION_RESTORE_RECOVERY_OPTION);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_RESTORE), ERROR_OPTION_INVALID_PAIR, '=', cfgOptionName(CFGOPT_RECOVERY_OPTION));
}
if ($self->begin(CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' invalid value ' . cfgOptionName(CFGOPT_RECOVERY_OPTION)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, '=' . BOGUS);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_RECOVERY_OPTION, '=' . BOGUS);
$self->configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, '=' . BOGUS, OPTION_RESTORE_RECOVERY_OPTION);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_RESTORE), ERROR_OPTION_INVALID_PAIR, '=' . BOGUS, cfgOptionName(CFGOPT_RECOVERY_OPTION));
}
if ($self->begin(CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' invalid value ' . cfgOptionName(CFGOPT_RECOVERY_OPTION)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, BOGUS . '=');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_RECOVERY_OPTION, BOGUS . '=');
$self->configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, BOGUS . '=', OPTION_RESTORE_RECOVERY_OPTION);
$self->configTestLoadExpect(
cfgCommandName(CFGCMD_RESTORE), ERROR_OPTION_INVALID_PAIR, BOGUS . '=', cfgOptionName(CFGOPT_RECOVERY_OPTION));
}
if ($self->begin(CMD_RESTORE . ' valid value ' . OPTION_RESTORE_RECOVERY_OPTION))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' valid value ' . cfgOptionName(CFGOPT_RECOVERY_OPTION)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, 'primary-conn-info=db.domain.net');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_RECOVERY_OPTION, 'primary-conn-info=db.domain.net');
$self->configLoadExpect($oOption, CMD_RESTORE);
$self->optionTestExpect(OPTION_RESTORE_RECOVERY_OPTION, 'db.domain.net', 'primary-conn-info');
$self->configTestLoadExpect(cfgCommandName(CFGCMD_RESTORE));
$self->optionTestExpect(&CFGOPT_RECOVERY_OPTION, 'db.domain.net', 'primary-conn-info');
}
if ($self->begin(CMD_RESTORE . ' values passed to ' . CMD_ARCHIVE_GET))
if ($self->begin(cfgCommandName(CFGCMD_RESTORE) . ' values passed to ' . cfgCommandName(CFGCMD_ARCHIVE_GET)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db path/main');
$self->optionSetTest($oOption, OPTION_REPO_PATH, '/repo');
$self->optionSetTest($oOption, OPTION_BACKUP_HOST, 'db.mydomain.com');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db path/main');
$self->optionTestSet(CFGOPT_REPO_PATH, '/repo');
$self->optionTestSet(CFGOPT_BACKUP_HOST, 'db.mydomain.com');
$self->configLoadExpect($oOption, CMD_RESTORE);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_RESTORE));
my $strCommand = commandWrite(CMD_ARCHIVE_GET);
my $strExpectedCommand = abs_path($0) . " --backup-host=db.mydomain.com \"--db-path=/db path/main\"" .
" --repo-path=/repo --stanza=app " . CMD_ARCHIVE_GET;
my $strCommand = cfgCommandWrite(CFGCMD_ARCHIVE_GET);
my $strExpectedCommand = abs_path($0) . " --backup-host=db.mydomain.com \"--db1-path=/db path/main\"" .
" --repo-path=/repo --stanza=app " . cfgCommandName(CFGCMD_ARCHIVE_GET);
if ($strCommand ne $strExpectedCommand)
{
@@ -352,31 +364,31 @@ sub run
}
}
if ($self->begin(CMD_BACKUP . ' default value ' . OPTION_DB_CMD))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' default value ' . cfgOptionName(CFGOPT_DB_CMD)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_HOST, 'db');
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_HOST, 'db');
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_DB_CMD, abs_path($0));
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_DB_CMD, abs_path($0));
}
if ($self->begin(CMD_BACKUP . ' missing option ' . OPTION_DB_PATH))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' missing option ' . cfgOptionName(CFGOPT_DB_PATH)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_REQUIRED, OPTION_DB_PATH, 'does this stanza exist?');
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP), ERROR_OPTION_REQUIRED, 'db1-path', 'does this stanza exist?');
}
if ($self->begin(CMD_BACKUP . ' automatically increase ' . OPTION_PROTOCOL_TIMEOUT))
if ($self->begin(cfgCommandName(CFGCMD_BACKUP) . ' automatically increase ' . cfgOptionName(CFGOPT_PROTOCOL_TIMEOUT)))
{
$self->optionSetTest($oOption, OPTION_STANZA, $self->stanza());
$self->optionSetTest($oOption, OPTION_DB_PATH, '/db');
$self->optionSetTest($oOption, OPTION_DB_TIMEOUT, OPTION_DEFAULT_PROTOCOL_TIMEOUT + 30);
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
$self->optionTestSet(CFGOPT_DB_PATH, '/db');
$self->optionTestSet(CFGOPT_DB_TIMEOUT, cfgRuleOptionDefault(CFGCMD_BACKUP, CFGOPT_PROTOCOL_TIMEOUT) + 30);
$self->configLoadExpect($oOption, CMD_BACKUP);
$self->optionTestExpect(OPTION_PROTOCOL_TIMEOUT, OPTION_DEFAULT_PROTOCOL_TIMEOUT + 60);
$self->configTestLoadExpect(cfgCommandName(CFGCMD_BACKUP));
$self->optionTestExpect(CFGOPT_PROTOCOL_TIMEOUT, cfgRuleOptionDefault(CFGCMD_BACKUP, CFGOPT_PROTOCOL_TIMEOUT) + 60);
}
}

View File

@@ -27,78 +27,86 @@ sub run
my $oConfig = {};
my $strConfigFile = $self->testPath() . '/pgbackrest.conf';
optionSet(OPTION_CONFIG, $strConfigFile, true);
commandSet(CMD_ARCHIVE_GET);
cfgCommandSet(CFGCMD_ARCHIVE_GET);
cfgOptionSet(CFGOPT_CONFIG, $strConfigFile, true);
if ($self->begin('Config::configFileValidate()'))
{
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_DB_PORT} = 1234;
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_DB_PORT)} = 1234;
$self->testResult(sub {configFileValidate($oConfig)}, false,
'valid option ' . OPTION_DB_PORT . ' under invalid section',
$self->testResult(sub {pgBackRest::Config::Config::configFileValidate($oConfig)}, false,
'valid option ' . cfgOptionName(CFGOPT_DB_PORT) . ' under invalid section',
{strLogExpect =>
"WARN: $strConfigFile valid option '" . OPTION_DB_PORT . "' is a stanza section option and is not valid in" .
" section " . CONFIG_SECTION_GLOBAL . "\nHINT: global options can be specified in global or stanza sections but" .
" not visa-versa"});
"WARN: $strConfigFile valid option '" . cfgOptionName(CFGOPT_DB_PORT) . "' is a stanza section option and is not" .
" valid in section " . CFGDEF_SECTION_GLOBAL . "\n" .
"HINT: global options can be specified in global or stanza sections but not visa-versa"});
#---------------------------------------------------------------------------------------------------------------------------
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_BACKUP}{&OPTION_DB_PORT} = 1234;
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_BACKUP)}{cfgOptionName(CFGOPT_DB_PORT)} = 1234;
$self->testResult(sub {configFileValidate($oConfig)}, false,
'valid option ' . OPTION_DB_PORT . ' for command ' . CMD_BACKUP . ' under invalid global section',
$self->testResult(sub {pgBackRest::Config::Config::configFileValidate($oConfig)}, false,
'valid option ' . cfgOptionName(CFGOPT_DB_PORT) . ' for command ' . cfgCommandName(CFGCMD_BACKUP) .
' under invalid global section',
{strLogExpect =>
"WARN: $strConfigFile valid option '" . OPTION_DB_PORT . "' is a stanza section option and is not valid in" .
" section " . CONFIG_SECTION_GLOBAL ."\nHINT: global options can be specified in global or stanza sections but" .
" not visa-versa"});
"WARN: $strConfigFile valid option '" . cfgOptionName(CFGOPT_DB_PORT) . "' is a stanza section option and is not" .
" valid in section " . CFGDEF_SECTION_GLOBAL . "\n" .
"HINT: global options can be specified in global or stanza sections but not visa-versa"});
#---------------------------------------------------------------------------------------------------------------------------
$oConfig = {};
$$oConfig{$self->stanza() . ':' . &CMD_ARCHIVE_PUSH}{&OPTION_DB_PORT} = 1234;
$$oConfig{$self->stanza() . ':' . cfgCommandName(CFGCMD_ARCHIVE_PUSH)}{cfgOptionName(CFGOPT_DB_PORT)} = 1234;
$self->testResult(sub {configFileValidate($oConfig)}, false,
'valid option ' . OPTION_DB_PORT . ' under invalid stanza section command',
$self->testResult(sub {pgBackRest::Config::Config::configFileValidate($oConfig)}, false,
'valid option ' . cfgOptionName(CFGOPT_DB_PORT) . ' under invalid stanza section command',
{strLogExpect =>
"WARN: $strConfigFile valid option '" . OPTION_DB_PORT . "' is not valid for command '" . CMD_ARCHIVE_PUSH ."'"});
"WARN: $strConfigFile valid option '" . cfgOptionName(CFGOPT_DB_PORT) . "' is not valid for command '" .
cfgCommandName(CFGCMD_ARCHIVE_PUSH) ."'"});
#---------------------------------------------------------------------------------------------------------------------------
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&BOGUS} = BOGUS;
$$oConfig{&CFGDEF_SECTION_GLOBAL}{&BOGUS} = BOGUS;
$self->testResult(sub {configFileValidate($oConfig)}, false, 'invalid option ' . $$oConfig{&CONFIG_SECTION_GLOBAL}{&BOGUS},
$self->testResult(
sub {pgBackRest::Config::Config::configFileValidate($oConfig)}, false,
'invalid option ' . $$oConfig{&CFGDEF_SECTION_GLOBAL}{&BOGUS},
{strLogExpect => "WARN: $strConfigFile file contains invalid option '" . BOGUS . "'"});
#---------------------------------------------------------------------------------------------------------------------------
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{'thread-max'} = 3;
$$oConfig{&CFGDEF_SECTION_GLOBAL}{'thread-max'} = 3;
$self->testResult(sub {configFileValidate($oConfig)}, true, 'valid alt name found');
$self->testResult(sub {pgBackRest::Config::Config::configFileValidate($oConfig)}, true, 'valid alt name found');
#---------------------------------------------------------------------------------------------------------------------------
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_LOG_LEVEL_STDERR} = OPTION_DEFAULT_LOG_LEVEL_STDERR;
$$oConfig{$self->stanza()}{&OPTION_DB_PATH} = '/db';
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_ARCHIVE_PUSH}{&OPTION_PROCESS_MAX} = 2;
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_LOG_LEVEL_STDERR)} =
cfgRuleOptionDefault(CFGCMD_ARCHIVE_PUSH, CFGOPT_LOG_LEVEL_STDERR);
$$oConfig{$self->stanza()}{cfgOptionName(CFGOPT_DB_PATH)} = '/db';
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_ARCHIVE_PUSH)}{cfgOptionName(CFGOPT_PROCESS_MAX)} = 2;
$self->testResult(sub {configFileValidate($oConfig)}, true, 'valid config file');
$self->testResult(sub {pgBackRest::Config::Config::configFileValidate($oConfig)}, true, 'valid config file');
#---------------------------------------------------------------------------------------------------------------------------
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&OPTION_LOG_LEVEL_STDERR} = OPTION_DEFAULT_LOG_LEVEL_STDERR;
$$oConfig{&CONFIG_SECTION_GLOBAL . ':' . &CMD_ARCHIVE_PUSH}{&OPTION_PROCESS_MAX} = 2;
$$oConfig{'unusual-section^name!:' . &CMD_CHECK}{&OPTION_DB_PATH} = '/db';
$$oConfig{&CFGDEF_SECTION_GLOBAL}{cfgOptionName(CFGOPT_LOG_LEVEL_STDERR)} =
cfgRuleOptionDefault(CFGCMD_ARCHIVE_PUSH, CFGOPT_LOG_LEVEL_STDERR);
$$oConfig{&CFGDEF_SECTION_GLOBAL . ':' . cfgCommandName(CFGCMD_ARCHIVE_PUSH)}{cfgOptionName(CFGOPT_PROCESS_MAX)} = 2;
$$oConfig{'unusual-section^name!:' . cfgCommandName(CFGCMD_CHECK)}{cfgOptionName(CFGOPT_DB_PATH)} = '/db';
$self->testResult(sub {configFileValidate($oConfig)}, true, 'valid unusual section name');
$self->testResult(sub {pgBackRest::Config::Config::configFileValidate($oConfig)}, true, 'valid unusual section name');
#---------------------------------------------------------------------------------------------------------------------------
$oConfig = {};
$$oConfig{&CONFIG_SECTION_GLOBAL}{&BOGUS} = BOGUS;
$$oConfig{&CFGDEF_SECTION_GLOBAL}{&BOGUS} = BOGUS;
# Change command to indicate remote
commandSet(CMD_REMOTE);
cfgCommandSet(CFGCMD_REMOTE);
$self->testResult(sub {configFileValidate($oConfig)}, true, 'invalid option but config file not validated on remote');
$self->testResult(
sub {pgBackRest::Config::Config::configFileValidate($oConfig)}, true,
'invalid option but config file not validated on remote');
}
}