1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Fix options being ignored by asynchronous commands.

The local, remote, archive-get-async, and archive-push-async commands were used to run functionality that was not directly available to the user. Unfortunately that meant they would not pick up options from the command that the user expected, e.g. backup, archive-get, etc.

Remove the internal commands and add roles which allow pgBackRest to determine what functionality is required without implementing special commands. This way the options are loaded from the expected command section.

Since remote is no longer a specific command with its own options, more manipulation is required when calling remote. This might be something we can improve in the config system but it may be worth leaving as is because it is a one-off, for now at least.
This commit is contained in:
David Steele 2020-01-15 12:24:58 -07:00
parent c43ec9d38c
commit 8d3710b2fe
39 changed files with 591 additions and 932 deletions

View File

@ -163,8 +163,6 @@ sub buildConfig
" CONFIG_COMMAND_INTERNAL(" . ($rhCommand->{&CFGDEF_INTERNAL} ? 'true' : 'false') . ")\n" .
" CONFIG_COMMAND_LOG_FILE(" . ($rhCommand->{&CFGDEF_LOG_FILE} ? 'true' : 'false') . ")\n" .
" CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevel" . ucfirst(lc($rhCommand->{&CFGDEF_LOG_LEVEL_DEFAULT})) . ")\n" .
" CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevel" .
ucfirst(lc($rhCommand->{&CFGDEF_LOG_LEVEL_STDERR_MAX})) . ")\n" .
" CONFIG_COMMAND_LOCK_REQUIRED(" . ($rhCommand->{&CFGDEF_LOCK_REQUIRED} ? 'true' : 'false') . ")\n" .
" CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(" .
($rhCommand->{&CFGDEF_LOCK_REMOTE_REQUIRED} ? 'true' : 'false') . ")\n" .

View File

@ -77,12 +77,8 @@ use pgBackRest::Version;
####################################################################################################################################
use constant CFGCMD_ARCHIVE_GET => 'archive-get';
push @EXPORT, qw(CFGCMD_ARCHIVE_GET);
use constant CFGCMD_ARCHIVE_GET_ASYNC => 'archive-get-async';
push @EXPORT, qw(CFGCMD_ARCHIVE_GET_ASYNC);
use constant CFGCMD_ARCHIVE_PUSH => 'archive-push';
push @EXPORT, qw(CFGCMD_ARCHIVE_PUSH);
use constant CFGCMD_ARCHIVE_PUSH_ASYNC => 'archive-push-async';
push @EXPORT, qw(CFGCMD_ARCHIVE_PUSH_ASYNC);
use constant CFGCMD_BACKUP => 'backup';
push @EXPORT, qw(CFGCMD_BACKUP);
use constant CFGCMD_CHECK => 'check';
@ -93,10 +89,6 @@ use constant CFGCMD_HELP => 'help';
push @EXPORT, qw(CFGCMD_HELP);
use constant CFGCMD_INFO => 'info';
push @EXPORT, qw(CFGCMD_INFO);
use constant CFGCMD_LOCAL => 'local';
push @EXPORT, qw(CFGCMD_LOCAL);
use constant CFGCMD_REMOTE => 'remote';
push @EXPORT, qw(CFGCMD_REMOTE);
use constant CFGCMD_RESTORE => 'restore';
push @EXPORT, qw(CFGCMD_RESTORE);
use constant CFGCMD_STANZA_CREATE => 'stanza-create';
@ -151,8 +143,6 @@ use constant CFGOPT_OUTPUT => 'output';
# Command-line only local/remote options
#-----------------------------------------------------------------------------------------------------------------------------------
use constant CFGOPT_COMMAND => 'command';
push @EXPORT, qw(CFGOPT_COMMAND);
use constant CFGOPT_PROCESS => 'process';
push @EXPORT, qw(CFGOPT_PROCESS);
use constant CFGOPT_HOST_ID => 'host-id';
@ -484,11 +474,6 @@ use constant CFGDEF_LOG_FILE => 'log-file
use constant CFGDEF_LOG_LEVEL_DEFAULT => 'log-level-default';
push @EXPORT, qw(CFGDEF_LOG_LEVEL_DEFAULT);
# Defines the max log level that may be assigned for the output type. For instance, it's not OK for the local and remote processes
# to log anything but errors to stderr because it will cause the process to error on exit.
use constant CFGDEF_LOG_LEVEL_STDERR_MAX => 'log-level-stderr-max';
push @EXPORT, qw(CFGDEF_LOG_LEVEL_STDERR_MAX);
# Does the command require a lock? This doesn't mean a lock can't be taken explicitly later, just controls whether a lock will be
# acquired as soon at the command starts.
use constant CFGDEF_LOCK_REQUIRED => 'lock-required';
@ -595,15 +580,6 @@ my $rhCommandDefine =
&CFGDEF_PARAMETER_ALLOWED => true,
},
&CFGCMD_ARCHIVE_GET_ASYNC =>
{
&CFGDEF_INTERNAL => true,
&CFGDEF_LOG_FILE => true,
&CFGDEF_LOCK_REQUIRED => true,
&CFGDEF_LOCK_TYPE => CFGDEF_LOCK_TYPE_ARCHIVE,
&CFGDEF_PARAMETER_ALLOWED => true,
},
&CFGCMD_ARCHIVE_PUSH =>
{
&CFGDEF_LOG_FILE => false,
@ -612,16 +588,6 @@ my $rhCommandDefine =
&CFGDEF_PARAMETER_ALLOWED => true,
},
&CFGCMD_ARCHIVE_PUSH_ASYNC =>
{
&CFGDEF_INTERNAL => true,
&CFGDEF_LOG_FILE => true,
&CFGDEF_LOCK_REQUIRED => true,
&CFGDEF_LOCK_REMOTE_REQUIRED => true,
&CFGDEF_LOCK_TYPE => CFGDEF_LOCK_TYPE_ARCHIVE,
&CFGDEF_PARAMETER_ALLOWED => true,
},
&CFGCMD_BACKUP =>
{
&CFGDEF_LOCK_REQUIRED => true,
@ -653,18 +619,6 @@ my $rhCommandDefine =
&CFGDEF_LOG_LEVEL_DEFAULT => DEBUG,
},
&CFGCMD_LOCAL =>
{
&CFGDEF_INTERNAL => true,
&CFGDEF_LOG_LEVEL_STDERR_MAX => ERROR,
},
&CFGCMD_REMOTE =>
{
&CFGDEF_INTERNAL => true,
&CFGDEF_LOG_LEVEL_STDERR_MAX => ERROR,
},
&CFGCMD_RESTORE =>
{
},
@ -725,15 +679,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -837,9 +787,7 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
@ -847,11 +795,6 @@ my %hConfigDefine =
{
&CFGDEF_REQUIRED => false
},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE =>
{
&CFGDEF_REQUIRED => false
},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1027,40 +970,39 @@ my %hConfigDefine =
# Command-line only local/remote options
#-------------------------------------------------------------------------------------------------------------------------------
&CFGOPT_COMMAND =>
{
&CFGDEF_TYPE => CFGDEF_TYPE_STRING,
&CFGDEF_COMMAND =>
{
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
}
},
&CFGOPT_HOST_ID =>
{
&CFGDEF_TYPE => CFGDEF_TYPE_INTEGER,
&CFGDEF_REQUIRED => false,
&CFGDEF_INTERNAL => true,
&CFGDEF_ALLOW_RANGE => [1, CFGDEF_INDEX_PG > CFGDEF_INDEX_REPO ? CFGDEF_INDEX_PG : CFGDEF_INDEX_REPO],
&CFGDEF_COMMAND =>
{
&CFGCMD_LOCAL => {},
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_BACKUP => {},
&CFGCMD_RESTORE => {},
},
},
&CFGOPT_PROCESS =>
{
&CFGDEF_TYPE => CFGDEF_TYPE_INTEGER,
&CFGDEF_REQUIRED => false,
&CFGDEF_INTERNAL => true,
&CFGDEF_ALLOW_RANGE => [0, 1024],
&CFGDEF_COMMAND =>
{
&CFGCMD_LOCAL =>
{
&CFGDEF_REQUIRED => true,
},
&CFGCMD_REMOTE =>
{
&CFGDEF_REQUIRED => true,
},
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_INFO => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
&CFGCMD_STANZA_UPGRADE => {},
&CFGCMD_STORAGE_LIST => {},
},
},
@ -1076,9 +1018,17 @@ my %hConfigDefine =
],
&CFGDEF_COMMAND =>
{
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
}
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_INFO => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
&CFGCMD_STANZA_UPGRADE => {},
&CFGCMD_STORAGE_LIST => {},
},
},
# Command-line only storage options
@ -1158,15 +1108,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1184,13 +1130,9 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
&CFGCMD_STANZA_UPGRADE => {},
@ -1218,9 +1160,7 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_RESTORE => {},
}
@ -1235,14 +1175,10 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1259,14 +1195,10 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1283,14 +1215,10 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1309,14 +1237,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1335,14 +1260,10 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1360,15 +1281,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1388,14 +1305,10 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1476,9 +1389,7 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP =>
{
&CFGDEF_INTERNAL => true,
@ -1489,7 +1400,6 @@ my %hConfigDefine =
&CFGDEF_INTERNAL => true,
},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE =>
{
@ -1523,12 +1433,9 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_CHECK => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_RESTORE => {},
&CFGCMD_START => {},
&CFGCMD_STOP => {},
@ -1762,21 +1669,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL =>
{
&CFGDEF_REQUIRED => false,
},
&CFGCMD_REMOTE =>
{
&CFGDEF_REQUIRED => false,
},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1900,15 +1797,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -1934,8 +1827,6 @@ my %hConfigDefine =
&CFGDEF_DEPEND_LIST => [true],
},
},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_LOCAL => {},
&CFGCMD_ARCHIVE_PUSH =>
{
&CFGDEF_DEPEND =>
@ -1944,7 +1835,6 @@ my %hConfigDefine =
&CFGDEF_DEPEND_LIST => [true],
},
},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
},
},
@ -1957,9 +1847,7 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_RESTORE => {},
}
@ -1985,9 +1873,7 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
@ -2011,21 +1897,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL =>
{
&CFGDEF_DEFAULT => lc(OFF),
},
&CFGCMD_REMOTE =>
{
&CFGDEF_DEFAULT => lc(OFF),
},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -2045,15 +1921,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -2072,15 +1944,11 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_INFO => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -2126,7 +1994,6 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_PUSH => {},
&CFGCMD_ARCHIVE_PUSH_ASYNC => {},
},
},
@ -2139,7 +2006,6 @@ my %hConfigDefine =
&CFGDEF_COMMAND =>
{
&CFGCMD_ARCHIVE_GET => {},
&CFGCMD_ARCHIVE_GET_ASYNC => {},
},
},
@ -2364,22 +2230,13 @@ my %hConfigDefine =
{
&CFGDEF_INTERNAL => true,
},
&CFGCMD_ARCHIVE_GET_ASYNC =>
{
&CFGDEF_INTERNAL => true,
},
&CFGCMD_ARCHIVE_PUSH =>
{
&CFGDEF_INTERNAL => true,
},
&CFGCMD_ARCHIVE_PUSH_ASYNC =>
{
&CFGDEF_INTERNAL => true,
},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_LOCAL => {},
&CFGCMD_RESTORE =>
{
&CFGDEF_INTERNAL => true,
@ -2409,7 +2266,6 @@ my %hConfigDefine =
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_EXPIRE => {},
&CFGCMD_LOCAL => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
&CFGCMD_STANZA_UPGRADE => {},
@ -2491,28 +2347,12 @@ my %hConfigDefine =
{
&CFGDEF_REQUIRED => false
},
&CFGCMD_ARCHIVE_GET_ASYNC =>
{
&CFGDEF_REQUIRED => false
},
&CFGCMD_ARCHIVE_PUSH =>
{
&CFGDEF_REQUIRED => false
},
&CFGCMD_ARCHIVE_PUSH_ASYNC =>
{
&CFGDEF_REQUIRED => false
},
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_LOCAL =>
{
&CFGDEF_REQUIRED => false
},
&CFGCMD_REMOTE =>
{
&CFGDEF_REQUIRED => false
},
&CFGCMD_RESTORE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
@ -2537,8 +2377,6 @@ my %hConfigDefine =
{
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
&CFGCMD_STANZA_UPGRADE => {},
@ -2573,8 +2411,6 @@ my %hConfigDefine =
{
&CFGCMD_BACKUP => {},
&CFGCMD_CHECK => {},
&CFGCMD_LOCAL => {},
&CFGCMD_REMOTE => {},
&CFGCMD_STANZA_CREATE => {},
&CFGCMD_STANZA_DELETE => {},
&CFGCMD_STANZA_UPGRADE => {},
@ -2609,12 +2445,6 @@ foreach my $strCommand (sort(keys(%{$rhCommandDefine})))
$rhCommandDefine->{$strCommand}{&CFGDEF_LOG_LEVEL_DEFAULT} = INFO;
}
# Default max stderr log level is TRACE
if (!defined($rhCommandDefine->{$strCommand}{&CFGDEF_LOG_LEVEL_STDERR_MAX}))
{
$rhCommandDefine->{$strCommand}{&CFGDEF_LOG_LEVEL_STDERR_MAX} = TRACE;
}
# Default lock required is false
if (!defined($rhCommandDefine->{$strCommand}{&CFGDEF_LOCK_REQUIRED}))
{

View File

@ -195,12 +195,6 @@ sub process
foreach my $strCommand (cfgDefineCommandList())
{
if ($strCommand eq CFGCMD_REMOTE || $strCommand eq CFGCMD_LOCAL || $strCommand eq CFGCMD_ARCHIVE_GET_ASYNC ||
$strCommand eq CFGCMD_ARCHIVE_PUSH_ASYNC)
{
next;
}
my $oCommandDoc = $oDoc->nodeGet('operation')->nodeGet('command-list')->nodeGetById('command', $strCommand);
$$oConfigHash{&CONFIG_HELP_COMMAND}{$strCommand} = {};

View File

@ -15,6 +15,17 @@
<release date="XXXX-XX-XX" version="2.21dev" title="UNDER DEVELOPMENT">
<release-core-list>
<release-bug-list>
<release-item>
<release-item-contributor-list>
<release-item-ideator id="urs.kramer"/>
<release-item-reviewer id="cynthia.shang"/>
</release-item-contributor-list>
<p>Fix options being ignored by asynchronous commands.</p>
<p>The asynchronous <cmd>archive-get</cmd>/<cmd>archive-push</cmd> processes were not loading options configured in command configuration sections, e.g. <id>[global:archive-get]</id>.</p>
</release-item>
<release-item>
<p>Fix handling of <id>\</id> in filenames.</p>
@ -8028,6 +8039,11 @@
<contributor-id type="github">ucando</contributor-id>
</contributor>
<contributor id="urs.kramer">
<contributor-name-display>Urs Kramer</contributor-name-display>
<contributor-id type="github">UrsKramer</contributor-id>
</contributor>
<contributor id="uspen">
<contributor-name-display>uspen</contributor-name-display>
<contributor-id type="github">uspen</contributor-id>

View File

@ -117,17 +117,13 @@ sub libcAutoExportTag
'CFGOPTVAL_RESTORE_TYPE_DEFAULT',
'CFGOPTVAL_RESTORE_TYPE_STANDBY',
'CFGCMD_ARCHIVE_GET',
'CFGCMD_ARCHIVE_GET_ASYNC',
'CFGCMD_ARCHIVE_PUSH',
'CFGCMD_ARCHIVE_PUSH_ASYNC',
'CFGCMD_BACKUP',
'CFGCMD_CHECK',
'CFGCMD_EXPIRE',
'CFGCMD_HELP',
'CFGCMD_INFO',
'CFGCMD_LOCAL',
'CFGCMD_LS',
'CFGCMD_REMOTE',
'CFGCMD_RESTORE',
'CFGCMD_STANZA_CREATE',
'CFGCMD_STANZA_DELETE',
@ -145,7 +141,6 @@ sub libcAutoExportTag
'CFGOPT_BUFFER_SIZE',
'CFGOPT_CHECKSUM_PAGE',
'CFGOPT_CMD_SSH',
'CFGOPT_COMMAND',
'CFGOPT_COMPRESS',
'CFGOPT_COMPRESS_LEVEL',
'CFGOPT_COMPRESS_LEVEL_NETWORK',

View File

@ -217,7 +217,7 @@ cmdArchiveGet(void)
kvPut(optionReplace, VARSTR(CFGOPT_LOG_LEVEL_STDERR_STR), VARSTRDEF("off"));
// Generate command options
StringList *commandExec = cfgExecParam(cfgCmdArchiveGetAsync, optionReplace, true, false);
StringList *commandExec = cfgExecParam(cfgCmdArchiveGet, cfgCmdRoleAsync, optionReplace, true, false);
strLstInsert(commandExec, 0, cfgExe());
// Clean the current queue using the list of WAL that we ideally want in the queue. queueNeed()
@ -243,8 +243,8 @@ cmdArchiveGet(void)
// Execute the binary. This statement will not return if it is successful.
THROW_ON_SYS_ERROR(
execvp(strPtr(cfgExe()), (char ** const)strLstPtr(commandExec)) == -1,
ExecuteError, "unable to execute '" CFGCMD_ARCHIVE_GET_ASYNC "'");
execvp(strPtr(cfgExe()), (char ** const)strLstPtr(commandExec)) == -1, ExecuteError,
"unable to execute asynchronous '" CFGCMD_ARCHIVE_GET "'");
}
// Mark the async process as forked so it doesn't get forked again. A single run of the async process should be

View File

@ -299,7 +299,7 @@ cmdArchivePush(void)
kvPut(optionReplace, VARSTR(CFGOPT_LOG_LEVEL_STDERR_STR), VARSTRDEF("off"));
// Generate command options
StringList *commandExec = cfgExecParam(cfgCmdArchivePushAsync, optionReplace, true, false);
StringList *commandExec = cfgExecParam(cfgCmdArchivePush, cfgCmdRoleAsync, optionReplace, true, false);
strLstInsert(commandExec, 0, cfgExe());
strLstAdd(commandExec, strPath(walFile));
@ -317,8 +317,8 @@ cmdArchivePush(void)
// Execute the binary. This statement will not return if it is successful.
THROW_ON_SYS_ERROR(
execvp(strPtr(cfgExe()), (char ** const)strLstPtr(commandExec)) == -1,
ExecuteError, "unable to execute '" CFGCMD_ARCHIVE_PUSH_ASYNC "'");
execvp(strPtr(cfgExe()), (char ** const)strLstPtr(commandExec)) == -1, ExecuteError,
"unable to execute asynchronous '" CFGCMD_ARCHIVE_PUSH "'");
}
// Mark the async process as forked so it doesn't get forked again. A single run of the async process should be
@ -434,7 +434,7 @@ cmdArchivePushAsync(void)
{
FUNCTION_LOG_VOID(logLevelDebug);
ASSERT(cfgCommand() == cfgCmdArchivePushAsync);
ASSERT(cfgCommand() == cfgCmdArchivePush && cfgCommandRole() == cfgCmdRoleAsync);
MEM_CONTEXT_TEMP_BEGIN()
{
@ -459,7 +459,7 @@ cmdArchivePushAsync(void)
// Get a list of WAL files that are ready for processing
jobData.walFileList = archivePushProcessList(jobData.walPath);
// The archive-push-async command should not have been called unless there are WAL files to process
// The archive-push:async command should not have been called unless there are WAL files to process
if (strLstSize(jobData.walFileList) == 0)
THROW(AssertError, "no WAL files to process");

View File

@ -51,7 +51,7 @@ cmdBegin(bool logOption)
MEM_CONTEXT_TEMP_BEGIN()
{
// Basic info on command start
String *info = strNewFmt("%s command begin", cfgCommandName(cfgCommand()));
String *info = strNewFmt("%s command begin", strPtr(cfgCommandRoleName()));
if (logOption)
{
@ -199,7 +199,7 @@ cmdEnd(int code, const String *errorMessage)
LOG_INFO(strPtr(httpClientStat));
// Basic info on command end
String *info = strNewFmt("%s command end: ", cfgCommandName(cfgCommand()));
String *info = strNewFmt("%s command end: ", strPtr(cfgCommandRoleName()));
if (errorMessage == NULL)
{

View File

@ -51,16 +51,14 @@ cmdRemote(int handleRead, int handleWrite)
// Only try the lock if this is process 0, i.e. the remote started from the main process
if (cfgOptionUInt(cfgOptProcess) == 0)
{
ConfigCommand commandId = cfgCommandId(strPtr(cfgOptionStr(cfgOptCommand)), true);
// Acquire a lock if this command requires a lock
if (cfgLockRemoteRequired(commandId))
if (cfgLockRemoteRequired())
{
// Make sure the local host is not stopped
lockStopTest();
// Acquire the lock
lockAcquire(cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), cfgLockRemoteType(commandId), 0, true);
lockAcquire(cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), cfgLockType(), 0, true);
}
}

View File

@ -1217,7 +1217,7 @@ restoreRecoveryOption(unsigned int pgVersion)
VARSTR(
strNewFmt(
"%s %s %%f \"%%p\"", strPtr(cfgExe()),
strPtr(strLstJoin(cfgExecParam(cfgCmdArchiveGet, optionReplace, true, true), " ")))));
strPtr(strLstJoin(cfgExecParam(cfgCmdArchiveGet, cfgCmdRoleDefault, optionReplace, true, true), " ")))));
}
// If recovery type is immediate

