Skip to content

Commit aec0b28

Browse files
Pass TimeoutTimer to WaitHandleDbConnectionPool.TryGetConnection in shutdown tests
Same root cause as previous commit: PR 4295 added a required TimeoutTimer parameter to WaitHandleDbConnectionPool.TryGetConnection. The shutdown tests still call the old 3-arg overload, which fails CI once PR 4295 is merged into main. Pass TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)) at all 5 call sites in WaitHandleDbConnectionPoolShutdownTest.cs to match the new 4-arg signature.
1 parent 9a45a66 commit aec0b28

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public void Shutdown_DrainsIdleStacks()
8888
// Vend a few connections then return them so they sit in _stackNew.
8989
var owner1 = new SqlConnection();
9090
var owner2 = new SqlConnection();
91-
pool.TryGetConnection(owner1, taskCompletionSource: null, out DbConnectionInternal? c1);
92-
pool.TryGetConnection(owner2, taskCompletionSource: null, out DbConnectionInternal? c2);
91+
pool.TryGetConnection(owner1, taskCompletionSource: null, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out DbConnectionInternal? c1);
92+
pool.TryGetConnection(owner2, taskCompletionSource: null, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out DbConnectionInternal? c2);
9393
Assert.NotNull(c1);
9494
Assert.NotNull(c2);
9595
pool.ReturnInternalConnection(c1!, owner1);
@@ -152,6 +152,7 @@ public void TryGetConnection_AfterShutdown_ReturnsNullWithoutBlocking()
152152
bool completed = pool.TryGetConnection(
153153
new SqlConnection(),
154154
taskCompletionSource: null,
155+
TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)),
155156
out DbConnectionInternal? conn);
156157

157158
// TryGetConnection returns true with a null connection when State != Running.
@@ -167,7 +168,7 @@ public void Shutdown_UnblocksSyncWaiter()
167168

168169
// Saturate the pool.
169170
var owner = new SqlConnection();
170-
Assert.True(pool.TryGetConnection(owner, taskCompletionSource: null, out DbConnectionInternal? blocking));
171+
Assert.True(pool.TryGetConnection(owner, taskCompletionSource: null, TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)), out DbConnectionInternal? blocking));
171172
Assert.NotNull(blocking);
172173

173174
// Park a sync waiter on a worker thread with a long creation timeout.
@@ -182,6 +183,7 @@ public void Shutdown_UnblocksSyncWaiter()
182183
waiterCompleted = pool.TryGetConnection(
183184
new SqlConnection(),
184185
taskCompletionSource: null,
186+
TimeoutTimer.StartNew(TimeSpan.FromSeconds(15)),
185187
out waiterResult);
186188
}
187189
catch (Exception ex)

0 commit comments

Comments
 (0)