Skip to content

test: stabilize unix socket test paths#90

Closed
YuminosukeSato wants to merge 1 commit intomainfrom
pr/1-test-infra
Closed

test: stabilize unix socket test paths#90
YuminosukeSato wants to merge 1 commit intomainfrom
pr/1-test-infra

Conversation

@YuminosukeSato
Copy link
Owner

Summary

  • Stabilize Unix socket test paths with a shared helper to avoid macOS path limits and permission issues.

Changes

  • Add tempSocketPath test helper.
  • Update UDS-related tests to use the helper.

Test plan

  • go test -v -race ./...

Copilot AI review requested due to automatic review settings February 6, 2026 14:12
@github-actions github-actions bot added lang/go Go code changes area/pool Worker pool management labels Feb 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 tempSocketPath helper 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.

Comment on lines +13 to +18
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)
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 13 to +20
// 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")
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +14 to +18
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")
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 60 to +66
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{}),
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +57 to +58
if cfg.MaxInFlightPerWorker == 0 {
cfg.MaxInFlightPerWorker = 1

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

YuminosukeSato added a commit that referenced this pull request Feb 6, 2026
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
YuminosukeSato added a commit that referenced this pull request Feb 6, 2026
* 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.
@YuminosukeSato
Copy link
Owner Author

Merged into PR #91 (pr/2-core-dispatch includes all commits from this PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/pool Worker pool management lang/go Go code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants