1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-09 00:45:49 +02:00

Improve testing of files that change size during the backup.

Files can change size during a backup so update and add tests to cover the various scenarios more thoroughly.
This commit is contained in:
David Steele
2020-03-18 13:40:16 -04:00
parent 4ec04e5163
commit 26c89b2c8c

View File

@ -2068,14 +2068,26 @@ testRun(void)
strLstAddZ(argList, "--" CFGOPT_ARCHIVE_COPY);
harnessCfgLoad(cfgCmdBackup, argList);
// Create files to copy from the standby. The files will be zero-size on the primary and non-zero on the standby to test
// that they were copied from the right place.
// Create file to copy from the standby. This file will be zero-length on the primary and non-zero-length on the standby
// but not bytes will be copied.
storagePutP(storageNewWriteP(storagePgIdWrite(1), STRDEF(PG_PATH_BASE "/1/1"), .timeModified = backupTimeStart), NULL);
storagePutP(storageNewWriteP(storagePgIdWrite(2), STRDEF(PG_PATH_BASE "/1/1")), BUFSTRDEF("DATA"));
storagePutP(storageNewWriteP(storagePgIdWrite(2), STRDEF(PG_PATH_BASE "/1/1")), BUFSTRDEF("1234"));
// Create file to copy from the standby. This file will be smaller on the primary than the standby and have no common
// data in the bytes that exist on primary and standby. If the file is copied from the primary instead of the standby
// the checksum will change but not the size.
storagePutP(
storageNewWriteP(storagePgIdWrite(1), STRDEF(PG_PATH_BASE "/1/2"), .timeModified = backupTimeStart),
BUFSTRDEF("D"));
storagePutP(storageNewWriteP(storagePgIdWrite(2), STRDEF(PG_PATH_BASE "/1/2")), BUFSTRDEF("DATA"));
BUFSTRDEF("DA"));
storagePutP(storageNewWriteP(storagePgIdWrite(2), STRDEF(PG_PATH_BASE "/1/2")), BUFSTRDEF("5678"));
// Create file to copy from the standby. This file will be larger on the primary than the standby and have no common
// data in the bytes that exist on primary and standby. If the file is copied from the primary instead of the standby
// the checksum and size will change.
storagePutP(
storageNewWriteP(storagePgIdWrite(1), STRDEF(PG_PATH_BASE "/1/3"), .timeModified = backupTimeStart),
BUFSTRDEF("TEST"));
storagePutP(storageNewWriteP(storagePgIdWrite(2), STRDEF(PG_PATH_BASE "/1/3")), BUFSTRDEF("ABC"));
// Create a file on the primary that does not exist on the standby to test that the file is removed from the manifest
storagePutP(
@ -2116,6 +2128,7 @@ testRun(void)
"pg_data/base/1 {path}\n"
"pg_data/base/1/1 {file, s=4}\n"
"pg_data/base/1/2 {file, s=4}\n"
"pg_data/base/1/3 {file, s=3}\n"
"pg_data/global {path}\n"
"pg_data/global/pg_control {file, s=8192}\n"
"pg_data/pg_xlog {path}\n"
@ -2130,9 +2143,11 @@ testRun(void)
",\"timestamp\":1571200000}\n"
"pg_data/backup_label={\"checksum\":\"8e6f41ac87a7514be96260d65bacbffb11be77dc\",\"size\":17"
",\"timestamp\":1571200002}\n"
"pg_data/base/1/1={\"checksum\":\"580393f5a94fb469585f5dd2a6859a4aab899f37\",\"master\":false,\"size\":4"
"pg_data/base/1/1={\"checksum\":\"7110eda4d09e062aa5e4a390b0a572ac0d2c0220\",\"master\":false,\"size\":4"
",\"timestamp\":1571200000}\n"
"pg_data/base/1/2={\"checksum\":\"580393f5a94fb469585f5dd2a6859a4aab899f37\",\"master\":false,\"size\":4"
"pg_data/base/1/2={\"checksum\":\"2abd55e001c524cb2cf6300a89ca6366848a77d5\",\"master\":false,\"size\":4"
",\"timestamp\":1571200000}\n"
"pg_data/base/1/3={\"checksum\":\"3c01bdbb26f358bab27f267924aa2c9a03fcfdb8\",\"master\":false,\"size\":3"
",\"timestamp\":1571200000}\n"
"pg_data/global/pg_control={\"size\":8192,\"timestamp\":1571200000}\n"
"pg_data/pg_xlog/0000000105DA69C000000000={\"size\":16777216,\"timestamp\":1571200002}\n"