2015-03-08 19:26:09 +02:00
|
|
|
####################################################################################################################################
|
2015-10-28 11:10:36 +02:00
|
|
|
# ConfigTest.pm - Unit Tests for BackRest::Param and BackRest::Config::Config
|
2015-03-08 19:26:09 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
package BackRestTest::ConfigTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
use Cwd qw(abs_path);
|
2015-06-14 00:25:49 +02:00
|
|
|
use Exporter qw(import);
|
|
|
|
use File::Basename qw(dirname);
|
2015-08-05 14:43:41 +02:00
|
|
|
use Scalar::Util qw(blessed);
|
2015-03-08 19:26:09 +02:00
|
|
|
|
|
|
|
use lib dirname($0) . '/../lib';
|
2015-08-29 20:20:46 +02:00
|
|
|
use BackRest::Common::Exception;
|
|
|
|
use BackRest::Common::Ini;
|
|
|
|
use BackRest::Common::Log;
|
2015-09-08 13:31:24 +02:00
|
|
|
use BackRest::Config::Config;
|
2015-03-08 19:26:09 +02:00
|
|
|
|
|
|
|
use BackRestTest::CommonTest;
|
|
|
|
|
|
|
|
sub optionSetTest
|
|
|
|
{
|
|
|
|
my $oOption = shift;
|
|
|
|
my $strKey = shift;
|
|
|
|
my $strValue = shift;
|
|
|
|
|
|
|
|
$$oOption{option}{$strKey} = $strValue;
|
|
|
|
}
|
|
|
|
|
2016-01-04 03:24:14 +02:00
|
|
|
sub optionBoolSetTest
|
2015-03-08 19:26:09 +02:00
|
|
|
{
|
|
|
|
my $oOption = shift;
|
|
|
|
my $strKey = shift;
|
2015-03-12 18:15:19 +02:00
|
|
|
my $bValue = shift;
|
2015-03-08 19:26:09 +02:00
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
$$oOption{boolean}{$strKey} = defined($bValue) ? $bValue : true;
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
sub commandSetTest
|
2015-03-08 19:26:09 +02:00
|
|
|
{
|
|
|
|
my $oOption = shift;
|
2015-06-18 22:55:09 +02:00
|
|
|
my $strCommand = shift;
|
2015-03-08 19:26:09 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
$$oOption{command} = $strCommand;
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub optionRemoveTest
|
|
|
|
{
|
|
|
|
my $oOption = shift;
|
|
|
|
my $strKey = shift;
|
|
|
|
|
|
|
|
delete($$oOption{option}{$strKey});
|
|
|
|
delete($$oOption{boolean}{$strKey});
|
|
|
|
}
|
|
|
|
|
|
|
|
sub argvWriteTest
|
|
|
|
{
|
|
|
|
my $oOption = shift;
|
|
|
|
|
|
|
|
@ARGV = ();
|
|
|
|
|
|
|
|
if (defined($$oOption{boolean}))
|
|
|
|
{
|
2015-06-21 18:06:13 +02:00
|
|
|
foreach my $strKey (keys(%{$$oOption{boolean}}))
|
2015-03-08 19:26:09 +02:00
|
|
|
{
|
|
|
|
if ($$oOption{boolean}{$strKey})
|
|
|
|
{
|
|
|
|
$ARGV[@ARGV] = "--${strKey}";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$ARGV[@ARGV] = "--no-${strKey}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined($$oOption{option}))
|
|
|
|
{
|
2015-06-21 18:06:13 +02:00
|
|
|
foreach my $strKey (keys(%{$$oOption{option}}))
|
2015-03-08 19:26:09 +02:00
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
$ARGV[@ARGV] = "--${strKey}=$$oOption{option}{$strKey}";
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
$ARGV[@ARGV] = $$oOption{command};
|
2015-03-08 19:26:09 +02:00
|
|
|
|
|
|
|
&log(INFO, " command line: " . join(" ", @ARGV));
|
|
|
|
|
|
|
|
%$oOption = ();
|
|
|
|
}
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
sub configLoadExpect
|
2015-03-08 19:26:09 +02:00
|
|
|
{
|
|
|
|
my $oOption = shift;
|
2015-06-18 22:55:09 +02:00
|
|
|
my $strCommand = shift;
|
2015-03-08 19:26:09 +02:00
|
|
|
my $iExpectedError = shift;
|
|
|
|
my $strErrorParam1 = shift;
|
|
|
|
my $strErrorParam2 = shift;
|
|
|
|
my $strErrorParam3 = shift;
|
|
|
|
|
|
|
|
my $oOptionRuleExpected = optionRuleGet();
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
commandSetTest($oOption, $strCommand);
|
2015-03-08 19:26:09 +02:00
|
|
|
argvWriteTest($oOption);
|
|
|
|
|
|
|
|
eval
|
|
|
|
{
|
|
|
|
configLoad();
|
|
|
|
};
|
|
|
|
|
|
|
|
if ($@)
|
|
|
|
{
|
|
|
|
if (!defined($iExpectedError))
|
|
|
|
{
|
|
|
|
confess $@;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $oMessage = $@;
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
if (blessed($oMessage) && $oMessage->isa('BackRest::Common::Exception'))
|
2015-03-08 19:26:09 +02:00
|
|
|
{
|
|
|
|
if ($oMessage->code() != $iExpectedError)
|
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
confess "expected error ${iExpectedError} from configLoad but got " . $oMessage->code() .
|
|
|
|
" '" . $oMessage->message() . "'";
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
my $strError;
|
|
|
|
|
|
|
|
if ($iExpectedError == ERROR_OPTION_REQUIRED)
|
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
$strError = "${strCommand} command requires option: ${strErrorParam1}" .
|
2015-05-29 02:52:42 +02:00
|
|
|
(defined($strErrorParam2) ? "\nHINT: ${strErrorParam2}" : '');
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
2015-06-18 22:55:09 +02:00
|
|
|
elsif ($iExpectedError == ERROR_COMMAND_REQUIRED)
|
2015-03-08 19:26:09 +02:00
|
|
|
{
|
2015-06-18 22:55:09 +02:00
|
|
|
$strError = "command must be specified";
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
elsif ($iExpectedError == ERROR_OPTION_INVALID)
|
|
|
|
{
|
|
|
|
$strError = "option '${strErrorParam1}' not valid without option '${strErrorParam2}'";
|
|
|
|
|
|
|
|
if (defined($strErrorParam3))
|
|
|
|
{
|
|
|
|
$strError .= @{$strErrorParam3} == 1 ? " = '$$strErrorParam3[0]'" :
|
|
|
|
" in ('" . join("', '",@{ $strErrorParam3}) . "')";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($iExpectedError == ERROR_OPTION_INVALID_VALUE)
|
|
|
|
{
|
|
|
|
$strError = "'${strErrorParam1}' is not valid for '${strErrorParam2}' option";
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
elsif ($iExpectedError == ERROR_OPTION_INVALID_RANGE)
|
|
|
|
{
|
|
|
|
$strError = "'${strErrorParam1}' is not valid for '${strErrorParam2}' option";
|
|
|
|
}
|
|
|
|
elsif ($iExpectedError == ERROR_OPTION_INVALID_PAIR)
|
|
|
|
{
|
|
|
|
$strError = "'${strErrorParam1}' not valid key/value for '${strErrorParam2}' option";
|
|
|
|
}
|
|
|
|
elsif ($iExpectedError == ERROR_OPTION_NEGATE)
|
|
|
|
{
|
|
|
|
$strError = "option '${strErrorParam1}' cannot be both set and negated";
|
|
|
|
}
|
|
|
|
elsif ($iExpectedError == ERROR_FILE_INVALID)
|
|
|
|
{
|
|
|
|
$strError = "'${strErrorParam1}' is not a file";
|
|
|
|
}
|
2015-03-08 19:26:09 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
confess "must construct message for error ${iExpectedError}, use this as an example: '" . $oMessage->message() . "'";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($oMessage->message() ne $strError)
|
|
|
|
{
|
|
|
|
confess "expected error message \"${strError}\" from configLoad but got \"" . $oMessage->message() . "\"";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
confess "configLoad should throw BackRest::Common::Exception:\n$oMessage";
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (defined($iExpectedError))
|
|
|
|
{
|
|
|
|
confess "expected error ${iExpectedError} from configLoad but got success";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# cmp_deeply(OPTION_rule_get(), $oOptionRuleExpected, 'compare original and new rule hashes')
|
|
|
|
# or die 'comparison failed';
|
|
|
|
}
|
|
|
|
|
|
|
|
sub optionTestExpect
|
|
|
|
{
|
|
|
|
my $strOption = shift;
|
|
|
|
my $strExpectedValue = shift;
|
2015-03-12 18:15:19 +02:00
|
|
|
my $strExpectedKey = shift;
|
2015-03-08 19:26:09 +02:00
|
|
|
|
|
|
|
if (defined($strExpectedValue))
|
|
|
|
{
|
|
|
|
my $strActualValue = optionGet($strOption);
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
if (defined($strExpectedKey))
|
|
|
|
{
|
|
|
|
# use Data::Dumper;
|
|
|
|
# &log(INFO, Dumper($strActualValue));
|
|
|
|
# exit 0;
|
|
|
|
|
|
|
|
$strActualValue = $$strActualValue{$strExpectedKey};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!defined($strActualValue))
|
|
|
|
{
|
|
|
|
confess "expected option ${strOption} to have value ${strExpectedValue} but [undef] found instead";
|
|
|
|
}
|
|
|
|
|
2015-03-08 19:26:09 +02:00
|
|
|
$strActualValue eq $strExpectedValue
|
2015-03-12 18:15:19 +02:00
|
|
|
or confess "expected option ${strOption} to have value ${strExpectedValue} but ${strActualValue} found instead";
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
elsif (optionTest($strOption))
|
|
|
|
{
|
|
|
|
confess "expected option ${strOption} to be [undef], but " . optionGet($strOption) . ' found instead';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# BackRestTestConfig_Test
|
|
|
|
####################################################################################################################################
|
2015-06-14 00:25:49 +02:00
|
|
|
our @EXPORT = qw(BackRestTestConfig_Test);
|
|
|
|
|
2015-03-08 19:26:09 +02:00
|
|
|
sub BackRestTestConfig_Test
|
|
|
|
{
|
|
|
|
my $strTest = shift;
|
2016-01-14 05:43:26 +02:00
|
|
|
my $iThreadMax = shift;
|
|
|
|
my $bVmOut = shift;
|
2015-03-08 19:26:09 +02:00
|
|
|
|
|
|
|
# Setup test variables
|
|
|
|
my $iRun;
|
|
|
|
my $bCreate;
|
|
|
|
my $strStanza = 'main';
|
|
|
|
my $oOption = {};
|
2015-03-12 18:15:19 +02:00
|
|
|
my $oConfig = {};
|
2015-03-08 19:26:09 +02:00
|
|
|
my @oyArray;
|
2015-03-12 18:15:19 +02:00
|
|
|
my $strConfigFile = BackRestTestCommon_TestPathGet() . '/pg_backrest.conf';
|
|
|
|
|
2015-03-08 19:26:09 +02:00
|
|
|
use constant BOGUS => 'bogus';
|
|
|
|
|
|
|
|
# Print test banner
|
2016-01-14 05:43:26 +02:00
|
|
|
if (!$bVmOut)
|
|
|
|
{
|
|
|
|
&log(INFO, 'CONFIG MODULE ******************************************************************');
|
|
|
|
}
|
|
|
|
|
2015-03-12 18:15:19 +02:00
|
|
|
BackRestTestCommon_Drop();
|
2015-03-08 19:26:09 +02:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2015-03-12 18:15:19 +02:00
|
|
|
# Test command-line options
|
2015-03-08 19:26:09 +02:00
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2016-01-09 15:21:53 +02:00
|
|
|
my $strThisTest = 'option';
|
|
|
|
|
|
|
|
if ($strTest eq 'all' || $strTest eq $strThisTest)
|
2015-03-08 19:26:09 +02:00
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
$iRun = 0;
|
2016-01-09 15:21:53 +02:00
|
|
|
|
2016-01-14 05:43:26 +02:00
|
|
|
if (!$bVmOut)
|
|
|
|
{
|
|
|
|
&log(INFO, "Test ${strThisTest}\n");
|
|
|
|
}
|
2015-03-08 19:26:09 +02:00
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup with no stanza'))
|
|
|
|
{
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_REQUIRED, OPTION_STANZA);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup with boolean stanza'))
|
|
|
|
{
|
2016-01-04 03:24:14 +02:00
|
|
|
optionBoolSetTest($oOption, OPTION_STANZA);
|
2015-03-08 19:26:09 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_COMMAND_REQUIRED);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup type defaults to ' . BACKUP_TYPE_INCR))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2015-03-08 19:26:09 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-08 19:26:09 +02:00
|
|
|
optionTestExpect(OPTION_TYPE, BACKUP_TYPE_INCR);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup type set to ' . BACKUP_TYPE_FULL))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_TYPE, BACKUP_TYPE_FULL);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-08 19:26:09 +02:00
|
|
|
optionTestExpect(OPTION_TYPE, BACKUP_TYPE_FULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup type invalid'))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_TYPE, BOGUS);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_TYPE);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup invalid force'))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2016-01-04 03:24:14 +02:00
|
|
|
optionBoolSetTest($oOption, OPTION_FORCE);
|
2015-03-08 19:26:09 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID, OPTION_FORCE, OPTION_NO_START_STOP);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup valid force'))
|
|
|
|
{
|
|
|
|
# $oOption = {};
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2016-01-04 03:24:14 +02:00
|
|
|
optionBoolSetTest($oOption, OPTION_NO_START_STOP);
|
|
|
|
optionBoolSetTest($oOption, OPTION_FORCE);
|
2015-03-08 19:26:09 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-08 19:26:09 +02:00
|
|
|
optionTestExpect(OPTION_NO_START_STOP, true);
|
|
|
|
optionTestExpect(OPTION_FORCE, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup invalid value for ' . OPTION_TEST_DELAY))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2016-01-04 03:24:14 +02:00
|
|
|
optionBoolSetTest($oOption, OPTION_TEST);
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_TEST_DELAY, BOGUS);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_TEST_DELAY);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup invalid ' . OPTION_TEST_DELAY))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_TEST_DELAY, 5);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID, OPTION_TEST_DELAY, OPTION_TEST);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'backup check ' . OPTION_TEST_DELAY . ' undef'))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2015-03-08 19:26:09 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-08 19:26:09 +02:00
|
|
|
optionTestExpect(OPTION_TEST_DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'restore invalid ' . OPTION_TARGET))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_TYPE, RECOVERY_TYPE_DEFAULT);
|
|
|
|
optionSetTest($oOption, OPTION_TARGET, BOGUS);
|
|
|
|
|
|
|
|
@oyArray = (RECOVERY_TYPE_NAME, RECOVERY_TYPE_TIME, RECOVERY_TYPE_XID);
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID, OPTION_TARGET, OPTION_TYPE, \@oyArray);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'restore ' . OPTION_TARGET))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_TYPE, RECOVERY_TYPE_NAME);
|
|
|
|
optionSetTest($oOption, OPTION_TARGET, BOGUS);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE);
|
2015-03-08 19:26:09 +02:00
|
|
|
optionTestExpect(OPTION_TYPE, RECOVERY_TYPE_NAME);
|
|
|
|
optionTestExpect(OPTION_TARGET, BOGUS);
|
|
|
|
optionTestExpect(OPTION_TARGET_TIMELINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'invalid string ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_THREAD_MAX, BOGUS);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_THREAD_MAX);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'invalid float ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_THREAD_MAX, '0.0');
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, '0.0', OPTION_THREAD_MAX);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'valid ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_THREAD_MAX, '2');
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'valid float ' . OPTION_TEST_DELAY))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2016-01-04 03:24:14 +02:00
|
|
|
optionBoolSetTest($oOption, OPTION_TEST);
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_TEST_DELAY, '0.25');
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'valid int ' . OPTION_TEST_DELAY))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2016-01-04 03:24:14 +02:00
|
|
|
optionBoolSetTest($oOption, OPTION_TEST);
|
2015-03-08 19:26:09 +02:00
|
|
|
optionSetTest($oOption, OPTION_TEST_DELAY, 3);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'restore valid ' . OPTION_TARGET_TIMELINE))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_TARGET_TIMELINE, 2);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'invalid ' . OPTION_BUFFER_SIZE))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_BUFFER_SIZE, '512');
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_RANGE, '512', OPTION_BUFFER_SIZE);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' invalid option ' . OPTION_RETENTION_ARCHIVE_TYPE))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_RETENTION_ARCHIVE_TYPE, BOGUS);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID, OPTION_RETENTION_ARCHIVE_TYPE, OPTION_RETENTION_ARCHIVE);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' invalid value ' . OPTION_RETENTION_ARCHIVE_TYPE))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_RETENTION_ARCHIVE, 3);
|
|
|
|
optionSetTest($oOption, OPTION_RETENTION_ARCHIVE_TYPE, BOGUS);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_RETENTION_ARCHIVE_TYPE);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' valid value ' . OPTION_RETENTION_ARCHIVE_TYPE))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_RETENTION_ARCHIVE, 1);
|
|
|
|
optionSetTest($oOption, OPTION_RETENTION_ARCHIVE_TYPE, BACKUP_TYPE_FULL);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_RETENTION_ARCHIVE, 1);
|
|
|
|
optionTestExpect(OPTION_RETENTION_ARCHIVE_TYPE, BACKUP_TYPE_FULL);
|
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-09-08 13:31:24 +02:00
|
|
|
optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, '=');
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, '=', OPTION_RESTORE_RECOVERY_OPTION);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-09-08 13:31:24 +02:00
|
|
|
optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, '=' . BOGUS);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, '=' . BOGUS, OPTION_RESTORE_RECOVERY_OPTION);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' invalid value ' . OPTION_RESTORE_RECOVERY_OPTION))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-09-08 13:31:24 +02:00
|
|
|
optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, BOGUS . '=');
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE, ERROR_OPTION_INVALID_PAIR, BOGUS . '=', OPTION_RESTORE_RECOVERY_OPTION);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' valid value ' . OPTION_RESTORE_RECOVERY_OPTION))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
2015-09-08 13:31:24 +02:00
|
|
|
optionSetTest($oOption, OPTION_RESTORE_RECOVERY_OPTION, 'primary-conn-info=db.domain.net');
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE);
|
2015-09-08 13:31:24 +02:00
|
|
|
optionTestExpect(OPTION_RESTORE_RECOVERY_OPTION, 'db.domain.net', 'primary-conn-info');
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' values passed to ' . CMD_ARCHIVE_GET))
|
2015-04-19 23:29:52 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db path/main');
|
|
|
|
optionSetTest($oOption, OPTION_REPO_PATH, '/repo');
|
|
|
|
optionSetTest($oOption, OPTION_BACKUP_HOST, 'db.mydomain.com');
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE);
|
2015-04-19 23:29:52 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
my $strCommand = commandWrite(CMD_ARCHIVE_GET);
|
2015-05-09 01:33:34 +02:00
|
|
|
my $strExpectedCommand = abs_path($0) . " --backup-host=db.mydomain.com \"--db-path=/db path/main\"" .
|
2015-06-18 22:55:09 +02:00
|
|
|
" --repo-path=/repo --repo-remote-path=/repo --stanza=main " . CMD_ARCHIVE_GET;
|
2015-04-19 23:29:52 +02:00
|
|
|
|
|
|
|
if ($strCommand ne $strExpectedCommand)
|
|
|
|
{
|
|
|
|
confess "expected command '${strExpectedCommand}' but got '${strCommand}'";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' default value ' . OPTION_COMMAND_REMOTE))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-06-17 17:26:07 +02:00
|
|
|
optionTestExpect(OPTION_COMMAND_REMOTE, abs_path($0));
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
2015-05-29 02:52:42 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' missing option ' . OPTION_DB_PATH))
|
2015-05-29 02:52:42 +02:00
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_REQUIRED, OPTION_DB_PATH, 'Does this stanza exist?');
|
2015-05-29 02:52:42 +02:00
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
# Test mixed command-line/config
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
2016-01-09 15:21:53 +02:00
|
|
|
$strThisTest = 'config';
|
|
|
|
|
|
|
|
if ($strTest eq 'all' || $strTest eq $strThisTest)
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
$iRun = 0;
|
2016-01-09 15:21:53 +02:00
|
|
|
|
2016-01-14 05:43:26 +02:00
|
|
|
if (!$bVmOut)
|
|
|
|
{
|
|
|
|
&log(INFO, "Test ${strThisTest}\n");
|
|
|
|
}
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
BackRestTestCommon_Create();
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'set and negate option ' . OPTION_CONFIG))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, '/dude/dude.conf');
|
2016-01-04 03:24:14 +02:00
|
|
|
optionBoolSetTest($oOption, OPTION_CONFIG, false);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_NEGATE, OPTION_CONFIG);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'option ' . OPTION_CONFIG))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
2016-01-04 03:24:14 +02:00
|
|
|
optionBoolSetTest($oOption, OPTION_CONFIG, false);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_CONFIG);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'default option ' . OPTION_CONFIG))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_CONFIG, OPTION_DEFAULT_CONFIG);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'config file is a path'))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, BackRestTestCommon_TestPathGet());
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_FILE_INVALID, BackRestTestCommon_TestPathGet());
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'load from config stanza section - option ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
2015-06-18 22:55:09 +02:00
|
|
|
$$oConfig{"${strStanza}:" . &CMD_BACKUP}{&OPTION_THREAD_MAX} = 2;
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_THREAD_MAX, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'load from config stanza inherited section - option ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{"$strStanza:" . &CONFIG_SECTION_GENERAL}{&OPTION_THREAD_MAX} = 3;
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_THREAD_MAX, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'load from config global section - option ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
2015-06-18 22:55:09 +02:00
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CMD_BACKUP}{&OPTION_THREAD_MAX} = 2;
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_THREAD_MAX, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'load from config global inherited section - option ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_GENERAL}{&OPTION_THREAD_MAX} = 5;
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_THREAD_MAX, 5);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'default - option ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_THREAD_MAX, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'command-line override - option ' . OPTION_THREAD_MAX))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_GENERAL}{&OPTION_THREAD_MAX} = 9;
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_THREAD_MAX, 7);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_THREAD_MAX, 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'invalid boolean - option ' . OPTION_HARDLINK))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
2015-06-18 22:55:09 +02:00
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CMD_BACKUP}{&OPTION_HARDLINK} = 'Y';
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, 'Y', OPTION_HARDLINK);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'invalid value - option ' . OPTION_LOG_LEVEL_CONSOLE))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_LOG}{&OPTION_LOG_LEVEL_CONSOLE} = BOGUS;
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP, ERROR_OPTION_INVALID_VALUE, BOGUS, OPTION_LOG_LEVEL_CONSOLE);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'valid value - option ' . OPTION_LOG_LEVEL_CONSOLE))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_LOG}{&OPTION_LOG_LEVEL_CONSOLE} = lc(INFO);
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Run(++$iRun, 'archive-push - option ' . OPTION_LOG_LEVEL_CONSOLE))
|
|
|
|
{
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_ARCHIVE_PUSH);
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_EXPIRE . ' ' . OPTION_RETENTION_FULL))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
$oConfig = {};
|
2015-03-25 00:50:14 +02:00
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_EXPIRE}{&OPTION_RETENTION_FULL} = 2;
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_EXPIRE);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_RETENTION_FULL, 2);
|
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' option ' . OPTION_COMPRESS))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_BACKUP}{&OPTION_COMPRESS} = 'n';
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_COMPRESS, false);
|
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' option ' . OPTION_RESTORE_RECOVERY_OPTION))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
$oConfig = {};
|
2015-09-08 13:31:24 +02:00
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_RESTORE_RECOVERY_OPTION}{'archive-command'} = '/path/to/pg_backrest';
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_RESTORE);
|
2015-09-08 13:31:24 +02:00
|
|
|
optionTestExpect(OPTION_RESTORE_RECOVERY_OPTION, '/path/to/pg_backrest', 'archive-command');
|
2015-03-12 18:15:19 +02:00
|
|
|
}
|
|
|
|
|
2015-09-08 13:31:24 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_RESTORE . ' option ' . OPTION_RESTORE_RECOVERY_OPTION))
|
2015-04-01 21:58:33 +02:00
|
|
|
{
|
|
|
|
$oConfig = {};
|
2015-09-08 13:31:24 +02:00
|
|
|
$$oConfig{$strStanza . ':' . &CONFIG_SECTION_RESTORE_RECOVERY_OPTION}{'standby-mode'} = 'on';
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-04-01 21:58:33 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_ARCHIVE_GET);
|
2015-04-01 21:58:33 +02:00
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' option ' . OPTION_DB_PATH))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{$strStanza}{&OPTION_DB_PATH} = '/path/to/db';
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_DB_PATH, '/path/to/db');
|
|
|
|
}
|
|
|
|
|
2016-01-04 03:24:14 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' option ' . OPTION_BACKUP_ARCHIVE_CHECK))
|
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{$strStanza}{&OPTION_DB_PATH} = '/path/to/db';
|
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
optionBoolSetTest($oOption, OPTION_BACKUP_ARCHIVE_CHECK, false);
|
|
|
|
|
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
|
|
|
optionTestExpect(OPTION_NO_START_STOP, false);
|
|
|
|
optionTestExpect(OPTION_BACKUP_ARCHIVE_CHECK, false);
|
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_ARCHIVE_PUSH . ' option ' . OPTION_DB_PATH))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{$strStanza}{&OPTION_DB_PATH} = '/path/to/db';
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_ARCHIVE_PUSH);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_DB_PATH, '/path/to/db');
|
|
|
|
}
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
if (BackRestTestCommon_Run(++$iRun, CMD_BACKUP . ' option ' . OPTION_REPO_PATH))
|
2015-03-12 18:15:19 +02:00
|
|
|
{
|
|
|
|
$oConfig = {};
|
|
|
|
$$oConfig{&CONFIG_GLOBAL . ':' . &CONFIG_SECTION_GENERAL}{&OPTION_REPO_PATH} = '/repo';
|
2015-06-14 00:25:49 +02:00
|
|
|
iniSave($strConfigFile, $oConfig, true);
|
2015-03-12 18:15:19 +02:00
|
|
|
|
|
|
|
optionSetTest($oOption, OPTION_STANZA, $strStanza);
|
|
|
|
optionSetTest($oOption, OPTION_DB_PATH, '/db');
|
|
|
|
optionSetTest($oOption, OPTION_CONFIG, $strConfigFile);
|
|
|
|
|
2015-06-18 22:55:09 +02:00
|
|
|
configLoadExpect($oOption, CMD_BACKUP);
|
2015-03-12 18:15:19 +02:00
|
|
|
optionTestExpect(OPTION_REPO_PATH, '/repo');
|
|
|
|
}
|
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
if (BackRestTestCommon_Cleanup())
|
|
|
|
{
|
|
|
|
&log(INFO, 'cleanup');
|
|
|
|
BackRestTestCommon_Drop(true);
|
2015-03-08 19:26:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|