test_indexcache_vacuum.py¶
tests/test_indexcache_vacuum.py
A successful build leaves the index cache without a mostly-free file.
test_a_flush_alone_does_not_vacuum
None test_indexcache_vacuum.test_a_flush_alone_does_not_vacuum(Path tmp_path)
An aborted build (flush, no commit) does not vacuum.
tests/test_indexcache_vacuum.py:74
Checks
assert _free_ratio(path) > VACUUM_FREE_RATIO
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-002 | measured |
Source · 15 lines
def test_a_flush_alone_does_not_vacuum(tmp_path: Path) -> None:
"""THE SUCCESS PATH ONLY. A VACUUM rewrites the whole file; an aborted build that paid for one
would pay it on every retry, which is the cost the cache exists to avoid.
@brief Free pages survive a flush.
@return None.
@version 1
"""
repo = tmp_path / "repo"
repo.mkdir()
path = tmp_path / "clew.db.idxcache"
cache = IndexCache(path, repo)
_churn(cache)
cache.close()
assert _free_ratio(path) > VACUUM_FREE_RATIO1 more lines, not shown
Activity · 7 steps
test_a_successful_build_reclaims_a_mostly_free_cache
None test_indexcache_vacuum.test_a_successful_build_reclaims_a_mostly_free_cache(Path tmp_path)
A commit over a mostly-free cache reclaims the space.
tests/test_indexcache_vacuum.py:54
Checks
assert _free_ratio(path) > VACUUM_FREE_RATIO, "fixture did not create free pages"assert _free_ratio(path) <= VACUUM_FREE_RATIO
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-002 | measured |
Source · 16 lines
def test_a_successful_build_reclaims_a_mostly_free_cache(tmp_path: Path) -> None:
"""@brief Free ratio is under the threshold after commit.
@return None.
@version 1
"""
repo = tmp_path / "repo"
repo.mkdir()
path = tmp_path / "clew.db.idxcache"
cache = IndexCache(path, repo)
_churn(cache)
assert _free_ratio(path) > VACUUM_FREE_RATIO, "fixture did not create free pages"
cache.commit()
cache.close()
assert _free_ratio(path) <= VACUUM_FREE_RATIO