diff --git a/tests/system/ci-runner/ci-artifact-contract.test.ts b/tests/system/ci-runner/ci-artifact-contract.test.ts index ec92a221..1eefff9a 100644 --- a/tests/system/ci-runner/ci-artifact-contract.test.ts +++ b/tests/system/ci-runner/ci-artifact-contract.test.ts @@ -6,7 +6,7 @@ import { tmpdir } from "node:os"; import path from "node:path"; import { setTimeout as delay } from "node:timers/promises"; -import { afterAll, afterEach, describe, expect, it } from "vitest"; +import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; import type { CiGateArtifact, @@ -62,6 +62,11 @@ import { * default instead would hide a genuinely hung test. */ const PROCESS_HEAVY_TIMEOUT_MS = 30_000; +/** + * The provider base fixture runs `build:release-candidate`, bounded at 120s + * (ensureProviderBaseFixture), and then copies and archives the result. + */ +const PROVIDER_BASE_FIXTURE_TIMEOUT_MS = 180_000; const temporaryRoots: string[] = []; let providerBaseRoot: string | undefined; @@ -448,7 +453,16 @@ describe("CI artifact validator", () => { }); }); -describe("candidate archive and provider upload boundaries", () => { +// 1103/11-03. Every test here spawns a provider launch chain or copies the +// release-candidate fixture, so the whole block runs on the provider budget; +// eight tests were still on the 10s unit default and timed out under load. +// The base fixture is built once in beforeAll, on its own ceiling, so a test +// selected alone with -t no longer pays for the build inside its own budget. +describe("candidate archive and provider upload boundaries", { timeout: PROCESS_HEAVY_TIMEOUT_MS }, () => { + beforeAll(async () => { + await ensureProviderBaseFixture(); + }, PROVIDER_BASE_FIXTURE_TIMEOUT_MS); + it("accepts only the manifest-bound candidate member set and bytes", async () => { const fixture = await createCandidateArchiveFixture(); await expect( @@ -601,7 +615,7 @@ describe("candidate archive and provider upload boundaries", () => { providerValidationInput(fixture, Buffer.from(`${JSON.stringify(report)}\n`)), ), ).rejects.toThrow(/candidate identity mismatch/i); - }, 30_000); + }); it("uses the reverified archive manifest when extracted candidate files are mutated", async () => { const fixture = await createProviderFixture(); @@ -686,7 +700,6 @@ describe("candidate archive and provider upload boundaries", () => { }); expect(retried.status, retried.stderr).toBe(0); }, - 20_000, ); it("drains and kills provider background processes before sealing evidence", async () => { @@ -728,7 +741,7 @@ describe("candidate archive and provider upload boundaries", () => { expect(JSON.parse(await readFile(sealedPath, "utf8"))).toEqual( expect.objectContaining({ provider: "fixture" }), ); - }, 10_000); + }); it("does not expose or mutate a host path outside the sandboxed workspace", async () => { const fixture = await createProviderFixture(); @@ -749,7 +762,7 @@ describe("candidate archive and provider upload boundaries", () => { }); expect(result.status, result.stderr).toBe(0); await expect(readFile(canary, "utf8")).resolves.toBe("host-secret\n"); - }, 10_000); + }); it("applies effective aggregate cgroup limits without exposing command or credentials", async () => { const fixture = await createProviderFixture(); @@ -851,7 +864,7 @@ describe("candidate archive and provider upload boundaries", () => { expect(trace.every((entry) => !processExists(entry.pid))).toBe(true); await expect(lstat(fixture.reportPath)).rejects.toMatchObject({ code: "ENOENT" }); await expect(findProviderRawReferences(fixture.reportPath, reportIdentity)).resolves.toEqual([]); - }, PROCESS_HEAVY_TIMEOUT_MS); + }); it("kills and collects an active provider when its guardian dies", async () => { const fixture = await createProviderFixture(); @@ -894,7 +907,7 @@ describe("candidate archive and provider upload boundaries", () => { sealedPath, }); expect(retried.status, retried.stderr).toBe(0); - }, 20_000); + }); it("collects the whole provider scope when its supervisor dies", async () => { const fixture = await createProviderFixture(); @@ -934,7 +947,7 @@ describe("candidate archive and provider upload boundaries", () => { await expect(lstat(cgroupRoot)).rejects.toMatchObject({ code: "ENOENT" }); expect(cgroupPids.every((pid) => !processExists(pid))).toBe(true); await expect(findProviderRawReferences(fixture.reportPath, reportIdentity)).resolves.toEqual([]); - }, 10_000); + }); it("fails closed when the guardian dies after scope collection and before commit", async () => { const fixture = await createProviderFixture(); @@ -979,7 +992,7 @@ describe("candidate archive and provider upload boundaries", () => { await execution.completion; } } - }, 10_000); + }); it("cleans published evidence when the supervisor dies and permits same-workspace retry", async () => { const fixture = await createProviderFixture(); @@ -1025,7 +1038,7 @@ describe("candidate archive and provider upload boundaries", () => { await execution.completion; } } - }, 15_000); + }); it("observes EMFILE at the provider FD limit and still emits valid evidence", async () => { const fixture = await createProviderFixture(); @@ -1046,7 +1059,7 @@ describe("candidate archive and provider upload boundaries", () => { }); expect(result.status, result.stderr).toBe(0); await expect(lstat(fixture.reportPath)).rejects.toMatchObject({ code: "ENOENT" }); - }, 10_000); + }); it("enforces CPU RLIMIT before the independent wall-clock timeout", async () => { const fixture = await createProviderFixture(); @@ -1063,7 +1076,7 @@ describe("candidate archive and provider upload boundaries", () => { expect(result.stderr).toMatch(/exit=(?:137|152)|signal=SIG(?:XCPU|KILL)/iu); expect(result.stderr).not.toMatch(/timed out/iu); await expect(lstat(fixture.reportPath)).rejects.toMatchObject({ code: "ENOENT" }); - }, 10_000); + }); it.each(["output", "timeout"] as const)( "kills descendants and collects the scope on provider %s termination", @@ -1107,7 +1120,6 @@ describe("candidate archive and provider upload boundaries", () => { expect(cgroupPids.every((pid) => !processExists(pid))).toBe(true); await expect(findProviderRawReferences(fixture.reportPath, reportIdentity)).resolves.toEqual([]); }, - 10_000, ); it.each(["vulnerability", "provenance"] as const)( @@ -1150,7 +1162,6 @@ describe("candidate archive and provider upload boundaries", () => { await waitForChildClose(canary.child); } }, - 10_000, ); });