test(testhealth): 替身竞态加锁 + 墙钟断言硬度(M33)
四处测试健康债务,只改 *_test.go,不动生产代码、不降并发: - channelbridge:stubChatter / stubSessions 的跨 goroutine 字段一律经 mu 访问 (Run/GetOrCreate 在车道 worker 上写、测试 goroutine 读,两者无 happens-before; 负向断言「等一会儿再看循环有没有被驱动」尤其如此)。读写走访问器,Messages() 返回副本;t.Parallel 与并发度不变。 - plugins/tools/io:claimProbeTimeout 2s(真实时间预算)→ 60s,并由 claimProbeWait 按 t.Deadline 收缩。探针只等 goroutine 被调度(无时间语义),放大余量把 「机器快慢」从断言里去掉,死锁仍以断言失败暴露。 - backthink:TestSelfWakeGate_WindowExpiry 窗口 120ms → 6s(给 waitFor 的 4s 上界 留 2s 余量),到期等待改为按首次受理时刻推算 window+250ms,不再盲睡 3×窗口。 另修 TestSelfWakeStatus_MatchesReceiptAndTracksPendingSlot:worker 先 take 再进 Think,卡 Think 并不占待跑槽 —— 改为「上一轮把 worker 占住再断言 Pending」。 - memory:墙钟实测用例显式给闸 5s 预算(measureGateBudget),不再因默认 150ms 超时 fail-open 打炸「每轮都真扫真判」前置断言;并把 GateFailed 纳入该断言。
This commit is contained in:
1 parent
da6a365222
commit
7d9b2132bb
18 files changed
+407
-242
No files matched your search
@@ -106,14 +106,14 @@ func TestColdShoulderCooldownMatrix(t *testing.T) {
|
||||
b := coldShoulderBridge(t, chat, hist, func() time.Time { return now })
|
||||
|
||||
b.process(context.Background(), coldShoulderMention("减少文本输出量"))
|
||||
if chat.sessionID != "" {
|
||||
t.Fatalf("未能进入冷却:循环被驱动 = %q", chat.sessionID)
|
||||
if chat.SessionID() != "" {
|
||||
t.Fatalf("未能进入冷却:循环被驱动 = %q", chat.SessionID())
|
||||
}
|
||||
before := len(hist.records())
|
||||
|
||||
b.process(context.Background(), tc.msg())
|
||||
|
||||
if got := chat.sessionID != ""; got != tc.wantReply {
|
||||
if got := chat.SessionID() != ""; got != tc.wantReply {
|
||||
t.Fatalf("冷却期内循环被驱动 = %v, want %v(%s)", got, tc.wantReply, tc.bite)
|
||||
}
|
||||
// 静默 ≠ 丢弃:本条必须已登记(被放行的那条在回合里另有一份落库)。
|
||||
@@ -140,16 +140,16 @@ func TestColdShoulderHighValueKeywordBaselineOutsideCooldown(t *testing.T) {
|
||||
b.process(context.Background(), coldShoulderMention("减少文本输出量")) // 进冷却
|
||||
now = now.Add(defaultCooldownDuration + time.Minute) // 推过冷却
|
||||
|
||||
chat.sessionID = ""
|
||||
chat.clearSessionID()
|
||||
b.process(context.Background(), nonOwnerGroupMsg("服务报错了"))
|
||||
if chat.sessionID != "sess-g" {
|
||||
t.Fatalf("冷却过后的高价值关键词未回:session = %q, want sess-g", chat.sessionID)
|
||||
if chat.SessionID() != "sess-g" {
|
||||
t.Fatalf("冷却过后的高价值关键词未回:session = %q, want sess-g", chat.SessionID())
|
||||
}
|
||||
|
||||
chat.sessionID = ""
|
||||
chat.clearSessionID()
|
||||
b.process(context.Background(), nonOwnerGroupMsg("今晚吃点什么"))
|
||||
if chat.sessionID != "" {
|
||||
t.Fatalf("冷却过后的普通消息不该被驱动:session = %q", chat.sessionID)
|
||||
if chat.SessionID() != "" {
|
||||
t.Fatalf("冷却过后的普通消息不该被驱动:session = %q", chat.SessionID())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user