feat(acceptance): 增加生产同构媒体压力验收模式
引入动态流量门禁、隔离验收身份与协议级 Gemini/Volces 模拟器,覆盖双站点 API、Worker、PostgreSQL、River、账务、回调和媒体物化链路。 新增 P24/P28/P32 容量阶梯、Worker 强杀恢复、真实小流量 canary、CAS 放量和失败保持 validation 的生产编排;Worker 执行槽、连接池、媒体并发和双站点副本数改为环境配置。 验证:Go 全量测试、真实 PostgreSQL 迁移集成测试、迁移安全检查、OpenAPI 生成、ShellCheck、Kustomize、gofmt 和 git diff --check。
This commit is contained in:
@@ -418,7 +418,7 @@ func (s *Service) executeWithToken(ctx context.Context, task store.GatewayTask,
|
||||
preprocessingByCandidate := map[string]parameterPreprocessResult{}
|
||||
reservationBillings := []any(nil)
|
||||
reservationPricingSnapshot := map[string]any(nil)
|
||||
if task.RunMode == "production" {
|
||||
if isBillableRunMode(task.RunMode) {
|
||||
billingMode := normalizedBillingEngineMode(s.cfg.BillingEngineMode)
|
||||
if billingMode == "hold" {
|
||||
holdErr := &clients.ClientError{Code: "billing_hold", Message: "production billing is temporarily on hold", Retryable: true}
|
||||
@@ -809,7 +809,7 @@ candidatesLoop:
|
||||
finalAmount := fixedAmount(0)
|
||||
finalAmountText := ""
|
||||
pricingSnapshot := map[string]any{"pricingVersion": pricingVersionV2, "source": "simulation"}
|
||||
if task.RunMode == "production" {
|
||||
if isBillableRunMode(task.RunMode) {
|
||||
billingMode := normalizedBillingEngineMode(s.cfg.BillingEngineMode)
|
||||
var billingErr error
|
||||
if billingMode == "observe" {
|
||||
@@ -1171,9 +1171,16 @@ func (s *Service) runCandidate(
|
||||
admittedLeases []store.ConcurrencyLease,
|
||||
) (clients.Response, error) {
|
||||
var err error
|
||||
candidate, err = candidateWithEnvironmentCredentials(candidate)
|
||||
if err != nil {
|
||||
return clients.Response{}, err
|
||||
if task.RunMode == "acceptance" {
|
||||
candidate, err = s.acceptanceCandidate(ctx, task, candidate)
|
||||
if err != nil {
|
||||
return clients.Response{}, err
|
||||
}
|
||||
} else {
|
||||
candidate, err = candidateWithEnvironmentCredentials(candidate)
|
||||
if err != nil {
|
||||
return clients.Response{}, err
|
||||
}
|
||||
}
|
||||
simulated := isSimulation(task, candidate)
|
||||
baseAttemptMetrics := mergeMetrics(attemptMetrics(candidate, attemptNo, simulated), parameterPreprocessingMetrics(preprocessing))
|
||||
@@ -2085,7 +2092,14 @@ func (s *Service) emit(ctx context.Context, taskID string, eventType string, sta
|
||||
if event.ID == "" {
|
||||
s.observeTaskEventSkip(event.SkippedReason)
|
||||
}
|
||||
if s.cfg.TaskProgressCallbackEnabled {
|
||||
acceptanceURL, acceptance, callbackErr := s.store.AcceptanceCallbackURL(ctx, taskID)
|
||||
if callbackErr != nil {
|
||||
return callbackErr
|
||||
}
|
||||
if acceptance && acceptanceURL != "" {
|
||||
return s.store.QueueTaskCallback(ctx, event, acceptanceURL)
|
||||
}
|
||||
if s.cfg.TaskProgressCallbackEnabled && s.cfg.TaskProgressCallbackURL != "" {
|
||||
return s.store.QueueTaskCallback(ctx, event, s.cfg.TaskProgressCallbackURL)
|
||||
}
|
||||
return nil
|
||||
@@ -2230,6 +2244,43 @@ func isSimulation(task store.GatewayTask, candidate store.RuntimeModelCandidate)
|
||||
return stringFromMap(candidate.Credentials, "mode") == "simulation" || boolFromMap(candidate.PlatformConfig, "testMode")
|
||||
}
|
||||
|
||||
func isBillableRunMode(runMode string) bool {
|
||||
return runMode == "production" || runMode == "acceptance" || runMode == "acceptance_canary"
|
||||
}
|
||||
|
||||
func (s *Service) acceptanceCandidate(
|
||||
ctx context.Context,
|
||||
task store.GatewayTask,
|
||||
candidate store.RuntimeModelCandidate,
|
||||
) (store.RuntimeModelCandidate, error) {
|
||||
if strings.TrimSpace(task.AcceptanceRunID) == "" {
|
||||
return candidate, &clients.ClientError{
|
||||
Code: "acceptance_run_missing",
|
||||
Message: "acceptance task is missing its run identifier",
|
||||
Retryable: false,
|
||||
}
|
||||
}
|
||||
baseURL, credential, err := s.store.AcceptanceCandidateOverride(ctx, task.AcceptanceRunID)
|
||||
if err != nil {
|
||||
return candidate, &clients.ClientError{
|
||||
Code: "acceptance_run_inactive",
|
||||
Message: err.Error(),
|
||||
Retryable: false,
|
||||
}
|
||||
}
|
||||
candidate.BaseURL = baseURL
|
||||
candidate.Credentials = map[string]any{"apiKey": credential}
|
||||
platformConfig := cloneMap(candidate.PlatformConfig)
|
||||
delete(platformConfig, "credentialEnv")
|
||||
delete(platformConfig, "credential_env")
|
||||
delete(platformConfig, "proxyMode")
|
||||
delete(platformConfig, "httpProxy")
|
||||
platformConfig["networkProxy"] = map[string]any{"mode": "none"}
|
||||
platformConfig["acceptanceRunId"] = task.AcceptanceRunID
|
||||
candidate.PlatformConfig = platformConfig
|
||||
return candidate, nil
|
||||
}
|
||||
|
||||
func retryEnabled(candidate store.RuntimeModelCandidate) bool {
|
||||
policy := effectiveRetryPolicy(candidate)
|
||||
if enabled, ok := policy["enabled"].(bool); ok {
|
||||
|
||||
Reference in New Issue
Block a user