From a7d6625aebd3efbf9f37c863001a40b6d11a8772 Mon Sep 17 00:00:00 2001 From: xiaoyi Date: Tue, 22 Sep 2026 09:57:58 +0800 Subject: [PATCH] =?UTF-8?q?test(distill):=20mock=20LLM=20=E6=8C=89=20path?= =?UTF-8?q?=20=E5=8C=BA=E5=88=86=E6=A7=BD=E4=BD=8D=E6=8E=A2=E6=B5=8B?= =?UTF-8?q?=E4=B8=8E=E8=92=B8=E9=A6=8F=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:19afe3b 引入 probeLLMSlots(GET /props 探本地 2B 槽位),而 mock LLM 的 handler 不检查 path、对任何请求都 calls++ ⇒ 断言「B 触发后恰好 base+1 次 LLM 调用」 被 flush 前后的两次探测撑成 base+3,TestCommitConflictGate_E2E 恒 FAIL。 修法:mock 对 /props 返回 {"total_slots":1} 且不计数 —— 探测不是「蒸馏 LLM 调用」。 不放松断言(判据本身是对的,是 mock 口径错了)。 验证:TestCommitConflictGate_E2E PASS;该包 go test 全绿。 --- go/internal/api/routes/zz_commit_conflict_gate_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/go/internal/api/routes/zz_commit_conflict_gate_test.go b/go/internal/api/routes/zz_commit_conflict_gate_test.go index a26a12d..ae8a89c 100644 --- a/go/internal/api/routes/zz_commit_conflict_gate_test.go +++ b/go/internal/api/routes/zz_commit_conflict_gate_test.go @@ -166,6 +166,14 @@ type mockLLM struct { func newMockLLM() *mockLLM { m := &mockLLM{} m.server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // 2026-09-22 修:槽位探测(probeLLMSlots,GET /props)不是"蒸馏 LLM 调用", + // 不能计入 calls —— 否则 A/B 批次断言(期望 base+1)会被 flush 前后的 + // 两次探测撑成 base+3。根因:5e2cc63 引入并发槽位探测后,本 mock 未按 path 区分。 + if r.URL.Path == "/props" { + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(map[string]any{"total_slots": 1}) + return + } atomic.AddInt32(&m.calls, 1) w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(map[string]any{