Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8afcbc7
Add failover config options
mdaigle Jun 12, 2025
0007a10
Test failovers
mdaigle Jun 16, 2025
03b8e49
Merge branch 'main' of github.com:dotnet/SqlClient into dev/mdaigle/f…
mdaigle Jul 16, 2025
2adf97c
Test routing through a transient error.
mdaigle Jul 16, 2025
5113fa7
Move startup to GenericTDSServer.
mdaigle Jul 16, 2025
522abba
Remove duplicate server start code from ManualTests
mdaigle Jul 17, 2025
c41d0dc
Refactor failover param ownership. Fix pool invalidation test.
mdaigle Jul 17, 2025
922b3ef
Cleanup. Rename GenericTDSServer to differentiate from the generic cl…
mdaigle Jul 17, 2025
6ef83d7
Rename classes to match style. Make GenericTdsServer<T> abstract.
mdaigle Jul 17, 2025
47cbb48
Fix connection string to use optional encryption.
mdaigle Jul 24, 2025
905bc5d
Fix connection string to use optional encryption.
mdaigle Jul 24, 2025
47aa3a3
Add transient timeout server. Add regression test for transient timeo…
mdaigle Jul 24, 2025
fe9e7e4
Clean up tests. Add new retry/failover tests.
mdaigle Jul 30, 2025
93ebf98
Add new retry/failover tests.
mdaigle Jul 30, 2025
04a4329
Added tests. Moved tests to UnitTests project. Removed failover repro.
mdaigle Jul 30, 2025
ee9d157
Restructure tests for readability.
mdaigle Jul 30, 2025
11d90db
Update tests to remove unneeded routing. Check that connections end u…
mdaigle Aug 1, 2025
846a493
Review changes
mdaigle Aug 1, 2025
f08447a
Add TDS projects to compile set for UnitTests.
mdaigle Aug 1, 2025
7780cdd
fix tds projects inclusion
mdaigle Aug 1, 2025
ed2285c
Fix test server disposal.
mdaigle Aug 4, 2025
47b7bc2
Remove tests for unsupported scenarios.
mdaigle Aug 4, 2025
7532181
Add comments for confusing behavior.
mdaigle Aug 4, 2025
57aeb4d
Rename files to match class names.
mdaigle Aug 4, 2025
12cbb82
Remove proj change.
mdaigle Aug 4, 2025
038a0cd
Skip failing unit tests.
mdaigle Aug 5, 2025
206216a
Rename test folder.
mdaigle Aug 14, 2025
487fc26
Review changes
mdaigle Aug 14, 2025
aeb0c29
Merge branch 'main' of github.com:dotnet/SqlClient into dev/mdaigle/f…
mdaigle Aug 14, 2025
767e99c
Adjust tests based on multisubnetfailover setting.
mdaigle Aug 15, 2025
4bda823
Improve test reliability.
mdaigle Aug 18, 2025
a92dc51
Make failover test more reliable.
mdaigle Aug 18, 2025
2638eca
Rename to fix missing file.
mdaigle Aug 18, 2025
1492ead
Update tests to work on linux/mac
mdaigle Aug 18, 2025
d237176
Add test for default TNIR setting in connection string.
mdaigle Aug 26, 2025
0c03ddc
Remove active issues and adapt tests to set multisubnetfailover and T…
mdaigle Aug 26, 2025
f379cba
Enable setting localhost as an azure endpoint.
mdaigle Aug 27, 2025
d1bb855
Rename files and test cases for clarity. Rework some failover connect…
mdaigle Aug 27, 2025
e515abe
Add azure routing tests.
mdaigle Aug 27, 2025
7d57e12
Serialize tests. Remove connection killing.
mdaigle Sep 3, 2025
2fe29ed
Add additional assertions.
mdaigle Sep 3, 2025
5eee939
Add common test project to unit test restore targets.
mdaigle Sep 3, 2025
c020ddf
Mark tests as flaky and skip in the pipeline for now.
mdaigle Sep 4, 2025
32b9a10
Merge branch 'main' of github.com:dotnet/SqlClient into dev/mdaigle/f…
mdaigle Sep 4, 2025
71a0228
Fix formatting.
mdaigle Sep 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@
<NetStandardDriver Include="**/netcore/ref/Microsoft.Data.SqlClient*.csproj" />
<AKVProvider Include="**/add-ons/**/AzureKeyVaultProvider/*.csproj" />

