You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-05-22 10:15:16 +02:00
Closed #207: Expire fails with unhandled exception.
* Fixed an issue where the expire command would refuse to run when explicitly called from the command line if the db-host option was set. This was not an issue when expire was run after a backup, which is the usual case. * Option handling is now far more strict. Previously it was possible for a command to use an option that was not explicitly assigned to it. This was especially true for the backup-host and db-host options which are used to determine locality. Reported by Chris Barber.
This commit is contained in:
@@ -1932,11 +1932,13 @@ push @EXPORT, qw(BackRestTestBackup_Expire);
|
||||
|
||||
sub BackRestTestBackup_Expire
|
||||
{
|
||||
my $bRemote = shift;
|
||||
my $strStanza = shift;
|
||||
my $strComment = shift;
|
||||
my $oFile = shift;
|
||||
my $iExpireFull = shift;
|
||||
my $iExpireDiff = shift;
|
||||
my $iExpectedExitStatus = shift;
|
||||
|
||||
$strComment = 'expire' .
|
||||
(defined($iExpireFull) ? " full=$iExpireFull" : '') .
|
||||
@@ -1946,7 +1948,8 @@ sub BackRestTestBackup_Expire
|
||||
&log(INFO, " ${strComment}");
|
||||
|
||||
my $strCommand = BackRestTestCommon_CommandMainGet() . ' --config=' . BackRestTestCommon_DbPathGet() .
|
||||
"/pgbackrest.conf --stanza=${strStanza} expire --log-level-console=detail";
|
||||
' --config=' . ($bRemote ? BackRestTestCommon_RepoPathGet() : BackRestTestCommon_DbPathGet()) . '/pgbackrest.conf' .
|
||||
" --stanza=${strStanza} expire --log-level-console=detail";
|
||||
|
||||
if (defined($iExpireFull))
|
||||
{
|
||||
@@ -1958,8 +1961,7 @@ sub BackRestTestBackup_Expire
|
||||
$strCommand .= ' --retention-diff=' . $iExpireDiff;
|
||||
}
|
||||
|
||||
executeTest($strCommand, {oLogTest => $oBackupLogTest,
|
||||
iExpectedExitStatus => $bBackupRemote ? ERROR_HOST_INVALID : undef});
|
||||
executeTest($strCommand, {bRemote => $bRemote, oLogTest => $oBackupLogTest, iExpectedExitStatus => $iExpectedExitStatus});
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@@ -1536,7 +1536,8 @@ sub BackRestTestBackup_Test
|
||||
|
||||
# Call expire
|
||||
#-----------------------------------------------------------------------------------------------------------------------
|
||||
BackRestTestBackup_Expire($strStanza, undef, $oFile, 1);
|
||||
BackRestTestBackup_Expire($bRemote && !$bCompress, $strStanza, undef, $oFile, 1, undef,
|
||||
$bRemote && $bCompress ? ERROR_HOST_INVALID : undef);
|
||||
|
||||
# Diff Backup
|
||||
#-----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -366,6 +366,7 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, 'restore invalid ' . OPTION_TARGET))
|
||||
{
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_TYPE, RECOVERY_TYPE_DEFAULT);
|
||||
optionSetTest($oOption, OPTION_TARGET, BOGUS);
|
||||
|
||||
@@ -376,6 +377,7 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, 'restore ' . OPTION_TARGET))
|
||||
{
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_TYPE, RECOVERY_TYPE_NAME);
|
||||
optionSetTest($oOption, OPTION_TARGET, BOGUS);
|
||||
|
||||
@@ -435,6 +437,7 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, 'restore valid ' . OPTION_TARGET_TIMELINE))
|
||||
{
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_TARGET_TIMELINE, 2);
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE);
|
||||
@@ -482,6 +485,7 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
|
||||
{
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, '=');
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, '=', OPTION_RESTORE_RECOVERY_OPTION);
|
||||
@@ -490,6 +494,7 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
|
||||
{
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, '=' . BOGUS);
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, '=' . BOGUS, OPTION_RESTORE_RECOVERY_OPTION);
|
||||
@@ -498,6 +503,7 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
|
||||
{
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, BOGUS . '=');
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, BOGUS . '=', OPTION_RESTORE_RECOVERY_OPTION);
|
||||
@@ -506,6 +512,7 @@ sub BackRestTestConfig_Test
|
||||
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' valid value ' . OPTION_RESTORE_RECOVERY_OPTION))
|
||||
{
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, 'primary-conn-info=db.domain.net');
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE);
|
||||
@@ -720,6 +727,7 @@ sub BackRestTestConfig_Test
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE);
|
||||
@@ -767,6 +775,7 @@ sub BackRestTestConfig_Test
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_VALUE, 'bogus=', OPTION_RESTORE_RECOVERY_OPTION);
|
||||
@@ -779,6 +788,7 @@ sub BackRestTestConfig_Test
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_VALUE, '=bogus', OPTION_RESTORE_RECOVERY_OPTION);
|
||||
@@ -792,6 +802,7 @@ sub BackRestTestConfig_Test
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE);
|
||||
@@ -805,6 +816,7 @@ sub BackRestTestConfig_Test
|
||||
iniSave($strConfigFile, $oConfig, true);
|
||||
|
||||
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
||||
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
||||
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
||||
|
||||
configLoadExpect($oOption, CMD_RESTORE);
|
||||
|
||||
Reference in New Issue
Block a user