Skip to content

test(engine): keep the probe cache bound test off the filesystem - #3828

Closed
miguel-heygen wants to merge 1 commit into
mainfrom
fix/probe-cache-test-io
Closed

test(engine): keep the probe cache bound test off the filesystem#3828
miguel-heygen wants to merge 1 commit into
mainfrom
fix/probe-cache-test-io

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

Why

probeMediaProfile > bounds the process-scoped probe cache is a recurring failure on the Windows test lane. It shows up on unrelated pull requests and on main, always as a 5s timeout. In a normal run the test takes ~300ms on Windows; on the failing runs it took over 5s while neighbouring tests in the same file only slowed about 2×.

The test created 129 real files in the temp dir, stat'ed each through the code under test, then deleted them, to check that the 129th insert evicts the oldest entry. That rule is in-memory. The file churn made the test's runtime a function of filesystem contention on the runner, not of the code.

What changed

  • The test synthesises statSync results (identity is dev:ino:size:mtime:ctime) instead of writing files, so it never touches disk. Locally it drops from ~115ms to ~35ms; on Windows it no longer scales with disk load.
  • The test now also covers the LRU touch: a hit before the bound is reached keeps that entry resident and the next-oldest is evicted instead. The old shape never produced a cache hit during the fill, so removing the touch left it green.

Verification

  • ffprobe.test.ts: 115 passed.
  • Raising the bound to 129 in ffprobe.ts fails the test (expected 130, got 129).
  • Removing the LRU re-insert on hit fails the test (expected 129, got 130).
  • oxfmt, oxlint and tsc --noEmit clean for the engine package.

No product code changes.

The eviction test wrote, stat'ed and deleted 129 temp files to exercise an
in-memory LRU rule. Its runtime tracked filesystem contention rather than
the code under test, and on a busy Windows runner the file churn alone
pushed a ~300ms test past the 5s timeout, failing unrelated pull requests.

Cache identity comes from stat, so the test now synthesises stat results
and never touches disk. While here, the test also asserts the LRU touch:
re-probing an entry before the bound is hit must keep it resident and
evict the next-oldest one instead. The previous shape never hit the cache
during the fill, so that branch was untested.
@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Folded into #3834 with the other CI flake fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant