[6.1] Test | Fix Transient Fault handling and other flaky unit tests (#4080)#4269
Open
cheenamalhotra wants to merge 1 commit into
Open
[6.1] Test | Fix Transient Fault handling and other flaky unit tests (#4080)#4269cheenamalhotra wants to merge 1 commit into
cheenamalhotra wants to merge 1 commit into
Conversation
* Test | Fix Transient Fault handling flaky tests * Attempt to fix * Fix the MultiPartIdentifier tests getting skipped * Fix serialization issue of SqlTypeWorkaroundsTests * Fix one more cases of possible error scenarios
Contributor
There was a problem hiding this comment.
Pull request overview
Ports the fixes from #4080 onto release/6.1, primarily stabilizing simulated-server unit tests around transient fault retry behavior on .NET Framework (TNIR/interval-timer retries) and addressing a few other flaky-test/discovery issues.
Changes:
- Make simulated-server retry assertions deterministic by tracking
Login7attempts and accounting for “abandoned”PreLoginattempts. - Reduce flakiness from pooling interactions in several simulated-server failover/routing tests (e.g., disabling pooling in specific cases, clearing pools in one test).
- Fix xUnit discovery issues by setting
DisableDiscoveryEnumeration = trueon selected[MemberData]usages.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs | Updates transient/network retry assertions and adjusts connection-string settings to reduce flakiness. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTestsAzure.cs | Updates routing retry assertions to account for abandoned pre-logins. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTests.cs | Updates routing retry assertions to account for abandoned pre-logins. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs | Adjusts pooling behavior and assertions for failover scenarios; adds pool clearing in one test. |
| src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlTypes/SqlTypeWorkaroundsTests.cs | Uses DisableDiscoveryEnumeration to fix test discovery/enumeration issues. |
| src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/TransientTdsErrorTdsServer.cs | Ensures Login7 is counted even when returning an error without calling base handler. |
| src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTdsServer.cs | Adds Login7Count + derived abandoned-prelogin metric; refactors endpoint initialization; increments login count on login handler. |
Comment on lines
243
to
+249
| /// <summary> | ||
| /// Handler for login request | ||
| /// </summary> | ||
| public virtual TDSMessageCollection OnLogin7Request(ITDSServerSession session, TDSMessage request) | ||
| { | ||
| Interlocked.Increment(ref _login7Count); | ||
|
|
Comment on lines
113
to
+125
| public int PreLoginCount => _preLoginCount; | ||
|
|
||
| /// <summary> | ||
| /// Counts Login7 requests to the server. | ||
| /// </summary> | ||
| public int Login7Count => _login7Count; | ||
|
|
||
| /// <summary> | ||
| /// Counts pre-login requests that did not result in a Login7 request, | ||
| /// which indicates the client abandoned the connection (e.g. interval | ||
| /// timer timeout during TNIR or failover). | ||
| /// </summary> | ||
| public int AbandonedPreLoginCount => _preLoginCount - _login7Count; |
| Assert.Equal($"localhost,{failoverServer.EndPoint.Port}", connection.DataSource); | ||
| Assert.Equal(1, server.PreLoginCount); | ||
| Assert.Equal(1, failoverServer.PreLoginCount); | ||
| Assert.Equal(0, server.Login7Count); |
Comment on lines
102
to
106
| await connection.OpenAsync(); | ||
| Assert.Equal(ConnectionState.Open, connection.State); | ||
| Assert.Equal($"localhost,{server.EndPoint.Port}", connection.DataSource); | ||
| Assert.Equal(2, server.PreLoginCount); | ||
| Assert.Equal(2, server.PreLoginCount - server.AbandonedPreLoginCount); | ||
| } |
mdaigle
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports #4080 to release/6.1 branch.