View File

@ -8,17 +8,13 @@ Automatically generated by Build.pm -- do not modify directly.
Command constants
***********************************************************************************************************************************/
STRING_EXTERN(CFGCMD_ARCHIVE_GET_STR, CFGCMD_ARCHIVE_GET);
STRING_EXTERN(CFGCMD_ARCHIVE_GET_ASYNC_STR, CFGCMD_ARCHIVE_GET_ASYNC);
STRING_EXTERN(CFGCMD_ARCHIVE_PUSH_STR, CFGCMD_ARCHIVE_PUSH);
STRING_EXTERN(CFGCMD_ARCHIVE_PUSH_ASYNC_STR, CFGCMD_ARCHIVE_PUSH_ASYNC);
STRING_EXTERN(CFGCMD_BACKUP_STR, CFGCMD_BACKUP);
STRING_EXTERN(CFGCMD_CHECK_STR, CFGCMD_CHECK);
STRING_EXTERN(CFGCMD_EXPIRE_STR, CFGCMD_EXPIRE);
STRING_EXTERN(CFGCMD_HELP_STR, CFGCMD_HELP);
STRING_EXTERN(CFGCMD_INFO_STR, CFGCMD_INFO);
STRING_EXTERN(CFGCMD_LOCAL_STR, CFGCMD_LOCAL);
STRING_EXTERN(CFGCMD_LS_STR, CFGCMD_LS);
STRING_EXTERN(CFGCMD_REMOTE_STR, CFGCMD_REMOTE);
STRING_EXTERN(CFGCMD_RESTORE_STR, CFGCMD_RESTORE);
STRING_EXTERN(CFGCMD_STANZA_CREATE_STR, CFGCMD_STANZA_CREATE);
STRING_EXTERN(CFGCMD_STANZA_DELETE_STR, CFGCMD_STANZA_DELETE);
@ -39,27 +35,12 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(false)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeArchive)
CONFIG_COMMAND_PARAMETER_ALLOWED(true)
)
CONFIG_COMMAND
(
CONFIG_COMMAND_NAME(CFGCMD_ARCHIVE_GET_ASYNC)
CONFIG_COMMAND_INTERNAL(true)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(true)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeArchive)
CONFIG_COMMAND_PARAMETER_ALLOWED(true)
)
CONFIG_COMMAND
(
CONFIG_COMMAND_NAME(CFGCMD_ARCHIVE_PUSH)
@ -67,27 +48,12 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(false)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(true)
CONFIG_COMMAND_LOCK_TYPE(lockTypeArchive)
CONFIG_COMMAND_PARAMETER_ALLOWED(true)
)
CONFIG_COMMAND
(
CONFIG_COMMAND_NAME(CFGCMD_ARCHIVE_PUSH_ASYNC)
CONFIG_COMMAND_INTERNAL(true)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(true)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(true)
CONFIG_COMMAND_LOCK_TYPE(lockTypeArchive)
CONFIG_COMMAND_PARAMETER_ALLOWED(true)
)
CONFIG_COMMAND
(
CONFIG_COMMAND_NAME(CFGCMD_BACKUP)
@ -95,7 +61,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(true)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(true)
CONFIG_COMMAND_LOCK_TYPE(lockTypeBackup)
@ -109,7 +74,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(false)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
@ -123,7 +87,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(true)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeBackup)
@ -137,7 +100,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(false)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelDebug)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
@ -151,21 +113,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(false)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelDebug)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
CONFIG_COMMAND_PARAMETER_ALLOWED(false)
)
CONFIG_COMMAND
(
CONFIG_COMMAND_NAME(CFGCMD_LOCAL)
CONFIG_COMMAND_INTERNAL(true)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelError)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
@ -179,27 +126,12 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(true)
CONFIG_COMMAND_LOG_FILE(false)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelDebug)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
CONFIG_COMMAND_PARAMETER_ALLOWED(true)
)
CONFIG_COMMAND
(
CONFIG_COMMAND_NAME(CFGCMD_REMOTE)
CONFIG_COMMAND_INTERNAL(true)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelError)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
CONFIG_COMMAND_PARAMETER_ALLOWED(false)
)
CONFIG_COMMAND
(
CONFIG_COMMAND_NAME(CFGCMD_RESTORE)
@ -207,7 +139,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
@ -221,7 +152,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(true)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeAll)
@ -235,7 +165,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(true)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeAll)
@ -249,7 +178,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(true)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeAll)
@ -263,7 +191,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
@ -277,7 +204,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(true)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelInfo)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
@ -291,7 +217,6 @@ static ConfigCommandData configCommandData[CFG_COMMAND_TOTAL] = CONFIG_COMMAND_L
CONFIG_COMMAND_INTERNAL(false)
CONFIG_COMMAND_LOG_FILE(false)
CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelDebug)
CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelTrace)
CONFIG_COMMAND_LOCK_REQUIRED(false)
CONFIG_COMMAND_LOCK_REMOTE_REQUIRED(false)
CONFIG_COMMAND_LOCK_TYPE(lockTypeNone)
@ -312,7 +237,6 @@ STRING_EXTERN(CFGOPT_BACKUP_STANDBY_STR, CFGOPT_BACKU
STRING_EXTERN(CFGOPT_BUFFER_SIZE_STR, CFGOPT_BUFFER_SIZE);
STRING_EXTERN(CFGOPT_CHECKSUM_PAGE_STR, CFGOPT_CHECKSUM_PAGE);
STRING_EXTERN(CFGOPT_CMD_SSH_STR, CFGOPT_CMD_SSH);
STRING_EXTERN(CFGOPT_COMMAND_STR, CFGOPT_COMMAND);
STRING_EXTERN(CFGOPT_COMPRESS_STR, CFGOPT_COMPRESS);
STRING_EXTERN(CFGOPT_COMPRESS_LEVEL_STR, CFGOPT_COMPRESS_LEVEL);
STRING_EXTERN(CFGOPT_COMPRESS_LEVEL_NETWORK_STR, CFGOPT_COMPRESS_LEVEL_NETWORK);
@ -561,14 +485,6 @@ static ConfigOptionData configOptionData[CFG_OPTION_TOTAL] = CONFIG_OPTION_LIST
CONFIG_OPTION_DEFINE_ID(cfgDefOptCmdSsh)
)
//------------------------------------------------------------------------------------------------------------------------------
CONFIG_OPTION
(
CONFIG_OPTION_NAME(CFGOPT_COMMAND)
CONFIG_OPTION_INDEX(0)
CONFIG_OPTION_DEFINE_ID(cfgDefOptCommand)
)
//------------------------------------------------------------------------------------------------------------------------------
CONFIG_OPTION
(

View File

@ -11,12 +11,8 @@ Command constants
***********************************************************************************************************************************/
#define CFGCMD_ARCHIVE_GET "archive-get"
STRING_DECLARE(CFGCMD_ARCHIVE_GET_STR);
#define CFGCMD_ARCHIVE_GET_ASYNC "archive-get-async"
STRING_DECLARE(CFGCMD_ARCHIVE_GET_ASYNC_STR);
#define CFGCMD_ARCHIVE_PUSH "archive-push"
STRING_DECLARE(CFGCMD_ARCHIVE_PUSH_STR);
#define CFGCMD_ARCHIVE_PUSH_ASYNC "archive-push-async"
STRING_DECLARE(CFGCMD_ARCHIVE_PUSH_ASYNC_STR);
#define CFGCMD_BACKUP "backup"
STRING_DECLARE(CFGCMD_BACKUP_STR);
#define CFGCMD_CHECK "check"
@ -27,12 +23,8 @@ Command constants
STRING_DECLARE(CFGCMD_HELP_STR);
#define CFGCMD_INFO "info"
STRING_DECLARE(CFGCMD_INFO_STR);
#define CFGCMD_LOCAL "local"
STRING_DECLARE(CFGCMD_LOCAL_STR);
#define CFGCMD_LS "ls"
STRING_DECLARE(CFGCMD_LS_STR);
#define CFGCMD_REMOTE "remote"
STRING_DECLARE(CFGCMD_REMOTE_STR);
#define CFGCMD_RESTORE "restore"
STRING_DECLARE(CFGCMD_RESTORE_STR);
#define CFGCMD_STANZA_CREATE "stanza-create"
@ -48,7 +40,7 @@ Command constants
#define CFGCMD_VERSION "version"
STRING_DECLARE(CFGCMD_VERSION_STR);
#define CFG_COMMAND_TOTAL 20
#define CFG_COMMAND_TOTAL 16
/***********************************************************************************************************************************
Option constants
@ -73,8 +65,6 @@ Option constants
STRING_DECLARE(CFGOPT_CHECKSUM_PAGE_STR);
#define CFGOPT_CMD_SSH "cmd-ssh"
STRING_DECLARE(CFGOPT_CMD_SSH_STR);
#define CFGOPT_COMMAND "command"
STRING_DECLARE(CFGOPT_COMMAND_STR);
#define CFGOPT_COMPRESS "compress"
STRING_DECLARE(CFGOPT_COMPRESS_STR);
#define CFGOPT_COMPRESS_LEVEL "compress-level"
@ -400,7 +390,7 @@ Option constants
#define CFGOPT_TYPE "type"
STRING_DECLARE(CFGOPT_TYPE_STR);
#define CFG_OPTION_TOTAL 173
#define CFG_OPTION_TOTAL 172
/***********************************************************************************************************************************
Command enum
@ -408,17 +398,13 @@ Command enum
typedef enum
{
cfgCmdArchiveGet,
cfgCmdArchiveGetAsync,
cfgCmdArchivePush,
cfgCmdArchivePushAsync,
cfgCmdBackup,
cfgCmdCheck,
cfgCmdExpire,
cfgCmdHelp,
cfgCmdInfo,
cfgCmdLocal,
cfgCmdLs,
cfgCmdRemote,
cfgCmdRestore,
cfgCmdStanzaCreate,
cfgCmdStanzaDelete,
@ -444,7 +430,6 @@ typedef enum
cfgOptBufferSize,
cfgOptChecksumPage,
cfgOptCmdSsh,
cfgOptCommand,
cfgOptCompress,
cfgOptCompressLevel,
cfgOptCompressLevelNetwork,

View File

@ -24,7 +24,6 @@ typedef struct ConfigCommandData
bool logFile:1;
unsigned int logLevelDefault:4;
unsigned int logLevelStdErrMax:4;
bool parameterAllowed:1;
} ConfigCommandData;
@ -47,8 +46,6 @@ typedef struct ConfigCommandData
.logFile = logFileParam,
#define CONFIG_COMMAND_LOG_LEVEL_DEFAULT(logLevelDefaultParam) \
.logLevelDefault = logLevelDefaultParam,
#define CONFIG_COMMAND_LOG_LEVEL_STDERR_MAX(logLevelStdErrMaxParam) \
.logLevelStdErrMax = logLevelStdErrMaxParam,
#define CONFIG_COMMAND_NAME(nameParam) \
.name = nameParam,
#define CONFIG_COMMAND_PARAMETER_ALLOWED(parameterAllowedParam) \
@ -94,6 +91,7 @@ Store the current command
This is generally set by the command parser but can also be set by during execute to change commands, i.e. backup -> expire.
***********************************************************************************************************************************/
static ConfigCommand command = cfgCmdNone;
static ConfigCommandRole commandRole = cfgCmdRoleDefault;
/***********************************************************************************************************************************
Store the location of the executable
@ -136,6 +134,7 @@ cfgInit(void)
// Reset configuration
command = cfgCmdNone;
commandRole = cfgCmdRoleDefault;
exe = NULL;
help = false;
paramList = NULL;
@ -172,16 +171,25 @@ cfgCommand(void)
FUNCTION_TEST_RETURN(command);
}
ConfigCommandRole
cfgCommandRole(void)
{
FUNCTION_TEST_VOID();
FUNCTION_TEST_RETURN(commandRole);
}
void
cfgCommandSet(ConfigCommand commandParam)
cfgCommandSet(ConfigCommand commandId, ConfigCommandRole commandRoleId)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(ENUM, commandParam);
FUNCTION_TEST_PARAM(ENUM, commandId);
FUNCTION_TEST_PARAM(ENUM, commandRoleId);
FUNCTION_TEST_END();
ASSERT(commandParam <= cfgCmdNone);
ASSERT(commandId <= cfgCmdNone);
command = commandParam;
command = commandId;
commandRole = commandRoleId;
FUNCTION_TEST_RETURN_VOID();
}
@ -264,6 +272,31 @@ cfgCommandName(ConfigCommand commandId)
FUNCTION_TEST_RETURN(configCommandData[commandId].name);
}
String *
cfgCommandRoleNameParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const String *separator)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(ENUM, commandId);
FUNCTION_TEST_PARAM(ENUM, commandRoleId);
FUNCTION_TEST_PARAM(STRING, separator);
FUNCTION_TEST_END();
String *result = strNew(cfgCommandName(commandId));
if (commandRoleId != cfgCmdRoleDefault)
strCatFmt(result, "%s%s", strPtr(separator), strPtr(cfgCommandRoleStr(commandRoleId)));
FUNCTION_TEST_RETURN(result);
}
String *
cfgCommandRoleName(void)
{
FUNCTION_TEST_VOID();
FUNCTION_TEST_RETURN(cfgCommandRoleNameParam(cfgCommand(), cfgCommandRole(), COLON_STR));
}
/***********************************************************************************************************************************
Command parameters, if any
***********************************************************************************************************************************/
@ -302,6 +335,66 @@ cfgCommandParamSet(const StringList *param)
FUNCTION_TEST_RETURN_VOID();
}
/**********************************************************************************************************************************/
STRING_STATIC(CONFIG_COMMAND_ROLE_ASYNC_STR, CONFIG_COMMAND_ROLE_ASYNC);
STRING_STATIC(CONFIG_COMMAND_ROLE_LOCAL_STR, CONFIG_COMMAND_ROLE_LOCAL);
STRING_STATIC(CONFIG_COMMAND_ROLE_REMOTE_STR, CONFIG_COMMAND_ROLE_REMOTE);
ConfigCommandRole
cfgCommandRoleEnum(const String *commandRole)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRING, commandRole);
FUNCTION_TEST_END();
if (commandRole == NULL)
FUNCTION_TEST_RETURN(cfgCmdRoleDefault);
else if (strEq(commandRole, CONFIG_COMMAND_ROLE_ASYNC_STR))
FUNCTION_TEST_RETURN(cfgCmdRoleAsync);
else if (strEq(commandRole, CONFIG_COMMAND_ROLE_LOCAL_STR))
FUNCTION_TEST_RETURN(cfgCmdRoleLocal);
else if (strEq(commandRole, CONFIG_COMMAND_ROLE_REMOTE_STR))
FUNCTION_TEST_RETURN(cfgCmdRoleRemote);
THROW_FMT(CommandInvalidError, "invalid command role '%s'", strPtr(commandRole));
}
const String *
cfgCommandRoleStr(ConfigCommandRole commandRole)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(ENUM, commandRole);
FUNCTION_TEST_END();
const String *result = NULL;
switch (commandRole)
{
case cfgCmdRoleDefault:
break;
case cfgCmdRoleAsync:
{
result = CONFIG_COMMAND_ROLE_ASYNC_STR;
break;
}
case cfgCmdRoleLocal:
{
result = CONFIG_COMMAND_ROLE_LOCAL_STR;
break;
}
case cfgCmdRoleRemote:
{
result = CONFIG_COMMAND_ROLE_REMOTE_STR;
break;
}
}
FUNCTION_TEST_RETURN(result);
}
/***********************************************************************************************************************************
Command parameters, if any
***********************************************************************************************************************************/
@ -355,22 +448,23 @@ cfgLockRequired(void)
ASSERT(command != cfgCmdNone);
FUNCTION_TEST_RETURN(configCommandData[cfgCommand()].lockRequired);
// Local roles never take a lock and the remote role has special logic for locking
FUNCTION_TEST_RETURN(
// If a lock is required for the command and the role is default
(configCommandData[cfgCommand()].lockRequired && cfgCommandRole() == cfgCmdRoleDefault) ||
// Or any command when the role is async
cfgCommandRole() == cfgCmdRoleAsync);
}
/***********************************************************************************************************************************
Does the command require an immediate lock?
***********************************************************************************************************************************/
bool
cfgLockRemoteRequired(ConfigCommand commandId)
cfgLockRemoteRequired(void)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(ENUM, commandId);
FUNCTION_TEST_END();
FUNCTION_TEST_VOID();
ASSERT(commandId < cfgCmdNone);
FUNCTION_TEST_RETURN(configCommandData[commandId].lockRemoteRequired);
FUNCTION_TEST_RETURN(configCommandData[cfgCommand()].lockRemoteRequired);
}
/***********************************************************************************************************************************
@ -386,21 +480,6 @@ cfgLockType(void)
FUNCTION_TEST_RETURN((LockType)configCommandData[cfgCommand()].lockType);
}
/***********************************************************************************************************************************
Get the remote lock type required for the command
***********************************************************************************************************************************/
LockType
cfgLockRemoteType(ConfigCommand commandId)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(ENUM, commandId);
FUNCTION_TEST_END();
ASSERT(commandId < cfgCmdNone);
FUNCTION_TEST_RETURN((LockType)configCommandData[commandId].lockType);
}
/***********************************************************************************************************************************
Does this command log to a file?
***********************************************************************************************************************************/
@ -411,7 +490,13 @@ cfgLogFile(void)
ASSERT(command != cfgCmdNone);
FUNCTION_TEST_RETURN(configCommandData[cfgCommand()].logFile);
FUNCTION_TEST_RETURN(
// If the command always logs to a file
configCommandData[cfgCommand()].logFile ||
// Or log-level-file was explicitly set as a param/env var
cfgOptionSource(cfgOptLogLevelFile) == cfgSourceParam ||
// Or the role is async
cfgCommandRole() == cfgCmdRoleAsync);
}
/***********************************************************************************************************************************
@ -427,19 +512,6 @@ cfgLogLevelDefault(void)
FUNCTION_TEST_RETURN((LogLevel)configCommandData[cfgCommand()].logLevelDefault);
}
/***********************************************************************************************************************************
Get max stderr log level -- used to suppress error output for higher log levels, e.g. local and remote commands
***********************************************************************************************************************************/
LogLevel
cfgLogLevelStdErrMax(void)
{
FUNCTION_TEST_VOID();
ASSERT(command != cfgCmdNone);
FUNCTION_TEST_RETURN((LogLevel)configCommandData[cfgCommand()].logLevelStdErrMax);
}
/***********************************************************************************************************************************
Does this command allow parameters?
***********************************************************************************************************************************/

