-
Notifications
You must be signed in to change notification settings - Fork 314
Refactor Test TDS Servers. Expand functional testing of connection pooling and transient failures. #3488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Test TDS Servers. Expand functional testing of connection pooling and transient failures. #3488
Conversation
…ailover-tds-server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, with a few suggestions.
src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionBasicTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionReadOnlyRoutingTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/AuthenticatingTDSServer.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTDSServer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTDSServer.cs
Outdated
Show resolved
Hide resolved
…ut. Clean up transient error server.
…p where they're supposed to, not just side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few tidying-up suggestions.
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPointConnection.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/TransientFaultTdsServer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/TransientTimeoutTdsServer.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/TransientTimeoutTdsServerArguments.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some outstanding requests from earlier PRs as well. I will go back through them and see if they have been addressed.
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTdsServer.cs
Show resolved
Hide resolved
Two small comments remain. Should this convereted from a draft now? |
There was a problem hiding this comment.
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 refactors the Test TDS Servers infrastructure by consolidating endpoint initialization and improving the construction flow for mock servers. The changes eliminate duplicated code across TDS.Servers, FunctionalTests, and ManualTests while making constructor parameters more explicit rather than hiding defaults in nested calls.
Key changes include:
- Standardized naming from "TDS" to "Tds" across server classes for consistency
- Replaced properties with field initializers for server arguments to make defaults explicit
- Simplified endpoint initialization by removing auto-generated connection strings
- Added new transient delay and error servers for improved testing scenarios
- Consolidated connection string building using SqlConnectionStringBuilder
Reviewed Changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
TransientTdsErrorTdsServerArguments.cs |
Renamed class and replaced properties with field initializers for clearer defaults |
TransientTdsErrorTdsServer.cs |
New server class for testing transient error scenarios with explicit error behavior |
TransientDelayTdsServerArguments.cs |
New arguments class for delay simulation testing |
TransientDelayTdsServer.cs |
New server class for simulating network delays during connections |
TdsServerArguments.cs |
Renamed class and converted properties to field initializers |
TdsServer.cs |
New simplified TDS server implementation |
GenericTdsServer.cs |
Refactored to use generics and added endpoint management |
Connection test files | Updated to use new server construction patterns and explicit connection strings |
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/TransientTdsErrorTdsServer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTdsServer.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTdsServer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.EndPoint/TDSServerEndPointConnection.cs
Show resolved
Hide resolved
...Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTestsAzure.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, lots of changes I'd like to see made to this PR - but on the whole excellent work! This will be very useful for us in how we do tests in the future. Thanks for fixing the names of TDS to Tds as part of it!
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
...soft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionStringDefaults.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs
Outdated
Show resolved
Hide resolved
...Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTestsAzure.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionTests.cs
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3488 +/- ##
==========================================
- Coverage 70.62% 0 -70.63%
==========================================
Files 276 0 -276
Lines 61674 0 -61674
==========================================
- Hits 43557 0 -43557
+ Misses 18117 0 -18117
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvements, thanks for bearing with my requests! Just want an update on the big C and a couple that went resolved with no changes. But otherwise I'll approve once I see those
...soft.Data.SqlClient/src/Microsoft/Data/Common/ConnectionString/DbConnectionStringDefaults.cs
Show resolved
Hide resolved
...ta.SqlClient/tests/ManualTests/SQL/ConnectionTestWithSSLCert/CertificateTestWithTdsServer.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionFailoverTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionRoutingTests.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTdsServer.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/tools/TDS/TDS.Servers/GenericTdsServer.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 🚀 🚀
Description
The TDS.Servers project provides mocked server implementations for a variety of use cases. The construction and endpoint initialization flows for these mock servers was complicated and resulted in duplicated code across TDS.Servers, FunctionalTests, and ManualTests. This PR consolidates endpoint initialization and makes test server constructor parameters more explicit (no more defaults buried a few layers deep).
One downside of this approach is that it's now slightly harder to get the connection string for a test server. Before, some servers had a ConnectionString property you could access. The issue with these connection strings is they had a lot of non-standard default behavior coded into them at the time they were constructed. This makes it hard to understand which properties you're actually using when connecting to a test server. With my changes, you now need to manually construct a connection string using SqlConnectionStringBuilder and explicitly set connection parameters. Any parameters you don't set use the stock connection string defaults.
Testing
I added some testing around pool invalidation during failover and routing behavior during transient errors.