From 3f0bb280724a08009d95cfaf15cebf8dfe6f88ad Mon Sep 17 00:00:00 2001 From: weichen Date: Sat, 12 Sep 2026 05:27:25 +0000 Subject: [PATCH] test(e2e): extend pi-agent lifecycle timeout to 1h Allow long-running ad-hoc pi-agent steps by raising the HTTP client limit and documenting the 1h go test invocation. Co-authored-by: Cursor --- internal/server/piagent_e2e_test.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/internal/server/piagent_e2e_test.go b/internal/server/piagent_e2e_test.go index b6427d86..60ee9820 100644 --- a/internal/server/piagent_e2e_test.go +++ b/internal/server/piagent_e2e_test.go @@ -22,6 +22,10 @@ import ( // TestPiAgent_FullLifecycle_MultiRole_RealWorld_E2E // 贯穿:新建项目 -> 角色权限配置 -> 分角色材料补充与真实对话 -> 自由非标任务执行 -> 工作流推进 -> 审核驳回/再批 -> 数据库落盘与全量审计追溯 +// +// 运行方式(需 pi-agent runner 在线,建议 1h 超时): +// +// go test ./internal/server/ -run TestPiAgent_FullLifecycle -timeout 1h -v func TestPiAgent_FullLifecycle_MultiRole_RealWorld_E2E(t *testing.T) { if testing.Short() { t.Skip("skipping slow real-world E2E test in short mode") @@ -42,8 +46,15 @@ func TestPiAgent_FullLifecycle_MultiRole_RealWorld_E2E(t *testing.T) { ts := httptest.NewServer(srv.Routes()) defer ts.Close() - client := &http.Client{Timeout: 10 * time.Minute} + // 单次 pi-agent 远程调用可能超过 10min;HTTP client 留 50min 余量,整体由 go test -timeout 1h 兜底。 + client := &http.Client{Timeout: 50 * time.Minute} ctx := context.Background() + stepStart := time.Now() + logStep := func(label string) { + elapsed := time.Since(stepStart).Round(time.Second) + t.Logf("⏱ [%s] 累计耗时 %s", label, elapsed) + stepStart = time.Now() + } // 2. 验证 Health 确认 AgentBackend 为 pi-agent respHealth, err := client.Get(ts.URL + "/api/v1/health") @@ -114,6 +125,7 @@ func TestPiAgent_FullLifecycle_MultiRole_RealWorld_E2E(t *testing.T) { // 4.2 业务补充与立项需求对话 intakeReply := postChat("我们准备正式立项 CUSA-Ultra 项目,刀头频率设定为 24kHz 与 35kHz 双频,具备实时灌注与负压吸引,满足神经外科浅脑肿瘤切除,请问法规应关注哪些强标?", authorID, authorName, "author") t.Logf("✓ [张工-立项需求对话] 协同参谋答复:\n%s", intakeReply) + logStep("步骤 1 对话完成") // 5. 推进成熟度工作流 V0.1: 立项摸底 (intake) t.Log("--------------------------------------------------------------------------------") @@ -160,6 +172,7 @@ func TestPiAgent_FullLifecycle_MultiRole_RealWorld_E2E(t *testing.T) { if targetDocID == "" { targetDocID = fmt.Sprintf("doc_proj%d_intake_v1", projectID) } + logStep("步骤 2 V0.1 阶段完成") // 6. 推进自由非标任务 (Free Ad-Hoc Task): 24kHz 高频空化钛合金刀头微裂纹与疲劳剥落风险专项分析报告 t.Log("--------------------------------------------------------------------------------") @@ -214,9 +227,16 @@ func TestPiAgent_FullLifecycle_MultiRole_RealWorld_E2E(t *testing.T) { ArtifactTitle string `json:"artifact_title"` WorkDir string `json:"work_dir"` } + if freeResp.StatusCode != http.StatusOK { + t.Fatalf("run free task HTTP %d", freeResp.StatusCode) + } _ = json.NewDecoder(freeResp.Body).Decode(&freeRes) freeResp.Body.Close() - t.Logf("✓ [自由非标任务完成] 任务成功=%v, 交付物=[%s]", freeRes.Success, freeRes.ArtifactTitle) + if !freeRes.Success { + t.Fatalf("free ad-hoc task failed: artifact=%q work_dir=%q", freeRes.ArtifactTitle, freeRes.WorkDir) + } + t.Logf("✓ [自由非标任务完成] 任务成功=%v, 交付物=[%s], work_dir=%s", freeRes.Success, freeRes.ArtifactTitle, freeRes.WorkDir) + logStep("步骤 3 自由非标任务完成") // 7. 若开启全量阶段环境变量 (RUN_HEAVY_STAGES=1),则继续演练 V0.5 与 V1.0 if os.Getenv("RUN_HEAVY_STAGES") == "1" {