View File

@ -14,6 +14,33 @@ config/parse.c sets the command and options and determines which options are val
#include "config/config.auto.h"
/***********************************************************************************************************************************
Command Role Enum
Commands may have multiple processes that work together to implement their functionality. These roles allow each process to know
what it is supposed to do.
***********************************************************************************************************************************/
typedef enum
{
// Called directly by the user. This is the main part of the command that may or may not spawn other command roles.
cfgCmdRoleDefault,
// Async worker that is spawned so the main process can return a result while work continues. An async worker may spawn local
// or remote workers.
cfgCmdRoleAsync,
// Local worker for parallelizing jobs. A local work may spawn a remote worker.
cfgCmdRoleLocal,
// Remote worker for accessing resources on another host
cfgCmdRoleRemote,
} ConfigCommandRole;
// Constants for the command roles
#define CONFIG_COMMAND_ROLE_ASYNC "async"
#define CONFIG_COMMAND_ROLE_LOCAL "local"
#define CONFIG_COMMAND_ROLE_REMOTE "remote"
/***********************************************************************************************************************************
Constants
@ -29,17 +56,22 @@ Command Functions
Access the current command and command parameters.
***********************************************************************************************************************************/
ConfigCommand cfgCommand(void);
// Current command role (async, local, remote)
ConfigCommandRole cfgCommandRole(void);
bool cfgCommandInternal(ConfigCommand commandId);
const char *cfgCommandName(ConfigCommand commandId);
// Get command:role name
String *cfgCommandRoleName(void);
bool cfgLockRequired(void);
bool cfgLockRemoteRequired(ConfigCommand commandId);
bool cfgLockRemoteRequired(void);
LockType cfgLockType(void);
LockType cfgLockRemoteType(ConfigCommand commandId);
bool cfgLogFile(void);
LogLevel cfgLogLevelDefault(void);
LogLevel cfgLogLevelStdErrMax(void);
bool cfgParameterAllowed(void);
@ -98,7 +130,14 @@ void cfgCommandHelpSet(bool helpParam);
ConfigCommand cfgCommandId(const char *commandName, bool error);
void cfgCommandParamSet(const StringList *param);
void cfgCommandSet(ConfigCommand commandParam);
void cfgCommandSet(ConfigCommand commandId, ConfigCommandRole commandRoleId);
// Get command/role name with custom separator
String *cfgCommandRoleNameParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const String *separator);
// Convert command role from String to enum and vice versa
ConfigCommandRole cfgCommandRoleEnum(const String *commandRole);
const String *cfgCommandRoleStr(ConfigCommandRole commandRole);
const String *cfgExe(void);
void cfgExeSet(const String *exeParam);

