test: 测试按行为命名、server 测试统一到 test/、PG 测试分组并行
- server 的 src/modules/*/__tests__ 挪到 test/<模块>/;e2e 去掉 eN- 前缀, w5a2 / v2 / search2 / *-dh1 / *-md1 / *-md2、web 的 agui3 / search2、domain 的 id2 / id3 改为按行为命名 - vitest 分三组:unit、pg(真实 PG + 假引擎,文件并行,最多 6 个)、serial(真实引擎 / worker / e2e,串行); pg 组用例超时放宽到 60s(迁移类用例并行时排队等 schema 锁)。server 测试 615s → 约 350s - CLAUDE.md 补测试约定;待办补 harness 去重与 continuous-series 偶发超时(疑似 Slot 评估竞争) - ADR-004 补充:维持 Deno,记录实际只用到 --allow-run 白名单 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b343dddbf6
commit
b61335eaf6
75 files changed
+159
-115
No files matched your search
@@ -1,11 +1,12 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
// 两组测试:
|
||||
// unit —— 纯内存、无 PG,文件并行;
|
||||
// pg —— 真实 PG 的集成/e2e(每文件独立业务 schema + 引擎 schema,真实 worker/后台循环),文件级串行,
|
||||
// 并排在 unit 之后(groupOrder)。并发全量跑时多个 e2e 的 worker/轮询/迁移互相抢 CPU 与连接,
|
||||
// 会把"入库→状态推进"这类时序拉长到超时,也会放大竞态;串行让每个文件拿到稳定的时序预算。
|
||||
// 新测试文件缺省归入 pg(串行,安全);确认不碰 PG 的才加进 UNIT。
|
||||
// 三组测试,按 groupOrder 依次跑:
|
||||
// unit —— 纯内存、无 PG,文件并行;
|
||||
// pg —— 真实 PG、假引擎(每文件独立 schema),文件并行;
|
||||
// serial —— 起真实引擎 / worker / 后台循环 / 子进程的集成与 e2e,文件级串行。并发跑时 worker、轮询、迁移
|
||||
// 互相抢 CPU 与连接,会把"入库→状态推进"这类时序拉长到超时,串行让每个文件拿到稳定的时序预算。
|
||||
// 新测试缺省进 pg;起真实 worker / 引擎的加进 SERIAL;确认不碰 PG 的加进 UNIT。
|
||||
// 并行文件数受开发库连接数约束(max_connections 100,每个 harness 连接池 5–10):MAX_WORKERS 别随手调大。
|
||||
const UNIT = [
|
||||
"test/api-registry.test.ts",
|
||||
"test/organize-in-place-verify.test.ts",
|
||||
@@ -22,23 +23,48 @@ const UNIT = [
|
||||
"test/static.test.ts",
|
||||
];
|
||||
|
||||
const SERIAL = [
|
||||
"test/e2e/**/*.test.ts",
|
||||
"test/auth-settings/admin-api.test.ts",
|
||||
"test/auth-settings/engine-retry.test.ts",
|
||||
"test/system/**/*.test.ts",
|
||||
"test/search/search.test.ts",
|
||||
"test/search/two-stage-search.test.ts",
|
||||
"test/worker-lanes.test.ts",
|
||||
"test/preflight.test.ts",
|
||||
"test/bootstrap.test.ts",
|
||||
];
|
||||
|
||||
const MAX_WORKERS = 6;
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
// 建/删 schema 在一把咨询锁上排队(withSchemaLock),迁移 + 引擎 schema 在负载下可能超过缺省 10s
|
||||
hookTimeout: 120_000,
|
||||
teardownTimeout: 60_000,
|
||||
maxWorkers: MAX_WORKERS,
|
||||
projects: [
|
||||
{ extends: true, test: { name: "unit", include: UNIT } },
|
||||
{
|
||||
extends: true,
|
||||
test: {
|
||||
name: "pg",
|
||||
include: ["test/**/*.test.ts", "src/**/*.test.ts"],
|
||||
exclude: UNIT,
|
||||
fileParallelism: false,
|
||||
include: ["test/**/*.test.ts"],
|
||||
exclude: [...UNIT, ...SERIAL],
|
||||
// 迁移类用例在用例体里建 schema + 迁移,并行时排队等同一把锁,缺省 5s 不够
|
||||
testTimeout: 60_000,
|
||||
sequence: { groupOrder: 1 },
|
||||
},
|
||||
},
|
||||
{
|
||||
extends: true,
|
||||
test: {
|
||||
name: "serial",
|
||||
include: SERIAL,
|
||||
fileParallelism: false,
|
||||
sequence: { groupOrder: 2 },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user