|
| 1 | +import fs from "node:fs/promises"; |
| 2 | +import path from "node:path"; |
| 3 | +import { afterEach, describe, expect, it } from "vitest"; |
| 4 | +import { useAutoCleanupTempDirTracker } from "../../../helpers/temp-dir.js"; |
| 5 | +import { runGatewayStabilityRuntime } from "./gateway-stability-runtime.js"; |
| 6 | + |
| 7 | +const tempDirs = useAutoCleanupTempDirTracker(afterEach); |
| 8 | + |
| 9 | +describe("gateway stability runtime evidence", () => { |
| 10 | + it( |
| 11 | + "proves live RPC, bounded retention, bundle filtering, and export", |
| 12 | + { timeout: 240_000 }, |
| 13 | + async () => { |
| 14 | + const artifactBase = tempDirs.make("gateway-stability-runtime-"); |
| 15 | + const evidence = await runGatewayStabilityRuntime({ |
| 16 | + artifactBase, |
| 17 | + repoRoot: process.cwd(), |
| 18 | + }); |
| 19 | + |
| 20 | + const result = evidence.entries[0]?.result; |
| 21 | + expect(result?.status, result?.failure?.reason).toBe("pass"); |
| 22 | + const summary = JSON.parse( |
| 23 | + await fs.readFile(path.join(artifactBase, "gateway-stability-summary.json"), "utf8"), |
| 24 | + ) as { |
| 25 | + liveRpcCapacity: number; |
| 26 | + retainedCount: number; |
| 27 | + droppedCount: number; |
| 28 | + filteredEvents: number; |
| 29 | + bundleReason: string; |
| 30 | + supportBytes: number; |
| 31 | + }; |
| 32 | + expect(summary.liveRpcCapacity).toBe(1000); |
| 33 | + expect(summary.retainedCount).toBe(1000); |
| 34 | + expect(summary.droppedCount).toBeGreaterThan(0); |
| 35 | + expect(summary.filteredEvents).toBe(3); |
| 36 | + expect(summary.bundleReason).toBe("qa_gateway_stability"); |
| 37 | + expect(summary.supportBytes).toBeGreaterThan(0); |
| 38 | + }, |
| 39 | + ); |
| 40 | +}); |
0 commit comments