File diff suppressed because it is too large Load Diff

View File

@ -12,17 +12,13 @@ Command define enum
typedef enum
{
cfgDefCmdArchiveGet,
cfgDefCmdArchiveGetAsync,
cfgDefCmdArchivePush,
cfgDefCmdArchivePushAsync,
cfgDefCmdBackup,
cfgDefCmdCheck,
cfgDefCmdExpire,
cfgDefCmdHelp,
cfgDefCmdInfo,
cfgDefCmdLocal,
cfgDefCmdLs,
cfgDefCmdRemote,
cfgDefCmdRestore,
cfgDefCmdStanzaCreate,
cfgDefCmdStanzaDelete,
@ -62,7 +58,6 @@ typedef enum
cfgDefOptBufferSize,
cfgDefOptChecksumPage,
cfgDefOptCmdSsh,
cfgDefOptCommand,
cfgDefOptCompress,
cfgDefOptCompressLevel,
cfgDefOptCompressLevelNetwork,

View File

@ -11,10 +11,11 @@ Exec Configuration
/**********************************************************************************************************************************/
StringList *
cfgExecParam(ConfigCommand commandId, const KeyValue *optionReplace, bool local, bool quote)
cfgExecParam(ConfigCommand commandId, ConfigCommandRole commandRoleId, const KeyValue *optionReplace, bool local, bool quote)
{
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(ENUM, commandId);
FUNCTION_LOG_PARAM(ENUM, commandRoleId);
FUNCTION_LOG_PARAM(KEY_VALUE, optionReplace);
FUNCTION_LOG_PARAM(BOOL, local); // Will the new process be running on the same host?
FUNCTION_LOG_PARAM(BOOL, quote); // Do parameters with spaces need to be quoted?
@ -124,8 +125,8 @@ cfgExecParam(ConfigCommand commandId, const KeyValue *optionReplace, bool local,
}
}
// Add the requested command
strLstAddZ(result, cfgCommandName(commandId));
// Add the command
strLstAdd(result, cfgCommandRoleNameParam(commandId, commandRoleId, COLON_STR));
// Move list to the calling context
strLstMove(result, MEM_CONTEXT_OLD());

View File

@ -14,6 +14,7 @@ Functions
// present. If local is set then the new command must have access to the local configuration files and environment since only
// options originally passed on the command-line will be added to the list. Use quote when the options will be used as a
// concatenated string rather than being passed directly to exec*() as a list.
StringList *cfgExecParam(ConfigCommand commandId, const KeyValue *optionReplace, bool local, bool quote);
StringList *cfgExecParam(
ConfigCommand commandId, ConfigCommandRole commandRoleId, const KeyValue *optionReplace, bool local, bool quote);
#endif

View File

@ -37,10 +37,6 @@ cfgLoadLogSetting(void)
if (cfgOptionValid(cfgOptLogLevelStderr))
{
logLevelStdErr = logLevelEnum(strPtr(cfgOptionStr(cfgOptLogLevelStderr)));
// If configured log level exceeds the max for a command, set it to the max
if (logLevelStdErr > cfgLogLevelStdErrMax())
logLevelStdErr = cfgLogLevelStdErrMax();
}
if (cfgOptionValid(cfgOptLogLevelFile))
@ -136,7 +132,7 @@ cfgLoadUpdateOption(void)
}
// Warn when repo-retention-full is not set on a configured repo
if (!cfgCommandHelp() && cfgOptionValid(cfgOptRepoRetentionFull))
if (!cfgCommandHelp() && cfgOptionValid(cfgOptRepoRetentionFull) && cfgCommandRole() == cfgCmdRoleDefault)
{
for (unsigned int optionIdx = 0; optionIdx < cfgOptionIndexTotal(cfgOptRepoType); optionIdx++)
{
@ -247,20 +243,29 @@ cfgLoadLogFile(void)
{
// Construct log filename prefix
String *logFile = strNewFmt(
"%s/%s-", strPtr(cfgOptionStr(cfgOptLogPath)),
cfgOptionTest(cfgOptStanza) ? strPtr(cfgOptionStr(cfgOptStanza)): "all");
"%s/%s-%s", strPtr(cfgOptionStr(cfgOptLogPath)),
cfgOptionTest(cfgOptStanza) ? strPtr(cfgOptionStr(cfgOptStanza)): "all", cfgCommandName(cfgCommand()));
// If local or remote command add command name and process id
if (cfgCommand() == cfgCmdLocal || cfgCommand() == cfgCmdRemote)
// ??? Append async for local/remote archive async commands. It would be good to find a more generic way to do this in
// case the async role is added to more commands.
if (cfgCommandRole() == cfgCmdRoleLocal || cfgCommandRole() == cfgCmdRoleRemote)
{
strCatFmt(
logFile, "%s-%s-%03u.log", strPtr(cfgOptionStr(cfgOptCommand)), cfgCommandName(cfgCommand()),
cfgOptionUInt(cfgOptProcess));
if (cfgOptionValid(cfgOptArchiveAsync) && cfgOptionBool(cfgOptArchiveAsync))
strCatFmt(logFile, "-async");
}
// Else add command name
else
strCatFmt(logFile, "%s.log", cfgCommandName(cfgCommand()));
// Add command role if it is not default
if (cfgCommandRole() != cfgCmdRoleDefault)
strCatFmt(logFile, "-%s", strPtr(cfgCommandRoleStr(cfgCommandRole())));
// Add process id if local or remote role
if (cfgCommandRole() == cfgCmdRoleLocal || cfgCommandRole() == cfgCmdRoleRemote)
strCatFmt(logFile, "-%03u", cfgOptionUInt(cfgOptProcess));
// Add extension
strCat(logFile, ".log");
// Attempt to open log file
if (!logFileSet(strPtr(logFile)))
cfgOptionSet(cfgOptLogLevelFile, cfgSourceParam, varNewStrZ("off"));
}

View File

@ -153,14 +153,6 @@ static const struct option optionList[] =
.val = PARSE_OPTION_FLAG | PARSE_RESET_FLAG | cfgOptCmdSsh,
},
// command option
// -----------------------------------------------------------------------------------------------------------------------------
{
.name = CFGOPT_COMMAND,
.has_arg = required_argument,
.val = PARSE_OPTION_FLAG | cfgOptCommand,
},
// compress option
// -----------------------------------------------------------------------------------------------------------------------------
{
@ -2343,7 +2335,6 @@ static const ConfigOption optionResolveOrder[] =
cfgOptBufferSize,
cfgOptChecksumPage,
cfgOptCmdSsh,
cfgOptCommand,
cfgOptCompress,
cfgOptCompressLevel,
cfgOptCompressLevelNetwork,

View File

@ -461,15 +461,34 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
// The first argument should be the command
if (!commandSet)
{
const char *command = argList[optind - 1];
// Try getting the command from the valid command list
ConfigCommand commandId = cfgCommandId(argList[optind - 1], false);
ConfigCommand commandId = cfgCommandId(command, false);
ConfigCommandRole commandRoleId = cfgCmdRoleDefault;
// If not successful then a command role may be appended
if (commandId == cfgCmdNone)
{
const StringList *commandPart = strLstNewSplit(STR(command), COLON_STR);
if (strLstSize(commandPart) == 2)
{
// Get command id
commandId = cfgCommandId(strPtr(strLstGet(commandPart, 0)), false);
// If command id is valid then get command role id
if (commandId != cfgCmdNone)
commandRoleId = cfgCommandRoleEnum(strLstGet(commandPart, 1));
}
}
// Error when command does not exist
if (commandId == cfgCmdNone)
THROW_FMT(CommandInvalidError, "invalid command '%s'", argList[optind - 1]);
THROW_FMT(CommandInvalidError, "invalid command '%s'", command);
// Set the command
cfgCommandSet(commandId);
cfgCommandSet(commandId, commandRoleId);
if (cfgCommand() == cfgCmdHelp)
cfgCommandHelpSet(true);
@ -596,7 +615,7 @@ configParse(unsigned int argListSize, const char *argList[], bool resetLogLevel)
}
// Enable logging (except for local and remote commands) so config file warnings will be output
if (cfgCommand() != cfgCmdLocal && cfgCommand() != cfgCmdRemote && resetLogLevel)
if (cfgCommandRole() != cfgCmdRoleLocal && cfgCommandRole() != cfgCmdRoleRemote && resetLogLevel)
logInit(logLevelWarn, logLevelWarn, logLevelOff, false, 1);
// Only continue if command options need to be validated, i.e. a real command is running or we are getting help for a

View File

@ -59,6 +59,7 @@ main(int argListSize, const char *argList[])
// Load the configuration
// -------------------------------------------------------------------------------------------------------------------------
cfgLoad((unsigned int)argListSize, argList);
ConfigCommandRole commandRole = cfgCommandRole();
// Display help
// -------------------------------------------------------------------------------------------------------------------------
@ -66,6 +67,18 @@ main(int argListSize, const char *argList[])
{
cmdHelp();
}
// Local role
// -------------------------------------------------------------------------------------------------------------------------
else if (commandRole == cfgCmdRoleLocal)
{
cmdLocal(STDIN_FILENO, STDOUT_FILENO);
}
// Remote role
// -------------------------------------------------------------------------------------------------------------------------
else if (commandRole == cfgCmdRoleRemote)
{
cmdRemote(STDIN_FILENO, STDOUT_FILENO);
}
else
{
switch (cfgCommand())
@ -74,15 +87,11 @@ main(int argListSize, const char *argList[])
// -----------------------------------------------------------------------------------------------------------------
case cfgCmdArchiveGet:
{
result = cmdArchiveGet();
break;
}
if (commandRole == cfgCmdRoleAsync)
cmdArchiveGetAsync();
else
result = cmdArchiveGet();
// Archive get async command
// -----------------------------------------------------------------------------------------------------------------
case cfgCmdArchiveGetAsync:
{
cmdArchiveGetAsync();
break;
}
@ -90,15 +99,11 @@ main(int argListSize, const char *argList[])
// -----------------------------------------------------------------------------------------------------------------
case cfgCmdArchivePush:
{
cmdArchivePush();
break;
}
if (commandRole == cfgCmdRoleAsync)
cmdArchivePushAsync();
else
cmdArchivePush();
// Archive push async command
// -----------------------------------------------------------------------------------------------------------------
case cfgCmdArchivePushAsync:
{
cmdArchivePushAsync();
break;
}
@ -111,7 +116,7 @@ main(int argListSize, const char *argList[])
// Switch to expire command
cmdEnd(0, NULL);
cfgCommandSet(cfgCmdExpire);
cfgCommandSet(cfgCmdExpire, cfgCmdRoleDefault);
cfgLoadLogFile();
cmdBegin(true);
@ -153,22 +158,6 @@ main(int argListSize, const char *argList[])
break;
}
// Local command
// -----------------------------------------------------------------------------------------------------------------
case cfgCmdLocal:
{
cmdLocal(STDIN_FILENO, STDOUT_FILENO);
break;
}
// Remote command
// -----------------------------------------------------------------------------------------------------------------
case cfgCmdRemote:
{
cmdRemote(STDIN_FILENO, STDOUT_FILENO);
break;
}
// Restore command
// -----------------------------------------------------------------------------------------------------------------
case cfgCmdRestore:

View File

@ -121,9 +121,6 @@ protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int hostId,
// Option replacements
KeyValue *optionReplace = kvNew();
// Add the command option
kvPut(optionReplace, VARSTR(CFGOPT_COMMAND_STR), VARSTRZ(cfgCommandName(cfgCommand())));
// Add the process id -- used when more than one process will be called
kvPut(optionReplace, VARSTR(CFGOPT_PROCESS_STR), VARUINT(protocolId));
@ -141,7 +138,10 @@ protocolLocalParam(ProtocolStorageType protocolStorageType, unsigned int hostId,
// Always output errors on stderr for debugging purposes
kvPut(optionReplace, VARSTR(CFGOPT_LOG_LEVEL_STDERR_STR), VARSTRDEF("error"));
result = strLstMove(cfgExecParam(cfgCmdLocal, optionReplace, true, false), MEM_CONTEXT_OLD());
// Disable output to stdout since it is used by the protocol
kvPut(optionReplace, VARSTR(CFGOPT_LOG_LEVEL_CONSOLE_STR), VARSTRDEF("off"));
result = strLstMove(cfgExecParam(cfgCommand(), cfgCmdRoleLocal, optionReplace, true, false), MEM_CONTEXT_OLD());
}
MEM_CONTEXT_TEMP_END();
@ -265,34 +265,68 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int protoc
optionReplace, VARSTR(CFGOPT_CONFIG_PATH_STR),
cfgOptionSource(optConfigPath) != cfgSourceDefault ? cfgOption(optConfigPath) : NULL);
// Update/remove pg options that are sent to the remote
// Update/remove repo/pg options that are sent to the remote
const String *repoHostPrefix = STR(cfgDefOptionName(cfgDefOptRepoHost));
const String *repoPrefix = strNewFmt("%s-", PROTOCOL_REMOTE_TYPE_REPO);
const String *pgHostPrefix = STR(cfgDefOptionName(cfgDefOptPgHost));
const String *pgPrefix = strNewFmt("%s-", PROTOCOL_REMOTE_TYPE_PG);
for (ConfigOption optionId = 0; optionId < CFG_OPTION_TOTAL; optionId++)
{
const String *optionDefName = STR(cfgDefOptionName(cfgOptionDefIdFromId(optionId)));
bool remove = false;
if (strBeginsWith(optionDefName, pgPrefix) && !strBeginsWith(optionDefName, pgHostPrefix) && cfgOptionIndex(optionId) > 0)
// Remove repo host options that are not needed on the remote. The remote is not expecting to see host settings and it
// could get confused about the locality of the repo, i.e. local or remote.
if (strBeginsWith(optionDefName, repoHostPrefix))
{
// If the option index matches the host-id then this is a pg option that the remote needs. Since the remote expects to
// find pg options in index 0 copy the option to index 0.
if (cfgOptionIndex(optionId) == hostIdx)
{
kvPut(
optionReplace, VARSTRZ(cfgOptionName(optionId - hostIdx)),
cfgOptionSource(optionId) != cfgSourceDefault ? cfgOption(optionId) : NULL);
}
// Remove pg options that are not needed on the remote. The remote is only going to look at index 0 so the options in
// higher indexes will not be used and just add clutter which makes debugging harder.
kvPut(optionReplace, VARSTRZ(cfgOptionName(optionId)), NULL);
remove = true;
}
// Remove repo options when the remote type is pg since they won't be used
else if (strBeginsWith(optionDefName, repoPrefix))
{
if (protocolStorageType == protocolStorageTypePg)
remove = true;
}
// Remove pg host options that are not needed on the remote. The remote is not expecting to see host settings and it could
// get confused about the locality of pg, i.e. local or remote.
else if (strBeginsWith(optionDefName, pgHostPrefix))
{
remove = true;
}
else if (strBeginsWith(optionDefName, pgPrefix))
{
// Remove pg options when the remote type is repo since they won't be used
if (protocolStorageType == protocolStorageTypeRepo)
{
remove = true;
}
// Else move/remove pg options with index > 0 since they won't be used
else if (cfgOptionIndex(optionId) > 0)
{
// If the option index matches the host-id then this is a pg option that the remote needs. Since the remote expects
// to find pg options in index 0, copy the option to index 0.
if (cfgOptionIndex(optionId) == hostIdx)
{
kvPut(
optionReplace, VARSTRZ(cfgOptionName(optionId - hostIdx)),
cfgOptionSource(optionId) != cfgSourceDefault ? cfgOption(optionId) : NULL);
}
// Remove pg options that are not needed on the remote. The remote is only going to look at index 0 so the options
// in higher indexes will not be used and just add clutter which makes debugging harder.
remove = true;
}
}
// Remove options that have been marked for removal if they are not already null or invalid. This is more efficient because
// cfgExecParam() won't have to search through as large a list looking for overrides.
if (remove && cfgOptionTest(optionId))
kvPut(optionReplace, VARSTRZ(cfgOptionName(optionId)), NULL);
}
// Add the command option (or use the current command option if it is valid)
if (!cfgOptionTest(cfgOptCommand))
kvPut(optionReplace, VARSTR(CFGOPT_COMMAND_STR), VARSTRZ(cfgCommandName(cfgCommand())));
// Don't pass host-id to the remote. The host will always be in index 0.
kvPut(optionReplace, VARSTR(CFGOPT_HOST_ID_STR), NULL);
// Add the process id (or use the current process id if it is valid)
if (!cfgOptionTest(cfgOptProcess))
@ -302,6 +336,17 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int protoc
kvPut(optionReplace, VARSTR(CFGOPT_LOG_PATH_STR), NULL);
kvPut(optionReplace, VARSTR(CFGOPT_LOCK_PATH_STR), NULL);
// ??? Don't pass restore options which the remote doesn't need and are likely to contain spaces because they might get mangled
// on the way to the remote depending on how SSH is set up on the server. This code should be removed when option passing with
// spaces is resolved.
kvPut(optionReplace, VARSTR(CFGOPT_TYPE_STR), NULL);
kvPut(optionReplace, VARSTR(CFGOPT_TARGET_STR), NULL);
kvPut(optionReplace, VARSTR(CFGOPT_TARGET_EXCLUSIVE_STR), NULL);
kvPut(optionReplace, VARSTR(CFGOPT_TARGET_ACTION_STR), NULL);
kvPut(optionReplace, VARSTR(CFGOPT_TARGET_STR), NULL);
kvPut(optionReplace, VARSTR(CFGOPT_TARGET_TIMELINE_STR), NULL);
kvPut(optionReplace, VARSTR(CFGOPT_RECOVERY_OPTION_STR), NULL);
// Only enable file logging on the remote when requested
kvPut(
optionReplace, VARSTR(CFGOPT_LOG_LEVEL_FILE_STR),
@ -310,10 +355,13 @@ protocolRemoteParam(ProtocolStorageType protocolStorageType, unsigned int protoc
// Always output errors on stderr for debugging purposes
kvPut(optionReplace, VARSTR(CFGOPT_LOG_LEVEL_STDERR_STR), VARSTRDEF("error"));
// Disable output to stdout since it is used by the protocol
kvPut(optionReplace, VARSTR(CFGOPT_LOG_LEVEL_CONSOLE_STR), VARSTRDEF("off"));
// Add the remote type
kvPut(optionReplace, VARSTR(CFGOPT_REMOTE_TYPE_STR), VARSTR(protocolStorageTypeStr(protocolStorageType)));
StringList *commandExec = cfgExecParam(cfgCmdRemote, optionReplace, false, true);
StringList *commandExec = cfgExecParam(cfgCommand(), cfgCmdRoleRemote, optionReplace, false, true);
strLstInsert(commandExec, 0, cfgOptionStr(isRepo ? cfgOptRepoHostCmd : cfgOptPgHostCmd + hostIdx));
strLstAdd(result, strLstJoin(commandExec, " "));

View File

@ -30,15 +30,16 @@ harnessCfgLoadRaw(unsigned int argListSize, const char *argList[])
/**********************************************************************************************************************************/
void
harnessCfgLoad(ConfigCommand commandId, const StringList *argOriginalList)
harnessCfgLoadRole(ConfigCommand commandId, ConfigCommandRole commandRoleId, const StringList *argListParam)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(ENUM, commandId);
FUNCTION_HARNESS_PARAM(STRING_LIST, argOriginalList);
FUNCTION_HARNESS_PARAM(ENUM, commandRoleId);
FUNCTION_HARNESS_PARAM(STRING_LIST, argListParam);
FUNCTION_HARNESS_END();
// Make a copy of the arg list that we can modify
StringList *argList = strLstDup(argOriginalList);
StringList *argList = strLstDup(argListParam);
// Set log path if valid
if (cfgDefOptionValid(cfgCommandDefIdFromId(commandId), cfgDefOptLogPath))
@ -49,7 +50,7 @@ harnessCfgLoad(ConfigCommand commandId, const StringList *argOriginalList)
strLstInsert(argList, 0, strNewFmt("--" CFGOPT_LOCK_PATH "=%s/lock", testDataPath()));
// Insert the command so it does not interfere with parameters
strLstInsertZ(argList, 0, cfgCommandName(commandId));
strLstInsert(argList, 0, cfgCommandRoleNameParam(commandId, commandRoleId, COLON_STR));
// Insert the project exe
strLstInsert(argList, 0, STRDEF(testProjectExe()));
@ -58,3 +59,17 @@ harnessCfgLoad(ConfigCommand commandId, const StringList *argOriginalList)
FUNCTION_HARNESS_RESULT_VOID();
}
/**********************************************************************************************************************************/
void
harnessCfgLoad(ConfigCommand commandId, const StringList *argListParam)
{
FUNCTION_HARNESS_BEGIN();
FUNCTION_HARNESS_PARAM(ENUM, commandId);
FUNCTION_HARNESS_PARAM(STRING_LIST, argListParam);
FUNCTION_HARNESS_END();
harnessCfgLoadRole(commandId, cfgCmdRoleDefault, argListParam);
FUNCTION_HARNESS_RESULT_VOID();
}

View File

@ -11,5 +11,6 @@ There's no need to open log files, acquire locks, reset log levels, etc.
// Low-level version used in a few places to simulate special cases and error conditions. Most tests should use harnessCfgLoad().
void harnessCfgLoadRaw(unsigned int argListSize, const char *argList[]);
// Automatically adds the exe, command, lock-path, and log-path so executing the binary works locally or in a container.
// Automatically adds the exe, command (and role), lock-path, and log-path so executing the binary works locally or in a container.
void harnessCfgLoad(ConfigCommand commandId, const StringList *argList);
void harnessCfgLoadRole(ConfigCommand commandId, ConfigCommandRole commandRoleId, const StringList *argList);

View File

@ -112,8 +112,8 @@ testRun(void)
StringList *argList = strLstNew();
strLstAdd(argList, strNewFmt("--spool-path=%s", testPath()));
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "archive-get-async");
harnessCfgLoad(cfgCmdArchiveGetAsync, argList);
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleAsync, argList);
String *walSegment = strNew("000000010000000100000001");

