Skip to content

Commit

Permalink
Add test to reproduce regression in Managed SNI.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Oct 18, 2021
1 parent 8ebeab0 commit e8f2283
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -639,5 +639,61 @@ public static async Task MarsScenarioClientJoin()
Assert.Equal(companyNames[supplier], name);
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
public static void MarsConcurrencyTest()
{
var table = DataTestUtility.GenerateObjectName();
using (var conn = new SqlConnection(DataTestUtility.TCPConnectionString))
{
conn.Open();
using var cmd = new SqlCommand
{
Connection = conn,
CommandText = @$"
DROP TABLE IF EXISTS [{table}];
CREATE TABLE [{table}] (
[Id] INTEGER,
[IsDeleted] BIT
)"
};

cmd.ExecuteNonQuery();
}
var connString = new SqlConnectionStringBuilder(DataTestUtility.TCPConnectionString) { MultipleActiveResultSets = true }.ConnectionString;
using (var conn = new SqlConnection(connString))
{
conn.Open();
try
{
for (int i = 0; i < 5; i++)
{
Parallel.For(
0, 300,
i =>
{
using var cmd = new SqlCommand
{
Connection = conn,
CommandText = @$"
SELECT [l].[Id], [l].[IsDeleted]
FROM [{table}] AS [l]
WHERE ([l].[IsDeleted] = CAST(0 AS bit)) AND [l].[Id] IN (1, 2, 3)"
};

using SqlDataReader _ = cmd.ExecuteReader();
});
}
}
catch (Exception e)
{
Assert.False(true, "CRITIAL: Test should not fail randomly. Exception occurred: " + e.Message);
}
finally
{
DataTestUtility.DropTable(conn, table);
}
}
}
}
}

0 comments on commit e8f2283

Please sign in to comment.