Skip to content

Quarantine new flaky tests - #4453

Merged
paulmedynski merged 17 commits into
mainfrom
dev/paul/quarantine
Jul 21, 2026
Merged

paulmedynski merged 17 commits into
mainfrom
dev/paul/quarantine

Conversation

@paulmedynski

@paulmedynski paulmedynski commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Some minimal changes to get our PR pipelines green:

  • Quarantining any tests that emerge as flaky.
  • Tweaks to our SQL Server setup scripts to be more resilient.
  • Any obvious changes to tests to prevent them from being flaky.

@paulmedynski paulmedynski added this to the 7.1.0-preview3 milestone Jul 17, 2026
@paulmedynski
paulmedynski requested a review from a team as a code owner July 17, 2026 12:15
Copilot AI review requested due to automatic review settings July 17, 2026 12:15
@paulmedynski paulmedynski added the Area\Tests Issues that are targeted to tests or test projects label Jul 17, 2026
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Jul 17, 2026
@paulmedynski paulmedynski linked an issue Jul 17, 2026 that may be closed by this pull request

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 quarantines several intermittently failing unit tests by marking them with the Category=flaky trait so they’re excluded from the default CI test filter.

Changes:

  • Added [Trait("Category", "flaky")] to additional simulated-server and connection-pool unit tests.
  • Updated/expanded inline comments around flaky failures (including pasted CI failure output).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs Quarantines an async transient-fault retry test.
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTests.cs Quarantines a routed-location network delay test.
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs Quarantines additional failover/transient-fault test cases and adjusts related comments.
src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolShutdownTest.cs Quarantines a shutdown/unblock waiter test that can fail on slow agents.

@paulmedynski
paulmedynski enabled auto-merge (squash) July 17, 2026 12:23
@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board Jul 17, 2026
Copilot AI review requested due to automatic review settings July 17, 2026 14:57

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

mdaigle
mdaigle previously approved these changes Jul 17, 2026
@paulmedynski
paulmedynski disabled auto-merge July 17, 2026 15:29
Copilot AI review requested due to automatic review settings July 17, 2026 16:36

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Copilot AI review requested due to automatic review settings July 17, 2026 17:55

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 17, 2026 19:07
Copilot AI review requested due to automatic review settings July 20, 2026 17:42

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

… ConnectionTest

Root-cause fix replacing the earlier ConnectionTest quarantine (3cebfbd).

A failing pooled Open() against a non-Azure endpoint (localhost) enters a
5-second BlockingPeriodErrorState that is keyed by connection string. When a
later test's ephemeral TdsServer reuses the same port, it inherits the cached
exception via ThrowIfActive() and fails without contacting the new server.
ConnectionTest was thus failing with a cached InvalidTDSVersion error seeded by
ConnectionRefusesUnsupportedServerTdsVersion.

Add Pooling=false to the failure-injecting tests so their expected failures do
not poison a shared pool:
  - ConnectionTests: RequestEncryption_ServerDoesNotSupportEncryption_ShouldFail,
    TransientFault_RetryDisabled_ShouldFail(+_Async), ConnectionTimeoutTest(+Async),
    ConnectionRefusesUnsupportedServerTdsVersion, TestConnWithVectorFeatExtVersionNegotiation
  - ConnectionRoutingTests / ConnectionRoutingTestsAzure: TransientFaultAtRoutedLocation_RetryDisabled_ShouldFail
  - ConnectionReadOnlyRoutingTests: RecursivelyRouted{,Async}Connection (ConnectionRoutingLimit)

Remove the [Trait("Category","flaky")] from ConnectionTest: it was a poisoning
victim, not a genuine flake, and is deterministic once the source is fixed.
Genuine timing-race quarantines are left in place.

Relates to PR #4453 (Quarantine new flaky tests).
Copilot AI review requested due to automatic review settings July 20, 2026 18:18

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

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

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

  • Spelling in the quoted failure text: "Principle server" should be "Principal server" (as in the primary/principal endpoint).
            Microsoft.Data.SqlClient.SqlException : Connection Timeout Expired.  The timeout period elapsed during the post-login phase.
                The connection could have timed out while waiting for server to complete the login process and respond;
                Or it could have timed out while attempting to create multiple active connections.
                This failure occurred while attempting to connect to the Principle server.
                The duration spent while attempting to connect to this server was - [Pre-Login] initialization=6; handshake=80;

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

  • Spelling in the quoted failure text: "Principle server" should be "Principal server" (as in the primary/principal endpoint).
            Microsoft.Data.SqlClient.SqlException : Connection Timeout Expired.
                The timeout period elapsed during the post-login phase.
                The connection could have timed out while waiting for server to complete the login process and respond;
                Or it could have timed out while attempting to create multiple active connections.
                This failure occurred while attempting to connect to the Principle server.
                The duration spent while attempting to connect to this server was - [Pre-Login] initialization=4; handshake=68;

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

  • Spelling in the quoted failure text: "Principle server" should be "Principal server" (as in the primary/principal endpoint).
            Microsoft.Data.SqlClient.SqlException : Connection Timeout Expired.
                The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement.
                This could be because the pre-login handshake failed or the server was unable to respond back in time.
                This failure occurred while attempting to connect to the Principle server.
                The duration spent while attempting to connect to this server was - [Pre-Login] initialization=0; handshake=5285;

@cheenamalhotra

cheenamalhotra commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

