Skip to content

Manage SimulatedServer flaky test failures - #4804

Merged
cheenamalhotra merged 2 commits into
mainfrom
dev/cheena/mark-failover-test-flaky
Oct 12, 2026
Merged

cheenamalhotra merged 2 commits into
mainfrom
dev/cheena/mark-failover-test-flaky

Conversation

@cheenamalhotra

@cheenamalhotra cheenamalhotra commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Description

Stabilizes two simulated-server unit tests that fail intermittently under CI load. Test-only change; no product code or public API changes.

1. Mark ConnectionFailoverTests.NetworkError_TriggersFailover_ClearsPool as flaky

Adds [Trait("category", "flaky")], consistent with the other flaky simulated-server failover tests, with a comment documenting the observed CI failure. The failover server intermittently records 3 pre-logins instead of the expected 2 after the pool is cleared and the connection is reopened. This appears to be agent-timing sensitivity under CI load.

Failed Microsoft.Data.SqlClient.UnitTests.SimulatedServerTests.ConnectionFailoverTests.NetworkError_TriggersFailover_ClearsPool [7 s]
Assert.Equal() Failure: Values differ
Expected: 2
Actual:   3
  at ...ConnectionFailoverTests.NetworkError_TriggersFailover_ClearsPool() in ...ConnectionFailoverTests.cs:line 170

2. Use a fixed setup login timeout in IsolationLevelResetTests.ResetSessionIsolationLevel_UsesOpenBudget

The CI case (1, 30, 1000) timed out during the real connection.Open() pre-login handshake (~999 ms) before the isolation-level reset under test ever ran. The setup connection now uses ConnectTimeout = 30.

ResetSessionIsolationLevel only uses the fake-clock TimeoutTimer passed to it, so the test still covers what it did before:

  • TimeoutTimer.StartNew(TimeSpan.FromSeconds(connectTimeout), clock) is unchanged.
  • CommandTimeout = commandTimeout is unchanged.
  • All InlineData cases and the exhausted-budget and remaining-budget assertions are unchanged.

Issues

N/A — CI flakiness.

Testing

  • ConnectionFailoverTests: only a test trait and comment were added; not run locally. The test now runs in the flaky test category in CI.
  • IsolationLevelResetTests: ran locally:
    dotnet test src\Microsoft.Data.SqlClient\tests\UnitTests\Microsoft.Data.SqlClient.UnitTests.csproj -f net10.0 --filter "FullyQualifiedName~IsolationLevelResetTests.ResetSessionIsolationLevel_UsesOpenBudget"
    
    Result: passed (5/5, net10.0). net462 was not run locally.

Guidelines

Please review the contribution guidelines before submitting a pull request:

Copilot AI balanced review requested due to automatic review settings October 7, 2026 21:50
@cheenamalhotra
cheenamalhotra requested a review from a team as a code owner October 7, 2026 21:50

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.

🟢 Approval recommended

The test-only change follows the repository’s quarantine convention and remains covered by dedicated flaky-test CI runs.

0 open findings

What changed in this PR

Quarantines an intermittent simulated-server failover test without changing product behavior.

Changes:

  • Adds the standard flaky trait.
  • Documents the observed CI timing failure.
File Description
ConnectionFailoverTests.cs Quarantines and documents the intermittent test.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…enBudget

The reset under test consumes the fake-clock TimeoutTimer, so the real setup
connection's ConnectTimeout does not affect coverage. A 1-second setup login
timeout caused CI failures in the pre-login handshake before the reset ran.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 7, 2026 21:54
@cheenamalhotra cheenamalhotra added this to the 8.0.0-preview1 milestone Oct 7, 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.

🟡 Changes recommended

The failover test can retain regular CI coverage by asserting completed logins, and the additional timeout change must be disclosed or removed.

1 open finding
Previously missed (1)

In code that hasn't changed since last review

Medium severity Avoid quarantining pool-clear regression due to raw pre-login count

src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​SimulatedServerTests/​ConnectionFailoverTests.cs:117

Avoid quarantining this pool-clear regression based on the raw pre-login count. GenericTdsServer.cs:150-155 defines abandoned pre-logins specifically for timing-dependent TNIR/failover attempts, and nearby failover tests normalize those attempts; this test's invariant is two completed logins after reopening, not exactly two pre-login attempts. Assert Login7Count (or subtract AbandonedPreLoginCount) at the final assertion and keep the test in regular CI, otherwise a pool-clearing regression is removed from normal coverage.

🧠 Review effort: Balanced

@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.79%. Comparing base (47c815c) to head (25ed340).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4804      +/-   ##
==========================================
- Coverage   66.86%   64.79%   -2.08%     
==========================================
  Files         292      286       -6     
  Lines       45357    68551   +23194     
==========================================
+ Hits        30328    44415   +14087     
- Misses      15029    24136    +9107     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 64.79% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@cheenamalhotra
cheenamalhotra enabled auto-merge (squash) October 8, 2026 22:29
@cheenamalhotra cheenamalhotra changed the title Mark NetworkError_TriggersFailover_ClearsPool as flaky Manage SimulatedServer flaky test failures Oct 8, 2026

@priyankatiwari08 priyankatiwari08 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.

Looks good — no concerns.

@cheenamalhotra
cheenamalhotra merged commit c7ab087 into main Oct 12, 2026
135 of 137 checks passed
@cheenamalhotra
cheenamalhotra deleted the dev/cheena/mark-failover-test-flaky branch October 12, 2026 06:44
@github-project-automation github-project-automation Bot moved this from In review to Done in SqlClient Board Oct 12, 2026
mdaigle added a commit that referenced this pull request Nov 16, 2026
Retain the target release without isolation-level reset tests; only the failover quarantine from c7ab087 applies.

Co-authored-by: Copilot App <[email protected]>
@paulmedynski paulmedynski added Hotfix 7.1.3 PRs targeting main that should be backported to release/7.1 for 7.1.3. and removed Hotfix 7.1.2 labels Nov 17, 2026
paulmedynski pushed a commit that referenced this pull request Nov 23, 2026
* Cherry-pick of #4804 requires manual resolution

To resolve, run:  git cherry-pick c7ab087

* Backport failover test quarantine to release/7.1 (#4804)

Retain the target release without isolation-level reset tests; only the failover quarantine from c7ab087 applies.

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Malcolm Daigle <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hotfix 7.1.3 PRs targeting main that should be backported to release/7.1 for 7.1.3.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants