Skip to content

Flaky tests / lighter test queries#4344

Open
mdaigle wants to merge 6 commits into
mainfrom
dev/mdaigle/flaky-tests
Open

Flaky tests / lighter test queries#4344
mdaigle wants to merge 6 commits into
mainfrom
dev/mdaigle/flaky-tests

Conversation

@mdaigle

@mdaigle mdaigle commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Marks a few flaky tests. Rewrites a manual test as a unit test. Reduces CPU/scan impact on a few high volume tests queries.

Copilot AI review requested due to automatic review settings June 5, 2026 23:11
@mdaigle
mdaigle requested a review from a team as a code owner June 5, 2026 23:11
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Jun 5, 2026
@mdaigle mdaigle changed the title Dev/mdaigle/flaky tests Flaky tests / lighter test queries Jun 5, 2026
@mdaigle mdaigle added this to the 7.1.0-preview2 milestone Jun 5, 2026
@mdaigle mdaigle added Hotfix 7.0.3 PRs targeting main that should be backported to release/7.0 branch for next release. Hotfix 6.1.7 PRs targeting main that should be backported to release/6.1 branch for future hotfix and removed Hotfix 7.0.3 PRs targeting main that should be backported to release/7.0 branch for next release. Hotfix 6.1.7 PRs targeting main that should be backported to release/6.1 branch for future hotfix labels Jun 5, 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 pull request updates the SqlClient test suite by quarantining a small set of intermittently failing unit tests, replacing a manual transaction-pool cleanup scenario with a deterministic unit test, and reducing CPU/scan overhead in high-volume MARS manual tests (notably for Azure SQL environments).

Changes:

  • Quarantines a few simulated-server transient fault/failover tests as Category=flaky with inline failure notes where helpful.
  • Adds a deterministic unit test validating that pool pruning does not impact transacted connections, and exposes the pruning callback internally to support that test.
  • Optimizes MARS manual test queries to avoid expensive system scanning (sys.databases, sp_who) while still producing sufficient observable request activity.

Reviewed changes

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

Show a summary per file
File Description
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs Marks select transient-fault test cases as flaky to prevent intermittent CI failures.
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs Quarantines an intermittently failing failover-related async test with a documented failure symptom.
src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/WaitHandleDbConnectionPoolTransactionTest.cs Adds a pruning-focused unit test asserting transacted connections are not pruned/destroyed.
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/MARSSessionPoolingTest/MarsSessionPoolingTest.cs Replaces high-cost SQL text/SP usage with lighter alternatives to reduce CPU/scan impact while preserving test intent.
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/TransactionPoolTest.cs Removes the older manual transaction-cleanup test (scenario now covered deterministically via unit test).
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs Makes the pruning callback internal (with documentation) so unit tests can invoke pruning deterministically.

@paulmedynski paulmedynski moved this from To triage to In review in SqlClient Board Jun 6, 2026
@paulmedynski paulmedynski added the Area\Tests Issues that are targeted to tests or test projects label Jun 6, 2026
paulmedynski
paulmedynski previously approved these changes Jun 6, 2026
apoorvdeshmukh
apoorvdeshmukh previously approved these changes Jun 8, 2026
@cheenamalhotra cheenamalhotra added the Author attention needed PRs that require author to respond or make updates to PR. label Jun 23, 2026
@github-actions

Copy link
Copy Markdown

@mdaigle This pull request has been marked as Author attention needed.

When you have addressed the reviewer feedback and are ready for another review, please post a comment with /ready to remove the label and re-engage reviewers.

@cheenamalhotra

Copy link
Copy Markdown
Member

@mdaigle I see test failures that needs attention here.

The VALUES-based query and sp_server_info produced result sets too
small for MARS flow control — the server completed requests
immediately, so dm_exec_requests showed no active requests. This
broke ExecuteReader_DisposeCommand which asserts open request counts.

Revert to sys.databases and sp_who which produce enough data to keep
server-side requests active while readers remain open.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 17, 2026 16:44

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 5 out of 5 changed files in this pull request and generated 1 comment.

/// Exposed as <c>internal</c> (rather than <c>private</c>) solely so unit tests can
/// invoke a deterministic prune cycle without waiting on the cleanup timer.
/// </remarks>
internal void CleanupCallback(object state)
paulmedynski
paulmedynski previously approved these changes Jul 17, 2026
# Conflicts:
#	src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/WaitHandleDbConnectionPool.cs
Copilot AI review requested due to automatic review settings July 17, 2026 17:39

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 5 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines 78 to 83
[Theory]
[InlineData(40613)]
[InlineData(42108)]
[InlineData(42109)]
[Trait("Category", "flaky")]
public async Task TransientFault_RetryEnabled_ShouldSucceed_Async(uint errorCode)
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4344      +/-   ##
==========================================
- Coverage   65.83%   65.17%   -0.66%     
==========================================
  Files         287      284       -3     
  Lines       43763    66782   +23019     
==========================================
+ Hits        28812    43528   +14716     
- Misses      14951    23254    +8303     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 65.17% <ø> (?)

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.

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 Author attention needed PRs that require author to respond or make updates to PR.

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

6 participants