将图像和视频的默认 HTTP/轮询超时分别提高到 20 分钟和 30 分钟。媒体任务超时后直接失败,不再重试、切换客户端或标记为 upstream_submission_unknown。OpenAI 图像端点遇到上游明确拒绝 response_format 时自动移除并缓存兼容结论。 验证:go test ./... -count=1;go vet ./...;gofmt;相关 Shell bash -n、ShellCheck 与发布脚本回归测试。
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package clients
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestProviderRequestTimeoutUsesMediaDefaults(t *testing.T) {
|
|
for _, test := range []struct {
|
|
kind string
|
|
want time.Duration
|
|
}{
|
|
{kind: "images.generations", want: 20 * time.Minute},
|
|
{kind: "images.edits", want: 20 * time.Minute},
|
|
{kind: "videos.generations", want: 30 * time.Minute},
|
|
{kind: "chat.completions", want: 10 * time.Minute},
|
|
} {
|
|
if got := ProviderRequestTimeout(test.kind); got != test.want {
|
|
t.Fatalf("timeout for %s: got %s want %s", test.kind, got, test.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestTransportTimeoutUsesTerminalTimeoutCode(t *testing.T) {
|
|
err := transportClientError(context.DeadlineExceeded)
|
|
if err.Code != "timeout" || err.Retryable {
|
|
t.Fatalf("transport timeout classification = %+v, want terminal timeout", err)
|
|
}
|
|
}
|
|
|
|
func TestMediaPollTimeoutsUseTaskDefaultsWithoutPlatformOverride(t *testing.T) {
|
|
image := Request{Kind: "images.generations", Candidate: storeCandidateWithConfig("", "", nil, nil)}
|
|
video := Request{Kind: "videos.generations", Candidate: storeCandidateWithConfig("", "", nil, nil)}
|
|
if got := providerPollTimeout(image); got != 20*time.Minute {
|
|
t.Fatalf("image provider poll timeout: got %s want %s", got, 20*time.Minute)
|
|
}
|
|
if got := providerPollTimeout(video); got != 30*time.Minute {
|
|
t.Fatalf("video provider poll timeout: got %s want %s", got, 30*time.Minute)
|
|
}
|
|
if got := kelingPollTimeout(video); got != 30*time.Minute {
|
|
t.Fatalf("Keling video poll timeout: got %s want %s", got, 30*time.Minute)
|
|
}
|
|
if got := volcesPollTimeout(video); got != 30*time.Minute {
|
|
t.Fatalf("Volces video poll timeout: got %s want %s", got, 30*time.Minute)
|
|
}
|
|
}
|