diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs index c02658284b..b257b28c42 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/Batch/BatchTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Threading.Tasks; @@ -74,9 +75,13 @@ public static void SqlBatchCanCreateParameter() [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] public static void StoredProcedureBatchSupported() { + SqlRetryLogicOption rto = new() { NumberOfTries = 3, DeltaTime = TimeSpan.FromMilliseconds(100), TransientErrors = new[] { 1205 } }; // Retry on 1205 / Deadlock + SqlRetryLogicBaseProvider prov = SqlConfigurableRetryFactory.CreateIncrementalRetryProvider(rto); + using (var connection = new SqlConnection(DataTestUtility.TCPConnectionString)) - using (var batch = new SqlBatch { Connection = connection, BatchCommands = { new SqlBatchCommand("sp_help", CommandType.StoredProcedure) } }) + using (var batch = new SqlBatch { Connection = connection, BatchCommands = { new SqlBatchCommand("sp_help", CommandType.StoredProcedure, new List { new("@objname", "sys.indexes") }) } }) { + connection.RetryLogicProvider = prov; connection.Open(); batch.ExecuteNonQuery(); } @@ -102,19 +107,24 @@ public static void TableDirectBatchNotSupported() [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] public static void MixedBatchSupported() { + SqlRetryLogicOption rto = new() { NumberOfTries = 3, DeltaTime = TimeSpan.FromMilliseconds(100), TransientErrors = new[] { 1205 } }; // Retry on 1205 / Deadlock + SqlRetryLogicBaseProvider prov = SqlConfigurableRetryFactory.CreateIncrementalRetryProvider(rto); + using (var connection = new SqlConnection(DataTestUtility.TCPConnectionString)) using (var batch = new SqlBatch + { + Connection = connection, + BatchCommands = + { + new SqlBatchCommand("select @@SPID", CommandType.Text), + new SqlBatchCommand("sp_help", CommandType.StoredProcedure, new List { new("@objname", "sys.indexes") }) + } + }) { - Connection = connection, - BatchCommands = - { - new SqlBatchCommand("select @@SPID", CommandType.Text), - new SqlBatchCommand("sp_help",CommandType.StoredProcedure) - } - }) - { + connection.RetryLogicProvider = prov; connection.Open(); batch.ExecuteNonQuery(); + return; } }