client and test-util and connector-hyper-0-14-x and wire-mock only.Expand description
A deterministic harness for testing connection-level client behavior.
Each endpoint assigns one complete ConnectionScript to each accepted
connection. An Http1Script parses requests and emits typed responses,
while a SocketScript runs ordered byte-level actions for malformed
framing, partial I/O, resets, and other transport behavior.
ManualGate synchronizes a test with a script without relying on elapsed
time. Reaching a gate records an arrival and blocks the script until the
gate is released. Release is permanent, so current and future waiters all
pass.
The harness records DNS lookups, accepted connections, parsed HTTP/1
requests, and connection closure. Its wait methods observe those events and
also surface failures from endpoint and connection tasks. Call
ConnectionTestHarness::shutdown at the end of a test to join those tasks
and report any background failure; dropping the harness only aborts them.
§Script ownership
Scripts describe connections, not requests. A queued endpoint plan moves one script to each connection in order. Repeated plans clone a complete script for each connection. Requests served over one keep-alive connection remain within that connection’s script.
§Extension via SocketScript
SocketScript is the extension point for framing the typed API does not
model; interim 1xx exchanges, for example, are expressible by adding
byte-level actions without changing existing scripts.
Structs§
- Body
Plan - A complete HTTP/1 response body, optionally paused at a gate.
- Connection
Id - The identity assigned to an accepted connection.
- Connection
Script - A complete high-level or byte-level script for one accepted connection.
- Connection
Test Harness - Running scripted endpoints with recorded connection events and mock DNS.
- Endpoint
Plan - Assigns a complete
ConnectionScriptto each accepted connection. - Gate
Waiter - A script-side handle for a
ManualGate. - Harness
Builder - Configures endpoints and DNS entries for a
ConnectionTestHarness. - Harness
Error - An error produced by the connection test harness.
- Http1
Response - One HTTP/1 response emitted by a script.
- Http1
Script - A typed HTTP/1 script for one connection.
- Manual
Gate - A one-shot broadcast gate used to synchronize a test with one or more scripts.
- Mock
DnsResolver - A DNS resolver backed by entries configured on the harness.
- Socket
Script - An ordered sequence of low-level socket actions for one connection.
- Test
Endpoint - A bound endpoint managed by a
ConnectionTestHarness.
Enums§
- Connection
Close Reason - Why a connection task stopped.
- Connection
Event - An event recorded by the harness.
- Finish
- What a finite HTTP/1 script does after sending its final response.