You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-03 00:26:59 +02:00
Add zNewFmt().
This replaces strZ(strNewFmt()), making the code simpler and reducing indentation.
This commit is contained in:
@ -1176,7 +1176,7 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(result.copyChecksum, "9bc8ab2dda60ef4beed07d1e19ce0676d5edde67", "copy checksum");
|
||||
TEST_RESULT_PTR(result.pageChecksumResult, NULL, "page checksum result is NULL");
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageRepo(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/%s.gz", strZ(backupLabel), strZ(pgFile))),
|
||||
storageRepo(), zNewFmt(STORAGE_REPO_BACKUP "/%s/%s.gz", strZ(backupLabel), strZ(pgFile)),
|
||||
.comment = "copy file to repo compress success");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1207,7 +1207,7 @@ testRun(void)
|
||||
TEST_RESULT_UINT(result.backupCopyResult, backupCopyResultChecksum, "checksum file");
|
||||
TEST_RESULT_STR_Z(result.copyChecksum, "9bc8ab2dda60ef4beed07d1e19ce0676d5edde67", "compressed repo file checksum matches");
|
||||
TEST_STORAGE_EXISTS(
|
||||
storageRepo(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/%s.gz", strZ(backupLabel), strZ(pgFile))),
|
||||
storageRepo(), zNewFmt(STORAGE_REPO_BACKUP "/%s/%s.gz", strZ(backupLabel), strZ(pgFile)),
|
||||
.comment = "compressed file exists");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1426,9 +1426,10 @@ testRun(void)
|
||||
TEST_TITLE("assign label when history is older");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
|
||||
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp - 4)))));
|
||||
storageRepoWrite(),
|
||||
zNewFmt(
|
||||
STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
|
||||
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp - 4))));
|
||||
|
||||
TEST_RESULT_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
|
||||
|
||||
@ -1436,8 +1437,7 @@ testRun(void)
|
||||
TEST_TITLE("assign label when backup is older");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp - 2)))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp - 2))));
|
||||
|
||||
TEST_RESULT_STR(backupLabelCreate(backupTypeFull, NULL, timestamp), backupLabel, "create label");
|
||||
|
||||
@ -1445,8 +1445,7 @@ testRun(void)
|
||||
TEST_TITLE("advance time when backup is same");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp)))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp))));
|
||||
|
||||
TEST_RESULT_STR_Z(backupLabelCreate(backupTypeFull, NULL, timestamp), "20191203-193413F", "create label");
|
||||
|
||||
@ -1454,8 +1453,7 @@ testRun(void)
|
||||
TEST_TITLE("error when new label is in the past even with advanced time");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 1)))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s", strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 1))));
|
||||
|
||||
TEST_ERROR(
|
||||
backupLabelCreate(backupTypeFull, NULL, timestamp), ClockError,
|
||||
@ -1467,9 +1465,10 @@ testRun(void)
|
||||
TEST_TITLE("error when new label is in the past even with advanced time (from history)");
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(
|
||||
strNewFmt(STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
|
||||
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 3600)))));
|
||||
storageRepoWrite(),
|
||||
zNewFmt(
|
||||
STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
|
||||
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 3600))));
|
||||
|
||||
TEST_ERROR(
|
||||
backupLabelCreate(backupTypeFull, NULL, timestamp), ClockError,
|
||||
@ -2239,7 +2238,7 @@ testRun(void)
|
||||
// Copy a file to be resumed that has not changed in the repo
|
||||
HRN_STORAGE_COPY(
|
||||
storagePg(), PG_FILE_PGVERSION, storageRepoWrite(),
|
||||
strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/PG_VERSION", strZ(resumeLabel))));
|
||||
zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/PG_VERSION", strZ(resumeLabel)));
|
||||
|
||||
ManifestFilePack **const filePack = manifestFilePackFindInternal(manifestResume, STRDEF("pg_data/PG_VERSION"));
|
||||
ManifestFile file = manifestFileUnpack(manifestResume, *filePack);
|
||||
@ -2331,11 +2330,11 @@ testRun(void)
|
||||
// File exists in cluster and repo but not in the resume manifest
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "not-in-resume", "TEST", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/not-in-resume.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/not-in-resume.gz", strZ(resumeLabel)));
|
||||
|
||||
// Remove checksum from file so it won't be resumed
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/pg_control.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/pg_control.gz", strZ(resumeLabel)));
|
||||
|
||||
ManifestFilePack **const filePack = manifestFilePackFindInternal(manifestResume, STRDEF("pg_data/global/pg_control"));
|
||||
ManifestFile file = manifestFileUnpack(manifestResume, *filePack);
|
||||
@ -2347,7 +2346,7 @@ testRun(void)
|
||||
// Size does not match between cluster and resume manifest
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "size-mismatch", "TEST", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/size-mismatch.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/size-mismatch.gz", strZ(resumeLabel)));
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){
|
||||
.name = STRDEF("pg_data/size-mismatch"), .checksumSha1 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
@ -2356,7 +2355,7 @@ testRun(void)
|
||||
// Time does not match between cluster and resume manifest
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "time-mismatch", "TEST", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/time-mismatch.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/time-mismatch.gz", strZ(resumeLabel)));
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){
|
||||
.name = STRDEF("pg_data/time-mismatch"), .checksumSha1 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", .size = 4,
|
||||
@ -2365,22 +2364,19 @@ testRun(void)
|
||||
// Size is zero in cluster and resume manifest. ??? We'd like to remove this requirement after the migration.
|
||||
HRN_STORAGE_PUT_EMPTY(storagePgWrite(), "zero-size", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_Z(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/zero-size.gz", strZ(resumeLabel))),
|
||||
"ZERO-SIZE");
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/zero-size.gz", strZ(resumeLabel)), "ZERO-SIZE");
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){.name = STRDEF("pg_data/zero-size"), .size = 0, .timestamp = backupTimeStart});
|
||||
|
||||
// Path is not in manifest
|
||||
HRN_STORAGE_PATH_CREATE(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/bogus_path", strZ(resumeLabel))));
|
||||
HRN_STORAGE_PATH_CREATE(storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/bogus_path", strZ(resumeLabel)));
|
||||
|
||||
// File is not in manifest
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/bogus.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/bogus.gz", strZ(resumeLabel)));
|
||||
|
||||
// File has incorrect compression type
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/bogus", strZ(resumeLabel))));
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/global/bogus", strZ(resumeLabel)));
|
||||
|
||||
// Save the resume manifest
|
||||
manifestSave(
|
||||
@ -2521,13 +2517,11 @@ testRun(void)
|
||||
manifestBackupLabelSet(manifestResume, resumeLabel);
|
||||
|
||||
// Reference in manifest
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/PG_VERSION.gz", strZ(resumeLabel))));
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/PG_VERSION.gz", strZ(resumeLabel)));
|
||||
|
||||
// Reference in resumed manifest
|
||||
HRN_STORAGE_PUT_EMPTY(storagePgWrite(), "resume-ref", .timeModified = backupTimeStart);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/resume-ref.gz", strZ(resumeLabel))));
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/resume-ref.gz", strZ(resumeLabel)));
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){.name = STRDEF("pg_data/resume-ref"), .size = 0, .reference = STRDEF("BOGUS")});
|
||||
|
||||
@ -2535,7 +2529,7 @@ testRun(void)
|
||||
// also that the repo file is intenionally corrupt to generate a warning about corruption in the repository.
|
||||
HRN_STORAGE_PUT_Z(storagePgWrite(), "time-mismatch2", "TEST", .timeModified = backupTimeStart + 100);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoWrite(), strZ(strNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/time-mismatch2.gz", strZ(resumeLabel))));
|
||||
storageRepoWrite(), zNewFmt(STORAGE_REPO_BACKUP "/%s/pg_data/time-mismatch2.gz", strZ(resumeLabel)));
|
||||
manifestFileAdd(
|
||||
manifestResume, &(ManifestFile){
|
||||
.name = STRDEF("pg_data/time-mismatch2"), .checksumSha1 = "984816fd329622876e14907634264e6f332e9fb3", .size = 4,
|
||||
@ -2877,7 +2871,7 @@ testRun(void)
|
||||
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageTest,
|
||||
strZ(strNewFmt("pg1-tblspc/32768/%s/1/5", strZ(pgTablespaceId(PG_VERSION_11, hrnPgCatalogVersion(PG_VERSION_11))))),
|
||||
zNewFmt("pg1-tblspc/32768/%s/1/5", strZ(pgTablespaceId(PG_VERSION_11, hrnPgCatalogVersion(PG_VERSION_11)))),
|
||||
.timeModified = backupTimeStart);
|
||||
|
||||
// Disable storageFeatureSymLink so tablespace (and latest) symlinks will not be created
|
||||
|
Reference in New Issue
Block a user