View File

@ -220,9 +220,10 @@ testRun(void)
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--pg1-path=%s/db", testPath()));
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
strLstAddZ(argList, "--repo1-cipher-type=aes-256-cbc");
setenv("PGBACKREST_REPO1_CIPHER_PASS", "12345678", true);
harnessCfgLoad(cfgCmdArchiveGetAsync, argList);
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleAsync, argList);
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
storagePathCreateP(storageTest, strNew("spool/archive/test1/in"));
@ -323,8 +324,9 @@ testRun(void)
strLstAdd(argCleanList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAdd(argCleanList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argCleanList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAddZ(argCleanList, "--" CFGOPT_ARCHIVE_ASYNC);
strLstAddZ(argCleanList, "--stanza=test2");
harnessCfgLoad(cfgCmdArchiveGetAsync, argCleanList);
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleAsync, argCleanList);
TEST_ERROR(cmdArchiveGetAsync(), ParamInvalidError, "at least one wal segment is required");
@ -347,7 +349,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
StringList *argList = strLstDup(argCleanList);
strLstAddZ(argList, "000000010000000100000001");
harnessCfgLoad(cfgCmdArchiveGetAsync, argList);
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleAsync, argList);
storagePathCreateP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN));
@ -376,7 +378,7 @@ testRun(void)
strLstAddZ(argList, "000000010000000100000001");
strLstAddZ(argList, "000000010000000100000002");
strLstAddZ(argList, "000000010000000100000003");
harnessCfgLoad(cfgCmdArchiveGetAsync, argList);
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleAsync, argList);
storagePathCreateP(storageSpoolWrite(), strNew(STORAGE_SPOOL_ARCHIVE_IN));
@ -438,8 +440,9 @@ testRun(void)
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
strLstAddZ(argList, "--stanza=test2");
strLstAddZ(argList, "archive-get-async");
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_ASYNC);
strLstAddZ(argList, "000000010000000100000001");
strLstAddZ(argList, "000000010000000100000002");
strLstAddZ(argList, "000000010000000100000003");

