You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-11 00:50:20 +02:00
Improve error when pg1-path option missing for archive-get command.
The assert thrown was not as descriptive as a proper option missing error.
This commit is contained in:
@ -2519,10 +2519,7 @@ my %hConfigDefine =
|
||||
},
|
||||
&CFGDEF_COMMAND =>
|
||||
{
|
||||
&CFGCMD_ARCHIVE_GET =>
|
||||
{
|
||||
&CFGDEF_REQUIRED => false
|
||||
},
|
||||
&CFGCMD_ARCHIVE_GET => {},
|
||||
&CFGCMD_ARCHIVE_PUSH =>
|
||||
{
|
||||
&CFGDEF_REQUIRED => false
|
||||
|
@ -22,6 +22,14 @@
|
||||
|
||||
<p>Improve handling of invalid HTTP response status.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-reviewer id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Improve error when <br-option>pg1-path</br-option> option missing for <cmd>archive-get</cmd> command.</p>
|
||||
</release-item>
|
||||
</release-improvement-list>
|
||||
</release-core-list>
|
||||
|
||||
|
@ -2487,13 +2487,6 @@ static ConfigDefineOptionData configDefineOptionData[] = CFGDEFDATA_OPTION_LIST
|
||||
CFGDEFDATA_OPTION_OPTIONAL_PREFIX("pg")
|
||||
CFGDEFDATA_OPTION_OPTIONAL_HELP_NAME_ALT("db-path")
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgDefCmdArchiveGet)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_REQUIRED(false)
|
||||
)
|
||||
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND_OVERRIDE
|
||||
(
|
||||
CFGDEFDATA_OPTION_OPTIONAL_COMMAND(cfgDefCmdArchivePush)
|
||||
|
@ -125,6 +125,7 @@ testRun(void)
|
||||
StringList *argList = strLstNew();
|
||||
strLstAdd(argList, strNewFmt("--spool-path=%s", testPath()));
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_ASYNC);
|
||||
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleAsync, argList);
|
||||
|
||||
@ -225,6 +226,7 @@ testRun(void)
|
||||
// Load configuration to set repo-path and stanza
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
|
||||
strLstAddZ(argList, "archive-get");
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
@ -249,6 +249,7 @@ testRun(void)
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--archive-async");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/unused");
|
||||
strLstAdd(argList, strNewFmt("--spool-path=%s/spool", testPath()));
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
||||
@ -509,6 +510,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
|
||||
strLstAdd(argList, strNewFmt("--log-level-file=debug"));
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s/repo", testPath()));
|
||||
strLstAdd(argList, strNewFmt("--" CFGOPT_PG1_PATH "=%s/db", testPath()));
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "archive-get");
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
@ -548,7 +550,6 @@ testRun(void)
|
||||
|
||||
String *walFile = strNewFmt("%s/db/pg_wal/RECOVERYXLOG", testPath());
|
||||
strLstAdd(argListTemp, walFile);
|
||||
strLstAdd(argListTemp, strNewFmt("--pg1-path=%s/db", testPath()));
|
||||
harnessCfgLoadRaw(strLstSize(argListTemp), strLstPtr(argListTemp));
|
||||
|
||||
// Test this in a fork so we can use different Perl options in later tests
|
||||
@ -576,7 +577,6 @@ testRun(void)
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argListTemp = strLstDup(argList);
|
||||
strLstAdd(argListTemp, strNewFmt("--pg1-path=%s/db", testPath()));
|
||||
strLstAddZ(argListTemp, "00000001.history");
|
||||
strLstAdd(argListTemp, walFile);
|
||||
strLstAddZ(argListTemp, "--archive-async");
|
||||
@ -611,7 +611,6 @@ testRun(void)
|
||||
strLstAddZ(argList, "--archive-async");
|
||||
strLstAdd(argList, walSegment);
|
||||
strLstAddZ(argList, "pg_wal/RECOVERYXLOG");
|
||||
strLstAdd(argList, strNewFmt("--pg1-path=%s/db", testPath()));
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
THROW_ON_SYS_ERROR(chdir(strPtr(cfgOptionStr(cfgOptPgPath))) != 0, PathMissingError, "unable to chdir()");
|
||||
|
@ -24,6 +24,7 @@ testRun(void)
|
||||
// Load configuration so lock path is set
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
|
@ -32,6 +32,7 @@ testRun(void)
|
||||
{
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--process=1");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
|
||||
strLstAddZ(argList, "--host-id=1");
|
||||
|
@ -69,6 +69,7 @@ testRun(void)
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
|
||||
strLstAddZ(argList, "--lock-path=/bogus");
|
||||
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_REMOTE);
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
|
@ -237,6 +237,7 @@ testRun(void)
|
||||
// Invalid bucket name with verification enabled fails
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNew("--repo1-type=s3"));
|
||||
strLstAdd(argList, strNew("--repo1-s3-bucket=bogus.bucket"));
|
||||
strLstAdd(argList, strNew("--repo1-s3-region=region"));
|
||||
@ -253,6 +254,7 @@ testRun(void)
|
||||
// Invalid bucket name with verification disabled succeeds
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNew("--repo1-type=s3"));
|
||||
strLstAdd(argList, strNew("--repo1-s3-bucket=bogus.bucket"));
|
||||
strLstAdd(argList, strNew("--repo1-s3-region=region"));
|
||||
@ -266,6 +268,7 @@ testRun(void)
|
||||
// Valid bucket name
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNew("--repo1-type=s3"));
|
||||
strLstAdd(argList, strNew("--repo1-s3-bucket=cool-bucket"));
|
||||
strLstAdd(argList, strNew("--repo1-s3-region=region"));
|
||||
@ -387,6 +390,7 @@ testRun(void)
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew("pgbackrest"));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNew("--log-level-console=off"));
|
||||
strLstAdd(argList, strNew("--log-level-stderr=off"));
|
||||
strLstAdd(argList, strNew("--log-level-file=off"));
|
||||
@ -403,6 +407,7 @@ testRun(void)
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew("pgbackrest"));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNew("--no-neutral-umask"));
|
||||
strLstAdd(argList, strNew("--log-level-console=off"));
|
||||
strLstAdd(argList, strNew("--log-level-stderr=off"));
|
||||
@ -517,6 +522,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNew("pgbackrest"));
|
||||
strLstAdd(argList, strNewFmt("--log-path=%s", testPath()));
|
||||
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
|
||||
strLstAddZ(argList, "--" CFGOPT_LOG_LEVEL_FILE "=info");
|
||||
strLstAddZ(argList, "--" CFGOPT_LOG_SUBPROCESS);
|
||||
@ -554,6 +560,7 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--" CFGOPT_LOG_PATH "=%s", testPath()));
|
||||
strLstAdd(argList, strNewFmt("--lock-path=%s/lock", testDataPath()));
|
||||
strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_ASYNC);
|
||||
|
||||
TEST_RESULT_VOID(cfgLoad(strLstSize(argList), strLstPtr(argList)), "open log file");
|
||||
|
@ -1132,6 +1132,7 @@ testRun(void)
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_ARCHIVE_GET));
|
||||
strLstAdd(argList, strNew("000000010000000200000003"));
|
||||
strLstAdd(argList, strNew("/path/to/wal/RECOVERYWAL"));
|
||||
|
@ -31,6 +31,7 @@ testRun(void)
|
||||
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-host=repo-host");
|
||||
strLstAddZ(argList, "--repo1-host-user=repo-host-user");
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
@ -437,6 +437,7 @@ testRun(void)
|
||||
// Load configuration to set repo-path and stanza
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
||||
|
@ -117,6 +117,7 @@ testRun(void)
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "archive-get");
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
@ -127,6 +128,7 @@ testRun(void)
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-host=remote-host");
|
||||
strLstAddZ(argList, "archive-get");
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
@ -187,13 +189,14 @@ testRun(void)
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "archive-get");
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 1, 0), "|"),
|
||||
"--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",
|
||||
"--host-id=1|--log-level-console=off|--log-level-file=off|--log-level-stderr=error|--pg1-path=/path/to/pg|--process=0"
|
||||
"|--remote-type=repo|--stanza=test1|archive-get:local",
|
||||
"local repo protocol params");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -221,6 +224,7 @@ testRun(void)
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-host=repo-host");
|
||||
strLstAddZ(argList, "--repo1-host-user=repo-host-user");
|
||||
// Local config settings should never be passed to the remote
|
||||
@ -233,8 +237,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 --log-level-console=off --log-level-file=off --log-level-stderr=error --process=0 --remote-type=repo"
|
||||
" --repo1-local --stanza=test1 archive-get:remote",
|
||||
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/pg"
|
||||
" --process=0 --remote-type=repo --repo1-local --stanza=test1 archive-get:remote",
|
||||
"remote protocol params");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -265,6 +269,7 @@ testRun(void)
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--process=3");
|
||||
strLstAddZ(argList, "--host-id=1");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
|
||||
@ -275,8 +280,8 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 66, 0), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|pgbackrest@repo-host"
|
||||
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --process=3 --remote-type=repo"
|
||||
" --repo1-local --stanza=test1 archive-get:remote",
|
||||
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/pg"
|
||||
" --process=3 --remote-type=repo --repo1-local --stanza=test1 archive-get:remote",
|
||||
"remote protocol params for backup local");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -886,6 +891,7 @@ testRun(void)
|
||||
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--protocol-timeout=10");
|
||||
strLstAdd(argList, strNewFmt("--config=%s/pgbackrest.conf", testPath()));
|
||||
strLstAddZ(argList, "--repo1-host=localhost");
|
||||
@ -944,6 +950,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--protocol-timeout=10");
|
||||
strLstAddZ(argList, "--process-max=2");
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
@ -17,6 +17,7 @@ testRun(void)
|
||||
// Load configuration
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-type=cifs");
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath()));
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
@ -1153,6 +1153,7 @@ testRun(void)
|
||||
// Load configuration to set repo-path and stanza
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAdd(argList, strNewFmt("--repo-path=%s", testPath()));
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
||||
|
@ -168,6 +168,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
StringList *argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-type=s3");
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s", strPtr(path)));
|
||||
strLstAdd(argList, strNewFmt("--repo1-s3-bucket=%s", strPtr(bucket)));
|
||||
@ -194,6 +195,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-type=s3");
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s", strPtr(path)));
|
||||
strLstAdd(argList, strNewFmt("--repo1-s3-bucket=%s", strPtr(bucket)));
|
||||
@ -221,6 +223,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-type=s3");
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s", strPtr(path)));
|
||||
strLstAdd(argList, strNewFmt("--repo1-s3-bucket=%s", strPtr(bucket)));
|
||||
@ -247,6 +250,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-type=s3");
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s", strPtr(path)));
|
||||
strLstAdd(argList, strNewFmt("--repo1-s3-bucket=%s", strPtr(bucket)));
|
||||
@ -274,6 +278,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/pg");
|
||||
strLstAddZ(argList, "--repo1-type=s3");
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s", strPtr(path)));
|
||||
strLstAdd(argList, strNewFmt("--repo1-s3-bucket=%s", strPtr(bucket)));
|
||||
|
Reference in New Issue
Block a user