test(acceptance): 增加视频容量阶梯场景
新增 30 至 45 秒模拟上游等待的视频容量场景,使单 Worker 自适应控制在每级突发负载中获得连续占满窗口,同时保持提交、轮询、结果处理和回调全链路。\n\n未修改生产 Worker 和厂商限流逻辑。已执行完整 Go 测试、go vet、gofmt、bash -n、ShellCheck 和生产验收脚本测试。
This commit is contained in:
@@ -674,9 +674,24 @@ func videoDelay(body map[string]any, longRun bool) time.Duration {
|
||||
if longRun {
|
||||
return 2*time.Minute + time.Duration(seed%61)*time.Second
|
||||
}
|
||||
if videoPromptContains(body, "acceptance-capacity-ladder") {
|
||||
return 30*time.Second + time.Duration(seed%16)*time.Second
|
||||
}
|
||||
return 5*time.Second + time.Duration(seed%11)*time.Second
|
||||
}
|
||||
|
||||
func videoPromptContains(body map[string]any, marker string) bool {
|
||||
content, _ := body["content"].([]any)
|
||||
for _, raw := range content {
|
||||
item, _ := raw.(map[string]any)
|
||||
if strings.TrimSpace(stringValue(item["type"])) == "text" &&
|
||||
strings.Contains(strings.ToLower(stringValue(item["text"])), marker) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func requestOrigin(r *http.Request) string {
|
||||
scheme := strings.TrimSpace(r.Header.Get("X-Forwarded-Proto"))
|
||||
if scheme == "" {
|
||||
|
||||
@@ -228,6 +228,20 @@ func TestScaledDelayStaysOnWholeSecondsWithinProfile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestVideoCapacityDelay(t *testing.T) {
|
||||
body := map[string]any{
|
||||
"seed": json.Number("7"),
|
||||
"content": []any{map[string]any{
|
||||
"type": "text",
|
||||
"text": "capacity acceptance-capacity-ladder",
|
||||
}},
|
||||
}
|
||||
delay := videoDelay(body, false)
|
||||
if delay < 30*time.Second || delay > 45*time.Second {
|
||||
t.Fatalf("video capacity delay=%s, want 30s..45s", delay)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVolcesProtocolAcceptsThreeSixAndNineReferenceImages(t *testing.T) {
|
||||
server := New(Config{Wait: func(context.Context, time.Duration) error { return nil }})
|
||||
httpServer := httptest.NewServer(server.Handler())
|
||||
|
||||
Reference in New Issue
Block a user