View File

@ -42,7 +42,8 @@ testRun(void)
strLstAddZ(argList, "--stanza=db");
strLstAdd(argList, strNewFmt("--pg1-path=%s/db", testPath()));
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
harnessCfgLoad(cfgCmdArchivePushAsync, argList);
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argList);
storagePathCreateP(storagePgWrite(), strNew("pg_wal/archive_status"));
storagePathCreateP(storageTest, strNew("spool/archive/db/out"));
@ -79,7 +80,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
StringList *argListDrop = strLstDup(argList);
strLstAdd(argListDrop, strNewFmt("--archive-push-queue-max=%zu", (size_t)1024 * 1024 * 1024));
harnessCfgLoad(cfgCmdArchivePushAsync, argListDrop);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argListDrop);
// Write the files that we claim are in pg_wal
Buffer *walBuffer = bufNew((size_t)16 * 1024 * 1024);
@ -100,7 +101,7 @@ testRun(void)
// Now set queue max low enough that WAL will be dropped
argListDrop = strLstDup(argList);
strLstAdd(argListDrop, strNewFmt("--archive-push-queue-max=%zu", (size_t)16 * 1024 * 1024 * 2));
harnessCfgLoad(cfgCmdArchivePushAsync, argListDrop);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argListDrop);
TEST_RESULT_BOOL(
archivePushDrop(strNew("pg_wal"), archivePushProcessList(strNewFmt("%s/db/pg_wal", testPath()))), true,
@ -556,10 +557,11 @@ testRun(void)
strLstAddZ(argList, "--stanza=test");
strLstAddZ(argList, "--no-compress");
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
strLstAdd(argList, strNewFmt("--pg1-path=%s/pg", testPath()));
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
strLstAddZ(argList, "--log-subprocess");
harnessCfgLoad(cfgCmdArchivePushAsync, argList);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argList);
TEST_ERROR(cmdArchivePushAsync(), ParamRequiredError, "WAL path to push required");
@ -576,7 +578,7 @@ testRun(void)
storagePathCreateP(storagePgWrite(), strNew("pg_xlog/archive_status"));
strLstAdd(argList, strNewFmt("%s/pg/pg_xlog", testPath()));
harnessCfgLoad(cfgCmdArchivePushAsync, argList);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argList);
TEST_ERROR(cmdArchivePushAsync(), AssertError, "no WAL files to process");
@ -628,7 +630,7 @@ testRun(void)
argListTemp = strLstDup(argList);
strLstAddZ(argListTemp, "--archive-push-queue-max=1gb");
harnessCfgLoad(cfgCmdArchivePushAsync, argListTemp);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argListTemp);
TEST_RESULT_VOID(cmdArchivePushAsync(), "push WAL segments");
harnessLogResult(
@ -655,7 +657,7 @@ testRun(void)
argListTemp = strLstDup(argList);
strLstAddZ(argListTemp, "--archive-push-queue-max=16m");
harnessCfgLoad(cfgCmdArchivePushAsync, argListTemp);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleAsync, argListTemp);
TEST_RESULT_VOID(cmdArchivePushAsync(), "push WAL segments");
harnessLogResult(

View File

@ -22,7 +22,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
cfgInit();
cfgCommandSet(cfgCmdArchiveGet);
cfgCommandSet(cfgCmdArchiveGet, cfgCmdRoleDefault);
cfgOptionValidSet(cfgOptCompress, true);
cfgOptionSet(cfgOptCompress, cfgSourceParam, varNewBool(true));
@ -45,7 +45,7 @@ testRun(void)
"P00 INFO: archive-get command begin " PROJECT_VERSION ": [param1, \"param 2\"] --compress");
cfgInit();
cfgCommandSet(cfgCmdArchiveGet);
cfgCommandSet(cfgCmdArchiveGet, cfgCmdRoleDefault);
cfgOptionValidSet(cfgOptConfig, true);
cfgOptionNegateSet(cfgOptConfig, true);
@ -78,14 +78,14 @@ testRun(void)
kvPut(recoveryKv, varNewStr(strNew("primary_conn_info")), varNewStr(strNew("blah")));
cfgOptionSet(cfgOptRecoveryOption, cfgSourceParam, recoveryVar);
cfgCommandSet(cfgCmdRestore);
cfgCommandSet(cfgCmdRestore, cfgCmdRoleDefault);
TEST_RESULT_VOID(cmdBegin(true), "command begin with option logging");
harnessLogResult(
"P00 INFO: restore command begin " PROJECT_VERSION ": --no-config --db-include=db1 --db-include=db2"
" --recovery-option=standby_mode=on --recovery-option=primary_conn_info=blah --reset-repo1-host"
" --repo1-path=\"/path/to the/repo\" --repo1-s3-key=<redacted>");
cfgCommandSet(cfgCmdArchiveGet);
cfgCommandSet(cfgCmdArchiveGet, cfgCmdRoleDefault);
TEST_RESULT_VOID(cmdBegin(true), "command begin with limited option logging");
harnessLogResult(
"P00 INFO: archive-get command begin " PROJECT_VERSION ": --no-config --reset-repo1-host"

View File

@ -32,11 +32,10 @@ testRun(void)
{
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
strLstAddZ(argList, "--command=archive-get-async");
strLstAddZ(argList, "--process=1");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAddZ(argList, "--host-id=1");
harnessCfgLoad(cfgCmdLocal, argList);
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList);
cmdLocal(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE());
}

View File