<UnitTests Include="**/Common/Common.csproj" />
<UnitTests Include="**/tools/TDS/TDS/TDS.csproj" />
<UnitTests Include="**/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
<UnitTests Include="**/tools/TDS/TDS.Servers/TDS.Servers.csproj" />
<UnitTests Include="**/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj" />
<UnitTestsProj Include="**/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj" />



<FunctionalTests Include="**/Common/Common.csproj" />
<FunctionalTests Include="**/tools/TDS/TDS/TDS.csproj" />
<FunctionalTests Include="**/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
Expand Down Expand Up @@ -220,6 +225,7 @@
-p:TestTargetOS=Windows$(TargetGroup)
--collect "Code coverage"
--results-directory $(ResultsDirectory)
--filter "category!=failing%26category!=flaky"
--logger:"trx;LogFilePrefix=Unit-Windows$(TargetGroup)-$(TestSet)"
</TestCommand>
<TestCommand>$(TestCommand.Replace($([System.Environment]::NewLine), " "))</TestCommand>
Expand All @@ -240,8 +246,9 @@
-p:TestTargetOS=Unixnetcoreapp
--collect "Code coverage"
--results-directory $(ResultsDirectory)
--filter "category!=failing%26category!=flaky"
--logger:"trx;LogFilePrefix=Unit-Unixnetcoreapp-$(TestSet)"
</TestCommand>
</TestCommand>
<TestCommand>$(TestCommand.Replace($([System.Environment]::NewLine), " "))</TestCommand>
</PropertyGroup>
<Message Text=">>> Running unit tests for Unix via command: $(TestCommand)"/>
Expand Down Expand Up @@ -320,7 +327,7 @@
<TestCommand>$(TestCommand.Replace($([System.Environment]::NewLine), " "))</TestCommand>
</PropertyGroup>
<Message Text=">>> Running Manual test for Windows via command: $(TestCommand)" />
<Exec ConsoleToMsBuild="true" Command="$(TestCommand)" />

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient-Package (Win22_Azure_ARM64_Sql net9_0_AnyCPU_NativeSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net9.0 -p:ReferenceType=Package -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win22_Azure_ARM64_Sql net9_0_AnyCPU_ManagedSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net9.0 -p:ReferenceType=Project -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient-Package (Win22_Azure_ARM64_Sql net8_0_AnyCPU_ManagedSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Package -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win22_Azure_ARM64_Sql net462_AnyCPU_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetfxVersion=net462 -p:ReferenceType=Project -p:TestSet=3 -p:TestTargetOS=Windowsnetfx --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetfx-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient-Package (Win22_Azure_Sql net9_0_AnyCPU_ManagedSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net9.0 -p:ReferenceType=Package -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (win11_Azure_Sql net9_0_AnyCPU_NativeSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net9.0 -p:ReferenceType=Project -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win22_Azure_Sql net8_0_AnyCPU_NativeSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Project -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win22_Azure_Sql net8_0_AnyCPU_NativeSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Project -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (win11_Azure_Sql net8_0_AnyCPU_NativeSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Project -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient-Package (win11_Azure_Sql net8_0_AnyCPU_NativeSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Package -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient-Package (win11_Azure_Sql net8_0_AnyCPU_NativeSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Package -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient-Package

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Package -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win22_Azure_Sql net8_0_AnyCPU_ManagedSNI_3)

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Project -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.

Check failure on line 330 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient

build.proj#L330

build.proj(330,5): Error MSB3073: The command " dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" --no-build -v n -p:Configuration=Release -p:TargetnetcoreVersion=net8.0 -p:ReferenceType=Project -p:TestSet=3 -p:TestTargetOS=Windowsnetcoreapp --collect "Code coverage" --results-directory TestResults --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" --logger:"trx;LogFilePrefix=Manual-Windowsnetcoreapp-3" " exited with code 1.
</Target>

<!-- Run all Manual tests applicable to Unix. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1713,8 +1713,11 @@ private void LoginNoFailover(ServerInfo serverInfo,
}

if (_parser == null
|| TdsParserState.Closed != _parser.State
|| IsDoNotRetryConnectError(sqlex)
// If state != closed, indicates that the parser encountered an error while processing the
// login response (e.g. an explicit error token). Transient network errors that impact
// connectivity will result in parser state being closed.
|| TdsParserState.Closed != _parser.State
|| timeout.IsExpired)
{
// no more time to try again
Expand Down Expand Up @@ -1993,6 +1996,9 @@ TimeoutTimer timeout
throw; // Caller will call LoginFailure()
}

// TODO: It doesn't make sense to connect to an azure sql server instance with a failover partner
// specified. Azure SQL Server does not support failover partners. Other availability technologies
// like Failover Groups should be used instead.
if (!ADP.IsAzureSqlServerEndpoint(connectionOptions.DataSource) && IsConnectionDoomed)
{
throw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using Microsoft.Identity.Client;
using Microsoft.SqlServer.Server;
using System.Security.Authentication;
using System.Collections.Generic;

#if NETFRAMEWORK
using System.Reflection;
Expand Down Expand Up @@ -780,7 +781,7 @@ internal static Version GetAssemblyVersion()
/// <remarks>This array includes endpoint URLs for Azure SQL in global, Germany, US Government,
/// China, and Fabric environments. These endpoints are used to identify and interact with Azure SQL services
/// in their respective regions or environments.</remarks>
internal static readonly string[] s_azureSqlServerEndpoints = { AZURE_SQL,
internal static readonly List<string> s_azureSqlServerEndpoints = new() { AZURE_SQL,
AZURE_SQL_GERMANY,
AZURE_SQL_USGOV,
AZURE_SQL_CHINA,
Expand Down Expand Up @@ -816,11 +817,11 @@ internal static bool IsAzureSynapseOnDemandEndpoint(string dataSource)

internal static bool IsAzureSqlServerEndpoint(string dataSource)
{
return IsEndpoint(dataSource, s_azureSqlServerEndpoints);
return IsEndpoint(dataSource, s_azureSqlServerEndpoints.AsReadOnly());
}

// This method assumes dataSource parameter is in TCP connection string format.
private static bool IsEndpoint(string dataSource, string[] endpoints)
private static bool IsEndpoint(string dataSource, IReadOnlyList<string> endpoints)
{
int length = dataSource.Length;
// remove server port
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal static class DbConnectionStringDefaults

#if NETFRAMEWORK
internal const bool ConnectionReset = true;
internal static readonly bool TransparentNetworkIpResolution = !LocalAppContextSwitches.DisableTnirByDefault;
internal static bool TransparentNetworkIpResolution => !LocalAppContextSwitches.DisableTnirByDefault;
internal const string NetworkLibrary = "";
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using Microsoft.SqlServer.TDS.Servers;
using Xunit;

namespace Microsoft.Data.SqlClient.Tests
Expand Down Expand Up @@ -55,9 +56,9 @@ private string GetLocalizedErrorMessage(string culture)
Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);

using TestTdsServer server = TestTdsServer.StartTestServer();
var connStr = server.ConnectionString;
connStr = connStr.Replace("localhost", "dummy");
using TdsServer server = new TdsServer(new TdsServerArguments() { });
server.Start();
var connStr = new SqlConnectionStringBuilder() { DataSource = $"dummy,{server.EndPoint.Port}" }.ConnectionString;
using SqlConnection connection = new SqlConnection(connStr);

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
<Compile Include="SqlBulkCopyTest.cs" />
<Compile Include="SqlClientMetaDataCollectionNamesTest.cs" />
<Compile Include="SqlDataAdapterTest.cs" />
<Compile Include="SqlConnectionBasicTests.cs" />
<Compile Include="SqlConnectionReadOnlyRoutingTests.cs" />
<Compile Include="SqlCommandTest.cs" />
<Compile Include="SqlConnectionTest.cs" />
<Compile Include="AADAuthenticationTests.cs" />
Expand All @@ -64,8 +62,6 @@
<Compile Include="SqlConnectionStringBuilderTest.cs" />
<Compile Include="SerializeSqlTypesTest.cs" />
<Compile Include="TdsParserStateObject.TestHarness.cs" />
<Compile Include="TestTdsServer.cs" />
<Compile Include="TestRoutingTdsServer.cs" />
<Compile Include="SqlHelperTest.cs" />
<Compile Include="..\..\src\Microsoft\Data\Common\MultipartIdentifier.cs" />
<Compile Include="..\..\src\Microsoft\Data\SqlClient\TdsParserStateObject.Multiplexer.cs" />
Expand All @@ -91,6 +87,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.SqlServer.Types" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="System.Security.Cryptography.Pkcs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading