MCPcopy
hub / github.com/borgbackup/borg / test_backoff

Method test_backoff

src/borg/testsuite/remote_test.py:142–166  ·  view source on GitHub ↗
(self, cache: RepositoryCache)

Source from the content-addressed store, hash-verified

140 assert cache.hits == 2
141
142 def test_backoff(self, cache: RepositoryCache):
143 def query_size_limit():
144 cache.size_limit = 0
145
146 assert [pdchunk(ch) for ch in cache.get_many([H(1), H(2)])] == [b"1234", b"5678"]
147 assert cache.misses == 2
148 assert cache.evictions == 0
149 iterator = cache.get_many([H(1), H(3), H(2)])
150 assert pdchunk(next(iterator)) == b"1234"
151
152 # Force cache to back off
153 qsl = cache.query_size_limit
154 cache.query_size_limit = query_size_limit # type: ignore[assignment]
155 cache.backoff()
156 cache.query_size_limit = qsl # type: ignore[assignment]
157 # Evicted H(1) and H(2)
158 assert cache.evictions == 2
159 assert H(1) not in cache.cache
160 assert H(2) not in cache.cache
161 assert pdchunk(next(iterator)) == bytes(100)
162 assert cache.slow_misses == 0
163 # Since H(2) was in the cache when we called get_many(), but has
164 # been evicted during iterating the generator, it will be a slow miss.
165 assert pdchunk(next(iterator)) == b"5678"
166 assert cache.slow_misses == 1
167
168 def test_enospc(self, cache: RepositoryCache):
169 class enospc_open:

Callers

nothing calls this directly

Calls 4

pdchunkFunction · 0.70
HFunction · 0.70
get_manyMethod · 0.45
backoffMethod · 0.45

Tested by

no test coverage detected