Skip to content

Test real stream use cases and fix native reader iteration and size validation - #111

Merged
egorsmkv merged 3 commits into
masterfrom
test/stream-lifecycle-tdd
Oct 10, 2026
Merged

egorsmkv merged 3 commits into
masterfrom
test/stream-lifecycle-tdd

Conversation

@egorsmkv

@egorsmkv egorsmkv commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Native streams were missing the async iterator protocol, so ordinary JSON Lines consumers using async for line in reader failed. Negative readexactly(n) sizes also raised a synchronous OverflowError instead of an awaited ValueError.

This PR follows a test-first sequence on master 3ff820a:

  • First commit adds loopback TCP application tests. Before the fix: 10 failed, 32 passed; all failures were native rsloop cases.
  • Second commit implements iteration using the existing readline path, corrects negative-size validation, and extends boundary coverage. 51/51 cases pass across asyncio, rsloop and uvloop.
  • A signed-size intermediate patch was rejected after a new EOF boundary test exposed narrowing of the supported unsigned size range. The final binding preserves the existing positive range and reports large expected sizes at EOF.

A third test-only commit forces the oversized prefix to fail before the peer sends the newline. This covers recovery without assuming that a single TCP write arrives in one read. Final expanded matrix: 60/60 passed locally across all three backends.

Scenarios cover UTF-8 JSON Lines with multiple write sizes and optional final newline; repeated iterator exhaustion; pipelined length-prefixed messages with empty/large bodies; truncated-body exception attributes; TCP half-close replies; oversized-line recovery; iteration cancellation and reuse; invalid sizes and EOF boundaries.

Tests use events and peer acknowledgements, propagate peer-task failures, check task leaks and loop exceptions, and assert native readers on both rsloop endpoints. They do not assume TCP packet boundaries or require external services. The existing matrix discovers them automatically; optional uvloop cases skip where unavailable. Development docs explain the contracts and test design.

Validation actually executed locally on Linux:

  • CPython 3.14.7 release extension: 60 new cases passed; full Python suite (with private Redis/hiredis): 541 passed, 2 Unix-socket EPERM failures, 3 skipped, 98 tooling cases deselected.
  • Tooling separately: 98 passed.
  • CPython 3.15.0rc3 free-threaded, GIL disabled: new use cases plus cancellation/connection suites 161 passed, 80 skipped (uvloop unavailable).
  • Rust default suite: 331 passed, 15 EPERM failures from unavailable io_uring/Unix-socket operations.
  • Final all-target/all-feature Clippy with warnings denied, Rust formatting, changed Python Ruff/Pyright and strict MkDocs: passed.
  • Hotpath inventory: 2081 definitions, zero missing hooks.

Local full suites are not claimed green. Windows/macOS and full all-feature Rust execution are delegated to CI. Final-head CI (caf4e80) completed successfully: Tests run 38043612494 and MkDocs run 38043612373. This covers the full OS/Python matrix (including free-threaded builds), default/all-feature Rust suites, Clippy, Miri, profiling/hotpath, typing, tooling, AnyIO and Redis/hiredis. No final CI failures remain. Windows/macOS validation was performed by GitHub Actions, not locally.

@egorsmkv
egorsmkv merged commit 237762f into master Oct 10, 2026
40 checks passed
@egorsmkv
egorsmkv deleted the test/stream-lifecycle-tdd branch October 10, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant