@@ -267,8 +267,8 @@ func TestConnectionHook(t *testing.T) {
267
267
EndpointType : EndpointTypeAuto ,
268
268
MaxWorkers : 2 ,
269
269
HandoffQueueSize : 10 ,
270
- MaxHandoffRetries : 3 ,
271
- HandoffTimeout : 1 * time .Second , // Shorter timeout for faster test
270
+ MaxHandoffRetries : 2 , // Reduced retries for faster test
271
+ HandoffTimeout : 500 * time .Millisecond , // Shorter timeout for faster test
272
272
LogLevel : 2 ,
273
273
}
274
274
processor := NewPoolHook (failingDialer , "tcp" , config , nil )
@@ -294,13 +294,12 @@ func TestConnectionHook(t *testing.T) {
294
294
}
295
295
296
296
// Wait for handoff to complete and fail with proper timeout and polling
297
- // Use longer timeout to account for handoff timeout + processing time
298
- timeout := time .After (5 * time .Second )
297
+ timeout := time .After (3 * time .Second )
299
298
ticker := time .NewTicker (10 * time .Millisecond )
300
299
defer ticker .Stop ()
301
300
302
301
// wait for handoff to start
303
- time .Sleep (100 * time .Millisecond )
302
+ time .Sleep (50 * time .Millisecond )
304
303
handoffCompleted := false
305
304
for ! handoffCompleted {
306
305
select {
@@ -318,10 +317,17 @@ func TestConnectionHook(t *testing.T) {
318
317
t .Error ("Connection should be removed from pending map after failed handoff" )
319
318
}
320
319
321
- // Handoff state should still be set (since handoff failed)
322
- if ! conn .ShouldHandoff () {
323
- t .Error ("Connection should still be marked for handoff after failed handoff" )
320
+ // Wait for retries to complete (with MaxHandoffRetries=2, it will retry twice then give up)
321
+ // Each retry has a delay of handoffTimeout/2 = 250ms, so wait for all retries to complete
322
+ time .Sleep (800 * time .Millisecond )
323
+
324
+ // After max retries are reached, the connection should be removed from pool
325
+ // and handoff state should be cleared
326
+ if conn .ShouldHandoff () {
327
+ t .Error ("Connection should not be marked for handoff after max retries reached" )
324
328
}
329
+
330
+ t .Logf ("EventDrivenHandoffDialerError test completed successfully" )
325
331
})
326
332
327
333
t .Run ("BufferedDataRESP2" , func (t * testing.T ) {
0 commit comments