test(h2-transport): comprehensive unit, integration, regression, and load tests#806
Conversation
…load tests Implements the testing plan from #805. Adds 79 tests across 7 files covering H2Headers, H2Response, H2Session, H2Pool, createH2Fetch, end-to-end integration, and 11 named regression cases tied to specific source invariants. Adds 5 load scripts under loadtest/ (multiplex throughput, pool growth, leak/soak, chaos, nghttp2 h2load wrapper). Replaces the single tests/lib/h2-transport.test.ts with a colocated test directory under tests/lib/h2-transport/, sharing testServer and faultServer helpers across suites. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Adds: - loadtest/push-to-loki.ts — runs all four load scripts and POSTs one structured JSON log line per test to Loki (job="h2-loadtest") - .github/workflows/h2-loadtest.yml — daily cron (06:00 UTC), connects via Tailscale tag:ci, pushes to https://dev-loki - README update documenting the automated run and local push usage Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Inline review comments on #806 from codeant-ai. Each addressed: helpers/certs.ts: - Switch from execSync with shelled-out openssl to execFileSync (argv array) so paths containing spaces or shell metacharacters don't break cert gen. helpers/testServer.ts: - goawayAll now has a 1s fallback that destroys sessions if the peer doesn't close promptly, so the promise can't hang indefinitely. - startBlackholeServer.close returns Promise<void> so test teardown can await actual shutdown completion. session.test.ts: - maxConcurrentStreams adoption tests poll for the expected state instead of using a fixed 50ms sleep — non-flaky on slower CI. - abort-listener tests use an instrumented AbortSignal that counts addEventListener/removeEventListener calls, proving the listener is removed on both success and mid-flight-abort paths. Added a second test for the abort path. regression.test.ts: - R12 polls for _maxConcurrentStreams instead of sleeping. integration.test.ts: - 'concurrent origins' and 'AbortSignal' tests put fetch.close() in finally so the H2 pool can't leak on assertion failure. loadtest/h2load.sh: - Run the server in its own process group via setsid; cleanup kills the whole group so npx + node both die. - Pass -k to h2load so the self-signed cert handshake doesn't fail. loadtest/h2-multiplex.ts: - Report both attemptedRps (N / wall) and effectiveRps (successful / wall) so failures can't inflate the throughput number. - Cert gen via execFileSync. loadtest/h2-pool-growth.ts: - Sample actual pool _sessions.length (drive via H2Pool directly since createH2Fetch's per-origin map is closure-private), and assert grow-on-ramp / no-shrink / bounded-by-maxConnections invariants. loadtest/h2-chaos.ts: - Validate durationSec > 0; guard against zero-denominator NaN in the success-rate check. - Cert gen via execFileSync. loadtest/h2-leak.ts, h2-multiplex-server.ts: - Cert gen via execFileSync. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Addressed all 13 inline review comments in f960de8. Per-comment: helpers/certs.ts — helpers/testServer.ts
session.test.ts
regression.test.ts — R12 polls instead of sleeping. integration.test.ts — loadtest/h2load.sh
loadtest/h2-multiplex.ts — reports both loadtest/h2-pool-growth.ts — rewritten to drive loadtest/h2-chaos.ts — validates All 80 tests still pass locally ( |
Fixes lint CI: prettier wants multi-line argv arrays for the execFileSync openssl calls. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
User description
Summary
Implements the testing plan from #805. 79 tests across 7 files, plus 5 load scripts.
Test layout
Deviations from the plan
tests/lib/h2-transport/(matches existing project layout) rather than colocated__tests__/next to source. Equivalent jest discovery, fewer conventions to introduce.response.test.tsalready; R10 (queued-request abort) requires a code change to honor and is best left for a follow-up that ships both the fix and the test together.maxConcurrentStreamssetting, not the harder pool-level queueing behavior (race between SETTINGS frame and first stream — flagged intesting.md§9).Notable behaviors documented by tests
H2Response.text()after reading.bodydirectly returns empty rather than throwing "already consumed" — current behavior, not the documented contract. Seeresponse.test.tscomment andtesting.md§9..text().Run
```sh
npx jest tests/lib/h2-transport/
```
All 79 pass in <2s on a warm machine.
Load tests are on-demand:
```sh
npx tsx loadtest/h2-multiplex.ts 10000
npx tsx loadtest/h2-pool-growth.ts
npx tsx loadtest/h2-leak.ts 600
npx tsx loadtest/h2-chaos.ts 60
./loadtest/h2load.sh
```
Test plan
🤖 Generated with Claude Code
CodeAnt-AI Description
Add broader HTTP/2 transport tests and scheduled load tracking
What Changed
Impact
✅ Clearer HTTP/2 regression coverage✅ Earlier detection of load-related regressions✅ Daily performance trend tracking💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.