fix(acceptance): 物化验收任务的最终媒体
仅对已认证 Acceptance Run 强制下载并持久化 URL 型结果,确保集群外压测端能验证最终视频;普通生产任务继续遵循现有文件存储策略。压测器仅对 Gateway 自有地址做双入口重写,避免向第三方媒体域名泄露验收凭据。\n\n同时修复本地集群重复使用同一快照文件时的幂等复制失败。验证:Go 全量测试、go vet、gofmt、bash -n、ShellCheck 和 git diff --check 通过。
This commit is contained in:
@@ -158,12 +158,15 @@ func TestGeminiLoadIsSplitAcrossTwoGatewayAPIs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateVideoAssetDownloadsFinalMedia(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) {
|
||||
if request.Header.Get("Authorization") != "" {
|
||||
t.Fatal("acceptance credentials leaked to external media host")
|
||||
}
|
||||
w.Header().Set("Content-Type", "video/mp4")
|
||||
_, _ = w.Write([]byte{0, 0, 0, 16, 'f', 't', 'y', 'p', 'i', 's', 'o', 'm'})
|
||||
}))
|
||||
defer server.Close()
|
||||
if err := validateVideoAsset(t.Context(), server.Client(), server.URL+"/result.mp4"); err != nil {
|
||||
if err := validateVideoAsset(t.Context(), server.Client(), options{}, server.URL+"/result.mp4", 0); err != nil {
|
||||
t.Fatalf("validate video asset: %v", err)
|
||||
}
|
||||
if got := findMediaURL(map[string]any{"content": map[string]any{"video_url": server.URL}}); got != server.URL {
|
||||
@@ -171,6 +174,34 @@ func TestValidateVideoAssetDownloadsFinalMedia(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateVideoAssetUsesGatewayForMaterializedPath(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) {
|
||||
if request.Host != "gateway.easyai.local" || request.Header.Get("Authorization") != "Bearer key-1" {
|
||||
t.Fatalf("host=%q authorization=%q", request.Host, request.Header.Get("Authorization"))
|
||||
}
|
||||
if request.URL.Path != "/static/generated/result.mp4" {
|
||||
t.Fatalf("path=%q", request.URL.Path)
|
||||
}
|
||||
w.Header().Set("Content-Type", "video/mp4")
|
||||
_, _ = w.Write([]byte{0, 0, 0, 16, 'f', 't', 'y', 'p', 'i', 's', 'o', 'm'})
|
||||
}))
|
||||
defer server.Close()
|
||||
opts := options{
|
||||
gateways: []string{server.URL}, apiKeys: []string{"key-1"},
|
||||
runID: "run-1", runToken: "token-1", gatewayTLSName: "gateway.easyai.local",
|
||||
}
|
||||
if err := validateVideoAsset(t.Context(), server.Client(), opts, "/static/generated/result.mp4", 0); err != nil {
|
||||
t.Fatalf("validate materialized video: %v", err)
|
||||
}
|
||||
got := findMediaURL(map[string]any{
|
||||
"raw": map[string]any{"video_url": "http://internal.invalid/video.mp4"},
|
||||
"data": []any{map[string]any{"video_url": "/static/generated/result.mp4"}},
|
||||
})
|
||||
if got != "/static/generated/result.mp4" {
|
||||
t.Fatalf("preferred media URL=%q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAcceptanceReportErrorRedactsSecretsAndURLs(t *testing.T) {
|
||||
got := redactError(
|
||||
`token-1 failed at https://example.invalid/video.mp4?token=signed`,
|
||||
|
||||
Reference in New Issue
Block a user