Skip to content

test(node): cover window pull-through served-but-not-cached finalize path (#896) - #925

Merged
thiras merged 1 commit into
mainfrom
test/node-896-tee-finalize-served-not-cached
Jun 17, 2026
Merged

thiras merged 1 commit into
mainfrom
test/node-896-tee-finalize-served-not-cached

Conversation

@thiras

@thiras thiras commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

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.rs window_forward_loop: after a window pull-through delivery, pull.finish() verifies the upstream whole-blob hash; on success it calls tee.finish() to promote the teed blob into the local cache. When tee.finish() fails (a store-side promote failure), the node increments node_pull_through_tee_finalize_failed, logs, and still writes StreamEnd — 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 by window_pull_through_lying_upstream_is_not_cached.

How

Deterministic store-fault injection without a mock: set node B's cache-engine cap (CacheEngine::open's max_blob_mb) to exactly one byte below the blob — 1 MiB cap against a 1 MiB + 1 blob — 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-loop tee.write failure (the node_pull_through_local_tee_failed path) instead. Sizing the blob to exactly cap + 1 guarantees the breach lands on the final chunk: every tee.write has already succeeded with no further write, so the overrun surfaces only at tee.finish() — the branch under test. This is robust against transport chunking, window pausing, and the bounded tee channel.

A new engine_max_blob_mb parameter is threaded through the build_node_b_with_leaves test helper; existing callers pass the default 64.

Assertions

  • Delivery still completes: outcome.completed (proves StreamEnd), hash_ok, received == total_bytes, and acks > 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 metrics upstream_verify_failed/local_tee_failed stay 0, 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 — pass
  • cargo 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 — clean
  • cargo fmt -p decdn-node -- --check — clean

Reviewed 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

…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]>
Copilot AI review requested due to automatic review settings June 17, 2026 02:28

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_leaves test helper to accept a engine_max_blob_mb parameter that controls the cache engine’s per-blob size cap.
  • Add window_pull_through_tee_finalize_failure_serves_but_does_not_cache to deterministically trigger a tee.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.

@github-actions

Copy link
Copy Markdown

Coverage report

Total: 85.76% (was 85.74%, ▲ +0.02%) — 37250/43436 lines

No coverage data for changed Rust files.

History
Commit Total Δ vs base
11342e0 (HEAD) 85.76% ▲ +0.02%

@thiras
thiras merged commit 0ba2ea3 into main Jun 17, 2026
21 checks passed
@thiras
thiras deleted the test/node-896-tee-finalize-served-not-cached branch June 17, 2026 03:24
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.

node: cover the window pull-through 'served-but-not-cached' path (node_pull_through_tee_finalize_failed)

2 participants