Skip to content

test: make Windows server E2E cleanup portable - #1841

Draft
dajiaohuang wants to merge 3 commits into
smart-mcp-proxy:mainfrom
dajiaohuang:codex/w4-mcpproxy-windows-tests-20261108
Draft

dajiaohuang wants to merge 3 commits into
smart-mcp-proxy:mainfrom
dajiaohuang:codex/w4-mcpproxy-windows-tests-20261108

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Make Windows E2E fixtures and cleanup portable, with path-safe JSON config and task-owned launcher process checks.
  • Capture server output when binary readiness fails and preserve per-test diagnostics.
  • Fix filter follow-through ordering with request sequence watermarks and synchronize legacy instance ID claims.
  • Keep test runner cleanup scoped to its owned artifacts and processes.

Validation

  • scripts/run-all-tests.sh at head 947ee449: build, full unit/race tests, unit coverage, mocked E2E, API E2E, Binary E2E, MCP Protocol E2E, and performance stages passed.
  • The optional lint stage did not run because golangci-lint is not installed.
  • gofmt and git diff --check passed. The full run used isolated UCRT64 compiler, Go caches, and task-local temporary directories.

Hosted CI has not been queried.

@Dumbris Dumbris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, @dajiaohuang — this is careful work, and most of it reads as a straight improvement: the request-sequence watermark in preflight_telemetry.go / mcp.go is a real fix (the counter is only touched under filterDiagMu, and "seq > startedThrough" no longer depends on clock resolution), moving the SSE subscribe ahead of the first flush closes a genuine 100 ms gap, and the scoped cleanup in run-all-tests.sh is the right direction.

Two things I would like to settle before merging, both small:

  1. legacyInstanceIDMu in internal/upstream/core/instance.go. In production adoptLegacyInstanceID runs once per process (inside instanceIDOnce.Do), so the mutex never contends. Its only effect is on TestAdoptLegacyInstanceIDConcurrentClaimIsExclusive, which races eight goroutines to prove that os.Rename lets exactly one claimant win; with the mutex the goroutines run one after another, so the test now exercises the mutex rather than rename exclusivity, while the function's comment still promises safety across processes. What did the test actually do on Windows — did two renames of the same file both succeed? If so, that is a real two-core race worth fixing in the claim protocol (or making the test spawn subprocesses); if it was something else, a comment explaining why the lock is needed would be enough. Happy to help dig into it.

  2. Caller-supplied directories are removed on cleanup in scripts/test-api-e2e.sh: with MCPPROXY_E2E_AUDIT_JSONL_DIR (likewise MCPPROXY_E2E_TEST_DATA_DIR / MCPPROXY_E2E_AUDIT_DATA_DIR) set, cleanup() later rm -rfs a directory the script did not create — MCPPROXY_E2E_AUDIT_JSONL_DIR=$TMPDIR would wipe $TMPDIR. Only deleting directories the script made itself would match the "owned artifacts" intent.

Two notes, no change needed: on Windows the default tray pipe now comes from socket.GetDefaultSocketPath(DataDir), so a non-default data_dir yields a hashed pipe name (the CLI already expects that; the tray falls back to TCP as it does on Unix) — worth one line in the PR description since it is a production behaviour change under a test: title; and COVER=true in run-e2e-tests.sh now exits 1 when coverage.out already exists, which trips a developer's second local run.

I have approved the CI workflow runs so the hosted checks can report on this head.

"enabled": false
}
}`, port, dataDir, TestAPIKey)
}`, port, encodedDataDir, TestAPIKey)
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 67.56757% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/testutil/binary.go 31.25% 11 Missing ⚠️
internal/server/listener.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

4 participants