Skip to content

Commit

Permalink
Improve timeout of tests (#3026)
Browse files Browse the repository at this point in the history
* Improve timeout of tests

* Increate timeout for column creation in setup
  • Loading branch information
MichelZ authored Nov 22, 2024
1 parent 1f9eb6a commit 1348c3c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public ConversionTests()

foreach (string connectionStr in DataTestUtility.AEConnStringsSetup)
{
using (SqlConnection sqlConnection = new SqlConnection(connectionStr))
var connectionString = new SqlConnectionStringBuilder(connectionStr);
connectionString.ConnectTimeout = Math.Max(connectionString.ConnectTimeout, 30); // The AE tests often fail with a connect timeout in this constructor. Making sure we have a reasonable timeout.

using (SqlConnection sqlConnection = new SqlConnection(connectionString.ConnectionString))
{
sqlConnection.Open();
_databaseObjects.ForEach(o => o.Create(sqlConnection));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH VALUES (
using (SqlCommand command = sqlConnection.CreateCommand())
{
command.CommandText = sql;
command.CommandTimeout = 60;
command.ExecuteNonQuery();
}
}
Expand All @@ -47,6 +48,7 @@ public override void Drop(SqlConnection sqlConnection)
using (SqlCommand command = sqlConnection.CreateCommand())
{
command.CommandText = sql;
command.CommandTimeout = 60;
command.ExecuteNonQuery();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public override void Create(SqlConnection sqlConnection)
if (!string.IsNullOrEmpty(sql))
{
command.CommandText = sql;
command.CommandTimeout = 60;
command.ExecuteNonQuery();
}
}
Expand All @@ -54,6 +55,7 @@ public override void Drop(SqlConnection sqlConnection)
using (SqlCommand command = sqlConnection.CreateCommand())
{
command.CommandText = sql;
command.CommandTimeout = 60;
command.ExecuteNonQuery();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public void EventCounter_ReclaimedConnectionsCounter_Functional()
// clean pools and pool groups
ClearConnectionPools();
var stringBuilder = new SqlConnectionStringBuilder(DataTestUtility.TCPConnectionString) { Pooling = true, MaxPoolSize = 1 };
stringBuilder.ConnectTimeout = Math.Max(stringBuilder.ConnectTimeout, 30);

long rc = SqlClientEventSourceProps.ReclaimedConnections;

Expand Down

0 comments on commit 1348c3c

Please sign in to comment.