7511c59987
build / build (push) Successful in 1m56s
F02:测试封存作业只展示只读导出测试版本,不再套用备份生产/同步 Wiki/ 生产验证/生产生效,也不再写目标维护;运行和失败终态都保留真实 export 状态。同一挂载覆盖 running→failed。 F03:版本列表按每个 snapshot_id 精确查询恢复验证记录,与详情使用同一 endpoint;同 scope 最新 passed 不再给其他快照染色,未演练与读取失败分开。 封存失败:已恢复写入者且确定不可重试的捕获校验错误使用永久失败,避免 第二次 attempt 的 already exists 覆盖第一因;业务 job 的 error 在失败重试 中保留第一条,成功时清除。瞬时不可达/超时仍保留重试。 验证:Go/前端全量、隔离 PG 精确快照与首因测试、临时独立 ES 的 Current→Prepare→Verify PASS、make verify 17 项。host libraryctl 仍是旧 f9c15a8f...dirty,360 镜像未替换 host 工具,本轮只单独准备包不切换。
52 lines
2.1 KiB
Go
52 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
|
|
"knowledge-governance/internal/jobs"
|
|
)
|
|
|
|
func TestLibraryCaptureValidationFailureIsTerminal(t *testing.T) {
|
|
original := errors.New("LIBRARYCTL_FAILED: unverified legacy library chunk index coverage;已执行 recover 并确认写入者恢复")
|
|
got := terminalLibraryCaptureError(original)
|
|
terminal, code := jobs.Terminal(got)
|
|
if !terminal || code != jobs.ErrCodeValidationFailed {
|
|
t.Fatalf("validation failure must park immediately: terminal=%v code=%q err=%v", terminal, code, got)
|
|
}
|
|
if got.Error() != original.Error() {
|
|
t.Fatalf("original cause changed: got %q want %q", got.Error(), original.Error())
|
|
}
|
|
}
|
|
|
|
func TestLibraryCaptureTransientFailureStillRetries(t *testing.T) {
|
|
for _, message := range []string{
|
|
"library agent is unreachable",
|
|
"context deadline exceeded",
|
|
`LIBRARYCTL_FAILED: job "lib-internal-x" already exists with state "failed";已执行 recover 并确认写入者恢复`,
|
|
} {
|
|
got := terminalLibraryCaptureError(errors.New(message))
|
|
if terminal, code := jobs.Terminal(got); terminal {
|
|
t.Fatalf("%q must stay retryable, got terminal code=%q", message, code)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestLibraryCaptureOriginalFailureSurvivesRetryOverwrite(t *testing.T) {
|
|
// 队列第二次 attempt 的 already exists 不能替换第一因;分类器保留首个
|
|
// 校验错误为永久失败,因此队列不会产生第二次自动 attempt。
|
|
first := errors.New("LIBRARYCTL_FAILED: unverified legacy library chunk index coverage;已执行 recover 并确认写入者恢复")
|
|
second := errors.New(`LIBRARYCTL_FAILED: job "lib-internal-20261105T054158" already exists with state "failed";已执行 recover 并确认写入者恢复`)
|
|
classified := terminalLibraryCaptureError(first)
|
|
if terminal, _ := jobs.Terminal(classified); !terminal {
|
|
t.Fatal("first validation error must terminate before retry")
|
|
}
|
|
if terminal, _ := jobs.Terminal(second); terminal {
|
|
t.Fatal("second retry error must not be terminal")
|
|
}
|
|
if !strings.Contains(classified.Error(), "unverified legacy library chunk index coverage") {
|
|
t.Fatalf("first cause lost: %v", classified)
|
|
}
|
|
}
|