Files
supervisor/tests
Mike Degatano 0a7aa22405 Fix OOM/memory growth in tests/api by clearing aiohttp's middleware cache (#7196)
aiohttp caches built middleware chains in a module-level, process-wide
functools.lru_cache(maxsize=1024) keyed on (handler, apps tuple). Our test
suite builds a fresh RestAPI/web.Application (bound to a fresh CoreSys) for
nearly every test, so almost every test call is a cache miss that inserts a
new, never-reused entry - each one pinning an entire CoreSys object graph
(docker mocks, D-Bus proxies, aiohttp routes, etc.) in memory until 1024
stale entries force LRU eviction. Over a full tests/api run this causes
steady, effectively unbounded memory growth that reliably OOMs.

Add an autouse fixture that clears aiohttp's internal
_cached_build_middleware cache after every test. Verified with the full
tests/api suite (1097 tests): now completes in ~2:15 with peak RSS ~490MB,
versus growing past several GB and crashing before this change.
2026-09-04 16:23:42 -04:00
..
…