1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add HRN_PG_CONTROL_PUT() and HRN_PG_CONTROL_TIME().

These macros simplify management of pg_control test files.

Centralize time updates for pg_control in the command/backup module. This caused some time updates in the logs.

Finally, move the postgres module after the storage module so it can use storage macros.
This commit is contained in:
David Steele 2021-11-30 13:23:11 -05:00
parent 01ac6b6cac
commit 0895cfcdf7
8 changed files with 81 additions and 118 deletions

View File

@ -427,27 +427,6 @@ unit:
coverage: coverage:
- common/lock - common/lock
# ********************************************************************************************************************************
- name: postgres
test:
# ----------------------------------------------------------------------------------------------------------------------------
- name: client
total: 1
harness: pq
coverage:
- postgres/client
# ----------------------------------------------------------------------------------------------------------------------------
- name: interface
total: 9
harness: postgres
coverage:
- postgres/interface
- postgres/interface/page
# ******************************************************************************************************************************** # ********************************************************************************************************************************
- name: protocol - name: protocol
@ -596,6 +575,27 @@ unit:
- storage/storage - storage/storage
- storage/write - storage/write
# ********************************************************************************************************************************
- name: postgres
test:
# ----------------------------------------------------------------------------------------------------------------------------
- name: client
total: 1
harness: pq
coverage:
- postgres/client
# ----------------------------------------------------------------------------------------------------------------------------
- name: interface
total: 9
harness: postgres
coverage:
- postgres/interface
- postgres/interface/page
# ******************************************************************************************************************************** # ********************************************************************************************************************************
- name: build - name: build

View File

@ -7,6 +7,8 @@ Harness for PostgreSQL Interface
#include "postgres/interface.h" #include "postgres/interface.h"
#include "postgres/version.h" #include "postgres/version.h"
#include "common/harnessStorage.h"
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Control file size used to create pg_control Control file size used to create pg_control
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
@ -46,6 +48,19 @@ System id constants by version
#define HRN_PG_SYSTEMID_14 (10000000000000000000ULL + (uint64_t)PG_VERSION_14) #define HRN_PG_SYSTEMID_14 (10000000000000000000ULL + (uint64_t)PG_VERSION_14)
#define HRN_PG_SYSTEMID_14_Z "10000000000000140000" #define HRN_PG_SYSTEMID_14_Z "10000000000000140000"
/***********************************************************************************************************************************
Put a control file to storage
***********************************************************************************************************************************/
#define HRN_PG_CONTROL_PUT(storageParam, versionParam, ...) \
HRN_STORAGE_PUT( \
storageParam, PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = versionParam, __VA_ARGS__}))
/***********************************************************************************************************************************
Update control file time
***********************************************************************************************************************************/
#define HRN_PG_CONTROL_TIME(storageParam, timeParam, ...) \
HRN_STORAGE_TIME(storageParam, PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, timeParam)
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/

View File

@ -150,8 +150,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("no segments to find"); TEST_TITLE("no segments to find");
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_10);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_10}));
HRN_INFO_PUT( HRN_INFO_PUT(
storageRepoWrite(), INFO_ARCHIVE_PATH_FILE, storageRepoWrite(), INFO_ARCHIVE_PATH_FILE,
@ -623,8 +622,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("no valid repo"); TEST_TITLE("no valid repo");
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_10);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_10}));
strLstAddZ(argList, TEST_PATH "/pg/pg_wal/RECOVERYXLOG"); strLstAddZ(argList, TEST_PATH "/pg/pg_wal/RECOVERYXLOG");
HRN_CFG_LOAD(cfgCmdArchiveGet, argList, .exeBogus = true); HRN_CFG_LOAD(cfgCmdArchiveGet, argList, .exeBogus = true);
@ -780,8 +778,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("pg version does not match archive.info"); TEST_TITLE("pg version does not match archive.info");
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_11);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_11}));
HRN_INFO_PUT( HRN_INFO_PUT(
storageRepoWrite(), INFO_ARCHIVE_PATH_FILE, storageRepoWrite(), INFO_ARCHIVE_PATH_FILE,
@ -810,9 +807,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("pg system id does not match archive.info"); TEST_TITLE("pg system id does not match archive.info");
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_10, .systemId = 1);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_10, .systemId = 1}));
TEST_ERROR(cmdArchiveGet(), RepoInvalidError, "unable to find a valid repository"); TEST_ERROR(cmdArchiveGet(), RepoInvalidError, "unable to find a valid repository");
@ -823,8 +818,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("file is missing"); TEST_TITLE("file is missing");
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_10);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_10}));
TEST_RESULT_INT(cmdArchiveGet(), 1, "get"); TEST_RESULT_INT(cmdArchiveGet(), 1, "get");

