1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-07 00:35:37 +02:00

Autogenerate test system identifiers.

hrnPgControlToBuffer() and hrnPgWalToBuffer() now generate the system id based on the version of Postgres. If a value less than 100 is specified for systemId then it will be added to the default system id so there can be multiple ids for a single version of PostgreSQL.

Add constants to represent version system ids in tests. These will eventually be auto-generated.

This changes some checksums and we no longer have big-endian tests systems, so X those checksums out so it is obvious they are no longer valid.
This commit is contained in:
David Steele
2021-11-30 08:28:36 -05:00
parent 3f7409019d
commit 01ac6b6cac
9 changed files with 233 additions and 207 deletions

View File

@ -151,8 +151,7 @@ testRun(void)
// Create pg_control for standby
HRN_STORAGE_PUT(
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92, .systemId = 6569239123849665679}));
storagePgWrite(), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL, hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92}));
// Standby database path doesn't match pg_control
harnessPqScriptSet((HarnessPq [])
@ -178,29 +177,29 @@ testRun(void)
// Create pg_control for primary
HRN_STORAGE_PUT(
storagePgIdxWrite(1), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92, .systemId = 6569239123849665679}));
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_92}));
// Create info files
HRN_INFO_PUT(
storageRepoIdxWrite(0), INFO_ARCHIVE_PATH_FILE,
"[db]\n"
"db-id=1\n"
"db-system-id=6569239123849665679\n"
"db-system-id=" HRN_PG_SYSTEMID_92_Z "\n"
"db-version=\"9.2\"\n"
"\n"
"[db:history]\n"
"1={\"db-id\":6569239123849665679,\"db-version\":\"9.2\"}\n");
"1={\"db-id\":" HRN_PG_SYSTEMID_92_Z ",\"db-version\":\"9.2\"}\n");
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"
"db-system-id=6569239123849665679\n"
"db-system-id=" HRN_PG_SYSTEMID_92_Z "\n"
"db-version=\"9.2\"\n"
"\n"
"[db:history]\n"
"1={\"db-catalog-version\":201608131,\"db-control-version\":920,\"db-system-id\":6569239123849665679,"
"1={\"db-catalog-version\":201608131,\"db-control-version\":920,\"db-system-id\":" HRN_PG_SYSTEMID_92_Z ","
"\"db-version\":\"9.2\"}\n");
// Single repo config - error when checking archive mode setting on database
@ -272,22 +271,22 @@ testRun(void)
storageRepoIdxWrite(1), INFO_ARCHIVE_PATH_FILE,
"[db]\n"
"db-id=1\n"
"db-system-id=6569239123849665679\n"
"db-system-id=" HRN_PG_SYSTEMID_92_Z "\n"
"db-version=\"9.2\"\n"
"\n"
"[db:history]\n"
"1={\"db-id\":6569239123849665679,\"db-version\":\"9.2\"}\n");
"1={\"db-id\":" HRN_PG_SYSTEMID_92_Z ",\"db-version\":\"9.2\"}\n");
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"
"db-system-id=6569239123849665679\n"
"db-system-id=" HRN_PG_SYSTEMID_92_Z "\n"
"db-version=\"9.2\"\n"
"\n"
"[db:history]\n"
"1={\"db-catalog-version\":201608131,\"db-control-version\":920,\"db-system-id\":6569239123849665679,"
"1={\"db-catalog-version\":201608131,\"db-control-version\":920,\"db-system-id\":" HRN_PG_SYSTEMID_92_Z ","
"\"db-version\":\"9.2\"}\n");
// Error when WAL segment not found
@ -574,7 +573,7 @@ testRun(void)
// Create pg_control
HRN_STORAGE_PUT(
storagePgIdxWrite(0), PG_PATH_GLOBAL "/" PG_FILE_PGCONTROL,
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_96, .systemId = 6569239123849665679}));
hrnPgControlToBuffer((PgControl){.version = PG_VERSION_96}));
// Create info files
TEST_RESULT_VOID(cmdStanzaCreate(), "stanza create - encryption");
@ -583,7 +582,7 @@ testRun(void)
// Version mismatch
TEST_ERROR(
checkStanzaInfoPg(
storageRepoIdx(0), PG_VERSION_94, 6569239123849665679, cfgOptionIdxStrId(cfgOptRepoCipherType, 0),
storageRepoIdx(0), PG_VERSION_94, HRN_PG_SYSTEMID_94, cfgOptionIdxStrId(cfgOptRepoCipherType, 0),
cfgOptionIdxStr(cfgOptRepoCipherPass, 0)),
FileInvalidError,
"backup and archive info files exist but do not match the database\n"