2019-08-01 20:35:01 -04:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test Check Command
|
|
|
|
***********************************************************************************************************************************/
|
2021-05-17 07:20:28 -04:00
|
|
|
#include "command/stanza/create.h"
|
|
|
|
#include "info/infoArchive.h"
|
|
|
|
#include "info/infoBackup.h"
|
2019-08-01 20:35:01 -04:00
|
|
|
#include "postgres/version.h"
|
|
|
|
#include "storage/helper.h"
|
|
|
|
|
|
|
|
#include "common/harnessConfig.h"
|
|
|
|
#include "common/harnessInfo.h"
|
2021-05-17 07:20:28 -04:00
|
|
|
#include "common/harnessPostgres.h"
|
2019-08-01 20:35:01 -04:00
|
|
|
#include "common/harnessPq.h"
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test Run
|
|
|
|
***********************************************************************************************************************************/
|
2021-10-18 12:22:48 -04:00
|
|
|
static void
|
2019-08-01 20:35:01 -04:00
|
|
|
testRun(void)
|
|
|
|
{
|
|
|
|
FUNCTION_HARNESS_VOID();
|
|
|
|
|
2019-12-07 17:33:34 -05:00
|
|
|
// PQfinish() is strictly checked
|
|
|
|
harnessPqScriptStrictSet(true);
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
StringList *argList = strLstNew();
|
2019-08-21 15:41:52 -04:00
|
|
|
|
2019-08-01 20:35:01 -04:00
|
|
|
// *****************************************************************************************************************************
|
|
|
|
if (testBegin("cmdCheck()"))
|
|
|
|
{
|
2019-10-08 18:04:09 -04:00
|
|
|
// Load Parameters
|
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, ".5");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-08-01 20:35:01 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("fail to connect to database");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
// Set up harness to expect a failure to connect to the database
|
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
|
|
|
{.function = HRNPQ_CONNECTDB, .param = "[\"dbname='postgres' port=5432\"]"},
|
|
|
|
{.function = HRNPQ_STATUS, .resultInt = CONNECTION_BAD},
|
|
|
|
{.function = HRNPQ_ERRORMESSAGE, .resultZ = "error"},
|
|
|
|
{.function = HRNPQ_FINISH},
|
|
|
|
{.function = NULL}
|
|
|
|
});
|
|
|
|
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(cmdCheck(), ConfigError, "no database found\nHINT: check indexed pg-path/pg-host configurations");
|
2021-05-22 14:09:45 -04:00
|
|
|
TEST_RESULT_LOG(
|
2019-10-08 18:04:09 -04:00
|
|
|
"P00 WARN: unable to check pg-1: [DbConnectError] unable to connect to 'dbname='postgres' port=5432': error");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("standby only, repo local - fail to find primary database");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-06-28 13:28:28 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg", true, NULL, NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
|
|
|
TEST_ERROR(cmdCheck(), ConfigError, "primary database not found\nHINT: check indexed pg-path/pg-host configurations");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("standby only, multiple pg databases and remote repos - fail to find primary database");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, "/path/to/standby2");
|
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPort, 8, "5433");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptRepoHost, 2, "repo.domain.com");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, ".5");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
// Two standbys found but no primary
|
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2020-06-24 18:40:19 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, "/pgdata", true, NULL, NULL),
|
|
|
|
HRNPQ_MACRO_OPEN_GE_92(8, "dbname='postgres' port=5433", PG_VERSION_92, "/pgdata", true, NULL, NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
HRNPQ_MACRO_CLOSE(8),
|
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
|
|
|
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
|
|
|
TEST_ERROR(cmdCheck(), ConfigError, "primary database not found\nHINT: check indexed pg-path/pg-host configurations");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("standby only, one pg database and remote repo - code coverage");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
// Standby only, repo remote but only one pg-path configured
|
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptRepoHost, 1, "repo.domain.com");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, ".5");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2020-06-24 18:40:19 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, "/pgdata", true, NULL, NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
// Only confirming we get passed the check for repoIsLocal || more than one pg-path configured
|
|
|
|
TEST_ERROR(
|
2021-06-28 13:28:28 -04:00
|
|
|
cmdCheck(), FileMissingError, "unable to open missing file '" TEST_PATH "/pg/global/pg_control' for read");
|
2021-06-24 12:23:09 -04:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("backup-standby set without standby");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, ".5");
|
|
|
|
hrnCfgArgRawBool(argList, cfgOptBackupStandby, true);
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
// Primary database connection ok
|
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-06-28 13:28:28 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg", false, NULL, NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
TEST_ERROR(
|
2021-06-28 13:28:28 -04:00
|
|
|
cmdCheck(), FileMissingError, "unable to open missing file '" TEST_PATH "/pg/global/pg_control' for read");
|
2021-06-28 10:58:27 -04:00
|
|
|
TEST_RESULT_LOG("P00 WARN: option 'backup-standby' is enabled but standby is not properly configured");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("standby and primary database - standby path doesn't match pg_control");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, ".5");
|
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, TEST_PATH "/pg8");
|
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPort, 8, "5433");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
// Create pg_control for standby
|
2021-11-30 13:23:11 -05:00
|
|
|
HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_92);
|
2021-06-24 12:23:09 -04:00
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
// Standby database path doesn't match pg_control
|
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-05-22 09:30:54 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH, true, NULL, NULL),
|
2021-06-24 12:23:09 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(8, "dbname='postgres' port=5433", PG_VERSION_92, TEST_PATH "/pg8", false, NULL, NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
HRNPQ_MACRO_CLOSE(8),
|
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
|
|
|
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
TEST_ERROR(
|
2021-05-22 11:59:43 -04:00
|
|
|
cmdCheck(), DbMismatchError,
|
|
|
|
"version '" PG_VERSION_92_STR "' and path '" TEST_PATH "' queried from cluster do not match version '" PG_VERSION_92_STR
|
2021-06-28 13:28:28 -04:00
|
|
|
"' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/global/pg_control'\n"
|
2021-06-24 12:23:09 -04:00
|
|
|
"HINT: the pg1-path and pg1-port settings likely reference different clusters.");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("standby and primary database - error on primary but standby check ok");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-01-21 15:21:50 -05:00
|
|
|
// Create pg_control for primary
|
2021-11-30 13:23:11 -05:00
|
|
|
HRN_PG_CONTROL_PUT(storagePgIdxWrite(1), PG_VERSION_92);
|
2021-01-21 15:21:50 -05:00
|
|
|
|
|
|
|
// Create info files
|
2021-06-24 12:23:09 -04:00
|
|
|
HRN_INFO_PUT(
|
|
|
|
storageRepoIdxWrite(0), INFO_ARCHIVE_PATH_FILE,
|
|
|
|
"[db]\n"
|
|
|
|
"db-id=1\n"
|
2021-11-30 08:28:36 -05:00
|
|
|
"db-system-id=" HRN_PG_SYSTEMID_92_Z "\n"
|
2021-06-24 12:23:09 -04:00
|
|
|
"db-version=\"9.2\"\n"
|
|
|
|
"\n"
|
|
|
|
"[db:history]\n"
|
2021-11-30 08:28:36 -05:00
|
|
|
"1={\"db-id\":" HRN_PG_SYSTEMID_92_Z ",\"db-version\":\"9.2\"}\n");
|
2021-06-24 12:23:09 -04:00
|
|
|
HRN_INFO_PUT(
|
|
|
|
storageRepoIdxWrite(0), INFO_BACKUP_PATH_FILE,
|
|
|
|
"[db]\n"
|
|
|
|
"db-catalog-version=201608131\n"
|
|
|
|
"db-control-version=920\n"
|
|
|
|
"db-id=1\n"
|
2021-11-30 08:28:36 -05:00
|
|
|
"db-system-id=" HRN_PG_SYSTEMID_92_Z "\n"
|
2021-06-24 12:23:09 -04:00
|
|
|
"db-version=\"9.2\"\n"
|
|
|
|
"\n"
|
|
|
|
"[db:history]\n"
|
2021-11-30 08:28:36 -05:00
|
|
|
"1={\"db-catalog-version\":201608131,\"db-control-version\":920,\"db-system-id\":" HRN_PG_SYSTEMID_92_Z ","
|
2021-06-24 12:23:09 -04:00
|
|
|
"\"db-version\":\"9.2\"}\n");
|
2021-01-21 15:21:50 -05:00
|
|
|
|
|
|
|
// Single repo config - error when checking archive mode setting on database
|
2019-10-08 18:04:09 -04:00
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-06-28 13:28:28 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg", true, NULL, NULL),
|
2021-06-24 12:23:09 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(8, "dbname='postgres' port=5433", PG_VERSION_92, TEST_PATH "/pg8", false, "off", NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
2021-01-21 15:21:50 -05:00
|
|
|
HRNPQ_MACRO_CLOSE(8),
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
2021-01-21 15:21:50 -05:00
|
|
|
// Error on primary but standby check ok
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(cmdCheck(), ArchiveDisabledError, "archive_mode must be enabled");
|
2021-05-22 14:09:45 -04:00
|
|
|
TEST_RESULT_LOG(
|
2021-01-21 15:21:50 -05:00
|
|
|
"P00 INFO: check repo1 (standby)\n"
|
|
|
|
"P00 INFO: switch wal not performed because this is a standby");
|
2019-08-01 20:35:01 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("mulit-repo - standby and primary database");
|
|
|
|
|
2021-01-21 15:21:50 -05:00
|
|
|
// Multi-repo - add a second repo (repo2)
|
|
|
|
StringList *argListRepo2 = strLstDup(argList);
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgKeyRawZ(argListRepo2, cfgOptRepoPath, 2, TEST_PATH "/repo2");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argListRepo2);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-06-28 13:28:28 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg", true, NULL, NULL),
|
2021-06-24 12:23:09 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(8, "dbname='postgres' port=5433", PG_VERSION_92, TEST_PATH "/pg8", false, NULL, NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
HRNPQ_MACRO_CLOSE(8),
|
2021-01-21 15:21:50 -05:00
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
2021-01-21 15:21:50 -05:00
|
|
|
// Stanza has not yet been created on repo2 but is created (and checked) on repo1
|
|
|
|
TEST_ERROR_FMT(
|
|
|
|
cmdCheck(), FileMissingError,
|
2021-05-22 11:59:43 -04:00
|
|
|
"unable to load info file '" TEST_PATH "/repo2/archive/test1/archive.info' or"
|
|
|
|
" '" TEST_PATH "/repo2/archive/test1/archive.info.copy':\n"
|
2021-01-21 15:21:50 -05:00
|
|
|
"FileMissingError: " STORAGE_ERROR_READ_MISSING "\n"
|
|
|
|
"FileMissingError: " STORAGE_ERROR_READ_MISSING "\n"
|
|
|
|
"HINT: archive.info cannot be opened but is required to push/get WAL segments.\n"
|
|
|
|
"HINT: is archive_command configured correctly in postgresql.conf?\n"
|
|
|
|
"HINT: has a stanza-create been performed?\n"
|
|
|
|
"HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving scheme.",
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_PATH "/repo2/archive/test1/archive.info", TEST_PATH "/repo2/archive/test1/archive.info.copy");
|
2021-05-22 14:09:45 -04:00
|
|
|
TEST_RESULT_LOG(
|
|
|
|
"P00 INFO: check repo1 (standby)\n"
|
|
|
|
"P00 INFO: check repo2 (standby)");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("multi-repo - primary database only, WAL not found");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptArchiveTimeout, ".5");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-01-21 15:21:50 -05:00
|
|
|
// Create stanza files on repo2
|
2021-06-24 12:23:09 -04:00
|
|
|
HRN_INFO_PUT(
|
|
|
|
storageRepoIdxWrite(1), INFO_ARCHIVE_PATH_FILE,
|
|
|
|
"[db]\n"
|
|
|
|
"db-id=1\n"
|
2021-11-30 08:28:36 -05:00
|
|
|
"db-system-id=" HRN_PG_SYSTEMID_92_Z "\n"
|
2021-06-24 12:23:09 -04:00
|
|
|
"db-version=\"9.2\"\n"
|
|
|
|
"\n"
|
|
|
|
"[db:history]\n"
|
2021-11-30 08:28:36 -05:00
|
|
|
"1={\"db-id\":" HRN_PG_SYSTEMID_92_Z ",\"db-version\":\"9.2\"}\n");
|
2021-06-24 12:23:09 -04:00
|
|
|
HRN_INFO_PUT(
|
|
|
|
storageRepoIdxWrite(1), INFO_BACKUP_PATH_FILE,
|
|
|
|
"[db]\n"
|
|
|
|
"db-catalog-version=201608131\n"
|
|
|
|
"db-control-version=920\n"
|
|
|
|
"db-id=1\n"
|
2021-11-30 08:28:36 -05:00
|
|
|
"db-system-id=" HRN_PG_SYSTEMID_92_Z "\n"
|
2021-06-24 12:23:09 -04:00
|
|
|
"db-version=\"9.2\"\n"
|
|
|
|
"\n"
|
|
|
|
"[db:history]\n"
|
2021-11-30 08:28:36 -05:00
|
|
|
"1={\"db-catalog-version\":201608131,\"db-control-version\":920,\"db-system-id\":" HRN_PG_SYSTEMID_92_Z ","
|
2021-06-24 12:23:09 -04:00
|
|
|
"\"db-version\":\"9.2\"}\n");
|
2021-01-21 15:21:50 -05:00
|
|
|
|
2019-08-01 20:35:01 -04:00
|
|
|
// Error when WAL segment not found
|
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-06-28 13:28:28 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg", false, NULL, NULL),
|
2019-08-01 20:35:01 -04:00
|
|
|
HRNPQ_MACRO_CREATE_RESTORE_POINT(1, "1/1"),
|
|
|
|
HRNPQ_MACRO_WAL_SWITCH(1, "xlog", "000000010000000100000001"),
|
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
|
|
|
TEST_ERROR(
|
|
|
|
cmdCheck(), ArchiveTimeoutError,
|
|
|
|
"WAL segment 000000010000000100000001 was not archived before the 500ms timeout\n"
|
2019-09-14 12:21:08 -04:00
|
|
|
"HINT: check the archive_command to ensure that all options are correct (especially --stanza).\n"
|
2020-09-03 07:49:49 -04:00
|
|
|
"HINT: check the PostgreSQL server log for errors.\n"
|
|
|
|
"HINT: run the 'start' command if the stanza was previously stopped.");
|
2021-05-22 14:09:45 -04:00
|
|
|
TEST_RESULT_LOG(
|
2021-01-21 15:21:50 -05:00
|
|
|
"P00 INFO: check repo1 configuration (primary)\n"
|
|
|
|
"P00 INFO: check repo2 configuration (primary)\n"
|
|
|
|
"P00 INFO: check repo1 archive for WAL (primary)");
|
2019-08-01 20:35:01 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("multi-repo - WAL segment switch performed once for all repos");
|
|
|
|
|
2019-08-01 20:35:01 -04:00
|
|
|
// Create WAL segment
|
|
|
|
Buffer *buffer = bufNew(16 * 1024 * 1024);
|
|
|
|
memset(bufPtr(buffer), 0, bufSize(buffer));
|
|
|
|
bufUsedSet(buffer, bufSize(buffer));
|
|
|
|
|
2021-01-21 15:21:50 -05:00
|
|
|
// WAL segment switch is performed once for all repos
|
2019-08-01 20:35:01 -04:00
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-06-28 13:28:28 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg", false, NULL, NULL),
|
2019-08-01 20:35:01 -04:00
|
|
|
HRNPQ_MACRO_CREATE_RESTORE_POINT(1, "1/1"),
|
|
|
|
HRNPQ_MACRO_WAL_SWITCH(1, "xlog", "000000010000000100000001"),
|
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
HRN_STORAGE_PUT(
|
|
|
|
storageRepoIdxWrite(0), STORAGE_REPO_ARCHIVE "/9.2-1/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
2021-01-21 15:21:50 -05:00
|
|
|
buffer);
|
2021-06-24 12:23:09 -04:00
|
|
|
HRN_STORAGE_PUT(
|
|
|
|
storageRepoIdxWrite(1), STORAGE_REPO_ARCHIVE "/9.2-1/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
2019-08-01 20:35:01 -04:00
|
|
|
buffer);
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
TEST_RESULT_VOID(cmdCheck(), "check primary, WAL archived");
|
2021-05-22 14:09:45 -04:00
|
|
|
TEST_RESULT_LOG(
|
|
|
|
"P00 INFO: check repo1 configuration (primary)\n"
|
|
|
|
"P00 INFO: check repo2 configuration (primary)\n"
|
|
|
|
"P00 INFO: check repo1 archive for WAL (primary)\n"
|
2021-06-28 13:28:28 -04:00
|
|
|
"P00 INFO: WAL segment 000000010000000100000001 successfully archived to '" TEST_PATH "/repo/archive/test1/9.2-1/"
|
2021-05-22 14:09:45 -04:00
|
|
|
"0000000100000001/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' on repo1\n"
|
|
|
|
"P00 INFO: check repo2 archive for WAL (primary)\n"
|
|
|
|
"P00 INFO: WAL segment 000000010000000100000001 successfully archived to '" TEST_PATH "/repo2/archive/test1/9.2-1/"
|
|
|
|
"0000000100000001/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' on repo2");
|
2019-08-01 20:35:01 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("Primary == NULL (for test coverage)");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
DbGetResult dbGroup = {0};
|
|
|
|
TEST_RESULT_VOID(checkPrimary(dbGroup), "primary == NULL");
|
|
|
|
}
|
|
|
|
|
|
|
|
// *****************************************************************************************************************************
|
|
|
|
if (testBegin("checkManifest()"))
|
|
|
|
{
|
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
2020-10-19 14:03:48 -04:00
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgHost, 5, "localhost");
|
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgHostCmd, 5, "pgbackrest-bogus");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 5, "/path/to/pg5");
|
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgHostUser, 5, TEST_USER);
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
// Placeholder test for manifest
|
|
|
|
TEST_ERROR(
|
|
|
|
checkManifest(), UnknownError,
|
2020-03-15 09:59:22 -04:00
|
|
|
"remote-0 process on 'localhost' terminated unexpectedly [127]: bash: pgbackrest-bogus: command not found");
|
2019-10-08 18:04:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// *****************************************************************************************************************************
|
|
|
|
if (testBegin("checkDbConfig(), checkArchiveCommand()"))
|
|
|
|
{
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkArchiveCommand() errors");
|
|
|
|
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(checkArchiveCommand(NULL), ArchiveCommandInvalidError, "archive_command '[null]' must contain " PROJECT_BIN);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(checkArchiveCommand(strNew()), ArchiveCommandInvalidError, "archive_command '' must contain " PROJECT_BIN);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(
|
|
|
|
checkArchiveCommand(STRDEF("backrest")), ArchiveCommandInvalidError,
|
|
|
|
"archive_command 'backrest' must contain " PROJECT_BIN);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkArchiveCommand() valid");
|
|
|
|
|
2021-05-21 17:36:43 -04:00
|
|
|
TEST_RESULT_BOOL(checkArchiveCommand(STRDEF("pgbackrest --stanza=demo archive-push %p")), true, "archive_command valid");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkDbConfig() valid");
|
|
|
|
|
2019-08-01 20:35:01 -04:00
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, TEST_PATH "/pg8");
|
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPort, 8, "5433");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-08-01 20:35:01 -04:00
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
DbGetResult db = {0};
|
|
|
|
|
2019-08-01 20:35:01 -04:00
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-06-28 13:28:28 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg", false, NULL, NULL),
|
2020-06-24 18:40:19 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(8, "dbname='postgres' port=5433", PG_VERSION_92, "/badpath", true, NULL, NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2019-08-01 20:35:01 -04:00
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
2019-10-08 18:04:09 -04:00
|
|
|
HRNPQ_MACRO_CLOSE(8),
|
2019-08-01 20:35:01 -04:00
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
2019-12-02 07:39:42 -05:00
|
|
|
TEST_ASSIGN(db, dbGet(false, false, false), "get primary and standby");
|
2019-08-01 20:35:01 -04:00
|
|
|
|
2020-10-26 10:25:16 -04:00
|
|
|
TEST_RESULT_VOID(checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), "valid db config");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkDbConfig() version mismatch");
|
|
|
|
|
|
|
|
TEST_ERROR(
|
2020-10-26 10:25:16 -04:00
|
|
|
checkDbConfig(PG_VERSION_94, db.primaryIdx, db.primary, false), DbMismatchError,
|
2021-06-28 13:28:28 -04:00
|
|
|
"version '" PG_VERSION_92_STR "' and path '" TEST_PATH "/pg' queried from cluster do not match version '"
|
|
|
|
PG_VERSION_94_STR "' and '" TEST_PATH "/pg' read from '" TEST_PATH "/pg/global/pg_control'\n"
|
2021-06-24 12:23:09 -04:00
|
|
|
"HINT: the pg1-path and pg1-port settings likely reference different clusters.");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkDbConfig() path mismatch");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
TEST_ERROR_FMT(
|
2020-10-26 10:25:16 -04:00
|
|
|
checkDbConfig(PG_VERSION_92, db.standbyIdx, db.standby, true), DbMismatchError,
|
2021-05-22 11:59:43 -04:00
|
|
|
"version '" PG_VERSION_92_STR "' and path '%s' queried from cluster do not match version '" PG_VERSION_92_STR "' and"
|
2021-06-28 10:58:27 -04:00
|
|
|
" '" TEST_PATH "/pg8' read from '" TEST_PATH "/pg8/global/pg_control'\n"
|
2019-10-08 18:04:09 -04:00
|
|
|
"HINT: the pg8-path and pg8-port settings likely reference different clusters.",
|
2021-06-24 12:23:09 -04:00
|
|
|
strZ(dbPgDataPath(db.standby)));
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkDbConfig() archive-check=false");
|
|
|
|
|
|
|
|
hrnCfgArgRawBool(argList, cfgOptArchiveCheck, false);
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2020-10-26 10:25:16 -04:00
|
|
|
TEST_RESULT_VOID(checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), "valid db config --no-archive-check");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkDbConfig() archive-check not valid for command");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 8, TEST_PATH "/pg8");
|
|
|
|
hrnCfgArgKeyRawZ(argList, cfgOptPgPort, 8, "5433");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
TEST_RESULT_VOID(
|
2020-10-26 10:25:16 -04:00
|
|
|
checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), "valid db config, archive-check not valid for command");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
TEST_RESULT_VOID(dbFree(db.primary), "free primary");
|
|
|
|
TEST_RESULT_VOID(dbFree(db.standby), "free standby");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkDbConfig() archive_mode=always not supported");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2019-08-21 15:41:52 -04:00
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
harnessPqScriptSet((HarnessPq [])
|
|
|
|
{
|
2021-06-28 13:28:28 -04:00
|
|
|
HRNPQ_MACRO_OPEN_GE_92(1, "dbname='postgres' port=5432", PG_VERSION_92, TEST_PATH "/pg", false, "always", NULL),
|
2019-10-08 18:04:09 -04:00
|
|
|
HRNPQ_MACRO_CLOSE(1),
|
|
|
|
HRNPQ_MACRO_DONE()
|
|
|
|
});
|
|
|
|
|
2019-12-02 07:39:42 -05:00
|
|
|
TEST_ASSIGN(db, dbGet(true, true, false), "get primary");
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(
|
2020-10-26 10:25:16 -04:00
|
|
|
checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), FeatureNotSupportedError,
|
2019-10-08 18:04:09 -04:00
|
|
|
"archive_mode=always not supported");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
2021-02-02 19:43:14 +01:00
|
|
|
TEST_TITLE("disable archive_mode=always check");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawBool(argList, cfgOptArchiveModeCheck, false);
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdCheck, argList);
|
2021-02-02 19:43:14 +01:00
|
|
|
TEST_RESULT_VOID(checkDbConfig(PG_VERSION_92, db.primaryIdx, db.primary, false), "check");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
TEST_RESULT_VOID(dbFree(db.primary), "free primary");
|
|
|
|
}
|
2019-08-21 15:41:52 -04:00
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
// *****************************************************************************************************************************
|
|
|
|
if (testBegin("checkStanzaInfo(), checkStanzaInfoPg()"))
|
|
|
|
{
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkStanzaInfo() - files match");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
InfoArchive *archiveInfo = infoArchiveNew(PG_VERSION_96, 6569239123849665679, NULL);
|
|
|
|
InfoPgData archivePg = infoPgData(infoArchivePg(archiveInfo), infoPgDataCurrentId(infoArchivePg(archiveInfo)));
|
|
|
|
|
2021-05-17 07:20:28 -04:00
|
|
|
InfoBackup *backupInfo = infoBackupNew(PG_VERSION_96, 6569239123849665679, hrnPgCatalogVersion(PG_VERSION_96), NULL);
|
2019-10-08 18:04:09 -04:00
|
|
|
InfoPgData backupPg = infoPgData(infoBackupPg(backupInfo), infoPgDataCurrentId(infoBackupPg(backupInfo)));
|
|
|
|
|
|
|
|
TEST_RESULT_VOID(checkStanzaInfo(&archivePg, &backupPg), "stanza info files match");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkStanzaInfo() - corrupted backup file: system id");
|
|
|
|
|
2021-05-17 07:20:28 -04:00
|
|
|
backupInfo = infoBackupNew(PG_VERSION_96, 6569239123849665999, hrnPgCatalogVersion(PG_VERSION_96), NULL);
|
2019-10-08 18:04:09 -04:00
|
|
|
backupPg = infoPgData(infoBackupPg(backupInfo), infoPgDataCurrentId(infoBackupPg(backupInfo)));
|
|
|
|
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(
|
|
|
|
checkStanzaInfo(&archivePg, &backupPg), FileInvalidError,
|
|
|
|
"backup info file and archive info file do not match\n"
|
2019-10-08 18:04:09 -04:00
|
|
|
"archive: id = 1, version = 9.6, system-id = 6569239123849665679\n"
|
|
|
|
"backup : id = 1, version = 9.6, system-id = 6569239123849665999\n"
|
|
|
|
"HINT: this may be a symptom of repository corruption!");
|
2019-08-21 15:41:52 -04:00
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkStanzaInfo() - corrupted backup file: system id and version");
|
|
|
|
|
2021-05-17 07:20:28 -04:00
|
|
|
backupInfo = infoBackupNew(PG_VERSION_95, 6569239123849665999, hrnPgCatalogVersion(PG_VERSION_95), NULL);
|
2019-10-08 18:04:09 -04:00
|
|
|
backupPg = infoPgData(infoBackupPg(backupInfo), infoPgDataCurrentId(infoBackupPg(backupInfo)));
|
|
|
|
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(
|
|
|
|
checkStanzaInfo(&archivePg, &backupPg), FileInvalidError,
|
|
|
|
"backup info file and archive info file do not match\n"
|
2019-10-08 18:04:09 -04:00
|
|
|
"archive: id = 1, version = 9.6, system-id = 6569239123849665679\n"
|
|
|
|
"backup : id = 1, version = 9.5, system-id = 6569239123849665999\n"
|
|
|
|
"HINT: this may be a symptom of repository corruption!");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkStanzaInfo() - corrupted backup file: version");
|
|
|
|
|
2021-05-17 07:20:28 -04:00
|
|
|
backupInfo = infoBackupNew(PG_VERSION_95, 6569239123849665679, hrnPgCatalogVersion(PG_VERSION_95), NULL);
|
2019-10-08 18:04:09 -04:00
|
|
|
backupPg = infoPgData(infoBackupPg(backupInfo), infoPgDataCurrentId(infoBackupPg(backupInfo)));
|
|
|
|
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(
|
|
|
|
checkStanzaInfo(&archivePg, &backupPg), FileInvalidError,
|
|
|
|
"backup info file and archive info file do not match\n"
|
2019-10-08 18:04:09 -04:00
|
|
|
"archive: id = 1, version = 9.6, system-id = 6569239123849665679\n"
|
|
|
|
"backup : id = 1, version = 9.5, system-id = 6569239123849665679\n"
|
|
|
|
"HINT: this may be a symptom of repository corruption!");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkStanzaInfo() - corrupted backup file: db id");
|
|
|
|
|
2021-05-17 07:20:28 -04:00
|
|
|
infoBackupPgSet(backupInfo, PG_VERSION_96, 6569239123849665679, hrnPgCatalogVersion(PG_VERSION_96));
|
2019-10-08 18:04:09 -04:00
|
|
|
backupPg = infoPgData(infoBackupPg(backupInfo), infoPgDataCurrentId(infoBackupPg(backupInfo)));
|
|
|
|
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(
|
|
|
|
checkStanzaInfo(&archivePg, &backupPg), FileInvalidError,
|
|
|
|
"backup info file and archive info file do not match\n"
|
2019-10-08 18:04:09 -04:00
|
|
|
"archive: id = 1, version = 9.6, system-id = 6569239123849665679\n"
|
|
|
|
"backup : id = 2, version = 9.6, system-id = 6569239123849665679\n"
|
|
|
|
"HINT: this may be a symptom of repository corruption!");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkStanzaInfoPg() - version mismatch");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
argList = strLstNew();
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawBool(argList, cfgOptOnline, false);
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
2021-06-28 13:28:28 -04:00
|
|
|
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH "/pg");
|
|
|
|
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
|
2021-06-24 12:23:09 -04:00
|
|
|
hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
|
|
|
|
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 1, TEST_CIPHER_PASS);
|
2021-06-01 09:03:44 -04:00
|
|
|
HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
// Create pg_control
|
2021-11-30 13:23:11 -05:00
|
|
|
HRN_PG_CONTROL_PUT(storagePgIdxWrite(0), PG_VERSION_96);
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
// Create info files
|
|
|
|
TEST_RESULT_VOID(cmdStanzaCreate(), "stanza create - encryption");
|
2021-05-22 14:09:45 -04:00
|
|
|
TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'test1' on repo1");
|
2019-10-08 18:04:09 -04:00
|
|
|
|
|
|
|
// Version mismatch
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(
|
2021-01-21 15:21:50 -05:00
|
|
|
checkStanzaInfoPg(
|
2021-11-30 08:28:36 -05:00
|
|
|
storageRepoIdx(0), PG_VERSION_94, HRN_PG_SYSTEMID_94, cfgOptionIdxStrId(cfgOptRepoCipherType, 0),
|
2021-01-21 15:21:50 -05:00
|
|
|
cfgOptionIdxStr(cfgOptRepoCipherPass, 0)),
|
|
|
|
FileInvalidError,
|
2019-10-08 18:04:09 -04:00
|
|
|
"backup and archive info files exist but do not match the database\n"
|
|
|
|
"HINT: is this the correct stanza?\n"
|
|
|
|
"HINT: did an error occur during stanza-upgrade?");
|
|
|
|
|
2021-06-24 12:23:09 -04:00
|
|
|
//--------------------------------------------------------------------------------------------------------------------------
|
|
|
|
TEST_TITLE("checkStanzaInfoPg() - systemId mismatch");
|
|
|
|
|
2019-10-08 18:04:09 -04:00
|
|
|
// SystemId mismatch
|
2021-05-22 11:59:43 -04:00
|
|
|
TEST_ERROR(
|
2021-01-21 15:21:50 -05:00
|
|
|
checkStanzaInfoPg(
|
2021-04-28 11:36:20 -04:00
|
|
|
storageRepoIdx(0), PG_VERSION_96, 6569239123849665699, cfgOptionIdxStrId(cfgOptRepoCipherType, 0),
|
2021-01-21 15:21:50 -05:00
|
|
|
cfgOptionIdxStr(cfgOptRepoCipherPass, 0)),
|
|
|
|
FileInvalidError,
|
2019-10-08 18:04:09 -04:00
|
|
|
"backup and archive info files exist but do not match the database\n"
|
|
|
|
"HINT: is this the correct stanza?\n"
|
|
|
|
"HINT: did an error occur during stanza-upgrade?");
|
2019-08-21 15:41:52 -04:00
|
|
|
}
|
|
|
|
|
2021-03-10 18:42:22 -05:00
|
|
|
FUNCTION_HARNESS_RETURN_VOID();
|
2019-08-01 20:35:01 -04:00
|
|
|
}
|