Skip to content

Stabilize Python and Java E2E harnesses - #2411

Merged
roji merged 4 commits into
mainfrom
roji-fix-python-shell-rpc-flake
Aug 26, 2026
Merged

Stabilize Python and Java E2E harnesses#2411
roji merged 4 commits into
mainfrom
roji-fix-python-shell-rpc-flake

Conversation

@roji

@roji roji commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Harden the Python and Java E2E harnesses against four independent sources of nondeterminism:

  • run the Windows shell RPC marker through cmd.exe directly instead of spawning nested PowerShell
  • synchronize Python cold-resume tests with server-side session-lock release
  • parse folded YAML prompt scalars correctly in the Java replay harness
  • reuse the Java replay proxy's HttpClient across the test JVM

Python fixes

Shell RPC process lifecycle

Merge-group run 32978642851 failed in windows-latest, inprocess after session.shell.exec returned a valid process ID but its nested PowerShell marker command never created the expected file. The test now uses the platform shell's built-in echo, runs in a distinct subdirectory, and writes a relative marker path. This removes an unnecessary child-process boundary while preserving shell execution and cwd coverage. The session is also scoped with async with so failures cannot leak runtime state.

Cold-resume synchronization

The requeued merge-group run 32980446331 failed in macos-latest, default because force_stop() had closed the original TCP client locally, but the shared server had not yet processed the disconnect. An immediate resume therefore sometimes reported sessionWasActive=true instead of exercising the intended cold-resume path.

The test now observes sessions.checkInUse from a separate runtime and waits for the original session lock to disappear before resuming. This provides a server-observable lifecycle barrier without adding sleeps or weakening the cold-resume assertions.

Java fixes

Folded YAML prompts

E2ETestContext now reconstructs folded YAML prompt scalars (>-) using YAML folding semantics instead of treating each source line as a separate prompt line. Regression coverage verifies the parsed prompt sent to the replay proxy.

Replay proxy resources

CapiProxy now shares one HttpClient across proxy instances. The Java E2E suite creates many proxies in one JVM; allocating a client per fixture accumulated selector-manager threads and native resources over the full run. Regression coverage verifies the shared-client behavior.

Validation

Python

  • uv run ruff format --check .
  • uv run ruff check
  • uv run ty check copilot
  • targeted in-process shell RPC E2E
  • full pending-work resume module: 7 passed
  • cold-resume regression repeated five times: 5 passed
  • all six Python matrix jobs passed on the Python-only revision, including Windows in-process

Java

  • mvn spotless:check
  • mvn -pl sdk test -Dtest=E2ETestContextTest,CapiProxyTest: 2 passed

The Windows shell path cannot be executed locally on macOS; the PR matrix provides the definitive Windows validation.

Use the Windows shell's built-in echo command and a relative marker path so the test avoids a flaky child-process launch while continuing to validate shell execution and cwd handling. Ensure the session is disconnected on assertion failures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@roji
roji requested a review from a team as a code owner August 26, 2026 14:31
Copilot AI balanced review requested due to automatic review settings August 26, 2026 14:31
@github-actions

This comment has been minimized.

Copilot AI 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.

Pull request overview

Improves Python shell RPC E2E reliability on Windows and ensures session cleanup.

Changes:

  • Replaces nested PowerShell with cmd.exe’s built-in echo.
  • Uses async context management for session cleanup.
  • Attempts to validate shell cwd handling via a relative marker path.
Show a summary per file
File Description
python/e2e/test_rpc_shell_and_fleet_e2e.py Updates Windows marker creation and session lifecycle handling.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread python/e2e/test_rpc_shell_and_fleet_e2e.py Outdated
Observe the session lock from a separate runtime and wait for the TCP server to process the original client's disconnect before resuming. This preserves the cold-resume assertion without relying on timing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@roji roji changed the title fix(python): avoid nested PowerShell in shell RPC E2E test fix(python): harden flaky process lifecycle E2E tests Aug 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

This PR only modifies Python E2E test files (python/e2e/), not any SDK client or public API code:

  • test_rpc_shell_and_fleet_e2e.py – Replaces nested PowerShell with cmd.exe built-in echo (Windows flake fix) and converts session usage to async with context manager.
  • test_pending_work_resume_e2e.py – Adds a sessions.checkInUse lifecycle barrier to eliminate a race condition in the cold-resume test.

No public API surface was added or changed, so no cross-SDK consistency concerns apply here. These are Python-specific test hardening changes that do not require equivalent updates in other language SDKs.

Generated by SDK Consistency Review Agent for #2411 · sonnet46 9.47 AIC · ⌖ 5.37 AIC · ⊞ 6.6K ·

@roji
roji enabled auto-merge August 26, 2026 15:00
roji and others added 2 commits August 26, 2026 17:40
Run the marker command from a distinct subdirectory and use a relative filename on every platform so the test fails if shell.exec ignores cwd.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Parse folded YAML prompt scalars correctly and share replay proxy HTTP resources across the monolithic test JVM.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@roji roji changed the title fix(python): harden flaky process lifecycle E2E tests Stabilize Python and Java E2E fixtures Aug 26, 2026
@roji roji changed the title Stabilize Python and Java E2E fixtures Stabilize Python and Java E2E harnesses Aug 26, 2026
@github-actions github-actions Bot mentioned this pull request Aug 26, 2026

@edburns edburns left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Java changes LGTM.

@roji
roji added this pull request to the merge queue Aug 26, 2026
Merged via the queue into main with commit f0a575a Aug 26, 2026
46 checks passed
@roji
roji deleted the roji-fix-python-shell-rpc-flake branch August 26, 2026 19:13
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.

3 participants