1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-19 21:07:53 +02:00

Move manifestBackupLabelSet() test in info/manifest unit.

Changing the label of a manifest that already had a label was not a good test and it ended up masking a bug where the current backup label was not being added to the reference list on manifest load, since manifestBackupLabelSet() added the label to the reference list. In fact, manifestBackupLabelSet() should never be called after a manifest load or even after the label has been set.

Add an assertion to prevent manifestBackupLabelSet() being called when the label is already set.

The bug exposed here will be fixed in a subsequent commit.
This commit is contained in:
David Steele 2022-11-26 10:48:02 +08:00
parent 3f363cb3ae
commit 28f660482a
2 changed files with 14 additions and 5 deletions
src/info
test/src/module/info

@ -3062,6 +3062,7 @@ manifestBackupLabelSet(Manifest *this, const String *backupLabel)
FUNCTION_TEST_END();
ASSERT(this != NULL);
ASSERT(this->pub.data.backupLabel == NULL);
MEM_CONTEXT_BEGIN(this->pub.memContext)
{

@ -46,6 +46,15 @@ testRun(void)
"backup-timestamp-stop=0\n" \
"backup-type=\"full\"\n"
#define TEST_MANIFEST_HEADER_LABEL \
"[backup]\n" \
"backup-label=\"20190818-084502F\"\n" \
"backup-reference=\"20190818-084502F\"\n" \
"backup-timestamp-copy-start=0\n" \
"backup-timestamp-start=0\n" \
"backup-timestamp-stop=0\n" \
"backup-type=\"full\"\n"
#define TEST_MANIFEST_HEADER_BUNDLE \
"[backup]\n" \
"backup-bundle=true\n" \
@ -332,6 +341,7 @@ testRun(void)
storagePg, PG_VERSION_90, hrnPgCatalogVersion(PG_VERSION_90), false, false, false, NULL,
pckWriteResult(tablespaceList)),
"build manifest");
TEST_RESULT_VOID(manifestBackupLabelSet(manifest, STRDEF("20190818-084502F")), "backup label set");
Buffer *contentSave = bufNew(0);
@ -339,7 +349,7 @@ testRun(void)
TEST_RESULT_STR(
strNewBuf(contentSave),
strNewBuf(harnessInfoChecksumZ(
TEST_MANIFEST_HEADER
TEST_MANIFEST_HEADER_LABEL
TEST_MANIFEST_DB_90
TEST_MANIFEST_OPTION_ALL
"\n"
@ -1496,7 +1506,7 @@ testRun(void)
"backup-lsn-start=\"285/89000028\"\n" \
"backup-lsn-stop=\"285/89001F88\"\n" \
"backup-prior=\"20190818-084502F\"\n" \
"backup-reference=\"20190818-084502F_20190819-084506D,20190818-084502F,20190818-084502F_20190820-084502D\"\n" \
"backup-reference=\"20190818-084502F_20190819-084506D,20190818-084502F\"\n" \
"backup-timestamp-copy-start=1565282141\n" \
"backup-timestamp-start=1565282140\n" \
"backup-timestamp-stop=1565282142\n" \
@ -1610,7 +1620,7 @@ testRun(void)
"backup-archive-start=\"000000040000028500000089\"\n"
"backup-archive-stop=\"000000040000028500000089\"\n"
"backup-bundle=true\n"
"backup-label=\"20190818-084502F\"\n"
"backup-label=\"20190818-084502F_20190820-084502D\"\n"
"backup-lsn-start=\"300/89000028\"\n"
"backup-lsn-stop=\"300/89001F88\"\n"
"backup-prior=\"20190818-084502F\"\n"
@ -1655,8 +1665,6 @@ testRun(void)
TEST_MANIFEST_PATH_DEFAULT))),
"load manifest");
TEST_RESULT_VOID(manifestBackupLabelSet(manifest, STRDEF("20190818-084502F_20190820-084502D")), "backup label set");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("manifest validation");