From e017212de2ad8b8ff84c761c273a5672ed7df17e Mon Sep 17 00:00:00 2001 From: Mrityunjay Raj Date: Sat, 30 May 2026 23:15:52 +0530 Subject: [PATCH 1/2] testsuite: decouple legacyrepository_test from RepoObj, refs #8572 --- src/borg/testsuite/legacyrepository_test.py | 29 +++++++-------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/borg/testsuite/legacyrepository_test.py b/src/borg/testsuite/legacyrepository_test.py index 4887b70b91..255293d56d 100644 --- a/src/borg/testsuite/legacyrepository_test.py +++ b/src/borg/testsuite/legacyrepository_test.py @@ -14,7 +14,6 @@ from ..legacy.remote import LegacyRemoteRepository, InvalidRPCMethod, PathNotAllowed from ..legacy.repository import LegacyRepository, LoggedIO from ..legacy.repository import MAGIC, MAX_DATA_SIZE, TAG_DELETE, TAG_PUT, TAG_COMMIT -from ..repoobj import RepoObj from .hashindex_test import H @@ -72,21 +71,15 @@ def get_path(repository): def fchunk(data, meta=b""): - # Create a raw chunk that has a valid RepoObj layout but does not use encryption or compression. - hdr = RepoObj.obj_header.pack(len(meta), len(data)) + # RepoObj1 blobs are raw bytes with no header; meta is unused in the borg 1.x format. assert isinstance(data, bytes) - chunk = hdr + meta + data - return chunk + assert meta == b"" + return data def pchunk(chunk): - # Parse data and meta from a raw chunk made by fchunk. - hdr_size = RepoObj.obj_header.size - hdr = chunk[:hdr_size] - meta_size, data_size = RepoObj.obj_header.unpack(hdr)[0:2] - meta = chunk[hdr_size : hdr_size + meta_size] - data = chunk[hdr_size + meta_size : hdr_size + meta_size + data_size] - return data, meta + # RepoObj1 blobs are raw bytes; meta is always empty in the borg 1.x format. + return chunk, b"" def pdchunk(chunk): @@ -147,13 +140,11 @@ def test_multiple_transactions(repo_fixtures, request): def test_read_data(repo_fixtures, request): with get_repository_from_fixture(repo_fixtures, request) as repository: - meta, data = b"meta", b"data" - hdr = RepoObj.obj_header.pack(len(meta), len(data)) - chunk_complete = hdr + meta + data - repository.put(H(0), chunk_complete) + data = b"somedata" + repository.put(H(0), data) repository.commit(compact=False) - assert repository.get(H(0)) == chunk_complete - assert repository.get(H(0), read_data=True) == chunk_complete + assert repository.get(H(0)) == data + assert repository.get(H(0), read_data=True) == data assert repository.get(H(0), read_data=False) is None @@ -222,7 +213,7 @@ def test_list(repo_fixtures, request): def test_max_data_size(repo_fixtures, request): with get_repository_from_fixture(repo_fixtures, request) as repository: - max_data = b"x" * (MAX_DATA_SIZE - RepoObj.obj_header.size) + max_data = b"x" * MAX_DATA_SIZE repository.put(H(0), fchunk(max_data)) assert pdchunk(repository.get(H(0))) == max_data with pytest.raises(IntegrityError): From a0494b29f474a37c6d22a4eed34747c1d5d03d47 Mon Sep 17 00:00:00 2001 From: Mrityunjay Raj Date: Sun, 31 May 2026 02:26:01 +0530 Subject: [PATCH 2/2] testsuite: use 1-byte ctype header in legacyrepository_test fchunk/pchunk, refs #8572 --- src/borg/testsuite/legacyrepository_test.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/borg/testsuite/legacyrepository_test.py b/src/borg/testsuite/legacyrepository_test.py index 255293d56d..eb1800fa14 100644 --- a/src/borg/testsuite/legacyrepository_test.py +++ b/src/borg/testsuite/legacyrepository_test.py @@ -14,6 +14,7 @@ from ..legacy.remote import LegacyRemoteRepository, InvalidRPCMethod, PathNotAllowed from ..legacy.repository import LegacyRepository, LoggedIO from ..legacy.repository import MAGIC, MAX_DATA_SIZE, TAG_DELETE, TAG_PUT, TAG_COMMIT +from ..compress import CNONE from .hashindex_test import H @@ -71,15 +72,15 @@ def get_path(repository): def fchunk(data, meta=b""): - # RepoObj1 blobs are raw bytes with no header; meta is unused in the borg 1.x format. + # simplified borg 1.x format: 1-byte ctype header (CNONE = no compression) followed by payload. assert isinstance(data, bytes) assert meta == b"" - return data + return bytes([CNONE.ID]) + data def pchunk(chunk): - # RepoObj1 blobs are raw bytes; meta is always empty in the borg 1.x format. - return chunk, b"" + # strip the 1-byte ctype header; meta is always empty in the borg 1.x format. + return chunk[1:], b"" def pdchunk(chunk): @@ -213,7 +214,7 @@ def test_list(repo_fixtures, request): def test_max_data_size(repo_fixtures, request): with get_repository_from_fixture(repo_fixtures, request) as repository: - max_data = b"x" * MAX_DATA_SIZE + max_data = b"x" * (MAX_DATA_SIZE - 1) repository.put(H(0), fchunk(max_data)) assert pdchunk(repository.get(H(0))) == max_data with pytest.raises(IntegrityError):