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.
This commit is contained in:
Thomas Waldmann 2024-05-31 20:04:00 +02:00
parent ab6049e269
commit e3a0c4f375
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
2 changed files with 10 additions and 1 deletions

View File

@ -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():

View File

@ -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)