Skip to content

blackbull.fault_injection.scenario_h2_client

blackbull.fault_injection.scenario_h2_client

HTTP/2 client-side scenarios for a target server.

Assemble fault bytes independently of production request sending. Shared transport steps do not make the two wire roles interchangeable.

ExpectServerFrame dataclass

Bases: _Expect

Read one frame and record whether it matched.

ScenarioH2Client dataclass

An ordered sequence of steps, plus a name for parametrisation.

ScenarioH2ClientResult dataclass

Outcome of one HTTP2Client.execute_scenario call.

Field names come from ScenarioResult, its twin, so a harness reporting on one does not need a second spelling for the other.

SendFrame dataclass

Emit one frame, built here rather than by the production sender.

payload is the frame payload; the 9-byte header is assembled from the other fields. Low-level on purpose: a length that disagrees with the payload, or a flag combination the typed frame classes refuse, is unreachable through FrameFactory.

declared_length overrides the header's length field without changing the bytes actually written — the direct way to express "the peer lied about how much is coming".

frame_type is the raw type byte: a FrameTypes member (which is a one-byte bytes), or an int for a type the enum does not name — an unregistered type being itself a fault worth staging.

SendHeaders dataclass

Emit a HEADERS frame, with the header block built for you.

pseudo and headers are encoded with HPACK in the order given, so a scenario can put :path after a regular field (RFC 9113 §8.3 forbids it) simply by saying so. Nothing here validates: the whole point is to send what a conforming client would not. The block uses only the static table and never indexes, so it decodes the same on any connection and leaves the peer's dynamic table untouched.

raw_block replaces the encoded block outright, for faults HPACK itself cannot produce — a truncated block, an invalid table index, a Huffman string that does not decode. When set, pseudo and headers are ignored.

SendPreface dataclass

Write the client connection preface (RFC 9113 §3.4).

A step, not the boolean ScenarioH2.send_preface the server side has: delaying or splitting the preface is the fault, and a flag cannot say "after 30 seconds".

StepOpH2Client

Bases: str, Enum

The v1 JSON tags, still read until v1 reading is removed.

WaitForServerFrame dataclass

Bases: _WaitFor

Filter frames until one matches — how a verdict behind the server's handshake SETTINGS is reached.

__getattr__(name)

Deprecated SendBytes alias for SendRawBytes (BBD005).

scenario_from_json(src)

Parse JSON Lines back to a ScenarioH2Client.

scenario_to_json(scenario)

Serialise to JSON Lines, name on the first HEADER line.