mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 18:24:57 +00:00
perf(test): reduce setup churn in block streaming and docker tests
This commit is contained in:
@@ -2,7 +2,6 @@ import fs from "node:fs/promises";
|
|||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import { withTempHome as withTempHomeBase } from "../../test/helpers/temp-home.js";
|
|
||||||
import { loadModelCatalog } from "../agents/model-catalog.js";
|
import { loadModelCatalog } from "../agents/model-catalog.js";
|
||||||
import { getReplyFromConfig } from "./reply.js";
|
import { getReplyFromConfig } from "./reply.js";
|
||||||
|
|
||||||
@@ -95,7 +94,12 @@ describe("block streaming", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await fs.rm(fixtureRoot, { recursive: true, force: true });
|
await fs.rm(fixtureRoot, {
|
||||||
|
recursive: true,
|
||||||
|
force: true,
|
||||||
|
maxRetries: 10,
|
||||||
|
retryDelay: 50,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -263,13 +267,9 @@ describe("block streaming", () => {
|
|||||||
|
|
||||||
expect(resStreamMode?.text).toBe("final");
|
expect(resStreamMode?.text).toBe("final");
|
||||||
expect(onBlockReplyStreamMode).not.toHaveBeenCalled();
|
expect(onBlockReplyStreamMode).not.toHaveBeenCalled();
|
||||||
});
|
vi.useFakeTimers();
|
||||||
});
|
try {
|
||||||
|
piEmbeddedMock.runEmbeddedPiAgent.mockReset();
|
||||||
it("queues followups for collect + summarize modes", async () => {
|
|
||||||
vi.useFakeTimers();
|
|
||||||
await withTempHomeBase(
|
|
||||||
async (home) => {
|
|
||||||
const prompts: string[] = [];
|
const prompts: string[] = [];
|
||||||
piEmbeddedMock.runEmbeddedPiAgent.mockImplementation(async (params) => {
|
piEmbeddedMock.runEmbeddedPiAgent.mockImplementation(async (params) => {
|
||||||
prompts.push(params.prompt);
|
prompts.push(params.prompt);
|
||||||
@@ -357,8 +357,9 @@ describe("block streaming", () => {
|
|||||||
await vi.advanceTimersByTimeAsync(50);
|
await vi.advanceTimersByTimeAsync(50);
|
||||||
await Promise.resolve();
|
await Promise.resolve();
|
||||||
expect(prompts.some((p) => p.includes("[Queue overflow]"))).toBe(true);
|
expect(prompts.some((p) => p.includes("[Queue overflow]"))).toBe(true);
|
||||||
},
|
} finally {
|
||||||
{ prefix: "openclaw-queue-" },
|
vi.useRealTimers();
|
||||||
);
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -152,19 +152,12 @@ describe("docker-setup.sh", () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sandbox = await createDockerSetupSandbox();
|
const syntaxCheck = spawnSync(systemBash, ["-n", join(repoRoot, "docker-setup.sh")], {
|
||||||
const env = createEnv(sandbox, {
|
|
||||||
OPENCLAW_EXTRA_MOUNTS: "",
|
|
||||||
OPENCLAW_HOME_VOLUME: "",
|
|
||||||
});
|
|
||||||
const result = spawnSync(systemBash, [sandbox.scriptPath], {
|
|
||||||
cwd: sandbox.rootDir,
|
|
||||||
env,
|
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.status).toBe(0);
|
expect(syntaxCheck.status).toBe(0);
|
||||||
expect(result.stderr).not.toContain("declare: -A: invalid option");
|
expect(syntaxCheck.stderr).not.toContain("declare: -A: invalid option");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps docker-compose gateway command in sync", async () => {
|
it("keeps docker-compose gateway command in sync", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user