Skip to content

Commit db3d616

Browse files
Fix PR #4302 CI: pass TimeoutTimer to ChannelDbConnectionPool.TryGetConnection in shutdown tests
PR #4295 (merged to main) added a required TimeoutTimer parameter to ChannelDbConnectionPool.TryGetConnection. The shutdown tests added in this PR still call the pre-#4295 3-arg overload, which compiles locally against PoolShutdown's older base but fails in the CI pipeline because the pipeline merges this PR's head into the post-#4295 main. Pass TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)) at all 5 call sites to match the new signature.
1 parent b8d56d9 commit db3d616

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/Microsoft.Data.SqlClient/tests/UnitTests/ConnectionPool/ChannelDbConnectionPoolShutdownTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void Shutdown_DrainsIdleConnections()
6767
{
6868
var owner = new SqlConnection();
6969
owners.Add(owner);
70-
Assert.True(pool.TryGetConnection(owner, taskCompletionSource: null, out DbConnectionInternal? c));
70+
Assert.True(pool.TryGetConnection(owner, taskCompletionSource: null, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out DbConnectionInternal? c));
7171
Assert.NotNull(c);
7272
conns.Add(c!);
7373
}
@@ -89,7 +89,7 @@ public void Shutdown_ReturnedConnection_IsDestroyedNotPooled()
8989
{
9090
var pool = ConstructPool();
9191
var owner = new SqlConnection();
92-
Assert.True(pool.TryGetConnection(owner, taskCompletionSource: null, out DbConnectionInternal? conn));
92+
Assert.True(pool.TryGetConnection(owner, taskCompletionSource: null, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out DbConnectionInternal? conn));
9393
Assert.NotNull(conn);
9494
Assert.Equal(1, pool.Count);
9595
Assert.Equal(0, pool.IdleCount);
@@ -122,12 +122,12 @@ public async Task Shutdown_UnblocksAsyncWaiter()
122122
var pool = ConstructPool(maxPoolSize: 1);
123123

124124
// Saturate the pool.
125-
Assert.True(pool.TryGetConnection(new SqlConnection(), taskCompletionSource: null, out DbConnectionInternal? blocking));
125+
Assert.True(pool.TryGetConnection(new SqlConnection(), taskCompletionSource: null, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out DbConnectionInternal? blocking));
126126
Assert.NotNull(blocking);
127127

128128
// Park an async waiter.
129129
var tcs = new TaskCompletionSource<DbConnectionInternal>();
130-
bool completed = pool.TryGetConnection(new SqlConnection(), tcs, out DbConnectionInternal? waiter);
130+
bool completed = pool.TryGetConnection(new SqlConnection(), tcs, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out DbConnectionInternal? waiter);
131131
Assert.False(completed);
132132
Assert.Null(waiter);
133133
Assert.False(tcs.Task.IsCompleted);
@@ -161,7 +161,7 @@ public void Shutdown_AfterShutdown_NewReturnsAreDestroyed()
161161
{
162162
var pool = ConstructPool();
163163
var owner = new SqlConnection();
164-
Assert.True(pool.TryGetConnection(owner, taskCompletionSource: null, out DbConnectionInternal? c));
164+
Assert.True(pool.TryGetConnection(owner, taskCompletionSource: null, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out DbConnectionInternal? c));
165165
Assert.NotNull(c);
166166

167167
pool.Shutdown();

0 commit comments

Comments
 (0)