test: server 测试共用建库与假引擎,sse-pg 归入串行组
- 新增 apps/server/test/support/{pg,engine}.ts:测试库地址、可用性探测、schema 咨询锁、
建 schema + 加锁迁移 + 删除、可选去重的假引擎;6 份 harness 改用它(acquisition-organize 与
file-manager 原先迁移不加锁,并行下有冲突隐患,一并修正)
- sse-pg 起子进程,并行下子进程启动超时,归入 serial
- 修正 b61335e 挪动 / 改名测试后遗留的 import 排序与格式(当时 lint 检查经管道被吞掉退出码)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
7cc3742d31
commit
c9e8120fc6
25 files changed
+254
-328
No files matched your search
@@ -0,0 +1,48 @@
|
||||
// 只记录入队、不执行的假引擎(处理器由测试直接调服务函数)。
|
||||
import { randomUUID } from "node:crypto";
|
||||
import type { TaskEngine } from "@umt/tasks";
|
||||
|
||||
export interface Enqueued {
|
||||
task: string;
|
||||
input: unknown;
|
||||
key: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* dedupe:同一幂等键只记一次并返回 deduplicated(贴近真实引擎);缺省每次都记,runId 为 run-1、run-2…
|
||||
*/
|
||||
export function fakeEngine(opts: { dedupe?: boolean } = {}): TaskEngine & { enqueued: Enqueued[] } {
|
||||
const enqueued: Enqueued[] = [];
|
||||
const keys = new Set<string>();
|
||||
let n = 0;
|
||||
return {
|
||||
enqueued,
|
||||
async enqueue(task, input, o) {
|
||||
if (opts.dedupe) {
|
||||
const dup = keys.has(o.idempotencyKey);
|
||||
if (!dup) {
|
||||
keys.add(o.idempotencyKey);
|
||||
enqueued.push({ task, input, key: o.idempotencyKey });
|
||||
}
|
||||
return { runId: randomUUID(), deduplicated: dup };
|
||||
}
|
||||
enqueued.push({ task, input, key: o.idempotencyKey });
|
||||
n++;
|
||||
return { runId: `run-${n}`, deduplicated: false };
|
||||
},
|
||||
async signal() {
|
||||
return { delivered: 0 };
|
||||
},
|
||||
async cancel() {
|
||||
return false;
|
||||
},
|
||||
async get() {
|
||||
return null;
|
||||
},
|
||||
async list() {
|
||||
return [];
|
||||
},
|
||||
async startWorker() {},
|
||||
async stop() {},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user