View File

@ -104,8 +104,7 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("mismatched pg_control and archive.info - pg version"); TEST_TITLE("mismatched pg_control and archive.info - pg version");
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_96);
storageTest, "pg/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_96}));
// Create incorrect archive info // Create incorrect archive info
HRN_INFO_PUT( HRN_INFO_PUT(
@ -288,8 +287,7 @@ testRun(void)
strLstAddZ(argListTemp, "pg_wal/000000010000000100000001"); strLstAddZ(argListTemp, "pg_wal/000000010000000100000001");
HRN_CFG_LOAD(cfgCmdArchivePush, argListTemp); HRN_CFG_LOAD(cfgCmdArchivePush, argListTemp);
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_11);
storageTest, "pg/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_11}));
HRN_INFO_PUT( HRN_INFO_PUT(
storageRepoIdxWrite(0), INFO_ARCHIVE_PATH_FILE, storageRepoIdxWrite(0), INFO_ARCHIVE_PATH_FILE,
@ -669,8 +667,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo"); hrnCfgArgRawZ(argList, cfgOptRepoPath, TEST_PATH "/repo");
hrnCfgArgRawBool(argList, cfgOptLogSubprocess, true); hrnCfgArgRawBool(argList, cfgOptLogSubprocess, true);
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_94);
storageTest, "pg/" PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_94}));
HRN_INFO_PUT( HRN_INFO_PUT(
storageTest, "repo/archive/test/archive.info", storageTest, "repo/archive/test/archive.info",

View File

@ -274,6 +274,9 @@ testBackupPqScript(unsigned int pgVersion, time_t backupTimeStart, TestBackupPqS
const char *lsnStopStr = strZ(pgLsnToStr(lsnStop)); const char *lsnStopStr = strZ(pgLsnToStr(lsnStop));
const char *walSegmentStop = strZ(pgLsnToWalSegment(param.timeline, lsnStop, pgControl.walSegmentSize)); const char *walSegmentStop = strZ(pgLsnToWalSegment(param.timeline, lsnStop, pgControl.walSegmentSize));
// Update pg_control on primary with the backup time
HRN_PG_CONTROL_TIME(storagePgIdxWrite(0), backupTimeStart);
// Write WAL segments to the archive // Write WAL segments to the archive
// ----------------------------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------------------------
if (!param.noPriorWal) if (!param.noPriorWal)
@ -1010,8 +1013,7 @@ testRun(void)
TEST_TITLE("warn and reset when backup from standby used in offline mode"); TEST_TITLE("warn and reset when backup from standby used in offline mode");
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_92);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92}));
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1"); hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
@ -1034,8 +1036,7 @@ testRun(void)
TEST_TITLE("error when pg_control does not match stanza"); TEST_TITLE("error when pg_control does not match stanza");
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_10);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_10}));
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1"); hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
@ -1062,8 +1063,7 @@ testRun(void)
TEST_TITLE("reset start-fast when PostgreSQL < 8.4"); TEST_TITLE("reset start-fast when PostgreSQL < 8.4");
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_83);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_83}));
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1"); hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
@ -1085,8 +1085,7 @@ testRun(void)
TEST_TITLE("reset stop-auto when PostgreSQL < 9.3"); TEST_TITLE("reset stop-auto when PostgreSQL < 9.3");
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_84);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_84}));
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1"); hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
@ -1108,8 +1107,7 @@ testRun(void)
TEST_TITLE("reset checksum-page when the cluster does not have checksums enabled"); TEST_TITLE("reset checksum-page when the cluster does not have checksums enabled");
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_93);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_93}));
// Create stanza // Create stanza
argList = strLstNew(); argList = strLstNew();
@ -1151,9 +1149,7 @@ testRun(void)
TEST_TITLE("ok if cluster checksums are enabled and checksum-page is any value"); TEST_TITLE("ok if cluster checksums are enabled and checksum-page is any value");
// Create pg_control with page checksums // Create pg_control with page checksums
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_93, .pageChecksum = true);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_93, .pageChecksum = true}));
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1"); hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
@ -1178,8 +1174,7 @@ testRun(void)
TEST_RESULT_BOOL(cfgOptionBool(cfgOptChecksumPage), false, "check checksum-page"); TEST_RESULT_BOOL(cfgOptionBool(cfgOptChecksumPage), false, "check checksum-page");
// Create pg_control without page checksums // Create pg_control without page checksums
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_93);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_93}));
harnessPqScriptSet((HarnessPq []) harnessPqScriptSet((HarnessPq [])
{ {
@ -1203,8 +1198,7 @@ testRun(void)
TEST_TITLE("sleep retries and stall error"); TEST_TITLE("sleep retries and stall error");
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_93);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_93}));
// Create stanza // Create stanza
StringList *argList = strLstNew(); StringList *argList = strLstNew();
@ -1482,8 +1476,7 @@ testRun(void)
HRN_CFG_LOAD(cfgCmdStanzaCreate, argList); HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_84);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_84}));
cmdStanzaCreate(); cmdStanzaCreate();
TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'test1' on repo1"); TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'test1' on repo1");
@ -1732,9 +1725,7 @@ testRun(void)
HRN_CFG_LOAD(cfgCmdStanzaCreate, argList); HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_95);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_95}),
.timeModified = backupTimeStart);
cmdStanzaCreate(); cmdStanzaCreate();
TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'test1' on repo1"); TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'test1' on repo1");
@ -1981,7 +1972,7 @@ testRun(void)
"[target:file]\n" "[target:file]\n"
"pg_data/PG_VERSION={\"checksum\":\"06d06bb31b570b94d7b4325f511f853dbe771c21\",\"size\":3" "pg_data/PG_VERSION={\"checksum\":\"06d06bb31b570b94d7b4325f511f853dbe771c21\",\"size\":3"
",\"timestamp\":1570000000}\n" ",\"timestamp\":1570000000}\n"
"pg_data/global/pg_control={\"size\":8192,\"timestamp\":1570000000}\n" "pg_data/global/pg_control={\"size\":8192,\"timestamp\":1570100000}\n"
"pg_data/not-in-resume={\"checksum\":\"984816fd329622876e14907634264e6f332e9fb3\",\"size\":4" "pg_data/not-in-resume={\"checksum\":\"984816fd329622876e14907634264e6f332e9fb3\",\"size\":4"
",\"timestamp\":1570100000}\n" ",\"timestamp\":1570100000}\n"
"pg_data/pg_xlog/0000000105D95D3000000000={\"size\":16777216,\"timestamp\":1570100002}\n" "pg_data/pg_xlog/0000000105D95D3000000000={\"size\":16777216,\"timestamp\":1570100002}\n"
@ -2139,7 +2130,7 @@ testRun(void)
"[target:file]\n" "[target:file]\n"
"pg_data/PG_VERSION={\"checksum\":\"06d06bb31b570b94d7b4325f511f853dbe771c21\",\"reference\":\"20191003-105320F\"" "pg_data/PG_VERSION={\"checksum\":\"06d06bb31b570b94d7b4325f511f853dbe771c21\",\"reference\":\"20191003-105320F\""
",\"size\":3,\"timestamp\":1570000000}\n" ",\"size\":3,\"timestamp\":1570000000}\n"
"pg_data/global/pg_control={\"reference\":\"20191003-105320F\",\"size\":8192,\"timestamp\":1570000000}\n" "pg_data/global/pg_control={\"reference\":\"20191003-105320F\",\"size\":8192,\"timestamp\":1570200000}\n"
"pg_data/postgresql.conf={\"checksum\":\"e3db315c260e79211b7b52587123b7aa060f30ab\"" "pg_data/postgresql.conf={\"checksum\":\"e3db315c260e79211b7b52587123b7aa060f30ab\""
",\"reference\":\"20191003-105320F\",\"size\":11,\"timestamp\":1570000000}\n" ",\"reference\":\"20191003-105320F\",\"size\":11,\"timestamp\":1570000000}\n"
"pg_data/resume-ref={\"size\":0,\"timestamp\":1570200000}\n" "pg_data/resume-ref={\"size\":0,\"timestamp\":1570200000}\n"
@ -2164,9 +2155,7 @@ testRun(void)
{ {
// Update pg_control // Update pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_96);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_96}),
.timeModified = backupTimeStart);
// Update version // Update version
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_96_STR, .timeModified = backupTimeStart); HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_96_STR, .timeModified = backupTimeStart);
@ -2307,10 +2296,7 @@ testRun(void)
{ {
// Update pg_control // Update pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_11, .pageChecksum = true, .walSegmentSize = 1024 * 1024);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_11, .pageChecksum = true, .walSegmentSize = 1024 * 1024}),
.timeModified = backupTimeStart);
// Update version // Update version
HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_11_STR, .timeModified = backupTimeStart); HRN_STORAGE_PUT_Z(storagePgWrite(), PG_FILE_PGVERSION, PG_VERSION_11_STR, .timeModified = backupTimeStart);
@ -2522,8 +2508,6 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error when pg_control not present"); TEST_TITLE("error when pg_control not present");
backupTimeStart = BACKUP_EPOCH + 2300000;
{ {
// Load options // Load options
StringList *argList = strLstNew(); StringList *argList = strLstNew();
@ -2535,8 +2519,11 @@ testRun(void)
hrnCfgArgRawBool(argList, cfgOptRepoHardlink, true); hrnCfgArgRawBool(argList, cfgOptRepoHardlink, true);
HRN_CFG_LOAD(cfgCmdBackup, argList); HRN_CFG_LOAD(cfgCmdBackup, argList);
// Preserve prior timestamp on pg_control
testBackupPqScriptP(PG_VERSION_11, BACKUP_EPOCH + 2300000, .errorAfterStart = true);
HRN_PG_CONTROL_TIME(storagePg(), backupTimeStart);
// Run backup // Run backup
testBackupPqScriptP(PG_VERSION_11, backupTimeStart, .errorAfterStart = true);
TEST_ERROR( TEST_ERROR(
cmdBackup(), FileMissingError, cmdBackup(), FileMissingError,
"pg_control must be present in all online backups\n" "pg_control must be present in all online backups\n"
@ -2574,9 +2561,6 @@ testRun(void)
hrnCfgArgRawBool(argList, cfgOptRepoHardlink, true); hrnCfgArgRawBool(argList, cfgOptRepoHardlink, true);
HRN_CFG_LOAD(cfgCmdBackup, argList); HRN_CFG_LOAD(cfgCmdBackup, argList);
// Update pg_control timestamp
HRN_STORAGE_TIME(storagePg(), "global/pg_control", backupTimeStart);
// Run backup. Make sure that the timeline selected converts to hexdecimal that can't be interpreted as decimal. // Run backup. Make sure that the timeline selected converts to hexdecimal that can't be interpreted as decimal.
testBackupPqScriptP(PG_VERSION_11, backupTimeStart, .timeline = 0x2C, .walTotal = 2); testBackupPqScriptP(PG_VERSION_11, backupTimeStart, .timeline = 0x2C, .walTotal = 2);
TEST_RESULT_VOID(cmdBackup(), "backup"); TEST_RESULT_VOID(cmdBackup(), "backup");

View File

@ -150,8 +150,7 @@ testRun(void)
HRN_CFG_LOAD(cfgCmdCheck, argList); HRN_CFG_LOAD(cfgCmdCheck, argList);
// Create pg_control for standby // Create pg_control for standby
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_92);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92}));
// Standby database path doesn't match pg_control // Standby database path doesn't match pg_control
harnessPqScriptSet((HarnessPq []) harnessPqScriptSet((HarnessPq [])
@ -175,9 +174,7 @@ testRun(void)
TEST_TITLE("standby and primary database - error on primary but standby check ok"); TEST_TITLE("standby and primary database - error on primary but standby check ok");
// Create pg_control for primary // Create pg_control for primary
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgIdxWrite(1), PG_VERSION_92);
storagePgIdxWrite(1), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92}));
// Create info files // Create info files
HRN_INFO_PUT( HRN_INFO_PUT(
@ -571,9 +568,7 @@ testRun(void)
HRN_CFG_LOAD(cfgCmdStanzaCreate, argList); HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgIdxWrite(0), PG_VERSION_96);
storagePgIdxWrite(0), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_96}));
// Create info files // Create info files
TEST_RESULT_VOID(cmdStanzaCreate(), "stanza create - encryption"); TEST_RESULT_VOID(cmdStanzaCreate(), "stanza create - encryption");

View File

@ -61,8 +61,7 @@ testRun(void)
HRN_CFG_LOAD(cfgCmdStanzaCreate, argList); HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_96);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_96}));
TEST_RESULT_VOID(cmdStanzaCreate(), "stanza create - one repo, no files exist"); TEST_RESULT_VOID(cmdStanzaCreate(), "stanza create - one repo, no files exist");
TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'db' on repo1"); TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'db' on repo1");
@ -527,8 +526,7 @@ testRun(void)
TEST_TITLE("pgControl and database match"); TEST_TITLE("pgControl and database match");
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_92);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92}));
harnessPqScriptSet((HarnessPq []) harnessPqScriptSet((HarnessPq [])
{ {
@ -566,9 +564,7 @@ testRun(void)
TEST_TITLE("pg_control and version mismatch"); TEST_TITLE("pg_control and version mismatch");
// Create pg_control with different version // Create pg_control with different version
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_91);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_91}));
harnessPqScriptSet((HarnessPq []) harnessPqScriptSet((HarnessPq [])
{ {
@ -586,8 +582,7 @@ testRun(void)
TEST_TITLE("pg_control and path mismatch"); TEST_TITLE("pg_control and path mismatch");
// Create pg_control // Create pg_control
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_92);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92}));
harnessPqScriptSet((HarnessPq []) harnessPqScriptSet((HarnessPq [])
{ {
@ -614,14 +609,10 @@ testRun(void)
HRN_CFG_LOAD(cfgCmdStanzaCreate, argList); HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
// Create pg_control for primary // Create pg_control for primary
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgIdxWrite(1), PG_VERSION_92);
storagePgIdxWrite(1), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92}));
// Create pg_control for standby // Create pg_control for standby
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgIdxWrite(0), PG_VERSION_94);
storagePgIdxWrite(0), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_94}));
harnessPqScriptSet((HarnessPq []) harnessPqScriptSet((HarnessPq [])
{ {
@ -661,8 +652,7 @@ testRun(void)
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
// Create pg_control for the rest of the tests // Create pg_control for the rest of the tests
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_96);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_96}));
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("stanza-upgrade - info file mismatch: db-id"); TEST_TITLE("stanza-upgrade - info file mismatch: db-id");
@ -909,8 +899,7 @@ testRun(void)
HRN_CFG_LOAD(cfgCmdStanzaCreate, argList); HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
// Create pg_control for stanza-create // Create pg_control for stanza-create
HRN_STORAGE_PUT( HRN_PG_CONTROL_PUT(storagePgWrite(), PG_VERSION_96);
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_96}));
TEST_RESULT_VOID(cmdStanzaCreate(), "create a stanza that will not be deleted"); TEST_RESULT_VOID(cmdStanzaCreate(), "create a stanza that will not be deleted");
TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'otherstanza' on repo1"); TEST_RESULT_LOG("P00 INFO: stanza-create for stanza 'otherstanza' on repo1");

