Conversation
There was a problem hiding this comment.
Pull request overview
Stabilizes Unix domain socket (UDS) test paths by introducing a shared helper and migrating existing tests away from per-test temp directories and hardcoded /tmp socket paths.
Changes:
- Added a shared
tempSocketPathhelper for generating shorter, consistent UDS paths. - Updated multiple UDS-related tests to use
tempSocketPath. - Adjusted some external-test socket temp directory creation to use a shared temp subdirectory.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/pyproc/worker_external_test.go | Moves external worker test socket temp files into a shared temp subdir |
| pkg/pyproc/transport_uds_test.go | Uses tempSocketPath for UDS transport test sockets |
| pkg/pyproc/transport_multiplexed_test.go | Uses tempSocketPath for multiplexed transport UDS sockets |
| pkg/pyproc/testutil_test.go | Introduces tempSocketPath helper |
| pkg/pyproc/socket_hmac_test.go | Uses tempSocketPath for HMAC listener/client-server tests |
| pkg/pyproc/pool_test.go | Switches pool-related tests to tempSocketPath and adjusts pool test helper initialization |
| pkg/pyproc/pool_external_test.go | Moves external pool test socket temp files into a shared temp subdir |
| pkg/pyproc/connection_test.go | Uses tempSocketPath for worker connection tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| base := filepath.Join(os.TempDir(), "pyproc") | ||
| if err := os.MkdirAll(base, 0755); err != nil { | ||
| t.Fatalf("failed to create temp dir: %v", err) | ||
| } | ||
| name := fmt.Sprintf("%s-%d.sock", prefix, time.Now().UnixNano()) | ||
| return filepath.Join(base, name) |
There was a problem hiding this comment.
tempSocketPath uses os.TempDir() which is often a long per-user path on macOS (e.g., /var/folders/...) and can still exceed Unix socket path length limits. Since the PR goal is to avoid macOS path issues, consider using a short fixed base dir on Unix (commonly /tmp/pyproc) or otherwise enforcing a short base path specifically for UDS tests.
| // It uses /tmp directly to avoid macOS socket path length limits. | ||
| func startTestUnixListener(t *testing.T) (net.Listener, string) { | ||
| t.Helper() | ||
| f, err := os.CreateTemp("/tmp", "pyproc-test-*.sock") | ||
| baseDir := filepath.Join(os.TempDir(), "pyproc") | ||
| if err := os.MkdirAll(baseDir, 0755); err != nil { | ||
| t.Fatalf("failed to create temp dir: %v", err) | ||
| } | ||
| f, err := os.CreateTemp(baseDir, "pyproc-test-*.sock") |
There was a problem hiding this comment.
The comment says this helper uses /tmp directly to avoid macOS socket path length limits, but the updated implementation uses os.TempDir() (which is frequently not /tmp on macOS). Update the comment to match the new behavior, or adjust the code to actually use a short /tmp-based path so the comment and intent remain correct.
| baseDir := filepath.Join(os.TempDir(), "pyproc") | ||
| if err := os.MkdirAll(baseDir, 0755); err != nil { | ||
| t.Fatalf("failed to create temp dir: %v", err) | ||
| } | ||
| f, err := os.CreateTemp(baseDir, "pyproc-ext-pool-*.sock") |
There was a problem hiding this comment.
Creating a predictable shared temp directory with permissions 0755 in a potentially shared temp location can be avoided in tests by using a per-process/per-test directory (os.MkdirTemp or t.TempDir) when possible, or by using more restrictive permissions (commonly 0700) for user-owned temp dirs. If the shared dir is needed to keep paths short, consider tightening permissions and/or centralizing this logic via the same helper used elsewhere to reduce duplication across tests.
| p := &Pool{ | ||
| opts: PoolOptions{Config: cfg}, | ||
| logger: NewLogger(LoggingConfig{Level: "error", Format: "json"}), | ||
| workers: make([]*poolWorker, len(workers)), | ||
| semaphore: make(chan struct{}, cfg.Workers*cfg.MaxInFlight), | ||
| activeRequests: make(map[uint64]*activeRequest), | ||
| opts: PoolOptions{Config: cfg}, | ||
| logger: NewLogger(LoggingConfig{Level: "error", Format: "json"}), | ||
| workers: make([]*poolWorker, len(workers)), | ||
| semaphore: make(chan struct{}, cfg.MaxInFlight), | ||
| workerAvailable: make(chan struct{}, cfg.Workers*cfg.MaxInFlightPerWorker), | ||
| shutdownCh: make(chan struct{}), |
There was a problem hiding this comment.
newPoolWithWorkers sizes p.workers from len(workers) but sizes workerAvailable from cfg.Workers. If cfg.Workers differs from len(workers) in any test, this can produce incorrect channel sizing and lead to hangs/flaky behavior. Prefer sizing internal channels consistently from len(workers) (or ensure cfg.Workers is set from len(workers) inside this helper before channel creation).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f8a8cef78
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if cfg.MaxInFlightPerWorker == 0 { | ||
| cfg.MaxInFlightPerWorker = 1 |
There was a problem hiding this comment.
Remove references to non-existent pool concurrency fields
This helper now assigns cfg.MaxInFlightPerWorker and initializes workerAvailable, shutdownCh, and inflightGate, but those members are not defined in this commit’s PoolConfig (pkg/pyproc/config.go) or Pool/poolWorker (pkg/pyproc/pool.go). As a result, the test package no longer compiles, so CI cannot run the UDS-path stabilization tests introduced here.
Useful? React with 👍 / 👎.
0f8a8ce to
29967bc
Compare
* ci: increase max-turns from 20 to 30 PR #92 used 21 turns and hit the limit. Increasing to 30 to allow more comprehensive reviews without artificial cutoffs. Observed usage: - PR #90: 18 turns (/bin/zsh.51) - PR #92: 21 turns (/bin/zsh.36) Expected cost: ~/bin/zsh.40-0.60 per PR * ci: remove Claude Code workflow Remove automated Claude Code reviews. Manual code reviews will be used instead.
29967bc to
7c7a7c1
Compare
|
Merged into PR #91 (pr/2-core-dispatch includes all commits from this PR) |
Summary
Changes
tempSocketPathtest helper.Test plan
go test -v -race ./...