test: isolate AF_UNIX socket paths + ambient HOME state (#4279 classes 2 & 4) - #4369
Open
abhay-codes07 wants to merge 1 commit into
Open
Conversation
…mnigent-ai#4279, classes 2 & 4) The remaining two test-isolation gaps from omnigent-ai#4279. Both are macOS/Databricks- dev-box-specific at runtime; I validated non-regression on Windows and followed the issue's prescribed patterns (and the in-repo precedents), but the macOS-only failure modes (AF_UNIX 103-byte cap, real Keychain) are not reproducible on my box. Class 2 - AF_UNIX 103-byte path cap: macOS caps a Unix socket path at ~103 bytes and its $TMPDIR is already ~48, so pytest's tmp_path (which embeds the test name) overflows before a socket name is appended. Added a shared `short_tmp_parent` fixture in tests/inner/conftest.py (generalizing the one test_relay.py already had) and used it for the two socket-binding tests that still used tmp_path: test_proxy.py::test_proxy_start_unix and test_terminal.py::test_server_survives_inner_process_exit_real_tmux. Class 4 - host state outside OMNIGENT_CONFIG_HOME: Ambient provider detection also reads ~/.codex/config.toml and ~/.databrickscfg (under $HOME), and on macOS _claude_login_detected() reads the Keychain, which no $HOME override can hide. Redirected $HOME (and $USERPROFILE for cross-platform expanduser) to an isolated temp dir in test_openai_agents_sdk_spawn_env.py and test_provider_spawn_env.py, plus stubbed _claude_login_detected -> False for the Keychain case, and scoped the same HOME redirect into the one affected pi-cwd runner test. Verified on Windows: the Class-4 files pass (99 passed; isolation is additive), and the Class-2 tests behave as before (AF_UNIX is unsupported on Windows regardless, identical to clean main). With omnigent-ai#4363 (classes 1 & 3) this covers all four classes of omnigent-ai#4279. Signed-off-by: abhay-codes07 <abhaysingh0293@gmail.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.
Related issue
Addresses #4279 (classes 2 & 4). Together with #4363 (classes 1 & 3) this covers all four classes.
Summary
The remaining two test-isolation gaps from #4279. Both are macOS / Databricks-dev-box-specific at runtime — I validated non-regression on a Windows checkout and followed the issue's prescribed fixes and the in-repo precedents, but the macOS-only failure modes (AF_UNIX 103-byte cap, real Keychain) aren't reproducible on my box, so I'm flagging them as pattern-applied rather than executed on the failing platform.
Class 2 — AF_UNIX 103-byte path cap
macOS caps a Unix socket path at ~103 bytes and its
$TMPDIRis already ~48, so pytest'stmp_path(which embeds the test name) overflows before a socket filename is appended. The repo already solves this with ashort_tmp_parentfixture (tests/inner/egress/test_relay.py), just not in the two other socket-binding tests. Promoted a sharedshort_tmp_parenttotests/inner/conftest.pyand used it in:test_proxy.py::test_proxy_start_unixtest_terminal.py::test_server_survives_inner_process_exit_real_tmuxClass 4 — host state outside
OMNIGENT_CONFIG_HOMEAmbient provider detection also reads
~/.codex/config.tomland~/.databrickscfg(under$HOME), and on macOS_claude_login_detected()falls back toclaude auth status, which reads the Keychain — no$HOMEoverride can hide it. Fixes:$HOME(and$USERPROFILE, soos.path.expanduseris isolated cross-platform) to a temp dir intest_openai_agents_sdk_spawn_env.pyandtest_provider_spawn_env.py.ambient._claude_login_detected -> Falsefor the Keychain case.$HOMEredirect into the one affected runner test (test_create_session_threads_workspace_to_pi_cwd).Test Plan
Verified on a Windows checkout:
The Class-2 tests use
AF_UNIX, which is unsupported on Windows, so they behave identically to cleanmainthere (theshort_tmp_parentfixture itself runs fine); their macOS path-length fix is validated by the establishedtest_relay.pyprecedent.ruff check+ruff format --checkclean.Demo
N/A. Test-only change (socket-path + env isolation); no product code touched.
Type of change
Test coverage
Note for a macOS reviewer
If you can run
uv run python -m pytest tests/inner tests/runtimeon a signed-in Mac with a gateway-pinned shell +~/.codex/config.toml+ multi-profile~/.databrickscfg, these are the tests #4279 lists for classes 2 & 4 — a green run there confirms the runtime fix I couldn't exercise on Windows.Changelog
Isolated the AF_UNIX socket paths and ambient
$HOME/Keychain provider state in the affected tests sopytestis a usable local signal on macOS.