chore(deadcode): prune stale test hooks

This commit is contained in:
Vincent Koc
2026-06-22 08:47:10 +08:00
parent dd89898133
commit fe7b78b05f
6 changed files with 31 additions and 39 deletions

View File

@@ -7,8 +7,31 @@ import path from "node:path";
import { performance } from "node:perf_hooks";
import { beforeAll, describe, expect, it } from "vitest";
import { testing } from "../../scripts/bench-gateway-restart.ts";
import type { DB as OpenClawStateKyselyDatabase } from "../../src/state/openclaw-state-db.generated.js";
import {
closeOpenClawStateDatabaseForTest,
openOpenClawStateDatabase,
} from "../../src/state/openclaw-state-db.js";
import {
executeSqliteQueryTakeFirstSync,
getNodeSqliteKysely,
} from "../../src/infra/kysely-sync.js";
import { registerStopChildBehaviorTests } from "./bench-gateway-child-test-support.js";
type GatewayRestartIntentDatabase = Pick<OpenClawStateKyselyDatabase, "gateway_restart_intent">;
function readRestartIntentRow(env: NodeJS.ProcessEnv) {
const { db } = openOpenClawStateDatabase({ env });
const stateDb = getNodeSqliteKysely<GatewayRestartIntentDatabase>(db);
return executeSqliteQueryTakeFirstSync(
db,
stateDb
.selectFrom("gateway_restart_intent")
.select(["intent_key", "kind", "pid", "reason"])
.where("intent_key", "=", "gateway-restart"),
);
}
describe("gateway restart benchmark script", () => {
let helpResult: ReturnType<typeof spawnSync>;
@@ -673,17 +696,16 @@ node 1234 user 12u IPv4 0t0 TCP localhost:1234
const env = { OPENCLAW_STATE_DIR: path.join(root, "state") };
expect(testing.writeRestartIntent(env, 12345, "gateway-restart-bench")).toBe(true);
const raw = fs.readFileSync(path.join(root, "state", "gateway-restart-intent.json"), "utf8");
const parsed = JSON.parse(raw) as {
kind?: unknown;
pid?: unknown;
reason?: unknown;
};
const row = readRestartIntentRow(env);
expect(parsed.kind).toBe("gateway-restart");
expect(parsed.pid).toBe(12345);
expect(parsed.reason).toBe("gateway-restart-bench");
expect(row).toMatchObject({
intent_key: "gateway-restart",
kind: "gateway-restart",
pid: 12345,
reason: "gateway-restart-bench",
});
} finally {
closeOpenClawStateDatabaseForTest();
fs.rmSync(root, { force: true, recursive: true });
}
});