@@ -25,7 +25,7 @@ func TestShutdownEndpointE2E(t *testing.T) {
2525 module : "async_sleep" ,
2626 predictorClass : "Predictor" ,
2727 concurrencyMax : 1 ,
28- runnerShutdownGracePeriod : 10 * time .Second ,
28+ runnerShutdownGracePeriod : 100 * time .Millisecond ,
2929 })
3030 defer httpTestServer .Close ()
3131
@@ -51,7 +51,7 @@ func TestShutdownEndpointE2E(t *testing.T) {
5151 // Service should shutdown gracefully
5252 require .Eventually (t , func () bool {
5353 return svc .IsStopped ()
54- }, 10 * time .Second , 100 * time .Millisecond , "service should have stopped after shutdown" )
54+ }, 1 * time .Second , 10 * time .Millisecond , "service should have stopped after shutdown" )
5555
5656 // Service should no longer be running
5757 assert .False (t , svc .IsRunning ())
@@ -73,7 +73,7 @@ func TestShutdownEndpointWaitsForInflightPredictions(t *testing.T) {
7373 module : "async_sleep" , // Use async predictor for cancellation support
7474 predictorClass : "Predictor" ,
7575 concurrencyMax : 1 ,
76- runnerShutdownGracePeriod : 30 * time .Second , // Allow time for graceful shutdown
76+ runnerShutdownGracePeriod : 200 * time .Millisecond , // Allow time for graceful shutdown
7777 })
7878 defer httpTestServer .Close ()
7979
@@ -108,7 +108,7 @@ func TestShutdownEndpointWaitsForInflightPredictions(t *testing.T) {
108108 case webhookEvent := <- receiverServer .webhookReceiverChan :
109109 assert .Equal (t , runner .PredictionProcessing , webhookEvent .Response .Status )
110110 assert .Equal (t , predictionID , webhookEvent .Response .ID )
111- case <- time .After (10 * time .Second ):
111+ case <- time .After (5 * time .Second ):
112112 t .Fatal ("did not receive prediction started webhook" )
113113 }
114114
@@ -143,15 +143,15 @@ func TestShutdownEndpointWaitsForInflightPredictions(t *testing.T) {
143143 case webhookEvent := <- receiverServer .webhookReceiverChan :
144144 assert .Equal (t , predictionID , webhookEvent .Response .ID )
145145 assert .Equal (t , runner .PredictionCanceled , webhookEvent .Response .Status )
146- case <- time .After (15 * time .Second ):
146+ case <- time .After (5 * time .Second ):
147147 t .Fatal ("did not receive prediction canceled webhook" )
148148 }
149149
150150 // The key test: verify the SERVICE itself has shut down gracefully
151151 // Wait for service to stop (it should stop automatically after shutdown)
152152 require .Eventually (t , func () bool {
153153 return svc .IsStopped ()
154- }, 10 * time .Second , 10 * time .Millisecond , "service should have stopped after shutdown" )
154+ }, 1 * time .Second , 10 * time .Millisecond , "service should have stopped after shutdown" )
155155
156156 // Service should no longer be running
157157 assert .False (t , svc .IsRunning ())
@@ -187,7 +187,7 @@ func TestShutdownEndpointFailsInNonAwaitMode(t *testing.T) {
187187 assert .Equal (t , http .StatusOK , shutdownResp .StatusCode )
188188
189189 // Give it a moment for shutdown to process
190- time .Sleep (1 * time .Second )
190+ time .Sleep (50 * time .Millisecond )
191191
192192 // Verify server has shut down by attempting health check
193193 // Should fail after shutdown completes since the server should be down
@@ -197,7 +197,7 @@ func TestShutdownEndpointFailsInNonAwaitMode(t *testing.T) {
197197 resp .Body .Close ()
198198 }
199199 return err != nil // Server should be down
200- }, 10 * time .Second , 500 * time .Millisecond , "server should have shut down" )
200+ }, 2 * time .Second , 50 * time .Millisecond , "server should have shut down" )
201201}
202202
203203func TestShutdownEndpointMultipleCallsIdempotent (t * testing.T ) {
@@ -238,7 +238,7 @@ func TestShutdownEndpointMultipleCallsIdempotent(t *testing.T) {
238238 // Service should shutdown gracefully (only once)
239239 require .Eventually (t , func () bool {
240240 return svc .IsStopped ()
241- }, 10 * time .Second , 100 * time .Millisecond , "service should have stopped after shutdown" )
241+ }, 1 * time .Second , 10 * time .Millisecond , "service should have stopped after shutdown" )
242242
243243 assert .False (t , svc .IsRunning ())
244244 assert .True (t , svc .IsStopped ())
0 commit comments