Skip to content

Deflake the initialize dial-error proxy test - #6264

Merged
ChrisJBurns merged 1 commit into
mainfrom
deflake-dial-error-test
Aug 10, 2026
Merged

Deflake the initialize dial-error proxy test#6264
ChrisJBurns merged 1 commit into
mainfrom
deflake-dial-error-test

Conversation

@amirejaz

Copy link
Copy Markdown
Contributor

Summary

TestRoundTripDoesNotReplayInitializeOnDialError fails intermittently in a full-suite run with Received unexpected error on the HTTP call, while passing every time in isolation (6/6 plain, 4/4 with -race).

It used http.DefaultClient, whose shared transport pools keep-alive connections across this package's parallel tests. Reusing one whose proxy has since been closed surfaces as a transport error before the request is even made.

  • Use a dedicated client with DisableKeepAlives.
  • Stop requiring NoError on the request itself. For a dial failure either outcome is legitimate — the reverse proxy may synthesize a 502, or the connection may fail outright — so that assertion pinned an incidental detail rather than the behaviour under test.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • Linting (task lint-fix)

Package green with -race, and the test still fails when the production guard it covers is removed:

--- FAIL: TestRoundTripDoesNotReplayInitializeOnDialError
    the proxy must not send its own initialize to the target service for an initialize dial error

So the relaxed HTTP assertion did not weaken what the test actually guards.

Does this introduce a user-facing change?

No. Test-only.

Special notes for reviewers

Mine from #6152, surfaced in a full-suite run rather than CI. Other tests in this file use http.DefaultClient too and are presumably exposed to the same reuse hazard; I have left them alone rather than widen this beyond the test that actually failed.

Generated with Claude Code

TestRoundTripDoesNotReplayInitializeOnDialError failed intermittently in
a full-suite run with "Received unexpected error" on the HTTP call, while
passing every time in isolation.

It used http.DefaultClient, whose shared transport pools keep-alive
connections across this package's parallel tests. Reusing one whose proxy
has since been closed surfaces as a transport error before the request is
made. Use a dedicated client with keep-alives disabled.

The HTTP outcome is also not what the test asserts. For a dial failure
either result is legitimate -- the reverse proxy may synthesize a 502, or
the connection may fail outright -- so requiring NoError pinned an
incidental detail. The substantive assertions, that no re-initialize
reached the target service and that the session was unpinned, are
unchanged and still fail when the production guard is removed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.70%. Comparing base (d163115) to head (9d1901c).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6264      +/-   ##
==========================================
- Coverage   72.71%   72.70%   -0.01%     
==========================================
  Files         742      742              
  Lines       77299    77299              
==========================================
- Hits        56209    56204       -5     
- Misses      17126    17134       +8     
+ Partials     3964     3961       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisJBurns
ChrisJBurns merged commit db86c06 into main Aug 10, 2026
57 of 58 checks passed
@ChrisJBurns
ChrisJBurns deleted the deflake-dial-error-test branch August 10, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants