2018-01-23 13:34:24 -05:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test Help Command
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#include "config/parse.h"
|
2019-05-03 15:46:15 -04:00
|
|
|
#include "storage/posix/storage.h"
|
2018-01-23 13:34:24 -05:00
|
|
|
#include "storage/storage.h"
|
|
|
|
#include "version.h"
|
|
|
|
|
2020-10-19 16:27:52 -04:00
|
|
|
#include "common/harnessConfig.h"
|
|
|
|
|
2018-01-23 13:34:24 -05:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test Run
|
|
|
|
***********************************************************************************************************************************/
|
2018-01-31 18:22:25 -05:00
|
|
|
void
|
2018-08-03 19:19:14 -04:00
|
|
|
testRun(void)
|
2018-01-23 13:34:24 -05:00
|
|
|
{
|
2018-05-18 11:57:32 -04:00
|
|
|
FUNCTION_HARNESS_VOID();
|
|
|
|
|
2018-01-23 13:34:24 -05:00
|
|
|
// Program name a version are used multiple times
|
2018-11-24 19:05:03 -05:00
|
|
|
const char *helpVersion = PROJECT_NAME " " PROJECT_VERSION;
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
// General help text is used in more than one test
|
2020-07-30 07:49:06 -04:00
|
|
|
const char *generalHelp = strZ(strNewFmt(
|
2018-01-23 13:34:24 -05:00
|
|
|
"%s - General help\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
" pgbackrest [options] [command]\n"
|
|
|
|
"\n"
|
|
|
|
"Commands:\n"
|
|
|
|
" archive-get Get a WAL segment from the archive.\n"
|
|
|
|
" archive-push Push a WAL segment to the archive.\n"
|
|
|
|
" backup Backup a database cluster.\n"
|
|
|
|
" check Check the configuration.\n"
|
|
|
|
" expire Expire backups that exceed retention.\n"
|
|
|
|
" help Get help.\n"
|
|
|
|
" info Retrieve information about backups.\n"
|
2021-02-05 10:39:03 -05:00
|
|
|
" repo-get Get files from a repository.\n"
|
2021-02-05 10:07:43 -05:00
|
|
|
" repo-ls List files in a repository.\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
" restore Restore a database cluster.\n"
|
|
|
|
" stanza-create Create the required stanza data.\n"
|
|
|
|
" stanza-delete Delete a stanza.\n"
|
|
|
|
" stanza-upgrade Upgrade a stanza.\n"
|
|
|
|
" start Allow pgBackRest processes to run.\n"
|
|
|
|
" stop Stop pgBackRest processes from running.\n"
|
|
|
|
" version Get version.\n"
|
|
|
|
"\n"
|
|
|
|
"Use 'pgbackrest help [command]' for more information.\n",
|
|
|
|
helpVersion));
|
|
|
|
|
|
|
|
// *****************************************************************************************************************************
|
|
|
|
if (testBegin("helpRenderText()"))
|
|
|
|
{
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRenderText(strNew("this is a short sentence"), 0, false, 80), "this is a short sentence", "one line");
|
2018-01-23 13:34:24 -05:00
|
|
|
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(
|
|
|
|
helpRenderText(strNew("this is a short sentence"), 4, false, 14),
|
2018-01-23 13:34:24 -05:00
|
|
|
"this is a\n"
|
|
|
|
" short\n"
|
|
|
|
" sentence",
|
|
|
|
"three lines, no indent first");
|
|
|
|
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(
|
|
|
|
helpRenderText(strNew("This is a short paragraph.\n\nHere is another one."), 2, true, 16),
|
2018-01-23 13:34:24 -05:00
|
|
|
" This is a\n"
|
|
|
|
" short\n"
|
|
|
|
" paragraph.\n"
|
|
|
|
"\n"
|
|
|
|
" Here is\n"
|
|
|
|
" another one.",
|
|
|
|
"two paragraphs, indent first");
|
|
|
|
}
|
|
|
|
|
|
|
|
// *****************************************************************************************************************************
|
|
|
|
if (testBegin("helpRenderValue()"))
|
|
|
|
{
|
2020-12-17 09:32:31 -05:00
|
|
|
TEST_RESULT_STR_Z(helpRenderValue(varNewBool(true), cfgOptTypeBoolean), "y", "boolean y");
|
|
|
|
TEST_RESULT_STR_Z(helpRenderValue(varNewBool(false), cfgOptTypeBoolean), "n", "boolean n");
|
|
|
|
TEST_RESULT_STR_Z(helpRenderValue(varNewStrZ("test-string"), cfgOptTypeString), "test-string", "string");
|
|
|
|
TEST_RESULT_STR_Z(helpRenderValue(varNewInt64(1234), cfgOptTypeInteger), "1234", "int");
|
|
|
|
TEST_RESULT_STR_Z(helpRenderValue(varNewInt64(1234000), cfgOptTypeTime), "1234", "time");
|
2018-01-23 13:34:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// *****************************************************************************************************************************
|
|
|
|
if (testBegin("helpRender()"))
|
|
|
|
{
|
|
|
|
StringList *argList = NULL;
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
2020-10-19 16:27:52 -04:00
|
|
|
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help from empty command line");
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), generalHelp, " check text");
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
2020-10-19 16:27:52 -04:00
|
|
|
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help from help command");
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), generalHelp, " check text");
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2020-07-30 07:49:06 -04:00
|
|
|
const char *commandHelp = strZ(strNewFmt(
|
2018-05-05 09:38:09 -04:00
|
|
|
"%s%s",
|
|
|
|
helpVersion,
|
|
|
|
" - 'version' command help\n"
|
|
|
|
"\n"
|
|
|
|
"Get version.\n"
|
|
|
|
"\n"
|
|
|
|
"Displays installed pgBackRest version.\n"));
|
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "version");
|
2020-10-19 16:27:52 -04:00
|
|
|
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for version command");
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), commandHelp, " check text");
|
2018-05-05 09:38:09 -04:00
|
|
|
|
|
|
|
// This test is broken up into multiple strings because C99 does not require compilers to support const strings > 4095 bytes
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2020-07-30 07:49:06 -04:00
|
|
|
commandHelp = strZ(strNewFmt(
|
2018-04-19 11:09:39 -04:00
|
|
|
"%s%s%s",
|
|
|
|
helpVersion,
|
2018-05-01 13:20:48 -04:00
|
|
|
" - 'restore' command help\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
2018-05-01 13:20:48 -04:00
|
|
|
"Restore a database cluster.\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
2018-05-01 13:20:48 -04:00
|
|
|
"This command is generally run manually, but there are instances where it might\n"
|
|
|
|
"be automated.\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
|
|
|
"Command Options:\n"
|
|
|
|
"\n"
|
2020-08-25 15:05:41 -04:00
|
|
|
" --archive-mode preserve or disable archiving on restored\n"
|
|
|
|
" cluster [default=preserve]\n"
|
2018-05-01 13:20:48 -04:00
|
|
|
" --db-include restore only specified databases\n"
|
2018-05-01 14:07:08 -04:00
|
|
|
" [current=db1, db2]\n"
|
2018-05-01 13:20:48 -04:00
|
|
|
" --force force a restore [default=n]\n"
|
|
|
|
" --link-all restore all symlinks [default=n]\n"
|
|
|
|
" --link-map modify the destination of a symlink\n"
|
2018-05-01 14:07:08 -04:00
|
|
|
" [current=/link1=/dest1, /link2=/dest2]\n"
|
2018-05-01 13:20:48 -04:00
|
|
|
" --recovery-option set an option in recovery.conf\n"
|
|
|
|
" --set backup set to restore [default=latest]\n"
|
|
|
|
" --tablespace-map restore a tablespace into the specified\n"
|
|
|
|
" directory\n"
|
|
|
|
" --tablespace-map-all restore all tablespaces into the specified\n"
|
|
|
|
" directory\n"
|
|
|
|
" --target recovery target\n"
|
|
|
|
" --target-action action to take when recovery target is\n"
|
|
|
|
" reached [default=pause]\n"
|
|
|
|
" --target-exclusive stop just before the recovery target is\n"
|
|
|
|
" reached [default=n]\n"
|
|
|
|
" --target-timeline recover along a timeline\n"
|
|
|
|
" --type recovery type [default=default]\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
|
|
|
"General Options:\n"
|
|
|
|
"\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --buffer-size buffer size for file operations\n"
|
Reduce buffer-size default to 1MiB.
The prior default was determined by benchmarking the Perl code prior to the 1.0 release. In general buffer allocation was more expensive in Perl so large buffers gave the best performance. This was due to multiple buffer allocations for each filter in an IO operation.
The C code allocates fixed buffers for each IO operation so the cost for buffer allocation is lower than Perl. That being the case it made sense to benchmark the C code to determine the optimal buffer default.
The performance/storage tests were used to measure the performance of a variety of filters. 1GiB of data was processed by each filter 10 times and the results of the tests were averaged.
While most buffer sizes gave similar performance, 1MiB appeared to perform the best overall. Of course, different architectures are likely to yield different results but this seems like a sensible default. The buffer-size option may still need to be manually configured to give optimal results.
Raw test data for reference:
4MB buffer (prior default)
copy time 1807ms, avg time 180ms, avg throughput: 5942MB/s
md5 time 14200ms, avg time 1420ms, avg throughput: 756MB/s
sha1 time 11431ms, avg time 1143ms, avg throughput: 939MB/s
sha256 time 23463ms, avg time 2346ms, avg throughput: 457MB/s
gzip -6 time 381199ms, avg time 38119ms, avg throughput: 28MB/s
lz4 -1 time 15484ms, avg time 1548ms, avg throughput: 693MB/s
1MB buffer (new default)
copy time 1760ms, avg time 176ms, avg throughput: 6100MB/s
md5 time 13739ms, avg time 1373ms, avg throughput: 781MB/s
sha1 time 11025ms, avg time 1102ms, avg throughput: 973MB/s
sha256 time 22539ms, avg time 2253ms, avg throughput: 476MB/s
gzip -6 time 372995ms, avg time 37299ms, avg throughput: 28MB/s
lz4 -1 time 15118ms, avg time 1511ms, avg throughput: 710MB/s
512K buffer
copy time 1782ms, avg time 178ms, avg throughput: 6025MB/s
md5 time 13724ms, avg time 1372ms, avg throughput: 782MB/s
sha1 time 10959ms, avg time 1095ms, avg throughput: 979MB/s
sha256 time 22982ms, avg time 2298ms, avg throughput: 467MB/s
gzip -6 time 378120ms, avg time 37812ms, avg throughput: 28MB/s
lz4 -1 time 15484ms, avg time 1548ms, avg throughput: 693MB/s
256K buffer
copy time 1805ms, avg time 180ms, avg throughput: 5948MB/s
md5 time 13706ms, avg time 1370ms, avg throughput: 783MB/s
sha1 time 11074ms, avg time 1107ms, avg throughput: 969MB/s
sha256 time 22588ms, avg time 2258ms, avg throughput: 475MB/s
gzip -6 time 372645ms, avg time 37264ms, avg throughput: 28MB/s
lz4 -1 time 16346ms, avg time 1634ms, avg throughput: 656MB/s
2020-05-19 16:58:49 -04:00
|
|
|
" [current=32768, default=1048576]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --cmd-ssh path to ssh client executable [default=ssh]\n"
|
2020-03-06 14:41:03 -05:00
|
|
|
" --compress-level-network network compression level [default=3]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --config pgBackRest configuration file\n"
|
|
|
|
" [default=/etc/pgbackrest/pgbackrest.conf]\n"
|
|
|
|
" --config-include-path path to additional pgBackRest configuration\n"
|
|
|
|
" files [default=/etc/pgbackrest/conf.d]\n"
|
|
|
|
" --config-path base path of pgBackRest configuration files\n"
|
|
|
|
" [default=/etc/pgbackrest]\n"
|
2018-09-19 11:12:45 -04:00
|
|
|
" --delta restore or backup using checksums [default=n]\n"
|
2020-04-17 09:18:52 -04:00
|
|
|
" --io-timeout i/O timeout [default=60]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --lock-path path where lock files are stored\n"
|
|
|
|
" [default=/tmp/pgbackrest]\n"
|
|
|
|
" --neutral-umask use a neutral umask [default=y]\n"
|
|
|
|
" --process-max max processes to use for compress/transfer\n"
|
|
|
|
" [default=1]\n"
|
|
|
|
" --protocol-timeout protocol timeout [default=1830]\n"
|
2020-04-01 15:44:51 -04:00
|
|
|
" --sck-keep-alive keep-alive enable [default=y]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --stanza defines the stanza\n"
|
2020-03-31 18:13:11 -04:00
|
|
|
" --tcp-keep-alive-count keep-alive count\n"
|
|
|
|
" --tcp-keep-alive-idle keep-alive idle time\n"
|
|
|
|
" --tcp-keep-alive-interval keep-alive interval time\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
|
|
|
"Log Options:\n"
|
|
|
|
"\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --log-level-console level for console logging [default=warn]\n"
|
|
|
|
" --log-level-file level for file logging [default=info]\n"
|
|
|
|
" --log-level-stderr level for stderr logging [default=warn]\n"
|
|
|
|
" --log-path path where log files are stored\n"
|
|
|
|
" [default=/var/log/pgbackrest]\n"
|
2018-08-22 20:05:49 -04:00
|
|
|
" --log-subprocess enable logging in subprocesses [default=n]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --log-timestamp enable timestamp in logging [default=y]\n"
|
2018-05-01 13:20:48 -04:00
|
|
|
"\n",
|
|
|
|
"Repository Options:\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
2020-07-02 16:24:34 -04:00
|
|
|
" --repo-azure-account azure repository account\n"
|
|
|
|
" --repo-azure-container azure repository container\n"
|
2020-10-06 17:15:48 -04:00
|
|
|
" --repo-azure-endpoint azure repository endpoint\n"
|
|
|
|
" [default=blob.core.windows.net]\n"
|
2020-07-09 14:46:48 -04:00
|
|
|
" --repo-azure-key azure repository key\n"
|
|
|
|
" --repo-azure-key-type azure repository key type [default=shared]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --repo-cipher-pass repository cipher passphrase\n"
|
2019-06-24 19:27:13 -04:00
|
|
|
" [current=<redacted>]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --repo-cipher-type cipher used to encrypt the repository\n"
|
2019-06-24 19:27:13 -04:00
|
|
|
" [current=aes-256-cbc, default=none]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --repo-host repository host when operating remotely via\n"
|
|
|
|
" SSH [current=backup.example.net]\n"
|
|
|
|
" --repo-host-cmd pgBackRest exe path on the repository host\n"
|
2020-10-19 16:27:52 -04:00
|
|
|
" [default=/path/to/pgbackrest]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --repo-host-config pgBackRest repository host configuration\n"
|
|
|
|
" file\n"
|
|
|
|
" [default=/etc/pgbackrest/pgbackrest.conf]\n"
|
|
|
|
" --repo-host-config-include-path pgBackRest repository host configuration\n"
|
|
|
|
" include path [default=/etc/pgbackrest/conf.d]\n"
|
|
|
|
" --repo-host-config-path pgBackRest repository host configuration\n"
|
|
|
|
" path [default=/etc/pgbackrest]\n"
|
|
|
|
" --repo-host-port repository host port when repo-host is set\n"
|
|
|
|
" --repo-host-user repository host user when repo-host is set\n"
|
|
|
|
" [default=pgbackrest]\n"
|
|
|
|
" --repo-path path where backups and archive are stored\n"
|
|
|
|
" [default=/var/lib/pgbackrest]\n"
|
2021-02-19 10:29:29 -05:00
|
|
|
" --repo-s3-bucket S3 repository bucket\n"
|
|
|
|
" --repo-s3-endpoint S3 repository endpoint\n"
|
|
|
|
" --repo-s3-key S3 repository access key\n"
|
|
|
|
" --repo-s3-key-secret S3 repository secret access key\n"
|
|
|
|
" --repo-s3-key-type S3 repository key type [default=shared]\n"
|
|
|
|
" --repo-s3-region S3 repository region\n"
|
|
|
|
" --repo-s3-role S3 repository role\n"
|
|
|
|
" --repo-s3-token S3 repository security token\n"
|
|
|
|
" --repo-s3-uri-style S3 URI Style [default=host]\n"
|
2021-03-02 13:51:40 -05:00
|
|
|
" --repo-storage-ca-file repository storage CA file\n"
|
|
|
|
" --repo-storage-ca-path repository storage CA path\n"
|
|
|
|
" --repo-storage-host repository storage host\n"
|
|
|
|
" --repo-storage-port repository storage port [default=443]\n"
|
|
|
|
" --repo-storage-verify-tls repository storage certificate verify\n"
|
|
|
|
" [default=y]\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --repo-type type of storage used for the repository\n"
|
|
|
|
" [default=posix]\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
|
|
|
"Stanza Options:\n"
|
|
|
|
"\n"
|
2018-04-19 11:09:39 -04:00
|
|
|
" --pg-path postgreSQL data directory\n"
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
2018-05-01 13:20:48 -04:00
|
|
|
"Use 'pgbackrest help restore [option]' for more information.\n"));
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
2018-05-01 13:20:48 -04:00
|
|
|
strLstAddZ(argList, "restore");
|
2018-01-23 13:34:24 -05:00
|
|
|
strLstAddZ(argList, "--buffer-size=32768");
|
2019-06-24 19:27:13 -04:00
|
|
|
strLstAddZ(argList, "--repo1-cipher-type=aes-256-cbc");
|
|
|
|
setenv("PGBACKREST_REPO1_CIPHER_PASS", "supersecret", true);
|
2018-02-03 18:27:38 -05:00
|
|
|
strLstAddZ(argList, "--repo1-host=backup.example.net");
|
2018-05-01 14:07:08 -04:00
|
|
|
strLstAddZ(argList, "--link-map=/link1=/dest1");
|
|
|
|
strLstAddZ(argList, "--link-map=/link2=/dest2");
|
|
|
|
strLstAddZ(argList, "--db-include=db1");
|
|
|
|
strLstAddZ(argList, "--db-include=db2");
|
2020-10-19 16:27:52 -04:00
|
|
|
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for restore command");
|
2019-06-24 19:27:13 -04:00
|
|
|
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), commandHelp, " check text");
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "archive-push");
|
|
|
|
strLstAddZ(argList, "buffer-size");
|
|
|
|
strLstAddZ(argList, "buffer-size");
|
2020-10-19 16:27:52 -04:00
|
|
|
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "parse too many options");
|
2018-01-23 13:34:24 -05:00
|
|
|
TEST_ERROR(helpRender(), ParamInvalidError, "only one option allowed for option help");
|
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "archive-push");
|
|
|
|
strLstAddZ(argList, BOGUS_STR);
|
2020-10-19 16:27:52 -04:00
|
|
|
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "parse bogus option");
|
2018-01-23 13:34:24 -05:00
|
|
|
TEST_ERROR(helpRender(), OptionInvalidError, "option 'BOGUS' is not valid for command 'archive-push'");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2020-07-30 07:49:06 -04:00
|
|
|
const char *optionHelp = strZ(strNewFmt(
|
2018-01-23 13:34:24 -05:00
|
|
|
"%s - 'archive-push' command - 'buffer-size' option help\n"
|
|
|
|
"\n"
|
|
|
|
"Buffer size for file operations.\n"
|
|
|
|
"\n"
|
|
|
|
"Set the buffer size used for copy, compress, and uncompress functions. A\n"
|
|
|
|
"maximum of 3 buffers will be in use at a time per process. An additional\n"
|
2018-04-25 15:46:05 -04:00
|
|
|
"maximum of 256K per process may be used for zlib buffers.\n"
|
|
|
|
"\n"
|
|
|
|
"Size can be entered in bytes (default) or KB, MB, GB, TB, or PB where the\n"
|
2018-09-11 10:55:55 -04:00
|
|
|
"multiplier is a power of 1024. For example, the case-insensitive value 32k (or\n"
|
|
|
|
"32KB) can be used instead of 32768.\n"
|
|
|
|
"\n"
|
|
|
|
"Allowed values, in bytes, are 16384, 32768, 65536, 131072, 262144, 524288,\n"
|
|
|
|
"1048576, 2097152, 4194304, 8388608, and 16777216.\n",
|
2018-01-23 13:34:24 -05:00
|
|
|
helpVersion));
|
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "archive-push");
|
|
|
|
strLstAddZ(argList, "buffer-size");
|
2018-07-20 18:51:42 -04:00
|
|
|
TEST_RESULT_VOID(
|
2020-10-19 16:27:52 -04:00
|
|
|
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, buffer-size option");
|
Reduce buffer-size default to 1MiB.
The prior default was determined by benchmarking the Perl code prior to the 1.0 release. In general buffer allocation was more expensive in Perl so large buffers gave the best performance. This was due to multiple buffer allocations for each filter in an IO operation.
The C code allocates fixed buffers for each IO operation so the cost for buffer allocation is lower than Perl. That being the case it made sense to benchmark the C code to determine the optimal buffer default.
The performance/storage tests were used to measure the performance of a variety of filters. 1GiB of data was processed by each filter 10 times and the results of the tests were averaged.
While most buffer sizes gave similar performance, 1MiB appeared to perform the best overall. Of course, different architectures are likely to yield different results but this seems like a sensible default. The buffer-size option may still need to be manually configured to give optimal results.
Raw test data for reference:
4MB buffer (prior default)
copy time 1807ms, avg time 180ms, avg throughput: 5942MB/s
md5 time 14200ms, avg time 1420ms, avg throughput: 756MB/s
sha1 time 11431ms, avg time 1143ms, avg throughput: 939MB/s
sha256 time 23463ms, avg time 2346ms, avg throughput: 457MB/s
gzip -6 time 381199ms, avg time 38119ms, avg throughput: 28MB/s
lz4 -1 time 15484ms, avg time 1548ms, avg throughput: 693MB/s
1MB buffer (new default)
copy time 1760ms, avg time 176ms, avg throughput: 6100MB/s
md5 time 13739ms, avg time 1373ms, avg throughput: 781MB/s
sha1 time 11025ms, avg time 1102ms, avg throughput: 973MB/s
sha256 time 22539ms, avg time 2253ms, avg throughput: 476MB/s
gzip -6 time 372995ms, avg time 37299ms, avg throughput: 28MB/s
lz4 -1 time 15118ms, avg time 1511ms, avg throughput: 710MB/s
512K buffer
copy time 1782ms, avg time 178ms, avg throughput: 6025MB/s
md5 time 13724ms, avg time 1372ms, avg throughput: 782MB/s
sha1 time 10959ms, avg time 1095ms, avg throughput: 979MB/s
sha256 time 22982ms, avg time 2298ms, avg throughput: 467MB/s
gzip -6 time 378120ms, avg time 37812ms, avg throughput: 28MB/s
lz4 -1 time 15484ms, avg time 1548ms, avg throughput: 693MB/s
256K buffer
copy time 1805ms, avg time 180ms, avg throughput: 5948MB/s
md5 time 13706ms, avg time 1370ms, avg throughput: 783MB/s
sha1 time 11074ms, avg time 1107ms, avg throughput: 969MB/s
sha256 time 22588ms, avg time 2258ms, avg throughput: 475MB/s
gzip -6 time 372645ms, avg time 37264ms, avg throughput: 28MB/s
lz4 -1 time 16346ms, avg time 1634ms, avg throughput: 656MB/s
2020-05-19 16:58:49 -04:00
|
|
|
TEST_RESULT_STR(helpRender(), strNewFmt("%s\ndefault: 1048576\n", optionHelp), " check text");
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
strLstAddZ(argList, "--buffer-size=32768");
|
2018-07-20 18:51:42 -04:00
|
|
|
TEST_RESULT_VOID(
|
2020-10-19 16:27:52 -04:00
|
|
|
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, buffer-size option");
|
Reduce buffer-size default to 1MiB.
The prior default was determined by benchmarking the Perl code prior to the 1.0 release. In general buffer allocation was more expensive in Perl so large buffers gave the best performance. This was due to multiple buffer allocations for each filter in an IO operation.
The C code allocates fixed buffers for each IO operation so the cost for buffer allocation is lower than Perl. That being the case it made sense to benchmark the C code to determine the optimal buffer default.
The performance/storage tests were used to measure the performance of a variety of filters. 1GiB of data was processed by each filter 10 times and the results of the tests were averaged.
While most buffer sizes gave similar performance, 1MiB appeared to perform the best overall. Of course, different architectures are likely to yield different results but this seems like a sensible default. The buffer-size option may still need to be manually configured to give optimal results.
Raw test data for reference:
4MB buffer (prior default)
copy time 1807ms, avg time 180ms, avg throughput: 5942MB/s
md5 time 14200ms, avg time 1420ms, avg throughput: 756MB/s
sha1 time 11431ms, avg time 1143ms, avg throughput: 939MB/s
sha256 time 23463ms, avg time 2346ms, avg throughput: 457MB/s
gzip -6 time 381199ms, avg time 38119ms, avg throughput: 28MB/s
lz4 -1 time 15484ms, avg time 1548ms, avg throughput: 693MB/s
1MB buffer (new default)
copy time 1760ms, avg time 176ms, avg throughput: 6100MB/s
md5 time 13739ms, avg time 1373ms, avg throughput: 781MB/s
sha1 time 11025ms, avg time 1102ms, avg throughput: 973MB/s
sha256 time 22539ms, avg time 2253ms, avg throughput: 476MB/s
gzip -6 time 372995ms, avg time 37299ms, avg throughput: 28MB/s
lz4 -1 time 15118ms, avg time 1511ms, avg throughput: 710MB/s
512K buffer
copy time 1782ms, avg time 178ms, avg throughput: 6025MB/s
md5 time 13724ms, avg time 1372ms, avg throughput: 782MB/s
sha1 time 10959ms, avg time 1095ms, avg throughput: 979MB/s
sha256 time 22982ms, avg time 2298ms, avg throughput: 467MB/s
gzip -6 time 378120ms, avg time 37812ms, avg throughput: 28MB/s
lz4 -1 time 15484ms, avg time 1548ms, avg throughput: 693MB/s
256K buffer
copy time 1805ms, avg time 180ms, avg throughput: 5948MB/s
md5 time 13706ms, avg time 1370ms, avg throughput: 783MB/s
sha1 time 11074ms, avg time 1107ms, avg throughput: 969MB/s
sha256 time 22588ms, avg time 2258ms, avg throughput: 475MB/s
gzip -6 time 372645ms, avg time 37264ms, avg throughput: 28MB/s
lz4 -1 time 16346ms, avg time 1634ms, avg throughput: 656MB/s
2020-05-19 16:58:49 -04:00
|
|
|
TEST_RESULT_STR(helpRender(), strNewFmt("%s\ncurrent: 32768\ndefault: 1048576\n", optionHelp), " check text");
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2021-03-02 13:51:40 -05:00
|
|
|
#define HELP_OPTION \
|
|
|
|
"%s - 'archive-push' command - 'repo-storage-host' option help\n" \
|
|
|
|
"\n" \
|
|
|
|
"Repository storage host.\n" \
|
|
|
|
"\n" \
|
|
|
|
"Connect to a host other than the storage (e.g. S3, Azure) endpoint. This is\n" \
|
|
|
|
"typically used for testing.\n" \
|
2018-01-23 13:34:24 -05:00
|
|
|
"\n"
|
2021-03-02 13:51:40 -05:00
|
|
|
|
|
|
|
#define HELP_OPTION_DEPRECATED_NAMES \
|
|
|
|
"deprecated names: repo-azure-host, repo-s3-host\n"
|
|
|
|
|
|
|
|
optionHelp = strZ(strNewFmt(
|
|
|
|
HELP_OPTION
|
|
|
|
HELP_OPTION_DEPRECATED_NAMES,
|
2018-01-23 13:34:24 -05:00
|
|
|
helpVersion));
|
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "archive-push");
|
2018-02-14 17:19:54 -05:00
|
|
|
strLstAddZ(argList, "repo1-s3-host");
|
|
|
|
TEST_RESULT_VOID(
|
2020-10-19 16:27:52 -04:00
|
|
|
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, repo1-s3-host option");
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
|
2018-02-03 18:27:38 -05:00
|
|
|
|
2021-03-02 13:51:40 -05:00
|
|
|
optionHelp = strZ(strNewFmt(
|
|
|
|
HELP_OPTION
|
|
|
|
"current: s3-host\n"
|
|
|
|
"\n"
|
|
|
|
HELP_OPTION_DEPRECATED_NAMES,
|
|
|
|
helpVersion));
|
|
|
|
|
2018-05-05 09:38:09 -04:00
|
|
|
strLstAddZ(argList, "--repo1-type=s3");
|
|
|
|
strLstAddZ(argList, "--repo1-s3-host=s3-host");
|
|
|
|
TEST_RESULT_VOID(
|
2020-10-19 16:27:52 -04:00
|
|
|
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, repo1-s3-host option");
|
2021-03-02 13:51:40 -05:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
|
2018-05-05 09:38:09 -04:00
|
|
|
|
2019-06-24 19:27:13 -04:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2020-07-30 07:49:06 -04:00
|
|
|
optionHelp = strZ(strNewFmt(
|
2019-06-24 19:27:13 -04:00
|
|
|
"%s - 'archive-push' command - 'repo-cipher-pass' option help\n"
|
|
|
|
"\n"
|
|
|
|
"Repository cipher passphrase.\n"
|
|
|
|
"\n"
|
|
|
|
"Passphrase used to encrypt/decrypt files of the repository.\n"
|
|
|
|
"\n"
|
|
|
|
"current: <redacted>\n",
|
|
|
|
helpVersion));
|
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "--repo1-cipher-type=aes-256-cbc");
|
|
|
|
setenv("PGBACKREST_REPO1_CIPHER_PASS", "supersecret", true);
|
|
|
|
strLstAddZ(argList, "archive-push");
|
|
|
|
strLstAddZ(argList, "repo-cipher-pass");
|
|
|
|
TEST_RESULT_VOID(
|
2020-10-19 16:27:52 -04:00
|
|
|
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, repo1-s3-host option");
|
2019-06-24 19:27:13 -04:00
|
|
|
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
|
2019-06-24 19:27:13 -04:00
|
|
|
|
2018-02-03 18:27:38 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2020-07-30 07:49:06 -04:00
|
|
|
optionHelp = strZ(strNewFmt(
|
2018-02-03 18:27:38 -05:00
|
|
|
"%s - 'backup' command - 'repo-hardlink' option help\n"
|
|
|
|
"\n"
|
|
|
|
"Hardlink files between backups in the repository.\n"
|
|
|
|
"\n"
|
|
|
|
"Enable hard-linking of files in differential and incremental backups to their\n"
|
|
|
|
"full backups. This gives the appearance that each backup is a full backup at\n"
|
|
|
|
"the file-system level. Be careful, though, because modifying files that are\n"
|
|
|
|
"hard-linked can affect all the backups in the set.\n"
|
|
|
|
"\n"
|
|
|
|
"default: n\n"
|
|
|
|
"\n"
|
|
|
|
"deprecated name: hardlink\n",
|
|
|
|
helpVersion));
|
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "backup");
|
|
|
|
strLstAddZ(argList, "repo-hardlink");
|
2018-07-20 18:51:42 -04:00
|
|
|
TEST_RESULT_VOID(
|
2020-10-19 16:27:52 -04:00
|
|
|
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for backup command, repo-hardlink option");
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
|
2018-12-30 16:40:20 +02:00
|
|
|
|
2020-10-20 11:24:26 -04:00
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "backup");
|
|
|
|
strLstAddZ(argList, "hardlink");
|
|
|
|
TEST_RESULT_VOID(
|
|
|
|
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for backup command, deprecated hardlink option");
|
|
|
|
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
|
|
|
|
|
2018-12-30 16:40:20 +02:00
|
|
|
// Check admonition
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2020-07-30 07:49:06 -04:00
|
|
|
optionHelp = strZ(strNewFmt(
|
2018-12-30 16:40:20 +02:00
|
|
|
"%s - 'backup' command - 'repo-retention-archive' option help\n"
|
|
|
|
"\n"
|
|
|
|
"Number of backups worth of continuous WAL to retain.\n"
|
|
|
|
"\n"
|
|
|
|
"NOTE: WAL segments required to make a backup consistent are always retained\n"
|
|
|
|
"until the backup is expired regardless of how this option is configured.\n"
|
|
|
|
"\n"
|
2020-05-08 15:25:03 -04:00
|
|
|
"If this value is not set and repo-retention-full-type is count (default), then\n"
|
|
|
|
"the archive to expire will default to the repo-retention-full (or\n"
|
|
|
|
"repo-retention-diff) value corresponding to the repo-retention-archive-type if\n"
|
|
|
|
"set to full (or diff). This will ensure that WAL is only expired for backups\n"
|
|
|
|
"that are already expired. If repo-retention-full-type is time, then this value\n"
|
|
|
|
"will default to removing archives that are earlier than the oldest full backup\n"
|
|
|
|
"retained after satisfying the repo-retention-full setting.\n"
|
2018-12-30 16:40:20 +02:00
|
|
|
"\n"
|
|
|
|
"This option must be set if repo-retention-archive-type is set to incr. If disk\n"
|
|
|
|
"space is at a premium, then this setting, in conjunction with\n"
|
|
|
|
"repo-retention-archive-type, can be used to aggressively expire WAL segments.\n"
|
|
|
|
"However, doing so negates the ability to perform PITR from the backups with\n"
|
|
|
|
"expired WAL and is therefore not recommended.\n"
|
|
|
|
"\n"
|
|
|
|
"deprecated name: retention-archive\n",
|
|
|
|
helpVersion));
|
|
|
|
|
|
|
|
argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
|
|
|
strLstAddZ(argList, "help");
|
|
|
|
strLstAddZ(argList, "backup");
|
|
|
|
strLstAddZ(argList, "repo-retention-archive");
|
|
|
|
TEST_RESULT_VOID(
|
2020-10-19 16:27:52 -04:00
|
|
|
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for backup command, repo-retention-archive option");
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check admonition text");
|
2018-01-23 13:34:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// *****************************************************************************************************************************
|
|
|
|
if (testBegin("cmdHelp()"))
|
|
|
|
{
|
|
|
|
StringList *argList = strLstNew();
|
|
|
|
strLstAddZ(argList, "/path/to/pgbackrest");
|
2020-10-19 16:27:52 -04:00
|
|
|
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "parse help from empty command line");
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
// Redirect stdout to a file
|
|
|
|
int stdoutSave = dup(STDOUT_FILENO);
|
|
|
|
String *stdoutFile = strNewFmt("%s/stdout.help", testPath());
|
2018-03-24 14:11:29 -04:00
|
|
|
|
2020-07-30 07:49:06 -04:00
|
|
|
THROW_ON_SYS_ERROR(freopen(strZ(stdoutFile), "w", stdout) == NULL, FileWriteError, "unable to reopen stdout");
|
2018-01-23 13:34:24 -05:00
|
|
|
|
|
|
|
// Not in a test wrapper to avoid writing to stdout
|
|
|
|
cmdHelp();
|
|
|
|
|
|
|
|
// Restore normal stdout
|
|
|
|
dup2(stdoutSave, STDOUT_FILENO);
|
|
|
|
|
2020-04-30 11:01:38 -04:00
|
|
|
Storage *storage = storagePosixNewP(strNew(testPath()));
|
2019-12-26 18:08:27 -07:00
|
|
|
TEST_RESULT_STR_Z(strNewBuf(storageGetP(storageNewReadP(storage, stdoutFile))), generalHelp, " check text");
|
2018-01-23 13:34:24 -05:00
|
|
|
}
|
2018-05-18 11:57:32 -04:00
|
|
|
|
|
|
|
FUNCTION_HARNESS_RESULT_VOID();
|
2018-01-23 13:34:24 -05:00
|
|
|
}
|