From 28f660482aa5abb97850a9d7c89c2e5e9f23a4c9 Mon Sep 17 00:00:00 2001 From: David Steele <david@pgmasters.net> Date: Sat, 26 Nov 2022 10:48:02 +0800 Subject: [PATCH] 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. --- src/info/manifest.c | 1 + test/src/module/info/manifestTest.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/info/manifest.c b/src/info/manifest.c index 7098306cf..c97e15968 100644 --- a/src/info/manifest.c +++ b/src/info/manifest.c @@ -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) { diff --git a/test/src/module/info/manifestTest.c b/test/src/module/info/manifestTest.c index 849c42d1d..06044dcae 100644 --- a/test/src/module/info/manifestTest.c +++ b/test/src/module/info/manifestTest.c @@ -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");