mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-05 22:32:12 +00:00
perf(test): refresh extension memory hotspots from gh logs (#60159)
This commit is contained in:
@@ -253,6 +253,34 @@ describe("scripts/test-parallel memory trace parsing", () => {
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("parses memory trace summaries from gh run job logs", () => {
|
||||
const summaries = parseMemoryTraceSummaryLines(
|
||||
[
|
||||
"checks-fast-extensions-6\tRun extensions (node)\t2026-04-03T04:07:10.5924943Z [test-parallel][mem] summary extensions-batch-22-shard-6 files=15 peak=2.66GiB totalDelta=+470.5MiB peakAt=poll top=extensions/microsoft-foundry/index.test.ts:+1.35GiB, extensions/acpx/src/service.test.ts:+212.1MiB",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
expect(summaries).toEqual([
|
||||
{
|
||||
lane: "extensions-batch-22-shard-6",
|
||||
files: 15,
|
||||
peakRssKb: parseMemoryValueKb("2.66GiB"),
|
||||
totalDeltaKb: parseMemoryValueKb("+470.5MiB"),
|
||||
peakAt: "poll",
|
||||
top: [
|
||||
{
|
||||
file: "extensions/microsoft-foundry/index.test.ts",
|
||||
deltaKb: parseMemoryValueKb("+1.35GiB"),
|
||||
},
|
||||
{
|
||||
file: "extensions/acpx/src/service.test.ts",
|
||||
deltaKb: parseMemoryValueKb("+212.1MiB"),
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("scripts/test-parallel lane planning", () => {
|
||||
|
||||
@@ -207,6 +207,38 @@ describe("test planner", () => {
|
||||
artifacts.cleanupTempArtifacts();
|
||||
});
|
||||
|
||||
it("auto-isolates newly-seeded extension memory survivors in CI", () => {
|
||||
const env = {
|
||||
CI: "true",
|
||||
GITHUB_ACTIONS: "true",
|
||||
RUNNER_OS: "Linux",
|
||||
OPENCLAW_TEST_HOST_CPU_COUNT: "4",
|
||||
OPENCLAW_TEST_HOST_MEMORY_GIB: "16",
|
||||
};
|
||||
const artifacts = createExecutionArtifacts(env);
|
||||
const plan = buildExecutionPlan(
|
||||
{
|
||||
profile: null,
|
||||
mode: "ci",
|
||||
surfaces: ["extensions"],
|
||||
passthroughArgs: [],
|
||||
},
|
||||
{
|
||||
env,
|
||||
platform: "linux",
|
||||
writeTempJsonArtifact: artifacts.writeTempJsonArtifact,
|
||||
},
|
||||
);
|
||||
|
||||
const hotspotFile = bundledPluginFile("bluebubbles", "src/send.test.ts");
|
||||
const hotspotUnit = plan.selectedUnits.find((unit) => unit.args.includes(hotspotFile));
|
||||
|
||||
expect(hotspotUnit).toBeTruthy();
|
||||
expect(hotspotUnit?.isolate).toBe(true);
|
||||
expect(hotspotUnit?.reasons).toContain("extensions-memory-heavy");
|
||||
artifacts.cleanupTempArtifacts();
|
||||
});
|
||||
|
||||
it("auto-isolates timed-heavy channel suites in CI", () => {
|
||||
const env = {
|
||||
CI: "true",
|
||||
|
||||
48
test/scripts/test-update-memory-hotspots-sources.test.ts
Normal file
48
test/scripts/test-update-memory-hotspots-sources.test.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { loadHotspotInputTexts } from "../../scripts/test-update-memory-hotspots-sources.mjs";
|
||||
|
||||
const tempFiles = [];
|
||||
|
||||
afterEach(() => {
|
||||
for (const tempFile of tempFiles.splice(0)) {
|
||||
try {
|
||||
fs.unlinkSync(tempFile);
|
||||
} catch {
|
||||
// Ignore temp cleanup races in tests.
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
describe("test-update-memory-hotspots source loading", () => {
|
||||
it("loads local log files with basename-derived source names", () => {
|
||||
const tempLog = path.join(os.tmpdir(), `openclaw-hotspots-${Date.now()}.log`);
|
||||
tempFiles.push(tempLog);
|
||||
fs.writeFileSync(tempLog, "local log");
|
||||
|
||||
expect(loadHotspotInputTexts({ logPaths: [tempLog] })).toEqual([
|
||||
{ sourceName: path.basename(tempLog, ".log"), text: "local log" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("loads GitHub Actions job logs through gh", () => {
|
||||
const execFileSyncImpl = vi.fn(() => "remote log");
|
||||
|
||||
expect(
|
||||
loadHotspotInputTexts({
|
||||
ghJobs: ["69804189668"],
|
||||
execFileSyncImpl,
|
||||
}),
|
||||
).toEqual([{ sourceName: "gh-job-69804189668", text: "remote log" }]);
|
||||
expect(execFileSyncImpl).toHaveBeenCalledWith(
|
||||
"gh",
|
||||
["run", "view", "--job", "69804189668", "--log"],
|
||||
{
|
||||
encoding: "utf8",
|
||||
maxBuffer: 64 * 1024 * 1024,
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user