View File

@ -47,8 +47,6 @@ testRun(void)
TEST_RESULT_UINT(pgInterface[0].version, PG_VERSION_MAX, "check max version"); TEST_RESULT_UINT(pgInterface[0].version, PG_VERSION_MAX, "check max version");
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
const String *controlFile = STRDEF(PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL);
// Create a bogus control file // Create a bogus control file
Buffer *result = bufNew(HRN_PG_CONTROL_SIZE); Buffer *result = bufNew(HRN_PG_CONTROL_SIZE);
memset(bufPtr(result), 0, bufSize(result)); memset(bufPtr(result), 0, bufSize(result));
@ -65,9 +63,7 @@ testRun(void)
"unexpected control version = 501 and catalog version = 19780101\nHINT: is this version of PostgreSQL supported?"); "unexpected control version = 501 and catalog version = 19780101\nHINT: is this version of PostgreSQL supported?");
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
storagePutP( HRN_PG_CONTROL_PUT(storageTest, PG_VERSION_11, .systemId = 0xFACEFACE, .walSegmentSize = 1024 * 1024);
storageNewWriteP(storageTest, controlFile),
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_11, .systemId = 0xFACEFACE, .walSegmentSize = 1024 * 1024}));
PgControl info = {0}; PgControl info = {0};
TEST_ASSIGN(info, pgControlFromFile(storageTest), "get control info v11"); TEST_ASSIGN(info, pgControlFromFile(storageTest), "get control info v11");
@ -76,26 +72,19 @@ testRun(void)
TEST_RESULT_UINT(info.catalogVersion, 201809051, " check catalog version"); TEST_RESULT_UINT(info.catalogVersion, 201809051, " check catalog version");
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
storagePutP( HRN_PG_CONTROL_PUT(storageTest, PG_VERSION_93, .walSegmentSize = 1024 * 1024);
storageNewWriteP(storageTest, controlFile),
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_93, .walSegmentSize = 1024 * 1024}));
TEST_ERROR( TEST_ERROR(
pgControlFromFile(storageTest), FormatError, "wal segment size is 1048576 but must be 16777216 for PostgreSQL <= 10"); pgControlFromFile(storageTest), FormatError, "wal segment size is 1048576 but must be 16777216 for PostgreSQL <= 10");
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
storagePutP( HRN_PG_CONTROL_PUT(storageTest, PG_VERSION_95, .pageSize = 32 * 1024);
storageNewWriteP(storageTest, controlFile),
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_95, .pageSize = 32 * 1024}));
TEST_ERROR(pgControlFromFile(storageTest), FormatError, "page size is 32768 but must be 8192"); TEST_ERROR(pgControlFromFile(storageTest), FormatError, "page size is 32768 but must be 8192");
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
storagePutP( HRN_PG_CONTROL_PUT(
storageNewWriteP(storageTest, controlFile), storageTest, PG_VERSION_83, .systemId = 0xEFEFEFEFEF, .catalogVersion = hrnPgCatalogVersion(PG_VERSION_83));
hrnPgControlToBuffer(
(PgControl){
.version = PG_VERSION_83, .systemId = 0xEFEFEFEFEF, .catalogVersion = hrnPgCatalogVersion(PG_VERSION_83)}));
TEST_ASSIGN(info, pgControlFromFile(storageTest), "get control info v83"); TEST_ASSIGN(info, pgControlFromFile(storageTest), "get control info v83");
TEST_RESULT_UINT(info.systemId, 0xEFEFEFEFEF, " check system id"); TEST_RESULT_UINT(info.systemId, 0xEFEFEFEFEF, " check system id");