diff --git a/docs/help/testing.md b/docs/help/testing.md index 485d89176b..6b22cd5dc4 100644 --- a/docs/help/testing.md +++ b/docs/help/testing.md @@ -62,6 +62,13 @@ Think of the suites as “increasing realism” (and increasing flakiness/cost): - Command: `pnpm test:e2e` - Config: `vitest.e2e.config.ts` - Files: `src/**/*.e2e.test.ts` +- Runtime defaults: + - Uses Vitest `vmForks` for faster file startup. + - Uses adaptive workers (CI: 2-4, local: 4-8). + - Runs in silent mode by default to reduce console I/O overhead. +- Useful overrides: + - `OPENCLAW_E2E_WORKERS=` to force worker count (capped at 16). + - `OPENCLAW_E2E_VERBOSE=1` to re-enable verbose console output. - Scope: - Multi-instance gateway end-to-end behavior - WebSocket/HTTP surfaces, node pairing, and heavier networking diff --git a/docs/reference/test.md b/docs/reference/test.md index 651b739572..ad22d7bc8e 100644 --- a/docs/reference/test.md +++ b/docs/reference/test.md @@ -12,7 +12,7 @@ title: "Tests" - `pnpm test:force`: Kills any lingering gateway process holding the default control port, then runs the full Vitest suite with an isolated gateway port so server tests don’t collide with a running instance. Use this when a prior gateway run left port 18789 occupied. - `pnpm test:coverage`: Runs Vitest with V8 coverage. Global thresholds are 70% lines/branches/functions/statements. Coverage excludes integration-heavy entrypoints (CLI wiring, gateway/telegram bridges, webchat static server) to keep the target focused on unit-testable logic. - `pnpm test` on Node 24+: OpenClaw auto-disables Vitest `vmForks` and uses `forks` to avoid `ERR_VM_MODULE_LINK_FAILURE` / `module is already linked`. You can force behavior with `OPENCLAW_TEST_VM_FORKS=0|1`. -- `pnpm test:e2e`: Runs gateway end-to-end smoke tests (multi-instance WS/HTTP/node pairing). +- `pnpm test:e2e`: Runs gateway end-to-end smoke tests (multi-instance WS/HTTP/node pairing). Defaults to `vmForks` + adaptive workers in `vitest.e2e.config.ts`; tune with `OPENCLAW_E2E_WORKERS=` and set `OPENCLAW_E2E_VERBOSE=1` for verbose logs. - `pnpm test:live`: Runs provider live tests (minimax/zai). Requires API keys and `LIVE=1` (or provider-specific `*_LIVE_TEST=1`) to unskip. ## Model latency bench (local keys) diff --git a/vitest.e2e.config.ts b/vitest.e2e.config.ts index da382ce6fe..0e395202a6 100644 --- a/vitest.e2e.config.ts +++ b/vitest.e2e.config.ts @@ -4,7 +4,15 @@ import baseConfig from "./vitest.config.ts"; const isCI = process.env.CI === "true" || process.env.GITHUB_ACTIONS === "true"; const cpuCount = os.cpus().length; -const e2eWorkers = isCI ? 2 : Math.min(4, Math.max(1, Math.floor(cpuCount * 0.25))); +const defaultWorkers = isCI + ? Math.min(4, Math.max(2, Math.floor(cpuCount * 0.5))) + : Math.min(8, Math.max(4, Math.floor(cpuCount * 0.6))); +const requestedWorkers = Number.parseInt(process.env.OPENCLAW_E2E_WORKERS ?? "", 10); +const e2eWorkers = + Number.isFinite(requestedWorkers) && requestedWorkers > 0 + ? Math.min(16, requestedWorkers) + : defaultWorkers; +const verboseE2E = process.env.OPENCLAW_E2E_VERBOSE === "1"; const baseTest = (baseConfig as { test?: { exclude?: string[] } }).test ?? {}; const exclude = (baseTest.exclude ?? []).filter((p) => p !== "**/*.e2e.test.ts"); @@ -13,7 +21,9 @@ export default defineConfig({ ...baseConfig, test: { ...baseTest, + pool: "vmForks", maxWorkers: e2eWorkers, + silent: !verboseE2E, include: ["test/**/*.e2e.test.ts", "src/**/*.e2e.test.ts"], exclude, },