Skip to content

Fix CI-MACOS flakiness in connection-timeout tests by giving login phase adequate headroom - #2953

Merged
Ananya Garg (Ananya2) merged 6 commits into
mainfrom
user/anagarg/macos-failure
May 19, 2026
Merged

Fix CI-MACOS flakiness in connection-timeout tests by giving login phase adequate headroom#2953
Ananya Garg (Ananya2) merged 6 commits into
mainfrom
user/anagarg/macos-failure

Conversation

@Ananya2

@Ananya2 Ananya Garg (Ananya2) commented May 14, 2026

Copy link
Copy Markdown
Contributor

Fix CI-MACOS flakiness in connection-timeout tests: Three tests were consistently failing on the MacOS CI pipeline with "Read timed out" errors while passing on Linux and Windows:

  • ConfigurableRetryLogicTest.connectionTimingTest
  • ReflectiveTests.testDefaultRetry
  • TimeoutTest.testDefaultSocketTimeoutUnlimitedAfterLogin

Root cause

All three tests assumed that prelogin + TLS handshake + LOGIN7 could complete within a short loginTimeout (5s, or the default 15s). Hosted MacOS runners are noticeably slower than Linux/Windows agents, so the JDBC socket-read deadline expired before the server's clean response arrived. The thrown SocketTimeoutException either bypassed the inner
assertion (ReflectiveTests) or produced an unexpected error message (ConfigurableRetryLogicTest), and in TimeoutTest the login phase itself timed out before the post-login behavior could be verified.

This was not caused by a driver regression. PR #2927 (IOBuffer login socket timeout fix) correctly tightened login-phase socket deadlines; the tests just had insufficient headroom to ride out slow CI agents.

Fixes

ReflectiveTests.testDefaultRetry
loginTimeout: 5 -> 15 (allow initial getConnection on slow agents)
bound: 6000 -> 32000 ms
Bound now matches the actual retry math: (retryCount + 1) * loginTimeout + slack = 0 + 15s + 5s = 20s. Tight enough to catch an accidental extra retry.
The previous 6000ms bound was inconsistent with retry semantics and only passed before #2927 because the login socket lacked a deadline.

ConfigurableRetryLogicTest.connectionTimingTest
Added loginTimeout=20 to all three retry connection strings so the TDS 4060 "cannot open database" round-trip always completes before the JDBC socket read deadline, even on slow CI agents.

TimeoutTest.testDefaultSocketTimeoutUnlimitedAfterLogin
loginTimeout: 5s -> 15s
WAITFOR DELAY: 8s -> 20s
The test verifies post-login socket behavior; raising both keeps the WAITFOR safely above loginTimeout while giving the login phase enough headroom to complete on any CI agent.

These changes are platform-agnostic - no @DisabledOnOs gates, no OS-specific branches, no relaxed error-message matching. The under-test assertions remain intact and will still fail fast on real regressions.

@codecov

codecov Bot commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.81%. Comparing base (dff9689) to head (a2f17c4).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2953   +/-   ##
=========================================
  Coverage     60.81%   60.81%           
+ Complexity     4974     4969    -5     
=========================================
  Files           151      151           
  Lines         35223    35223           
  Branches       5900     5900           
=========================================
+ Hits          21421    21422    +1     
+ Misses        10934    10931    -3     
- Partials       2868     2870    +2     

☔ View full report in Codecov by Sentry.
📢 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.

@Ananya2 Ananya Garg (Ananya2) changed the title [WIP] Revert socket timeout fix to verify macOS failure root cause [WIP] Fix retry/socket-timeout tests against slow macOS CI runners May 14, 2026
@Ananya2 Ananya Garg (Ananya2) changed the title [WIP] Fix retry/socket-timeout tests against slow macOS CI runners Fix retry/socket-timeout tests against slow macOS CI runners May 14, 2026
@Ananya2 Ananya Garg (Ananya2) changed the title Fix retry/socket-timeout tests against slow macOS CI runners Fix CI-MACOS flakiness in connection-timeout tests by giving login phase adequate headroom May 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts several connection-timeout-related tests to be less flaky on slower CI agents (notably macOS hosted runners) by increasing loginTimeout headroom (and related timing windows) so login-phase socket deadlines don’t expire before expected server responses arrive.

Changes:

  • Increased loginTimeout in multiple tests to reduce macOS CI “Read timed out” failures during the login phase.
  • Updated timing bounds / delays in tests to align with longer login headroom and preserve the original assertions’ intent.
  • Added clarifying comments explaining why longer login headroom is needed for CI.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/test/java/com/microsoft/sqlserver/jdbc/resiliency/ReflectiveTests.java Raises loginTimeout and adjusts the expected timing bound in the default retry resiliency test.
src/test/java/com/microsoft/sqlserver/jdbc/connection/TimeoutTest.java Increases loginTimeout and WAITFOR DELAY to validate post-login unlimited socket timeout on slower agents.
src/test/java/com/microsoft/sqlserver/jdbc/configurableretry/ConfigurableRetryLogicTest.java Adds explicit loginTimeout=30 to retry connection strings to avoid login-phase read timeouts during 4060 round-trips.

Comment thread src/test/java/com/microsoft/sqlserver/jdbc/resiliency/ReflectiveTests.java Outdated
@Ananya2
Ananya Garg (Ananya2) merged commit fc0330c into main May 19, 2026
23 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Closed/Merged PRs in MSSQL JDBC May 19, 2026
@Ananya2 Ananya Garg (Ananya2) added this to the 13.5.1 milestone May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed/Merged PRs

Development

Successfully merging this pull request may close these issues.

5 participants