Adopt PromptKit timeout fix and complete verification
This commit is contained in:
@@ -1227,6 +1227,42 @@ func TestHandlerDeadlineCancelsBuiltInRetryWait(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerDeadlineDuringBuiltInGeneration(t *testing.T) {
|
||||
started := make(chan struct{}, 1)
|
||||
release := make(chan struct{})
|
||||
provider := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
started <- struct{}{}
|
||||
<-release
|
||||
}))
|
||||
defer provider.Close()
|
||||
defer close(release)
|
||||
h := newRetryHandler(t, provider.URL+"/v1", intPointer(0), 0, nil)
|
||||
failures := observeRunnerFailures(h)
|
||||
w := httptest.NewRecorder()
|
||||
h.ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(`{"prompt_id":"p","run_timeout_seconds":1,"include_execution_report":true}`)))
|
||||
select {
|
||||
case <-started:
|
||||
default:
|
||||
t.Fatal("provider call did not start")
|
||||
}
|
||||
err := <-failures
|
||||
if !errors.Is(err, promptkit.ErrOperationTimeout) || !errors.Is(err, context.DeadlineExceeded) {
|
||||
t.Errorf("engine did not attribute in-flight generation to operation timeout: %v (deadline cause: %t)", err, errors.Is(err, context.DeadlineExceeded))
|
||||
}
|
||||
var response struct {
|
||||
Execution *struct {
|
||||
Failure string `json:"failure"`
|
||||
} `json:"execution"`
|
||||
}
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &response); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if response.Execution == nil || response.Execution.Failure != "deadline" {
|
||||
t.Errorf("terminal report did not classify deadline: %+v", response.Execution)
|
||||
}
|
||||
assertHTTPErrorCode(t, w, http.StatusGatewayTimeout, "deadline_exceeded")
|
||||
}
|
||||
|
||||
func TestHandlerDeadlineCancelsCapacityWaitAndReleasesAdmission(t *testing.T) {
|
||||
started := make(chan struct{}, 1)
|
||||
release := make(chan struct{})
|
||||
|
||||
Reference in New Issue
Block a user