From 9e9cfba67dc4a0a050552aedd364d8436c7b4186 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sun, 22 Nov 2026 13:27:03 -0500 Subject: [PATCH] fix(tests): bound oxlint test threads, throttle export spin loop, align process-boundary workers, and use level-1 zlib in large synthetic fixtures (#13471) * fix(tests): bound oxlint test threads, throttle export spin loop, align process-boundary workers, and use level-1 zlib in large synthetic fixtures (#13357) * test(mcp): gate Evidence export cancellation before publication * test(ghidra): verify Java timeout after doctor settles --- src/rust/RustAuditableReader.test.ts | 4 +- .../filesystem/staticCheckReports.test.ts | 6 ++- tests/boundary/mcp/buildSecretsMcp.test.ts | 2 +- .../mcp/evidenceExportCancellation.test.ts | 50 ++++++++----------- .../evaluation/noBabelVisitorKeysRule.test.ts | 1 + tests/evaluation/noLocaleCompareRule.test.ts | 1 + tests/evaluation/noRawCdpSessionRule.test.ts | 1 + vitest.config.ts | 2 +- 8 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/rust/RustAuditableReader.test.ts b/src/rust/RustAuditableReader.test.ts index c7a6f83294..c4e9f511c5 100644 --- a/src/rust/RustAuditableReader.test.ts +++ b/src/rust/RustAuditableReader.test.ts @@ -286,7 +286,9 @@ it("names the padded-storage basis when a padded section overflows inflate alloc it("names the fixed cap when it bounds a large padded section's inflate allocation", () => { // Storage above 128 KiB derives more than the fixed 8 MiB cap, so the cap, // not the padded storage size, is the enforced bound. - const compressed = deflateSync(Buffer.alloc(9 * 1024 * 1024, 0x20)); + const compressed = deflateSync(Buffer.alloc(9 * 1024 * 1024, 0x20), { + level: 1, + }); const fileAlignment = 512; const stored = Buffer.alloc(132 * 1024); compressed.copy(stored); diff --git a/tests/boundary/filesystem/staticCheckReports.test.ts b/tests/boundary/filesystem/staticCheckReports.test.ts index 67c0e8297d..fa099b632a 100644 --- a/tests/boundary/filesystem/staticCheckReports.test.ts +++ b/tests/boundary/filesystem/staticCheckReports.test.ts @@ -61,7 +61,11 @@ const lintDiagnostics = async (root: string) => it("covers the lint inventory and root tool configs in resolved cache inputs", () => { const scan = spawnSync( process.execPath, - [join(repository, "node_modules/oxlint/bin/oxlint"), "--debug=files"], + [ + join(repository, "node_modules/oxlint/bin/oxlint"), + "--threads=1", + "--debug=files", + ], { cwd: repository, encoding: "utf8", timeout: 15_000 }, ); expect(scan.error).toBeUndefined(); diff --git a/tests/boundary/mcp/buildSecretsMcp.test.ts b/tests/boundary/mcp/buildSecretsMcp.test.ts index 4e683bf42e..ae2b3c2237 100644 --- a/tests/boundary/mcp/buildSecretsMcp.test.ts +++ b/tests/boundary/mcp/buildSecretsMcp.test.ts @@ -395,7 +395,7 @@ it("refuses a gzip file that expands past what REA checks for known secrets", as Buffer.from(`token=${token}\n`), Buffer.alloc(65 * 1024 * 1024), ]); - await writeFile(join(seed, "large.txt.gz"), gzipSync(inside)); + await writeFile(join(seed, "large.txt.gz"), gzipSync(inside, { level: 1 })); const directory = join(await createTestTempDirectory("build-out-"), "notes"); const refused = await client.callTool({ name: "export_build_environment", diff --git a/tests/boundary/mcp/evidenceExportCancellation.test.ts b/tests/boundary/mcp/evidenceExportCancellation.test.ts index 326f28f775..6cdbd2daf9 100644 --- a/tests/boundary/mcp/evidenceExportCancellation.test.ts +++ b/tests/boundary/mcp/evidenceExportCancellation.test.ts @@ -2,14 +2,15 @@ import { unknownTarget } from "../../../src/domain/targetIdentity.js"; import { Client, InMemoryTransport } from "@modelcontextprotocol/client"; import { readdir, readFile, stat, writeFile } from "node:fs/promises"; import { join } from "node:path"; -import { setImmediate } from "node:timers/promises"; -import { expect, it, onTestFinished } from "vitest"; +import { expect, it, onTestFinished, vi } from "vitest"; import { readEvidenceBundle } from "../../../src/application/EvidenceBundleFiles.js"; import { createEvidence } from "../../../src/domain/evidence.js"; +import { OwnedStagedOutput } from "../../../src/filesystem/OwnedStagedOutput.js"; import { createServer } from "../../../src/server/createServer.js"; import { createTestBinarySession } from "../../fixtures/binarySession.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; import { createMcpSchemaValidation } from "../../fixtures/mcpSchemaValidation.js"; +import { phaseGate } from "../../support/lifecycleHarness.js"; it.each([false, true])( "stops an SDK export cancellation before publication and keeps the same session usable (overwrite: %s)", @@ -24,9 +25,9 @@ it.each([false, true])( unknownTarget("not-observed"), { id: "fixture", name: "Fixture", version: "1" }, { - operation: "large_observation", + operation: "fixture_observation", parameters: {}, - result: { observed: "雪😀".repeat(1024 * 1024) }, + result: { observed: "雪😀" }, }, ); expect(session.recordEvidence(evidence).ok).toBe(true); @@ -39,8 +40,10 @@ it.each([false, true])( { jsonSchemaValidator: createMcpSchemaValidation() }, ); const controller = new AbortController(); + const stagedWrite = phaseGate(); onTestFinished(async () => { controller.abort(); + stagedWrite.release(); await client.close(); await server.close(); await session.close(); @@ -49,6 +52,14 @@ it.each([false, true])( InMemoryTransport.createLinkedPair(); await server.connect(serverTransport); await client.connect(clientTransport); + const closeFile = OwnedStagedOutput.prototype.closeFile; + const stagedClose = vi + .spyOn(OwnedStagedOutput.prototype, "closeFile") + .mockImplementationOnce(async function (this: OwnedStagedOutput) { + await closeFile.call(this); + await stagedWrite.hold(this.directory); + }); + onTestFinished(() => stagedClose.mockRestore()); const cancellation = client .callTool( { name: "export_evidence_bundle", arguments: { path, overwrite } }, @@ -58,34 +69,17 @@ it.each([false, true])( () => "completed", (error: unknown) => error, ); - // Observe actual staged bytes, rather than only a locally rejected promise. - const deadline = performance.now() + 5000; - let stagedBytes = 0; - while (stagedBytes === 0 && performance.now() < deadline) { - const staging = (await readdir(root)).find((name) => - name.startsWith(".rea-write-"), - ); - if (staging !== undefined) { - const staged = await stat(join(root, staging, "content")).catch( - (cause: unknown) => { - if ( - cause instanceof Error && - "code" in cause && - cause.code === "ENOENT" - ) - return undefined; - throw cause; - }, - ); - stagedBytes = staged?.size ?? 0; - } - await setImmediate(); - } - expect(stagedBytes).toBeGreaterThan(0); + const directory = await stagedWrite.reached( + cancellation, + "staged file close", + ); + expect((await stat(join(directory, "content"))).size).toBeGreaterThan(0); controller.abort(new Error("SDK export cancellation verification")); expect(await cancellation).toMatchObject({ message: expect.stringContaining("SDK export cancellation verification"), }); + await client.ping(); + stagedWrite.release(); await expect .poll(() => readdir(root)) .toEqual(overwrite ? ["bundle.json"] : []); diff --git a/tests/evaluation/noBabelVisitorKeysRule.test.ts b/tests/evaluation/noBabelVisitorKeysRule.test.ts index c650a69395..002c3a6f30 100644 --- a/tests/evaluation/noBabelVisitorKeysRule.test.ts +++ b/tests/evaluation/noBabelVisitorKeysRule.test.ts @@ -61,6 +61,7 @@ it("limits the shared Babel child expansion exception to its owner", async () => process.execPath, [ resolve("node_modules/oxlint/bin/oxlint"), + "--threads=1", "-c", config, "--format", diff --git a/tests/evaluation/noLocaleCompareRule.test.ts b/tests/evaluation/noLocaleCompareRule.test.ts index ec89a3005c..028417d0d4 100644 --- a/tests/evaluation/noLocaleCompareRule.test.ts +++ b/tests/evaluation/noLocaleCompareRule.test.ts @@ -42,6 +42,7 @@ it("applies the ordering rule to domain production files and excludes tests", as process.execPath, [ resolve("node_modules/oxlint/bin/oxlint"), + "--threads=1", "-c", config, "--format", diff --git a/tests/evaluation/noRawCdpSessionRule.test.ts b/tests/evaluation/noRawCdpSessionRule.test.ts index 1f1a4a7323..32f9ff5367 100644 --- a/tests/evaluation/noRawCdpSessionRule.test.ts +++ b/tests/evaluation/noRawCdpSessionRule.test.ts @@ -61,6 +61,7 @@ it("allows raw Playwright CDP sessions only in their owner and tests, including process.execPath, [ resolve("node_modules/oxlint/bin/oxlint"), + "--threads=1", "-c", config, "--format", diff --git a/vitest.config.ts b/vitest.config.ts index c27ffe1756..db53389f1a 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -108,7 +108,7 @@ const PROJECT_POLICIES = { }, "process-boundary": { pool: "forks" as const, - maxWorkers: MAX_TEST_WORKERS, + maxWorkers: 1, // Process-tree observations share host sampling resources; keep this small // lane serial while the independent projects run together. fileParallelism: false,