fix(acceptance): 隔离控制面抖动与租约瞬态故障
线上 P24 验收暴露出高频 kubectl exec 放大 K3s API 压力、门禁查询挤占关键连接池,以及 PostgreSQL 锁超时被误判为租约所有权丢失。 本次合并验收身份查询、在租约有效期内重试瞬态续期错误、修复人工审核残留 attempt,并增加滚动后 etcd 稳定窗口、节点直连指标和双站独立报告。 验证:Go 全量测试、go vet、聚焦 race、gofmt、迁移安全检查、bash -n、ShellCheck、manual release test。
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/easyai/easyai-ai-gateway/apps/api/internal/store"
|
||||
)
|
||||
|
||||
func TestLeaseRenewalFatalityDistinguishesTransientDatabaseErrors(t *testing.T) {
|
||||
now := time.Now()
|
||||
deadline := now.Add(time.Minute)
|
||||
transient := errors.New("lock timeout")
|
||||
if taskExecutionLeaseRenewalIsFatal(transient, now, deadline) {
|
||||
t.Fatal("transient task lease renewal error must be retried before expiry")
|
||||
}
|
||||
if concurrencyLeaseRenewalIsFatal(transient, now, deadline) {
|
||||
t.Fatal("transient concurrency lease renewal error must be retried before expiry")
|
||||
}
|
||||
if !taskExecutionLeaseRenewalIsFatal(store.ErrTaskExecutionLeaseLost, now, deadline) {
|
||||
t.Fatal("confirmed task lease ownership loss must be fatal")
|
||||
}
|
||||
if !concurrencyLeaseRenewalIsFatal(store.ErrConcurrencyLeaseLost, now, deadline) {
|
||||
t.Fatal("confirmed concurrency lease ownership loss must be fatal")
|
||||
}
|
||||
if !taskExecutionLeaseRenewalIsFatal(transient, deadline, deadline) {
|
||||
t.Fatal("task lease renewal error at expiry must be fatal")
|
||||
}
|
||||
if !concurrencyLeaseRenewalIsFatal(transient, deadline, deadline) {
|
||||
t.Fatal("concurrency lease renewal error at expiry must be fatal")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user