mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-07 10:34:44 +00:00
chore(deadcode): prune stale test hooks
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user