From e3a0c4f3758ae8bb2cf573a49408bded72362173 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 31 May 2024 20:04:00 +0200 Subject: [PATCH] fix check_cache and test_check_cache NewCache and AdHocCache do not have a persistent chunks index, so both check_cache and test_check_cache are pointless. --- src/borg/testsuite/archiver/__init__.py | 8 +++++++- src/borg/testsuite/archiver/checks.py | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/borg/testsuite/archiver/__init__.py b/src/borg/testsuite/archiver/__init__.py index bb5a7e169..abfadf6ce 100644 --- a/src/borg/testsuite/archiver/__init__.py +++ b/src/borg/testsuite/archiver/__init__.py @@ -18,7 +18,7 @@ import pytest from ... import xattr, platform from ...archive import Archive from ...archiver import Archiver, PURE_PYTHON_MSGPACK_WARNING -from ...cache import Cache +from ...cache import Cache, LocalCache from ...constants import * # NOQA from ...helpers import Location, umount from ...helpers import EXIT_SUCCESS @@ -356,9 +356,15 @@ def check_cache(archiver): manifest = Manifest.load(repository, Manifest.NO_OPERATION_CHECK) with Cache(repository, manifest, sync=False) as cache: original_chunks = cache.chunks + # the LocalCache implementation has an on-disk chunks cache, + # but NewCache and AdHocCache don't have persistent chunks cache. + persistent = isinstance(cache, LocalCache) Cache.destroy(repository) with Cache(repository, manifest) as cache: correct_chunks = cache.chunks + if not persistent: + # there is no point in doing the checks + return assert original_chunks is not correct_chunks seen = set() for id, (refcount, size) in correct_chunks.iteritems(): diff --git a/src/borg/testsuite/archiver/checks.py b/src/borg/testsuite/archiver/checks.py index 1de88d4e1..60fc48f7e 100644 --- a/src/borg/testsuite/archiver/checks.py +++ b/src/borg/testsuite/archiver/checks.py @@ -317,6 +317,9 @@ def test_check_cache(archivers, request): cache.begin_txn() cache.chunks.incref(list(cache.chunks.iteritems())[0][0]) cache.commit() + persistent = isinstance(cache, LocalCache) + if not persistent: + pytest.skip("check_cache is pointless if we do not have a persistent chunks cache") with pytest.raises(AssertionError): check_cache(archiver)