test(schemas): 스키마 생성 시험이 fsync 없는 writer로 임시 폴더에 쓴다
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Canceled after 0s
frontend-quality-gates / main / checker self-tests (pull_request) Canceled after 0s
frontend-quality-gates / merge / static checks (pull_request) Canceled after 0s
frontend-quality-gates / merge / tests (pull_request) Canceled after 0s
frontend-quality-gates / merge / browser tests (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Canceled after 0s
frontend-quality-gates / external-vulnerability-provider (pull_request) Canceled after 0s
frontend-quality-gates / external-provenance-provider (pull_request) Canceled after 0s
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Canceled after 0s
frontend-quality-gates / deploy-promoted-release (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Canceled after 0s
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Canceled after 0s

문제: json-schema 시험 「generates deterministic … detects drift」가
임시 폴더에 스키마 넷을 쓸 때 파일과 폴더를 fsync한다. 이 시험의
대부분이 fsync이고, 디스크가 바쁘면 시간이 크게 뛴다(desktop
89~1,075ms, CPU를 제한한 coverage 측정에서 7.4초). 이 시험은 생성한
바이트와 drift 판정을 보고, 내구성은 validated-json-artifact 시험이
본다. 기본 timeout 10초 아래라 자기 timeout도 없다.

고른 방법: `generateArtifactSchemas`가 writer를 받는다(기본은 지금의
`writeValidatedJsonArtifact`). 시험은 같은 검증·원자적 rename writer를
`createValidatedJsonArtifactWriter`로 만들고 sync만 뺀다.
- 버린 대안: 시험에 timeout 선언. 시간을 줄이지 않고 흔들림을 덮는다.

위험·한계: 생성 명령과 check:artifact-schemas의 쓰기는 그대로다.

검증(desktop, 고치기 전·후 번갈아 3회, 부하 11~16): 89/1,075/98 →
36/48/35ms. coverage + CPU 소모 12개에서도 208~519 → 73~151ms. 시험
통과, check:artifact-schemas rc=0, check:types·eslint rc=0. 로그
/tmp/claude-gates/w2fe2-slow2·6/.
This commit is contained in:
DongHyeonka
2026-11-12 22:17:32 +09:00
parent 0bb1f0afc0
commit 198e9856f6
2 changed files with 38 additions and 4 deletions
+12 -2
View File
@@ -11,7 +11,10 @@ import {
registrySnapshotArtifactSchema,
supplyChainVerificationArtifactSchema,
} from "./contracts/release-artifacts.ts";
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
import {
type ValidatedJsonArtifactInput,
writeValidatedJsonArtifact,
} from "./lib/validated-json-artifact.ts";
const ARTIFACT_SCHEMA_DEFINITIONS = Object.freeze([
{
@@ -39,6 +42,13 @@ const ARTIFACT_SCHEMA_DEFINITIONS = Object.freeze([
type GenerateArtifactSchemasOptions = Readonly<{
root?: string;
check?: boolean;
/**
* Publishes one schema document. The default writes durably (fsync of the
* file and its directory). A test that only checks the generated bytes in a
* temporary root passes a writer without fsync: four fsync pairs were most
* of its time and grew to seconds under the parallel suite's disk load.
*/
writeArtifact?: (input: ValidatedJsonArtifactInput) => Promise<void>;
}>;
function canonicalize(value: unknown): unknown {
@@ -90,7 +100,7 @@ export async function generateArtifactSchemas(
continue;
}
await mkdir(path.dirname(destination), { recursive: true });
await writeValidatedJsonArtifact({
await (options.writeArtifact ?? writeValidatedJsonArtifact)({
path: destination,
schema: jsonSchemaDocumentArtifactSchema,
value: document,
+26 -2
View File
@@ -1,4 +1,4 @@
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { mkdtemp, open, readFile, rename, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
@@ -6,6 +6,30 @@ import { afterEach, describe, expect, it } from "vitest";
import { generateArtifactSchemas } from "../../scripts/generate-artifact-schemas.ts";
import { assertMatchesJsonSchema } from "../../scripts/lib/json-schema.ts";
import { createValidatedJsonArtifactWriter } from "../../scripts/lib/validated-json-artifact.ts";
// The same validated, atomic-rename writer as the generator's default, without
// fsync. This suite checks generated bytes in a temporary root; durability is
// validated-json-artifact.test.ts's subject, and the fsync pairs were most of
// this test's time under the parallel suite's disk load.
const writeArtifactWithoutSync = createValidatedJsonArtifactWriter({
fileSystem: {
open: async (target, flags, mode) => {
const handle = await open(target, flags, mode);
return {
writeFile: async (data, encoding) => handle.writeFile(data, encoding),
sync: async () => undefined,
close: async () => handle.close(),
};
},
openDirectory: async () => ({
sync: async () => undefined,
close: async () => undefined,
}),
rename: async (source, destination) => rename(source, destination),
rm: async (target, options) => rm(target, options),
},
});
const temporaryDirectories: string[] = [];
@@ -77,7 +101,7 @@ describe("checked-in JSON Schema execution", () => {
it("generates deterministic draft 2020-12 artifact schemas and detects drift", async () => {
const root = await temporaryDirectory();
await generateArtifactSchemas({ root });
await generateArtifactSchemas({ root, writeArtifact: writeArtifactWithoutSync });
const generatedPath = path.join(
root,
"config/schemas/artifacts/dependency-inventory.schema.json",