tests: pin /fastboot wire format + recv-leftover stress#90
Merged
Conversation
Test-only PR — locks in two integration points that previously rested on real-hardware verification alone. ### /fastboot binary blob (tests/test_power_rack.py) `RackController.fastboot()` packs profile + SPL + agent into a single big-endian binary blob that the pod's C handler in `rack/firmware/main/http_api.c` parses field-by-field. Any drift between the two breaks bring-up silently — pod returns 400, but the host can't tell why. Six new tests pin it down: - `test_packs_expected_layout` — round-trip every field - `test_prestep1_passthrough` — optional prestep1 not dropped - `test_success_response_returned_verbatim` — done/elapsed/markers - `test_pod_500_returns_json_body_not_exception` — protocol failure comes back as a dict (so callers can read `failed_phase`/`error`) rather than raising - `test_pod_unreachable_raises_power_controller_error` - `test_realistic_blob_size_within_pod_limit` — 41 834 B for a typical hi3516ev300 upload, well under the pod's 1 MiB cap Shared helper `_parse_fastboot_blob()` is the inverse of the host packer — if anyone bumps either side, the round-trip test fails loudly. ### Async recv_packet leftover (tests/test_agent_protocol.py) PR #86 added a per-transport leftover buffer so multi-packet TCP chunks don't drop trailing packets. The existing tests cover the two simplest cases (two/three packets in one chunk). Six stress tests added to lock down the corner cases: - `test_frame_split_across_two_reads_recombines` — half a packet arrives, then the other half (TCP MTU split) - `test_large_stream_50_packets_in_one_chunk` — catches off-by-one in leftover slicing - `test_recv_response_skips_ready_in_leftover` — READY skipping still works when the READYs are in leftover, not on the wire - `test_per_transport_isolation` — two transports must not share leftover state - `test_incomplete_frame_in_leftover_blocks_until_timeout` — half a frame must wait for the rest, never spuriously return partial - `test_corrupt_frame_skipped_then_recovers` — bit-flipped CRC mid-stream must be discarded; parser picks up the next valid frame Suite: **480 passed / 2 skipped** (was 468); ruff + mypy clean. No production code touched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Test-only PR — locks in two integration points that previously rested on real-hardware verification alone.
1.
/fastbootbinary blob (tests/test_power_rack.py)RackController.fastboot()packs profile + SPL + agent into a single big-endian binary blob that the pod's C handler inrack/firmware/main/http_api.cparses field by field. Any drift between the two breaks bring-up silently — pod returns 400, the host can't tell why.Six new
TestFastbootWireFormatcases:test_packs_expected_layouttest_prestep1_passthroughtest_success_response_returned_verbatimtest_pod_500_returns_json_body_not_exceptionfailed_phase/errortest_pod_unreachable_raises_power_controller_errortest_realistic_blob_size_within_pod_limitShared helper
_parse_fastboot_blob()is the inverse of the host packer; if either side bumps the format, the round-trip test fails loudly.2. Async
recv_packetleftover stress (tests/test_agent_protocol.py)PR #86 added a per-transport leftover buffer so multi-packet TCP chunks don't drop trailing packets. The existing tests covered the two simplest cases (two/three packets in one chunk). Six stress cases added:
test_frame_split_across_two_reads_recombinestest_large_stream_50_packets_in_one_chunktest_recv_response_skips_ready_in_leftovertest_per_transport_isolationtest_incomplete_frame_in_leftover_blocks_until_timeouttest_corrupt_frame_skipped_then_recoversTest plan
uv run pytest tests/ -x -v --ignore=tests/fuzz— 480 passed / 2 skipped (was 468)uv run ruff check tests/ src/defib/uv run mypy src/defib/ --ignore-missing-importsNo production code touched.
🤖 Generated with Claude Code