feat: record task attempt chains
This commit is contained in:
@@ -722,6 +722,31 @@ WHERE reference_type = 'gateway_task'
|
||||
if failoverTask.Task.Status != "succeeded" {
|
||||
t.Fatalf("failover task should succeed through second client: %+v", failoverTask.Task)
|
||||
}
|
||||
var failoverDetail struct {
|
||||
Attempts []struct {
|
||||
AttemptNo int `json:"attemptNo"`
|
||||
PlatformName string `json:"platformName"`
|
||||
Status string `json:"status"`
|
||||
Retryable bool `json:"retryable"`
|
||||
ErrorCode string `json:"errorCode"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
ResponseMS int64 `json:"responseDurationMs"`
|
||||
} `json:"attempts"`
|
||||
Metrics map[string]any `json:"metrics"`
|
||||
}
|
||||
doJSON(t, server.URL, http.MethodGet, "/api/v1/tasks/"+failoverTask.Task.ID, apiKeyResponse.Secret, nil, http.StatusOK, &failoverDetail)
|
||||
if len(failoverDetail.Attempts) != 2 {
|
||||
t.Fatalf("failover task history should include two attempts, got %+v", failoverDetail.Attempts)
|
||||
}
|
||||
if failoverDetail.Attempts[0].PlatformName != "OpenAI Retryable Failure" || failoverDetail.Attempts[0].Status != "failed" || !failoverDetail.Attempts[0].Retryable || failoverDetail.Attempts[0].ErrorCode == "" {
|
||||
t.Fatalf("first failover attempt should preserve failed platform and reason: %+v", failoverDetail.Attempts[0])
|
||||
}
|
||||
if failoverDetail.Attempts[1].PlatformName != "OpenAI Retry Success" || failoverDetail.Attempts[1].Status != "succeeded" || failoverDetail.Attempts[1].ResponseMS <= 0 {
|
||||
t.Fatalf("second failover attempt should preserve successful platform: %+v", failoverDetail.Attempts[1])
|
||||
}
|
||||
if summary, ok := failoverDetail.Metrics["attempts"].([]any); !ok || len(summary) != 2 {
|
||||
t.Fatalf("task metrics should keep attempt-chain summary, got %+v", failoverDetail.Metrics)
|
||||
}
|
||||
|
||||
var degradePolicySet struct {
|
||||
ID string `json:"id"`
|
||||
|
||||
Reference in New Issue
Block a user