Repository navigation
feat(cli): --load-connections spreads a load run over many sessions - #2791
Merged
Merged
Conversation
…2746) --load ran every call over the one connection the CLI opened, so it could not show how a server behaves with many clients at once. --load-connections <n> opens n independent InspectorClient connections over the same resolved transport, headers and OAuth, pins worker i to connection i % n, and reports one combined summary. - HTTP/SSE only: over stdio each connection would spawn its own server. - --load-concurrency (and --load-rate) stay totals across connections, and --load-connections may not exceed --load-concurrency. - Extras are opened concurrently before the clock starts; their connect times are reported apart, in connections.connectMs. - A failed connect is counted under connections, never as a call error; the run goes ahead on the connections that opened. - Extras connect stored-auth-only and are disconnected in a finally. - The default (1) leaves the summary byte-identical: the connections field appears only above one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues remain in connection lifecycle handling, worker routing, validation, or single-connection compatibility.
No open issues 🎉
What changed in this PR
Adds opt-in multi-session load testing to the one-shot CLI, using the shared load engine while preserving the default single-connection behavior.
Changes:
- Adds
--load-connectionswith HTTP/SSE-only validation and a limit tied to total concurrency. - Distributes workers across connections, reports setup timing and connection failures separately, and cleans up extra connections.
- Documents the behavior and adds engine and CLI tests for session routing, lifecycle handling, validation, and compatibility.
| File | Description |
|---|---|
core/cli/handlers/load-test.ts |
Adds connection orchestration, worker routing, and combined connection metrics. |
clients/cli/src/cli.ts |
Wires the flag, validation, and stored-auth-only connection factory. |
clients/cli/README.md |
Documents multi-session behavior, metrics, and OAuth limitations. |
clients/cli/__tests__/load-test.test.ts |
Covers orchestration, distinct HTTP sessions, failures, and default compatibility. |
Review effort: Balanced
Member
Author
|
Copilot review loop closed: round 1 was clean (no inline comments, no headline findings, no suppressed comments), so per pr-flow 7c no further round is requested. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2746
What
--load-connections <n>(default1) spreads a--loadrun overnindependent connections (sessions) to the same server — same resolved transport, headers and OAuth — and reports one combined summary. It answers what a single-session run cannot: per-session state, session setup cost, connection limits and contention that only shows up across sessions.Decisions on the issue's open questions
nconnections would testnisolated servers, not one server undernsessions.--load-connectionsabove 1 against a stdio server fails with exit1before anything connects. Loosening this later is non-breaking; tightening it would not be.--load-concurrencyis the total across all connections (as is--load-rate), so both keep their existing meaning. Workeriis pinned to connectioni % n, which splits workers as evenly as the counts allow.--load-connectionsmay not exceed--load-concurrency(default concurrency included): a connection with no worker would carry no calls and would only inflate the session count the run claims to have tested.connections.connectMs(a latency distribution). The first connection is excluded because the CLI opens it before any load run.connections.failed/connections.errorMessages, never intoerrors/errorRate. A server refusing its Nth session is exactly what this mode is for finding.errorRateandlatencyMs.p99keep their meaning: calls only.nconnections never startninteractive flows. They share the process-wide in-memory OAuth store, so a token refreshed by one is visible to the rest. Two connections hitting an expired token at the same instant can each try a refresh. A single connection under--load-concurrencyalready has that same exposure; it is not new here. Against a server that rotates refresh tokens, the losing refresh may surface as call errors. The README says so. Adding single-flight refresh would mean changing SDK-owned auth plumbing, which is out of scope.finally. The disconnects are settled independently, so one failing teardown neither hides another nor replaces the summary or error. An extra that fails mid-connect is disconnected by the factory that made it.Default unchanged
With
--load-connectionsabsent or1, the run is exactly the old path (runLoadon the primary connection) and the summary is byte-identical. The newconnectionsobject is added only when more than one connection is requested. A test pins this.Shape
core/cli/handlers/load-test.ts:connectionsinLoadOptions/resolveLoadOptions.runLoadhands each call its worker index. The newrunLoadAcrossConnectionsholds all of the orchestration (open before the clock, pin workers, tally connect failures, close infinally).runToolLoadtakes an optionalopenConnectionfactory.clients/cli/src/cli.ts: theInspectorClientoptions are named so anopenLoadConnectionfactory can build identical clients. The factory goes torunToolLoad. There is also the flag, its bound check, and the stdio check at the top ofcallMethod. The stdio check sits there, rather than at parse time, because the server's transport is only resolved later.clients/cli/README.md: flag row, plus the multi-connection section in "Load testing a tool".Tests
Engine unit tests cover even spread and pinning, extras closed but never the primary, closing on a thrown run and a failing close, partial and total connect failure, connect time kept out of latency, and the missing-factory guard. CLI tests cover three distinct
Mcp-Session-Ids against the HTTP test server,--load-connections 1leaving the summary unchanged, and the stdio, bound andrequires --loadrejections.load-test.tsis at 100% lines and functions and 98.9% branches;cli.tsis at 99.4% lines.npm run local:gate: green.🤖 Generated with Claude Code