From ea01ccd5ee40d884b0d46efd8fce6d7f5da656d6 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 18 Mar 2025 21:51:34 -0700 Subject: [PATCH 1/5] Update dependencies to latest --- tools/props/Versions.props | 20 +++++++------- tools/props/VersionsNet9OrLater.props | 12 ++++++--- tools/specs/Microsoft.Data.SqlClient.nuspec | 30 ++++++++++----------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/tools/props/Versions.props b/tools/props/Versions.props index c0f6a3fdf2..d999f5e50a 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -26,17 +26,17 @@ 6.0.2 4.5.1 4.5.5 - 6.0.0 - 6.0.10 + 8.0.0 + 8.0.5 4.3.0 - 1.11.4 + 1.13.2 8.0.0 8.0.1 - 7.5.0 - 7.5.0 + 7.7.1 + 7.7.1 4.3.0 8.0.1 @@ -48,15 +48,15 @@ - [1.38.0,2.0.0) - [4.5.0,5.0.0) + [1.44.1,2.0.0) + [4.7.0,5.0.0) 0.13.2 3.1.6 - 10.0.0-beta.24564.1 - 8.0.0-beta.24123.1 + 10.0.0-beta.25164.6 + 10.0.0-beta.25164.6 6.0.1 2.0.8 1.0.3 @@ -71,7 +71,7 @@ 5.0.0 6.0.0 6.0.0 - 2.6.3 + 2.9.2 2.5.5 diff --git a/tools/props/VersionsNet9OrLater.props b/tools/props/VersionsNet9OrLater.props index 3901034263..d57d9f25e1 100644 --- a/tools/props/VersionsNet9OrLater.props +++ b/tools/props/VersionsNet9OrLater.props @@ -2,9 +2,13 @@ - 9.0.0 - 9.0.0 - 9.0.0 - 9.0.0 + 9.0.3 + 9.0.3 + 9.0.3 + 9.0.3 + + + + 9.0.3 \ No newline at end of file diff --git a/tools/specs/Microsoft.Data.SqlClient.nuspec b/tools/specs/Microsoft.Data.SqlClient.nuspec index 4018a35c29..2f660a608b 100644 --- a/tools/specs/Microsoft.Data.SqlClient.nuspec +++ b/tools/specs/Microsoft.Data.SqlClient.nuspec @@ -30,23 +30,23 @@ When using NuGet 3.x this package requires at least version 3.4. - + - - + + - - + + - + - - + + @@ -54,14 +54,14 @@ When using NuGet 3.x this package requires at least version 3.4. - - - - + + + + - - - + + + From b424ae8679b5df260dcd930b528020bb57ff6e47 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Wed, 19 Mar 2025 19:04:00 -0700 Subject: [PATCH 2/5] Address test failure --- .../ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs index 5236fd2aeb..bec7d2a0c1 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs @@ -507,7 +507,7 @@ public static void ActiveDirectoryManagedIdentityWithInvalidUserIdMustFail(strin SqlException e = Assert.Throws(() => ConnectAndDisconnect(connStrWithNoCred)); - string expectedMessage = "ManagedIdentityCredential authentication unavailable"; + string expectedMessage = "[Managed Identity] authentication unavailable"; Assert.Contains(expectedMessage, e.GetBaseException().Message); } From 9de13c050e309cc4bcbb6dd15f06da5ccc30307e Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 10 Apr 2025 17:14:33 -0700 Subject: [PATCH 3/5] fix case --- .../ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs index bec7d2a0c1..8490f888df 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs @@ -507,8 +507,8 @@ public static void ActiveDirectoryManagedIdentityWithInvalidUserIdMustFail(strin SqlException e = Assert.Throws(() => ConnectAndDisconnect(connStrWithNoCred)); - string expectedMessage = "[Managed Identity] authentication unavailable"; - Assert.Contains(expectedMessage, e.GetBaseException().Message); + string expectedMessage = "[Managed Identity] Authentication unavailable"; + Assert.Contains(expectedMessage, e.GetBaseException().Message, StringComparison.OrdinalIgnoreCase); } [ConditionalFact(nameof(IsAADConnStringsSetup))] From d00bd0bf3ed670882b68c4b6b217b2814fbda753 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 24 Apr 2025 13:43:30 -0700 Subject: [PATCH 4/5] Fix test --- .../DistributedTransactionTest.Windows.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs index 5719130cf9..b6d7b95f37 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs @@ -48,15 +48,15 @@ public async Task Delegated_transaction_deadlock_in_SinglePhaseCommit() private static bool s_EnlistedTransactionPreservedWhilePooledCondition => DataTestUtility.AreConnStringsSetup() && DataTestUtility.IsNotX86Architecture; [ConditionalFact(nameof(s_EnlistedTransactionPreservedWhilePooledCondition), Timeout = 10000)] - public void Test_EnlistedTransactionPreservedWhilePooled() + public async Task Test_EnlistedTransactionPreservedWhilePooled() { #if NET TransactionManager.ImplicitDistributedTransactions = true; #endif - RunTestSet(EnlistedTransactionPreservedWhilePooled); + await RunTestSet(EnlistedTransactionPreservedWhilePooled); } - private void EnlistedTransactionPreservedWhilePooled() + private async Task EnlistedTransactionPreservedWhilePooled() { Exception commandException = null; Exception transactionException = null; @@ -67,19 +67,19 @@ private void EnlistedTransactionPreservedWhilePooled() { // Leave first connection open so that the transaction is promoted SqlConnection rootConnection = new SqlConnection(ConnectionString); - rootConnection.Open(); + await rootConnection.OpenAsync(); using (SqlCommand command = rootConnection.CreateCommand()) { command.CommandText = $"INSERT INTO {TestTableName} VALUES ({InputCol1}, '{InputCol2}')"; - command.ExecuteNonQuery(); + await command.ExecuteNonQueryAsync(); } // Closing and reopening cycles the connection through the pool. // We want to verify that the transaction state is preserved through this cycle. SqlConnection enlistedConnection = new SqlConnection(ConnectionString); - enlistedConnection.Open(); + await enlistedConnection.OpenAsync(); enlistedConnection.Close(); - enlistedConnection.Open(); + await enlistedConnection.OpenAsync(); // Forcibly kill the root connection to mimic gateway's behavior when using the proxy connection policy // https://techcommunity.microsoft.com/blog/azuredbsupport/azure-sql-database-idle-sessions-are-killed-after-about-30-minutes-when-proxy-co/3268601 @@ -92,7 +92,7 @@ private void EnlistedTransactionPreservedWhilePooled() command.CommandText = $"INSERT INTO {TestTableName} VALUES ({InputCol1}, '{InputCol2}')"; try { - command.ExecuteNonQuery(); + await command.ExecuteNonQueryAsync(); } catch (Exception ex) { @@ -109,25 +109,25 @@ private void EnlistedTransactionPreservedWhilePooled() } // Even if an application swallows the command exception, completing the transaction should indicate that it failed. - var expectedTransactionExceptions = new[] { typeof(TransactionAbortedException), typeof(TransactionInDoubtException) }; + Type[] expectedTransactionExceptions = new[] { typeof(TransactionAbortedException), typeof(TransactionInDoubtException) }; Assert.Contains(transactionException.GetType(), expectedTransactionExceptions); - var expectedCommandExceptions = new[] { typeof(SqlException), typeof(InvalidOperationException) }; + Type[] expectedCommandExceptions = new[] { typeof(SqlException), typeof(InvalidOperationException) }; Assert.Contains(commandException.GetType(), expectedCommandExceptions); - if (commandException is SqlException) + if (commandException is SqlException exception) { // See https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-8000-to-8999?view=sql-server-ver16 // The distributed transaction failed // See https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors-3000-to-3999?view=sql-server-ver16 // Error 3971 corresponds to "The server failed to resume the transaction." var expectedExceptionCodes = new[] { 3971, 8525 }; - Assert.Contains(((SqlException)commandException).Number, expectedExceptionCodes); + Assert.Contains(exception.Number, expectedExceptionCodes); } // Verify that nothing made it into the database DataTable result = DataTestUtility.RunQuery(ConnectionString, $"select col2 from {TestTableName} where col1 = {InputCol1}"); - Assert.True(result.Rows.Count == 0); + Assert.Equal(0, result.Rows.Count); } private void KillProcess(int serverProcessId) @@ -152,7 +152,7 @@ private void KillProcess(int serverProcessId) private const int InputCol1 = 1; private const string InputCol2 = "One"; - private static void RunTestSet(Action TestCase) + private static async Task RunTestSet(Func TestCase) { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(DataTestUtility.TCPConnectionString); @@ -165,7 +165,7 @@ private static void RunTestSet(Action TestCase) DataTestUtility.RunNonQuery(ConnectionString, $"create table {TestTableName} (col1 int, col2 text)"); try { - TestCase(); + await TestCase(); } finally { From 02a10b9ef627949f85f6fb29964ae4866907fe24 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 25 Apr 2025 15:42:03 -0700 Subject: [PATCH 5/5] Use sync APIs for now --- .../TransactionTest/DistributedTransactionTest.Windows.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs index b6d7b95f37..049ed28092 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/TransactionTest/DistributedTransactionTest.Windows.cs @@ -71,15 +71,15 @@ private async Task EnlistedTransactionPreservedWhilePooled() using (SqlCommand command = rootConnection.CreateCommand()) { command.CommandText = $"INSERT INTO {TestTableName} VALUES ({InputCol1}, '{InputCol2}')"; - await command.ExecuteNonQueryAsync(); + command.ExecuteNonQuery(); } // Closing and reopening cycles the connection through the pool. // We want to verify that the transaction state is preserved through this cycle. SqlConnection enlistedConnection = new SqlConnection(ConnectionString); - await enlistedConnection.OpenAsync(); + enlistedConnection.Open(); enlistedConnection.Close(); - await enlistedConnection.OpenAsync(); + enlistedConnection.Open(); // Forcibly kill the root connection to mimic gateway's behavior when using the proxy connection policy // https://techcommunity.microsoft.com/blog/azuredbsupport/azure-sql-database-idle-sessions-are-killed-after-about-30-minutes-when-proxy-co/3268601 @@ -92,7 +92,7 @@ private async Task EnlistedTransactionPreservedWhilePooled() command.CommandText = $"INSERT INTO {TestTableName} VALUES ({InputCol1}, '{InputCol2}')"; try { - await command.ExecuteNonQueryAsync(); + command.ExecuteNonQuery(); } catch (Exception ex) {