There are more flaky tests:

  • Failed Microsoft.Data.SqlClient.ManualTesting.Tests.TransactionEnlistmentTest.TestManualEnlistment_Enlist_TxScopeComplete [5 s]
    
  • Also we have a lot of timeout errors in tests in unrelated test cases (Mars Session Pooling, Transaction Pool, more MARS) - can you investigate why so (Are they due to new code changes, since when are we getting more and more) and can they be reproduced by running tests in stressed conditions? This might need a dedicated investigation why are we suddenly observing a lot many errors in CI than before.
    Microsoft.Data.SqlClient.SqlException : Connection Timeout Expired.  The timeout period elapsed during the post-login phase.  The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.  This failure occurred while attempting to connect to the Principle server.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=3; handshake=83; [Login] initialization=0; authentication=0; [Post-Login] complete=5389;
    ---- System.ComponentModel.Win32Exception : The wait operation timed out
    
    Microsoft.Data.SqlClient.SqlException : Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
    Operation cancelled by user.
    ---- System.ComponentModel.Win32Exception : The wait operation timed out.
    

@paulmedynski

Copy link
Copy Markdown
Contributor Author

@cheenamalhotra - Tracking the connection/command timeouts as AB#46533.

I'll keep quarantining flaky tests as they appear in the PR runs, but I'd like to get this merged once I get a green run.

The Lima hostagent that backs Colima intermittently fails to become ready
within its short startup window on the macOS CI runners ("hostagent did not
start up in 5s"), which is transient. Retry 'colima start' up to 3 times,
dumping ha.stderr.log and tearing down the half-created instance
(colima delete --force) between attempts before giving up.

Relates to PR #4453 (Quarantine new flaky tests).
Copilot AI review requested due to automatic review settings July 21, 2026 10:46

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

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

Comments suppressed due to low confidence (4)

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

  • Spelling in the TODO failure text: "Principle server" should be "Principal server".
                This failure occurred while attempting to connect to the Principle server.

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

  • Spelling in the TODO failure text: "Principle server" should be "Principal server".
                This failure occurred while attempting to connect to the Principle server.

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

  • Spelling in the TODO failure text: "Principle server" should be "Principal server".
                This failure occurred while attempting to connect to the Principle server.

src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs:642

  • In ConnectionTimeoutTestAsync, the Stopwatch is only stopped in the catch block. If OpenAsync unexpectedly succeeds (or throws outside the catch), the timer can remain running and the failure message becomes misleading. Stop the timer in a finally so the assertions report the real issue.
                Pooling = false, // Disable pooling so this expected timeout failure does not poison a shared pool
            }.ConnectionString;
            using SqlConnection connection = new(connStr);

            // Dispose the server to force connection timeout

@codecov

codecov Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.93%. Comparing base (fdebcd2) to head (c73f8cd).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4453      +/-   ##
==========================================
- Coverage   65.83%   64.93%   -0.91%     
==========================================
  Files         287      287              
  Lines       43763    66958   +23195     
==========================================
+ Hits        28812    43476   +14664     
- Misses      14951    23482    +8531     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 64.93% <ø> (?)

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.

@paulmedynski
paulmedynski marked this pull request as ready for review July 21, 2026 13:39
@paulmedynski paulmedynski moved this from In progress to In review in SqlClient Board Jul 21, 2026
@paulmedynski

Copy link
Copy Markdown
Contributor Author

We achieved green PR runs while in Draft. I have moved to Open, which unfortunately re-triggers everything. I will babysit this until these new PR runs are green.

@paulmedynski
paulmedynski enabled auto-merge (squash) July 21, 2026 13:41
Copilot AI review requested due to automatic review settings July 21, 2026 16:58
The async non-pooled open runs the entire multi-hop routing chain in a single
thread-pool-scheduled continuation under one Connect Timeout budget (default
15s). Under CI thread-pool congestion, 12 in-process TdsServers contend for the
same starved pool, so the 11-hop chain can exceed 15s and trip a
NonPooledOpenTimeout (only the async variant is affected; the sync path runs on
the caller thread).

Add ConnectTimeout=60 to the recursive routing test connections so the chain
rides out CI congestion while preserving the 11-succeed / 12-fail boundary
coverage.

Relates to PR #4453 (Quarantine new flaky tests).

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

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

Comments suppressed due to low confidence (3)

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

  • In this quoted failure text, "Principle server" is a spelling error (should be "Principal server"). Since this comment block was touched in this PR, please correct the wording to avoid confusion when scanning logs.
                This failure occurred while attempting to connect to the Principle server.

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

  • In this quoted failure text, "Principle server" is a spelling error (should be "Principal server"). Since this comment block was touched in this PR, please correct the wording to avoid confusion when scanning logs.
                This failure occurred while attempting to connect to the Principle server.

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

  • In this quoted failure text, "Principle server" is a spelling error (should be "Principal server"). Since this comment block was touched in this PR, please correct the wording to avoid confusion when scanning logs.
                This failure occurred while attempting to connect to the Principle server.

@paulmedynski
paulmedynski merged commit 8e5bf00 into main Jul 21, 2026
359 checks passed
@paulmedynski
paulmedynski deleted the dev/paul/quarantine branch July 21, 2026 20:13
@github-project-automation github-project-automation Bot moved this from In review to Done in SqlClient Board Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Tests Issues that are targeted to tests or test projects

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Tests | Failing tests that need to marked flaky

4 participants