Skip to content

test(relay): behavioral coverage for request streaming, cancel, and error paths - #47

Open
duyet wants to merge 1 commit into
mainfrom
cursor/008-relay-streaming-tests-4ce0
Open

test(relay): behavioral coverage for request streaming, cancel, and error paths#47
duyet wants to merge 1 commit into
mainfrom
cursor/008-relay-streaming-tests-4ce0

Conversation

@duyet

@duyet duyet commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Closes #23 (Plan 008).

Why

The relay streams local HTTP responses back over WebSocket as Head/Chunk/Done. Existing tests covered frame parsing and config only. A refactor could break forwarding, cancel, or UTF-8 splitting with green CI.

Scope

  • src/relay.rs tests only. A loopback HTTP stub plus five handle_request tests.
    • streams_local_response_back_as_head_chunk_done
    • non_2xx_from_target_relays_status_and_body
    • unreachable_target_produces_error_frame
    • cancel_flag_stops_streaming
    • utf8_split_body_round_trips
  • No production logic change. No new dependencies.
  • Skipped the unused WebSocket FakeCloud from the issue. The five tests drive handle_request directly, which is the serving core.

Out of scope: tests/cli.rs, fixing production bugs (none found).

Tradeoffs

Cancel-before-call still POSTs, then returns after Head. The test allows Head and forbids Chunk/Done, matching the live handle_request loop.

Blast radius

Test-only. CI time grows by a loopback accept plus one 1 MiB stub body. No user-facing change.

Verification

  • cargo test --locked --lib relay::tests — 19 passed, including the five new names
  • Five consecutive reruns with --test-threads=1 — all passed
  • cargo test --locked --all-targets — 186 lib + 68 cli + 7 release_lock passed
  • git diff is +216 lines inside #[cfg(test)] only

Checklist

  • Version stays on 0.1.x (do not introduce 0.2 / 1.0)
  • Do not auto-merge release-please PRs
Open in Web Open in Cursor 

…rror paths

Drive handle_request against a loopback HTTP stub. Cover Head/Chunk/Done,
non-2xx relay, unreachable Error frames, cancel-before-stream, and UTF-8
reassembly of a multibyte body.

Closes #23

Co-authored-by: Duyet Le <me@duyet.net>
Co-authored-by: duyetbot <bot@duyet.net>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

anyr size and startup

Startup is wall time for a cold anyr --version / anyr --help (median of 21 runs). Size is the stripped release binary, or the .wasm for the browser demo.

Size budget: anyr-linux-x86_64 must stay ≤ 4.0 MiB (4194304 bytes) stripped.

Asset Kind Size --version median --help median
anyr-darwin-arm64 native 2.8 MiB 5.13 ms 3.72 ms
anyr-darwin-x86_64 native 3.0 MiB 42.44 ms 42.37 ms
anyr-linux-arm64 native 2.8 MiB 0.84 ms 0.84 ms
anyr-linux-x86_64 native 3.1 MiB 0.63 ms 0.62 ms
anyr-windows-x86_64.exe native 2.5 MiB 9.79 ms 10.33 ms
anyr.wasm wasm 176.5 KiB

Budget check: ok

raw timings
[
  {
    "asset": "anyr-darwin-arm64",
    "kind": "native",
    "path": "/Users/runner/work/cli/cli/anyr-darwin-arm64",
    "bytes": 2905320,
    "size": "2.8 MiB",
    "version": "0.1.11 (built 2026-09-03 18:07:13)",
    "target": "aarch64-apple-darwin",
    "os": "macos-latest",
    "startup_version": {
      "n": 21,
      "min_ms": 3.5,
      "median_ms": 5.13,
      "p95_ms": 10.46,
      "mean_ms": 6.14
    },
    "startup_help": {
      "n": 21,
      "min_ms": 3.29,
      "median_ms": 3.72,
      "p95_ms": 4.25,
      "mean_ms": 3.71
    }
  },
  {
    "asset": "anyr-darwin-x86_64",
    "kind": "native",
    "path": "/Users/runner/work/cli/cli/anyr-darwin-x86_64",
    "bytes": 3119656,
    "size": "3.0 MiB",
    "version": "0.1.11 (built 2026-09-03 18:07:19)",
    "target": "x86_64-apple-darwin",
    "os": "macos-latest",
    "startup_version": {
      "n": 21,
      "min_ms": 33.97,
      "median_ms": 42.44,
      "p95_ms": 47.51,
      "mean_ms": 42.53
    },
    "startup_help": {
      "n": 21,
      "min_ms": 35.67,
      "median_ms": 42.37,
      "p95_ms": 54.79,
      "mean_ms": 43.01
    }
  },
  {
    "asset": "anyr-linux-arm64",
    "kind": "native",
    "path": "/home/runner/work/cli/cli/anyr-linux-arm64",
    "bytes": 2888744,
    "size": "2.8 MiB",
    "version": "0.1.11 (built 2026-09-03 18:06:31)",
    "target": "aarch64-unknown-linux-gnu",
    "os": "ubuntu-24.04-arm",
    "startup_version": {
      "n": 21,
      "min_ms": 0.81,
      "median_ms": 0.84,
      "p95_ms": 0.9,
      "mean_ms": 0.85
    },
    "startup_help": {
      "n": 21,
      "min_ms": 0.78,
      "median_ms": 0.84,
      "p95_ms": 0.92,
      "mean_ms": 0.85
    }
  },
  {
    "asset": "anyr-linux-x86_64",
    "kind": "native",
    "path": "/home/runner/work/cli/cli/anyr-linux-x86_64",
    "bytes": 3216904,
    "size": "3.1 MiB",
    "version": "0.1.11 (built 2026-09-03 18:06:30)",
    "target": "x86_64-unknown-linux-gnu",
    "os": "ubuntu-latest",
    "startup_version": {
      "n": 21,
      "min_ms": 0.61,
      "median_ms": 0.63,
      "p95_ms": 0.68,
      "mean_ms": 0.64
    },
    "startup_help": {
      "n": 21,
      "min_ms": 0.6,
      "median_ms": 0.62,
      "p95_ms": 0.84,
      "mean_ms": 0.66
    }
  },
  {
    "asset": "anyr-windows-x86_64.exe",
    "kind": "native",
    "path": "D:\\a\\cli\\cli\\anyr-windows-x86_64.exe",
    "bytes": 2665984,
    "size": "2.5 MiB",
    "version": "0.1.11 (built 2026-09-03T18:07:55Z)",
    "target": "x86_64-pc-windows-msvc",
    "os": "windows-latest",
    "startup_version": {
      "n": 21,
      "min_ms": 9.53,
      "median_ms": 9.79,
      "p95_ms": 11.95,
      "mean_ms": 10.06
    },
    "startup_help": {
      "n": 21,
      "min_ms": 9.89,
      "median_ms": 10.33,
      "p95_ms": 11.46,
      "mean_ms": 10.58
    }
  },
  {
    "asset": "anyr.wasm",
    "kind": "wasm",
    "path": "/home/runner/work/cli/cli/target/wasm-pkg/anyr_cli_bg.wasm",
    "bytes": 180713,
    "size": "176.5 KiB",
    "version": "wasm",
    "target": "wasm32-unknown-unknown",
    "os": ""
  }
]

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.

Plan 008: Behaviorally test the relay streaming core

2 participants