Skip to content

testsuite: add UpgraderFrom12To20 unit tests, refs #9556#9675

Merged
ThomasWaldmann merged 2 commits into
borgbackup:masterfrom
mr-raj12:legacy-upgrade-phase7
May 30, 2026
Merged

testsuite: add UpgraderFrom12To20 unit tests, refs #9556#9675
ThomasWaldmann merged 2 commits into
borgbackup:masterfrom
mr-raj12:legacy-upgrade-phase7

Conversation

@mr-raj12
Copy link
Copy Markdown
Contributor

Description

Unit tests for UpgraderFrom12To20, refs #9556.

UpgraderFrom12To20 (legacy/upgrade.py) shipped in earlier phases without any test coverage. This PR adds src/borg/testsuite/legacy_upgrade_test.py covering all three public methods.

src/borg/testsuite/legacy_upgrade_test.py -- 20 tests for UpgraderFrom12To20:

upgrade_item (8 tests):

  • regular file passes through unchanged
  • whitelist strips legacy-only keys (acl, chunks_healthy, hardlink_master)
  • user/group set to None are dropped
  • symlink source renamed to target
  • hardlink master gets hlid assigned and hardlink_master key removed
  • hardlink slave resolves hlid and reuses chunks via cache.reuse_chunk
  • master and slave share the same hlid
  • REQUIRED_ITEM_KEYS always present in output

upgrade_archive_metadata (9 tests):

  • cmdline list becomes command_line string
  • recreate_cmdline list becomes recreate_command_line string
  • time gets +00:00 UTC offset appended
  • 4-tuple chunker_params gets buzhash prefix
  • 5-tuple chunker_params passes through unchanged
  • rechunking override replaces stored chunker_params
  • recreate fields (recreate_source_id, recreate_args, recreate_partial_chunks) dropped
  • tags always set to []
  • missing optional attrs absent from result

upgrade_compressed_chunk (3 tests):

  • ZLIB-legacy data detected and ctype promoted to ZLIB.ID
  • non-ZLIB chunks have two prefix bytes stripped
  • ObfuscateSize big-endian csize header re-parsed correctly; inner payload and padding preserved

Also fixes src/borg/compress.pyi: CompressorBase.ID was typed as bytes but is int at runtime in every subclass.

No production code changes.

Refs #9556

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

Comment thread src/borg/compress.pyi
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.99%. Comparing base (828e72b) to head (b7c8417).
⚠️ Report is 6 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9675      +/-   ##
==========================================
+ Coverage   83.82%   83.99%   +0.16%     
==========================================
  Files          93       93              
  Lines       15592    15592              
  Branches     2337     2337              
==========================================
+ Hits        13070    13096      +26     
+ Misses       1786     1771      -15     
+ Partials      736      725      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these.

BTW, it's not correct there were no test for the upgrader, there is a quite big and quite practical one inside the transfer_cmd tests, do a real repository upgrade from 1.2 to 2.

Comment thread src/borg/testsuite/legacy_upgrade_test.py Outdated
Comment thread src/borg/testsuite/legacy_upgrade_test.py Outdated
Copy link
Copy Markdown
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ThomasWaldmann ThomasWaldmann merged commit c613d80 into borgbackup:master May 30, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants