fix(acceptance): 修复线上双站压测失真
将线上压力生成器拆分为宁波、香港宿主机上的 K3s 外进程,按全局序号分片并保守合并站点报告,避免操作者本机上行带宽成为容量瓶颈。\n\n为每次负载执行生成独立幂等键和 Run 级图片变体,阻止三轮验收重放旧任务或复用历史媒体缓存,并新增直接 OSS 物化一致性门禁。\n\n验证:Go 全量测试、go vet、迁移安全检查、bash -n、ShellCheck、manual-release-test 和双宿主机 linux/amd64 启动冒烟通过。
This commit is contained in:
@@ -146,7 +146,7 @@ func TestGeminiLoadIsSplitAcrossTwoGatewayAPIs(t *testing.T) {
|
||||
gateways: []string{first.URL, second.URL}, apiKeys: []string{"key-1", "key-2"}, runID: "run-1",
|
||||
runToken: "token-1", geminiModel: "gemini-image-test",
|
||||
}
|
||||
result := runGemini(t.Context(), http.DefaultClient, opts, "dual-api", 8, 256<<10, 256<<10, false)
|
||||
result := runGemini(t.Context(), http.DefaultClient, opts, "dual-api", 8, 256<<10, 256<<10, false, 0, 1)
|
||||
if result.err != nil || result.report.Completed != 8 {
|
||||
t.Fatalf("result=%+v err=%v", result.report, result.err)
|
||||
}
|
||||
@@ -158,6 +158,53 @@ func TestGeminiLoadIsSplitAcrossTwoGatewayAPIs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistributedShardIndexesCoverWorkloadWithoutOverlap(t *testing.T) {
|
||||
first := options{shardIndex: 0, shardCount: 2}
|
||||
second := options{shardIndex: 1, shardCount: 2}
|
||||
if first.shardRequestCount(1001) != 501 || second.shardRequestCount(1001) != 500 {
|
||||
t.Fatalf("shard counts=%d/%d", first.shardRequestCount(1001), second.shardRequestCount(1001))
|
||||
}
|
||||
seen := map[int]bool{}
|
||||
for local := 0; local < first.shardRequestCount(1001); local++ {
|
||||
seen[first.logicalRequestIndex(local)] = true
|
||||
}
|
||||
for local := 0; local < second.shardRequestCount(1001); local++ {
|
||||
index := second.logicalRequestIndex(local)
|
||||
if seen[index] {
|
||||
t.Fatalf("duplicate logical index %d", index)
|
||||
}
|
||||
seen[index] = true
|
||||
}
|
||||
if len(seen) != 1001 {
|
||||
t.Fatalf("covered indexes=%d", len(seen))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGeminiInputVariantIsRunScoped(t *testing.T) {
|
||||
if geminiInputVariant("run-a", 7) == geminiInputVariant("run-b", 7) {
|
||||
t.Fatal("different Run IDs produced the same input variant")
|
||||
}
|
||||
if geminiInputVariant("run-a", 7) == geminiInputVariant("run-a", 8) {
|
||||
t.Fatal("different logical indexes produced the same input variant")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAcceptanceIdempotencyKeyIncludesExecutionAndLogicalIndex(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodPost, "https://gateway.example/v1", nil)
|
||||
opts := options{
|
||||
apiKeys: []string{"key-1"}, runID: "run-1", runToken: "token-1", executionID: "p24-2-gemini-baseline",
|
||||
}
|
||||
opts.setHeaders(request, 17, false)
|
||||
if got := request.Header.Get("Idempotency-Key"); got != "acceptance-run-1-p24-2-gemini-baseline-17" {
|
||||
t.Fatalf("idempotency key=%q", got)
|
||||
}
|
||||
poll := httptest.NewRequest(http.MethodGet, "https://gateway.example/result", nil)
|
||||
opts.setHeaders(poll, 17, false)
|
||||
if got := poll.Header.Get("Idempotency-Key"); got != "" {
|
||||
t.Fatalf("GET request unexpectedly has idempotency key %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateVideoAssetDownloadsFinalMedia(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) {
|
||||
if request.Header.Get("Authorization") != "" {
|
||||
|
||||
Reference in New Issue
Block a user