Repository navigation
test(node): cover window pull-through served-but-not-cached finalize path (#896) - #925
Conversation
…path (#896) Pin the `window_forward_loop` branch where `pull.finish()` verifies the upstream whole-blob hash but `tee.finish()` fails to promote into the local cache: the bytes are already forwarded and paid, so delivery still completes (StreamEnd sent) while only the warm-cache benefit is forfeited. This path metered `node_pull_through_tee_finalize_failed` but had zero coverage; its sibling (`upstream_verify_failed`) was already covered. Inject the store-side promote failure deterministically without a mock by setting B's cache-engine cap (`max_blob_mb`) to exactly one byte below the blob (1 MiB cap, 1 MiB+1 blob) while leaving the handler serve cap unlimited. Sizing the blob to `cap + 1` lands the mid-stream size breach on the FINAL chunk, so every `tee.write` succeeds and the overrun surfaces only at `tee.finish()` — not the in-loop `local_tee_failed` path. Thread an `engine_max_blob_mb` param through `build_node_b_with_leaves` (existing callers pass the default 64). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the test helper functions build_node_b and build_node_b_with_leaves in node_origin_pull.rs to accept an engine_max_blob_mb parameter, allowing tests to configure the cache engine's maximum blob size limit. It also adds a new integration test, window_pull_through_tee_finalize_failure_serves_but_does_not_cache, which verifies that when a cache promote fails during finalization (e.g., due to exceeding the engine's size limit), the data delivery still completes successfully but the blob is not cached. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
Adds an integration test to cover the node’s “served-but-not-cached” window pull-through finalize branch, ensuring that a cache promote failure at tee.finish() does not prevent successful delivery (and payment) to the client.
Changes:
- Extend the
build_node_b_with_leavestest helper to accept aengine_max_blob_mbparameter that controls the cache engine’s per-blob size cap. - Add
window_pull_through_tee_finalize_failure_serves_but_does_not_cacheto deterministically trigger atee.finish()promote failure via engine cap sizing and assert the correct outcome + metrics. - Update existing helper call sites to pass the default
engine_max_blob_mb = 64.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 85.76% (was 85.74%, ▲ +0.02%) — 37250/43436 lines No coverage data for changed Rust files. History
|
What
Adds
window_pull_through_tee_finalize_failure_serves_but_does_not_cache, closing the test-coverage gap in #896.The production branch under test is in
crates/node/src/handlers/client.rswindow_forward_loop: after a window pull-through delivery,pull.finish()verifies the upstream whole-blob hash; on success it callstee.finish()to promote the teed blob into the local cache. Whentee.finish()fails (a store-side promote failure), the node incrementsnode_pull_through_tee_finalize_failed, logs, and still writesStreamEnd— the client was served and paid; only the warm-cache benefit is forfeited. This "served-but-not-cached" path had zero coverage; its sibling (pull.finish()Err →upstream_verify_failed) was already covered bywindow_pull_through_lying_upstream_is_not_cached.How
Deterministic store-fault injection without a mock: set node B's cache-engine cap (
CacheEngine::open'smax_blob_mb) to exactly one byte below the blob —1 MiBcap against a1 MiB + 1blob — while leaving the handler serve cap (max_blob_size_bytes) unlimited so the serve is never rejected up front.The cap is enforced mid-stream by
count_and_cap_stream, so a breach before the final chunk would surface as an in-looptee.writefailure (thenode_pull_through_local_tee_failedpath) instead. Sizing the blob to exactlycap + 1guarantees the breach lands on the final chunk: everytee.writehas already succeeded with no further write, so the overrun surfaces only attee.finish()— the branch under test. This is robust against transport chunking, window pausing, and the bounded tee channel.A new
engine_max_blob_mbparameter is threaded through thebuild_node_b_with_leavestest helper; existing callers pass the default64.Assertions
outcome.completed(provesStreamEnd),hash_ok,received == total_bytes, andacks > 0(the served bytes were paid for).!cache_b.has(hash)— the blob is not promoted.node_pull_through_tee_finalize_failed_total == 1, and the sibling metricsupstream_verify_failed/local_tee_failedstay0, pinning the exact branch.The
HashMismatch(error-level) arm of the same branch is deliberately left uncovered — it differs only in log level (same metric, same served-anyway flow) and would need an engine-internal fault injector.Verification
cargo nextest run -p decdn-node window_pull_through_tee_finalize_failure_serves_but_does_not_cache— passcargo nextest run -p decdn-node window_pull_through— all 12 pass (regression after the helper change)cargo clippy -p decdn-node --tests --all-features -- -D warnings— cleancargo fmt -p decdn-node -- --check— cleanReviewed by the pr-review-toolkit (code-reviewer, pr-test-analyzer, comment-analyzer); no critical/important findings, three low-severity suggestions applied.
Closes #896.
🤖 Generated with Claude Code