Skip to content

(6/7) test(session): InloopSessionServer replaces the in-process SessionServer test harness#1566

Open
guapisolo wants to merge 3 commits into
refactor/session-mp-lifecyclefrom
refactor/session-mp-test-harness
Open

(6/7) test(session): InloopSessionServer replaces the in-process SessionServer test harness#1566
guapisolo wants to merge 3 commits into
refactor/session-mp-lifecyclefrom
refactor/session-mp-test-harness

Conversation

@guapisolo

@guapisolo guapisolo commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Migrates every test fixture off the in-process SessionServer app onto InloopSessionServer — the production router app (build_router_app) served on a real port, with N SessionWorker shards wired as in-loop IPC handlers on the server thread's event loop (real socketpair framing and worker dispatch, none of the OS-process spawn cost). Assertions are unchanged across the migrated suites — this PR is the migration-equivalence evidence that the router-app topology preserves the behavior the old harness pinned, which is what licenses deleting the single-process chassis in #1519.

Stacked on #1569#1510#1563#1518#1565. Base = refactor/session-mp-lifecycle. Merge order within the split: #1565 → this → #1519.

What's here

  • miles/utils/test_utils/inloop_session_server.py — router app + n_workers in-loop worker shards served from one thread; process lifecycle (spawn, readiness, fail-fast, teardown) stays the supervisor's job, covered by its own test in (5/7) feat(session): process-lifecycle layer — supervisor spawns N session workers + router #1565.
  • generation_fixtures.py / rollout_fixtures.py / session_pretokenized_test_utils.py / test_session_race_conditions.py / test_sessions.py — harness swap only; assertions untouched.
  • test_session_dataplane.py — the equivalence reference becomes the same topology with one shard, and the transport-error test asserts the 502 shape directly instead of comparing against SessionServer.do_proxy.

Testing

🤖 Generated with Claude Code

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces InloopSessionServer, an in-thread session server designed to replace the process-spawning SessionServer and UvicornThreadServer across various test suites, thereby reducing test execution overhead. The review feedback focuses on improving robustness and preventing resource leaks by ensuring that server startup and channel setup are safely enclosed within try...finally blocks. Additionally, a minor type annotation mismatch in rollout_fixtures.py was identified.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread miles/utils/test_utils/inloop_session_server.py
Comment thread tests/fast/router/test_session_dataplane.py
Comment thread tests/fast/router/test_session_race_conditions.py
Comment thread tests/fast/router/test_sessions.py
Comment thread tests/fast/fixtures/rollout_fixtures.py Outdated
@guapisolo guapisolo force-pushed the refactor/session-mp-test-harness branch from 6a97c87 to bc6f752 Compare July 3, 2026 03:29
@guapisolo guapisolo force-pushed the refactor/session-mp-lifecycle branch from 996fd19 to c2af32a Compare July 3, 2026 03:29
@guapisolo guapisolo changed the title test(session): InloopSessionServer replaces the in-process SessionServer test harness (6/7) test(session): InloopSessionServer replaces the in-process SessionServer test harness Jul 3, 2026
@guapisolo guapisolo force-pushed the refactor/session-mp-lifecycle branch from c2af32a to 0fd7c91 Compare July 6, 2026 05:14
@guapisolo guapisolo force-pushed the refactor/session-mp-test-harness branch from bc6f752 to 736dd29 Compare July 6, 2026 05:14
@guapisolo guapisolo force-pushed the refactor/session-mp-lifecycle branch from 0fd7c91 to d7d0a7d Compare July 6, 2026 05:57
@guapisolo guapisolo force-pushed the refactor/session-mp-test-harness branch 2 times, most recently from 2fac59c to e87eab4 Compare July 6, 2026 09:08
guapisolo added a commit that referenced this pull request Jul 6, 2026
…tation

- _router_env / router_env: server.start() moves inside the try so a
  readiness-timeout failure still runs stop() — the uvicorn thread may be
  alive with the port bound; matches _with_session_server's existing idiom
- _with_session_server yields InloopSessionServer, not UvicornThreadServer
  (annotation was a stale copy from _with_miles_router)

Addresses Gemini review comments 3-5 on #1566.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
guapisolo and others added 3 commits July 6, 2026 10:05
…ver test harness

Fixtures that served an in-process SessionServer app from a thread now
use InloopSessionServer (miles/utils/test_utils/): the production router
app (build_router_app) served on a real port, with N SessionWorker
shards wired as in-loop IPC handlers on the server thread's event loop —
real socketpair framing and worker dispatch, none of the OS-process
spawn cost. Process lifecycle (spawn, readiness, fail-fast, teardown) is
the supervisor's job, covered by its own test.

Assertions are unchanged across the migrated suites — the evidence that
the router-app topology preserves the behavior the old harness pinned.
test_session_dataplane's equivalence reference becomes the same topology
with one shard, and the transport-error test asserts the 502 shape
directly instead of comparing against SessionServer.do_proxy.

The in-process chassis itself is still in place; it goes away with the
launch switchover.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tation

- _router_env / router_env: server.start() moves inside the try so a
  readiness-timeout failure still runs stop() — the uvicorn thread may be
  alive with the port bound; matches _with_session_server's existing idiom
- _with_session_server yields InloopSessionServer, not UvicornThreadServer
  (annotation was a stale copy from _with_miles_router)

Addresses Gemini review comments 3-5 on #1566.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Same comment-only sweep as the lifecycle branch, applied to the
docstrings this branch introduces.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@guapisolo guapisolo force-pushed the refactor/session-mp-test-harness branch from ee3eeeb to e755326 Compare July 6, 2026 10:06

@Shi-Dong Shi-Dong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. But it seems that you are deleting the tests for the original session server before it is retired (presumably in the next PR).

No problem for this PR chain, but ideally this PR should only introduce new tests, and the next PR should delete the old tests.

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.

2 participants