Skip to content

test(cloud): keep the Liquid template tests stable on a busy machine - #862

Merged
ValentinKolb merged 1 commit into
mainfrom
test/test-liquid-budget-deterministic
Oct 10, 2026
Merged

ValentinKolb merged 1 commit into
mainfrom
test/test-liquid-budget-deterministic

Conversation

@ValentinKolb

Copy link
Copy Markdown
Collaborator

Outcome

The Liquid template tests in packages/cloud/src/shared/template-rendering.test.ts no longer fail on a busy machine. Every test in the file now runs on a fake performance.now() clock, so only the limit under test can trip a render budget.

  • The default 1,000 ms budget is proven exactly: 1,000 ms passes, 1,001 ms times out.
  • Nested loops and where_exp expressions still time out, and only checks inside the loop or expression can cause that.
  • A slow final filter still times out.
  • 300 writes of 1,000 bytes render up to exactly the default byte cap.

Runtime behavior and defaults are unchanged.

Root cause

The tests read the real performance.now(), so under host load they measured the machine instead of the renderer. The default byte-cap test rendered 30,000 iterations against the real 1,000 ms budget and failed with render_timeout (#804). The captured-output and memory-limit tests fail the same way under heavier load, and several tests asserted wall-time upper bounds. Sixteen parallel runs of the file pinned to one CPU failed in every run.

Trade-off: a reintroduced quadratic output emitter (#759) is no longer caught. That is a timing property a deterministic test cannot observe.

Docs

No Fibel or cloud-dev skill change: the change is test-only, and runtime behavior and defaults are unchanged.

Verification

  • bun test src/shared/template-rendering.test.ts in packages/cloud: 28 pass.
  • 16 parallel runs of the file pinned to one CPU (taskset -c 0) after the rebase onto main: 16/16 pass (32 parallel runs also passed before the rebase).
  • bun run check after the rebase.

Closes #804

The Liquid template tests read the real performance.now(), so on a busy
machine they measured host load instead of the renderer. The default
byte-cap test rendered 30,000 iterations against the real 1,000 ms budget
and failed with render_timeout (#804). The captured-output and
memory-limit tests fail the same way under heavier load, and several
tests asserted wall-time upper bounds. Sixteen parallel runs of the file
pinned to one CPU failed in every run.

Every test in the file now runs on a fake clock. Time passes only where a
test moves it, so only the limit under test can trip:

- the default budget is proven exactly: 1,000 ms passes, 1,001 ms times
  out;
- nested loops and where_exp expressions time out, which only checks
  inside the loop or expression can cause;
- a slow final filter still times out;
- 300 writes of 1,000 bytes render up to exactly the default byte cap.

The byte-cap test and the where_exp range are smaller, so they cost
little real time under load, and a missing where_exp check fails at once
instead of scanning for about 25 seconds. Sixteen and thirty-two parallel
runs pinned to one CPU now pass.

A reintroduced quadratic output emitter (#759) is no longer caught. That
is a timing property a deterministic test cannot observe: large renders
made of many small writes would then fail with render_timeout, and no
test would notice.

No Fibel or cloud-dev skill change: the change is test-only, and runtime
behavior and defaults are unchanged.

Closes #804
@ValentinKolb
ValentinKolb added this pull request to the merge queue Oct 10, 2026
Merged via the queue into main with commit 4f299d4 Oct 10, 2026
22 checks passed
@ValentinKolb
ValentinKolb deleted the test/test-liquid-budget-deterministic branch October 10, 2026 13:08
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.

test(cloud): the Liquid default time budget test fails on a busy machine because it measures wall time

1 participant