@ -34,10 +34,9 @@ testRun(void)
{
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
strLstAddZ(argList, "--command=info");
strLstAddZ(argList, "--process=1");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
harnessCfgLoad(cfgCmdRemote, argList);
harnessCfgLoadRole(cfgCmdInfo, cfgCmdRoleRemote, argList);
cmdRemote(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE());
}
@ -67,11 +66,11 @@ testRun(void)
{
StringList *argList = strLstNew();
strLstAddZ(argList, testProjectExe());
strLstAddZ(argList, "--command=archive-get-async");
strLstAddZ(argList, "--process=0");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAddZ(argList, "--lock-path=/bogus");
strLstAddZ(argList, "remote");
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_REMOTE);
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
cmdRemote(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE());
@ -104,11 +103,10 @@ testRun(void)
StringList *argList = strLstNew();
strLstAddZ(argList, testProjectExe());
strLstAddZ(argList, "--stanza=test");
strLstAddZ(argList, "--command=archive-push-async");
strLstAddZ(argList, "--process=0");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAddZ(argList, "--lock-path=/bogus");
strLstAddZ(argList, "remote");
strLstAddZ(argList, CFGCMD_ARCHIVE_PUSH ":" CONFIG_COMMAND_ROLE_REMOTE);
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
cmdRemote(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE());
@ -139,10 +137,9 @@ testRun(void)
{
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test");
strLstAddZ(argList, "--command=archive-push-async");
strLstAddZ(argList, "--process=0");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
harnessCfgLoad(cfgCmdRemote, argList);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleRemote, argList);
cmdRemote(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE());
}
@ -180,10 +177,9 @@ testRun(void)
{
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test");
strLstAddZ(argList, "--command=archive-push-async");
strLstAddZ(argList, "--process=0");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
harnessCfgLoad(cfgCmdRemote, argList);
harnessCfgLoadRole(cfgCmdArchivePush, cfgCmdRoleRemote, argList);
cmdRemote(HARNESS_FORK_CHILD_READ(), HARNESS_FORK_CHILD_WRITE());
}

View File

@ -43,13 +43,13 @@ testRun(void)
if (testBegin("exitSafe()"))
{
cfgInit();
cfgCommandSet(cfgCmdNone);
cfgCommandSet(cfgCmdNone, cfgCmdRoleDefault);
TEST_RESULT_INT(exitSafe(0, false, signalTypeNone), 0, "exit with no command")
// -------------------------------------------------------------------------------------------------------------------------
cfgInit();
cfgCommandSet(cfgCmdArchivePush);
cfgCommandSet(cfgCmdArchivePush, cfgCmdRoleDefault);
TEST_RESULT_INT(exitSafe(0, false, signalTypeNone), 0, "exit with no error")
harnessLogResult("P00 INFO: archive-push command end: completed successfully");

View File

@ -56,38 +56,57 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_INT(cfgCommand(), cfgCmdNone, "command begins as none");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup), "command set to backup");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault), "command set to backup");
TEST_RESULT_INT(cfgCommand(), cfgCmdBackup, "command is backup");
TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup", "command:role is backup");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup), "command set to backup");
TEST_RESULT_INT(cfgCommandInternal(cfgCmdLocal), true, "local is internal");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleLocal), "command set to backup:local");
TEST_RESULT_STR_Z(cfgCommandRoleName(), "backup:local", "command:role is backup:local");
TEST_RESULT_INT(cfgCommandInternal(cfgCmdBackup), false, "backup is external");
TEST_RESULT_INT(cfgLogLevelDefault(), logLevelInfo, "default log level is info");
TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on");
TEST_RESULT_BOOL(cfgLockRequired(), true, "lock is required");
TEST_RESULT_BOOL(cfgLockRemoteRequired(cfgCmdBackup), true, "remote lock is required");
TEST_RESULT_BOOL(cfgLockRequired(), false, "lock is not required");
TEST_RESULT_BOOL(cfgLockRemoteRequired(), true, "remote lock is required");
TEST_RESULT_INT(cfgLockType(), lockTypeBackup, "lock is type backup");
TEST_RESULT_INT(cfgLockRemoteType(cfgCmdBackup), lockTypeBackup, "remote lock is type backup");
TEST_RESULT_BOOL(cfgParameterAllowed(), false, "parameters not allowed");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdInfo), "command set to info");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdInfo, cfgCmdRoleDefault), "command set to info");
TEST_RESULT_INT(cfgLogLevelDefault(), logLevelDebug, "default log level is debug");
TEST_RESULT_INT(cfgLogLevelStdErrMax(), logLevelTrace, "max stderr log level is trace");
TEST_RESULT_BOOL(cfgLogFile(), false, "log file is off");
TEST_RESULT_BOOL(cfgLockRequired(), false, "lock is not required");
TEST_RESULT_BOOL(cfgLockRemoteRequired(cfgCmdInfo), false, "remote lock is not required");
TEST_RESULT_BOOL(cfgLockRemoteRequired(), false, "remote lock is not required");
TEST_RESULT_INT(cfgLockType(), lockTypeNone, "lock is type none");
TEST_RESULT_INT(cfgLockRemoteType(cfgCmdInfo), lockTypeNone, "remote lock is type none");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdStanzaCreate), "command set to stanza-create");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdStanzaCreate, cfgCmdRoleDefault), "command set to stanza-create");
TEST_RESULT_BOOL(cfgLockRequired(), true, "lock is required");
TEST_RESULT_INT(cfgLockType(), lockTypeAll, "lock is type all");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdLocal), "command set to local");
TEST_RESULT_INT(cfgLogLevelStdErrMax(), logLevelError, "max stderr log level is error");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdArchiveGet, cfgCmdRoleAsync), "command set to archive-get:async");
TEST_RESULT_BOOL(cfgLockRequired(), true, "lock is required");
TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdInfo, cfgCmdRoleDefault), "command set to info");
cfgOptionSet(cfgOptLogLevelFile, cfgSourceParam, VARSTRDEF("info"));
cfgOptionValidSet(cfgOptLogLevelFile, true);
TEST_RESULT_BOOL(cfgLogFile(), true, "log file is on");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("command roles");
TEST_ERROR(cfgCommandRoleEnum(strNew(BOGUS_STR)), CommandInvalidError, "invalid command role 'BOGUS'");
TEST_RESULT_UINT(cfgCommandRoleEnum(NULL), cfgCmdRoleDefault, "command default role enum");
TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("async")), cfgCmdRoleAsync, "command async role enum");
TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("local")), cfgCmdRoleLocal, "command local role enum");
TEST_RESULT_UINT(cfgCommandRoleEnum(strNew("remote")), cfgCmdRoleRemote, "command remote role enum");
TEST_RESULT_STR(cfgCommandRoleStr(cfgCmdRoleDefault), NULL, "command default role str");
TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleAsync), "async", "command async role str");
TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleLocal), "local", "command local role str");
TEST_RESULT_STR_Z(cfgCommandRoleStr(cfgCmdRoleRemote), "remote", "command remote role str");
// -------------------------------------------------------------------------------------------------------------------------
TEST_RESULT_BOOL(cfgCommandHelp(), false, "command help defaults to false");
TEST_RESULT_VOID(cfgCommandHelpSet(true), "set command help");
@ -207,7 +226,7 @@ testRun(void)
unsigned int port = 55555;
cfgInit();
cfgCommandSet(cfgCmdBackup);
cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault);
cfgOptionValidSet(cfgOptRepoS3Host, true);
cfgOptionSet(cfgOptRepoS3Host, cfgSourceConfig, varNewStrZ("host.com")) ;
@ -241,7 +260,7 @@ testRun(void)
if (testBegin("cfgOptionDefault() and cfgOptionDefaultSet()"))
{
TEST_RESULT_VOID(cfgInit(), "config init");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup), "backup command");
TEST_RESULT_VOID(cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault), "backup command");
TEST_ERROR(
strPtr(varStr(cfgOptionDefaultValue(cfgOptDbInclude))), AssertError, "default value not available for option type 4");

View File

@ -58,7 +58,6 @@ testRun(void)
"assertion 'optionDefId < cfgDefOptionTotal()' failed");
TEST_RESULT_Z(cfgDefOptionDefault(cfgDefCmdBackup, cfgDefOptCompressLevel), "6", "option default exists");
TEST_RESULT_Z(cfgDefOptionDefault(cfgDefCmdRestore, cfgDefOptType), "default", "command default exists");
TEST_RESULT_Z(cfgDefOptionDefault(cfgDefCmdLocal, cfgDefOptType), NULL, "command default does not exist");
TEST_RESULT_Z(cfgDefOptionDefault(cfgDefCmdBackup, cfgDefOptRepoHost), NULL, "default does not exist");
TEST_RESULT_BOOL(cfgDefOptionDepend(cfgDefCmdRestore, cfgDefOptRepoS3Key), true, "has depend option");

View File

@ -23,6 +23,7 @@ testRun(void)
strLstAddZ(argList, "--no-config");
strLstAddZ(argList, "--reset-neutral-umask");
strLstAddZ(argList, "--repo-cipher-type=aes-256-cbc");
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
strLstAddZ(argList, "archive-get");
// Set repo1-cipher-pass to make sure it is not passed on the command line
@ -31,12 +32,20 @@ testRun(void)
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
TEST_RESULT_STR(
strLstJoin(cfgExecParam(cfgCmdLocal, NULL, false, true), "|"),
strLstJoin(cfgExecParam(cfgCmdArchiveGet, cfgCmdRoleAsync, NULL, false, true), "|"),
strNewFmt(
"--no-config|--log-subprocess|--reset-neutral-umask|--pg1-path=\"%s/db path\"|--repo1-path=%s/repo"
"|--stanza=test1|local",
"--archive-async|--no-config|--log-subprocess|--reset-neutral-umask|--pg1-path=\"%s/db path\"|--repo1-path=%s/repo"
"|--stanza=test1|archive-get:async",
testPath(), testPath()),
"exec archive-get -> local");
"exec archive-get -> archive-get:async");
TEST_RESULT_STR(
strLstJoin(cfgExecParam(cfgCmdBackup, cfgCmdRoleDefault, NULL, false, false), "|"),
strNewFmt(
"--no-config|--log-subprocess|--reset-neutral-umask|--pg1-path=%s/db path|--repo1-path=%s/repo"
"|--stanza=test1|backup",
testPath(), testPath()),
"exec archive-get -> backup");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
@ -59,7 +68,7 @@ testRun(void)
kvPut(optionReplace, varNewStr(strNew("stanza")), NULL);
TEST_RESULT_STR(
strLstJoin(cfgExecParam(cfgCmdRestore, optionReplace, true, false), "|"),
strLstJoin(cfgExecParam(cfgCmdRestore, cfgCmdRoleDefault, optionReplace, true, false), "|"),
strNewFmt(
"--db-include=1|--db-include=2|--pg1-path=%s/db path|--recovery-option=a=b|--recovery-option=c=d"
"|--repo1-path=/replace/path|restore",

View File

@ -35,36 +35,6 @@ testRun(void)
TEST_RESULT_INT(logLevelStdErr, logLevelOff, "stderr logging is off");
TEST_RESULT_INT(logLevelFile, logLevelOff, "file logging is off");
TEST_RESULT_BOOL(logTimestamp, true, "timestamp logging is on");
// -------------------------------------------------------------------------------------------------------------------------
cfgInit();
cfgCommandSet(cfgCmdLocal);
cfgOptionValidSet(cfgOptLogLevelConsole, true);
cfgOptionSet(cfgOptLogLevelConsole, cfgSourceParam, varNewStrZ("info"));
cfgOptionValidSet(cfgOptLogLevelStderr, true);
cfgOptionSet(cfgOptLogLevelStderr, cfgSourceParam, varNewStrZ("error"));
cfgOptionValidSet(cfgOptLogLevelFile, true);
cfgOptionSet(cfgOptLogLevelFile, cfgSourceParam, varNewStrZ("debug"));
cfgOptionValidSet(cfgOptLogTimestamp, true);
cfgOptionSet(cfgOptLogTimestamp, cfgSourceParam, varNewBool(false));
TEST_RESULT_VOID(cfgLoadLogSetting(), "load log settings no defaults");
TEST_RESULT_INT(logLevelStdOut, logLevelInfo, "console logging is info");
TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error");
TEST_RESULT_INT(logLevelFile, logLevelDebug, "file logging is debugging");
TEST_RESULT_BOOL(logTimestamp, false, "timestamp logging is off");
// -------------------------------------------------------------------------------------------------------------------------
cfgInit();
cfgCommandSet(cfgCmdLocal);
cfgOptionValidSet(cfgOptLogLevelStderr, true);
cfgOptionSet(cfgOptLogLevelStderr, cfgSourceParam, varNewStrZ("info"));
TEST_RESULT_VOID(cfgLoadLogSetting(), "load log settings reset stderr");
TEST_RESULT_INT(logLevelStdErr, logLevelError, "stderr logging is error");
}
// *****************************************************************************************************************************
@ -74,7 +44,7 @@ testRun(void)
String *exeOther = strNew("/other/path/to/pgbackrest");
cfgInit();
cfgCommandSet(cfgCmdBackup);
cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault);
cfgExeSet(exe);
cfgOptionValidSet(cfgOptRepoHost, true);
@ -148,7 +118,7 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
cfgInit();
cfgCommandSet(cfgCmdBackup);
cfgCommandSet(cfgCmdBackup, cfgCmdRoleDefault);
cfgExeSet(exe);
cfgOptionValidSet(cfgOptPgHost, true);
@ -408,18 +378,20 @@ testRun(void)
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "lock and open log file");
TEST_RESULT_INT(lstat(strPtr(strNewFmt("%s/db-backup.log", testPath())), &statLog), 0, " check log file exists");
lockRelease(true);
// Local command opens log file with special filename
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--stanza=db"));
strLstAdd(argList, strNew("--command=backup"));
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to");
strLstAdd(argList, strNew("--process=1"));
strLstAdd(argList, strNew("--host-id=1"));
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAdd(argList, strNew("--log-level-file=warn"));
strLstAdd(argList, strNew("local"));
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(
@ -429,16 +401,68 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--command=backup"));
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAdd(argList, strNew("--log-level-file=warn"));
strLstAddZ(argList, "--" CFGOPT_LOG_LEVEL_FILE "=info");
strLstAddZ(argList, "--" CFGOPT_LOG_SUBPROCESS);
strLstAdd(argList, strNew("--process=0"));
strLstAdd(argList, strNew("remote"));
strLstAddZ(argList, CFGCMD_INFO ":" CONFIG_COMMAND_ROLE_REMOTE);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(
lstat(strPtr(strNewFmt("%s/all-backup-remote-000.log", testPath())), &statLog), 0, " check log file exists");
lstat(strPtr(strNewFmt("%s/all-info-remote-000.log", testPath())), &statLog), 0, " check log file exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("remote command without archive-async option");
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAddZ(argList, "--" CFGOPT_LOG_LEVEL_FILE "=info");
strLstAddZ(argList, "--" CFGOPT_LOG_SUBPROCESS);
strLstAdd(argList, strNew("--process=1"));
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_REMOTE);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(
lstat(strPtr(strNewFmt("%s/test-archive-get-remote-001.log", testPath())), &statLog), 0, " check log file exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("local command with archive-async option");
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAddZ(argList, "--" CFGOPT_LOG_LEVEL_FILE "=info");
strLstAddZ(argList, "--" CFGOPT_LOG_SUBPROCESS);
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
strLstAdd(argList, strNew("--process=1"));
strLstAddZ(argList, CFGCMD_ARCHIVE_PUSH ":" CONFIG_COMMAND_ROLE_LOCAL);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(
lstat(strPtr(strNewFmt("%s/test-archive-push-async-local-001.log", testPath())), &statLog), 0,
" check log file exists");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("archive-get command with async role");
argList = strLstNew();
strLstAddZ(argList, PROJECT_BIN);
strLstAdd(argList, strNewFmt("--" CFGOPT_LOG_PATH "=%s", testPath()));
strLstAdd(argList, strNewFmt("--lock-path=%s/lock", testDataPath()));
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_ASYNC);
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
TEST_RESULT_INT(
lstat(strPtr(strNewFmt("%s/test-archive-get-async.log", testPath())), &statLog), 0, " check log file exists");
lockRelease(true);
}
FUNCTION_HARNESS_RESULT_VOID();

View File

@ -610,6 +610,13 @@ testRun(void)
strLstAdd(argList, strNew(BOGUS_STR));
TEST_ERROR(configParse(strLstSize(argList), strLstPtr(argList), false), CommandInvalidError, "invalid command 'BOGUS'");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
strLstAdd(argList, strNew(BOGUS_STR ":" BOGUS_STR));
TEST_ERROR(
configParse(strLstSize(argList), strLstPtr(argList), false), CommandInvalidError, "invalid command 'BOGUS:BOGUS'");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
@ -779,12 +786,12 @@ testRun(void)
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAdd(argList, strNew("--host-id=1"));
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to");
strLstAdd(argList, strNew("--process=1"));
strLstAdd(argList, strNew("--command=backup"));
strLstAdd(argList, strNew("--stanza=db"));
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAdd(argList, strNew("--log-level-stderr=info"));
strLstAdd(argList, strNew("local"));
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
logLevelStdOut = logLevelError;
logLevelStdErr = logLevelError;
@ -794,12 +801,12 @@ testRun(void)
argList = strLstNew();
strLstAdd(argList, strNew("pgbackrest"));
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to");
strLstAdd(argList, strNew("--process=1"));
strLstAdd(argList, strNew("--command=backup"));
strLstAdd(argList, strNew("--stanza=db"));
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAdd(argList, strNew("--log-level-stderr=info"));
strLstAdd(argList, strNew("remote"));
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_REMOTE);
logLevelStdOut = logLevelError;
logLevelStdErr = logLevelError;

View File

@ -72,10 +72,9 @@ testRun(void)
StringList *argList = strLstNew();
strLstAddZ(argList, "--stanza=test1");
strLstAddZ(argList, "--pg1-path=/path/to/pg");
strLstAddZ(argList, "--command=backup");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
strLstAddZ(argList, "--process=0");
harnessCfgLoad(cfgCmdRemote, argList);
harnessCfgLoadRole(cfgCmdBackup, cfgCmdRoleRemote, argList);
// Set script
harnessPqScriptSet((HarnessPq [])

View File

@ -150,13 +150,14 @@ testRun(void)
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAddZ(argList, "--stanza=test1");
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/bogus");
strLstAddZ(argList, "--pg7-path=/path/to");
strLstAddZ(argList, "--pg7-host=test1");
strLstAddZ(argList, "--host-id=7");
strLstAddZ(argList, "--command=backup");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
strLstAddZ(argList, "--process=0");
strLstAddZ(argList, "local");
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_BOOL(pgIsLocal(7), false, "pg is remote");
@ -173,8 +174,8 @@ testRun(void)
TEST_RESULT_STR_Z(
strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 1, 0), "|"),
"--command=archive-get|--host-id=1|--log-level-file=off|--log-level-stderr=error|--process=0|--remote-type=repo"
"|--stanza=test1|local",
"--host-id=1|--log-level-console=off|--log-level-file=off|--log-level-stderr=error|--process=0|--remote-type=repo"
"|--stanza=test1|archive-get:local",
"local repo protocol params");
// -------------------------------------------------------------------------------------------------------------------------
@ -189,8 +190,8 @@ testRun(void)
TEST_RESULT_STR_Z(
strLstJoin(protocolLocalParam(protocolStorageTypePg, 2, 1), "|"),
"--command=backup|--host-id=2|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg1-path=/pg"
"|--process=1|--remote-type=pg|--stanza=test1|local",
"--host-id=2|--log-level-console=off|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg1-path=/pg"
"|--process=1|--remote-type=pg|--repo1-retention-full=1|--stanza=test1|backup:local",
"local pg protocol params");
}
@ -214,8 +215,8 @@ testRun(void)
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 0, 0), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|repo-host-user@repo-host"
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=0"
" --remote-type=repo --stanza=test1 remote",
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --process=0 --remote-type=repo"
" --stanza=test1 archive-get:remote",
"remote protocol params");
// -------------------------------------------------------------------------------------------------------------------------
@ -235,28 +236,27 @@ testRun(void)
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 1, 0), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|-p|444|repo-host-user@repo-host"
"|pgbackrest --command=archive-get --config=/path/pgbackrest.conf --config-include-path=/path/include"
" --config-path=/path/config --log-level-file=info --log-level-stderr=error --log-subprocess --process=1"
" --remote-type=repo --stanza=test1 remote",
"|pgbackrest --config=/path/pgbackrest.conf --config-include-path=/path/include --config-path=/path/config"
" --log-level-console=off --log-level-file=info --log-level-stderr=error --log-subprocess --process=1"
" --remote-type=repo --stanza=test1 archive-get:remote",
"remote protocol params with replacements");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAddZ(argList, "--stanza=test1");
strLstAddZ(argList, "--command=archive-get");
strLstAddZ(argList, "--process=3");
strLstAddZ(argList, "--host-id=1");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
strLstAddZ(argList, "--repo1-host=repo-host");
strLstAddZ(argList, "local");
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_LOCAL);
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 66, 0), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|pgbackrest@repo-host"
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=3"
" --remote-type=repo --stanza=test1 remote",
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --process=3 --remote-type=repo"
" --stanza=test1 archive-get:remote",
"remote protocol params for backup local");
// -------------------------------------------------------------------------------------------------------------------------
@ -272,15 +272,14 @@ testRun(void)
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 0), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg1-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/1"
" --process=1 --remote-type=pg --stanza=test1 remote",
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/1"
" --process=1 --remote-type=pg --stanza=test1 backup:remote",
"remote protocol params for db backup");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAddZ(argList, "--stanza=test1");
strLstAddZ(argList, "--command=backup");
strLstAddZ(argList, "--process=4");
strLstAddZ(argList, "--host-id=2");
strLstAddZ(argList, "--pg1-path=/path/to/1");
@ -289,21 +288,21 @@ testRun(void)
strLstAddZ(argList, "--pg2-path=/path/to/2");
strLstAddZ(argList, "--pg2-host=pg2-host");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
strLstAddZ(argList, "local");
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 1), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg2-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/2"
" --process=4 --remote-type=pg --stanza=test1 remote",
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/2"
" --process=4 --remote-type=pg --stanza=test1 backup:remote",
"remote protocol params for db local");
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAddZ(argList, "pgbackrest");
strLstAddZ(argList, "--stanza=test1");
strLstAddZ(argList, "--command=backup");
strLstAddZ(argList, "--process=4");
strLstAddZ(argList, "--host-id=3");
strLstAddZ(argList, "--pg1-path=/path/to/1");
@ -312,14 +311,15 @@ testRun(void)
strLstAddZ(argList, "--pg3-socket-path=/socket3");
strLstAddZ(argList, "--pg3-port=3333");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
strLstAddZ(argList, "local");
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
TEST_RESULT_STR_Z(
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 2), "|"),
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg3-host"
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/3"
" --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg --stanza=test1 remote",
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/3"
" --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg --stanza=test1 backup:remote",
"remote protocol params for db local");
}
@ -872,10 +872,9 @@ testRun(void)
strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser()));
strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath()));
strLstAddZ(argList, "--process=999");
strLstAddZ(argList, "--command=archive-get");
strLstAddZ(argList, "--host-id=1");
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
harnessCfgLoad(cfgCmdLocal, argList);
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList);
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoCipherPass), "acbd", "check cipher pass before");
TEST_ASSIGN(client, protocolRemoteGet(protocolStorageTypeRepo, 1), "get remote protocol");
@ -908,7 +907,7 @@ testRun(void)
TEST_RESULT_VOID(protocolFree(), "free remote protocol objects");
// Start db protocol
// Start remote protocol
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAddZ(argList, "--stanza=db");
@ -927,7 +926,7 @@ testRun(void)
strLstAddZ(argList, "--stanza=db");
strLstAddZ(argList, "--protocol-timeout=10");
strLstAddZ(argList, "--process-max=2");
harnessCfgLoad(cfgCmdArchiveGetAsync, argList);
harnessCfgLoad(cfgCmdArchiveGet, argList);
TEST_ASSIGN(client, protocolLocalGet(protocolStorageTypeRepo, 1, 1), "get local protocol");
TEST_RESULT_PTR(protocolLocalGet(protocolStorageTypeRepo, 1, 1), client, "get local cached protocol");