Skip to content

Conversation

mdaigle
Copy link
Contributor

@mdaigle mdaigle commented Jul 17, 2025

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.

@mdaigle mdaigle added the Area\Tests Issues that are targeted to tests or test projects label Jul 17, 2025
Copy link
Contributor

@paulmedynski paulmedynski left a 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.

Copy link
Contributor

@paulmedynski paulmedynski left a 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.

@paulmedynski paulmedynski self-assigned this Sep 4, 2025
Copy link
Contributor

@paulmedynski paulmedynski left a 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.

@paulmedynski
Copy link
Contributor

Two small comments remain. Should this convereted from a draft now?

@mdaigle mdaigle marked this pull request as ready for review September 5, 2025 16:20
@Copilot Copilot AI review requested due to automatic review settings September 5, 2025 16:20
@mdaigle mdaigle requested a review from a team as a code owner September 5, 2025 16:20
Copy link
Contributor

@Copilot Copilot AI left a 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

paulmedynski
paulmedynski previously approved these changes Sep 23, 2025
Copy link
Contributor

@benrr101 benrr101 left a 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!

Copy link

codecov bot commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (10ccb20) to head (9ef9949).
⚠️ Report is 6 commits behind head on main.

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     
Flag Coverage Δ
addons ?
netcore ?
netfx ?

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

@benrr101 benrr101 left a 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

paulmedynski
paulmedynski previously approved these changes Sep 25, 2025
Copy link
Contributor

@benrr101 benrr101 left a 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! 🚀 🚀

@mdaigle mdaigle merged commit d244be2 into dotnet:main Sep 25, 2025
236 checks passed
@mdaigle mdaigle deleted the dev/mdaigle/failover-tds-server branch September 25, 2025 18:32
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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants