1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

fix test_cache_chunks

- skip test_cache_chunks if there is no persistent chunks cache file
- init self.chunks for AdHocCache
- remove warning output from AdHocCache.__init__, it gets mixed with JSON output and fails the JSON decoder.
This commit is contained in:
Thomas Waldmann 2024-07-12 18:57:49 +02:00
parent 561dcc8abf
commit c7249583e7
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
3 changed files with 8 additions and 8 deletions

View file

@ -428,6 +428,9 @@ def __str__(self):
def stats(self):
from .archive import Archive
if isinstance(self, AdHocCache) and getattr(self, "chunks", None) is None:
self.chunks = self._load_chunks_from_repo() # AdHocCache usually only has .chunks after begin_txn.
# XXX: this should really be moved down to `hashindex.pyx`
total_size, unique_size, total_unique_chunks, total_chunks = self.chunks.summarize()
# since borg 1.2 we have new archive metadata telling the total size per archive,
@ -1340,8 +1343,6 @@ def __init__(self, manifest, warn_if_unencrypted=True, lock_wait=None, iec=False
self.security_manager = SecurityManager(self.repository)
self.security_manager.assert_secure(manifest, self.key, lock_wait=lock_wait)
logger.warning("Note: --no-cache-sync is an experimental feature.")
# Public API
def __enter__(self):

View file

@ -53,11 +53,10 @@ def test_cache_chunks(archiver):
create_src_archive(archiver, "test")
chunks_path = os.path.join(archiver.cache_path, "chunks")
chunks_before_corruption = set(ChunkIndex(path=chunks_path).iteritems())
if not os.path.exists(chunks_path):
pytest.skip("no persistent chunks index for this kind of Cache implementation")
chunks_index = os.path.join(archiver.cache_path, "chunks")
if not os.path.exists(chunks_index):
pytest.skip("Only works with LocalCache.")
chunks_before_corruption = set(ChunkIndex(path=chunks_path).iteritems())
corrupt(chunks_path)

View file

@ -546,8 +546,8 @@ def test_create_no_cache_sync_adhoc(archivers, request): # TODO: add test for N
cmd(archiver, "rcreate", RK_ENCRYPTION)
cmd(archiver, "rdelete", "--cache-only")
create_json = json.loads(
cmd(archiver, "create", "--no-cache-sync", "--prefer-adhoc-cache", "--json", "--error", "test", "input")
) # ignore experimental warning
cmd(archiver, "create", "--no-cache-sync", "--prefer-adhoc-cache", "--json", "test", "input")
)
info_json = json.loads(cmd(archiver, "info", "-a", "test", "--json"))
create_stats = create_json["cache"]["stats"]
info_stats = info_json["cache"]["stats"]