소유자 결정(2026-11-07, design-docs repo-structure/README.md 3.4절)으로 템플릿 샘플을 지운다. 샘플이 맡던 시험 대상은 앞 커밋들이 옮겼다. 참조 기능과 예제 화면, 두 context, 그 시험, e2e 3개, 수동 접근성 기록 7개, 런타임 프로필 키, test:reference-feature(명령, 산출물, 게이트 참조), 커버리지 정책 행을 지웠다. removable-template-features 목록은 비우고 장치는 남겼다: test:sample-removal은 인자가 없으면 목록을 하나씩 지우고, 비면 SKIP을 출력하고 보고서에 건너뛴 사례를 남긴다. 기능 스위치 시험과 홈 시작 링크 스위치 시험은 시험 전용 fixture 기능으로 옮겼다. browser soak은 생성 기능을 넣은 빌드에서 돈다. 문서의 샘플 경로를 고쳤다. 날짜가 붙은 설계·리뷰 기록의 본문은 그대로 두었다. 레지스트리 기준선(update:registry-baseline, OWNER DongHyeonka), CI 계약 기준선과 workflow, 초기 JS 기록(194,354B, 17파일, 첫 기능 6,327B, 기능 539B, context 4B)을 다시 받았다. 위험: 레지스트리 행 삭제는 breaking이다. 샘플을 고쳐 쓰는 다운스트림은 수정/삭제 충돌을 만난다. 성능 lab의 기능 라우트 측정은 템플릿에 공개 기능 라우트가 없어 measured:false다. TEMPLATE_FIXTURE 출처는 플랫폼 코드에 남았다. 검증(desktop): check:types, lint, check:architecture, check:registries, check:ci, verify:documentation, test:unit, test:component, test:contract, test:integration, test:recipes, test:coverage(Risk coverage PASS 378/378, 문턱 68개), test:e2e 183, test:a11y, test:visual, test:storybook, test:browser-capabilities, test:feature-scaffold PASS(76 checks), test:sample-removal SKIP, build, check:bundle.
155 lines
5.1 KiB
TypeScript
155 lines
5.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
classifyCounterSeries,
|
|
classifyMemorySlope,
|
|
linearSlope,
|
|
} from "../../scripts/scale/memory-slope.ts";
|
|
import {
|
|
evaluateSoak,
|
|
runBrowserSoak,
|
|
summarizeSoak,
|
|
} from "../../scripts/scale/browser-soak.ts";
|
|
|
|
describe("soak slope classifier", () => {
|
|
it("flags a persistent positive heap slope after warmup", () => {
|
|
expect(
|
|
classifyMemorySlope([
|
|
{ minute: 10, heapMb: 100 },
|
|
{ minute: 20, heapMb: 200 },
|
|
{ minute: 30, heapMb: 300 },
|
|
]),
|
|
).toBe("unbounded-growth");
|
|
});
|
|
|
|
it("treats warm-up growth followed by a plateau as stable", () => {
|
|
expect(
|
|
classifyMemorySlope(
|
|
[
|
|
{ minute: 0, heapMb: 20 },
|
|
{ minute: 5, heapMb: 80 },
|
|
{ minute: 10, heapMb: 100 },
|
|
{ minute: 20, heapMb: 101 },
|
|
{ minute: 30, heapMb: 99 },
|
|
{ minute: 40, heapMb: 100.5 },
|
|
],
|
|
{ warmupMinutes: 10 },
|
|
),
|
|
).toBe("stable");
|
|
});
|
|
|
|
it("does not flag GC sawtooth noise around a flat baseline", () => {
|
|
const sawtooth = Array.from({ length: 40 }, (_, minute) => ({
|
|
minute,
|
|
heapMb: 100 + (minute % 4) * 3,
|
|
}));
|
|
expect(classifyMemorySlope(sawtooth)).toBe("stable");
|
|
});
|
|
|
|
it("needs enough post-warm-up evidence", () => {
|
|
expect(classifyMemorySlope([{ minute: 1, heapMb: 1 }, { minute: 2, heapMb: 2 }])).toBe(
|
|
"insufficient-data",
|
|
);
|
|
});
|
|
|
|
it("classifies logical counters and computes a least-squares slope", () => {
|
|
expect(linearSlope([{ x: 0, y: 1 }, { x: 1, y: 3 }, { x: 2, y: 5 }])).toBeCloseTo(2);
|
|
expect(classifyCounterSeries([0, 0, 0, 0, 0])).toBe("stable");
|
|
expect(classifyCounterSeries([1, 2, 3, 4, 5])).toBe("unbounded-growth");
|
|
});
|
|
|
|
it("summarizes a browser series recorded as { elapsedMs, heapBytes, domNodes, activeTimers }", () => {
|
|
const mb = 1024 * 1024;
|
|
const flat = Array.from({ length: 12 }, (_, index) => ({
|
|
elapsedMs: index * 10_000,
|
|
heapBytes: 40 * mb + (index % 2) * mb,
|
|
domNodes: 900,
|
|
listeners: 120,
|
|
activeTimers: 3,
|
|
}));
|
|
const leaking = flat.map((sample, index) => ({
|
|
...sample,
|
|
heapBytes: 40 * mb + index * 8 * mb,
|
|
}));
|
|
expect(summarizeSoak(flat, 20_000)).toBe("stable");
|
|
expect(summarizeSoak(leaking, 20_000)).toBe("unbounded-growth");
|
|
});
|
|
});
|
|
|
|
describe("soak evaluation", () => {
|
|
const base = (index: number) => ({
|
|
elapsedMs: index * 5_000,
|
|
cycles: index * 100,
|
|
heapBytes: 40 * 1024 * 1024,
|
|
domNodes: 900,
|
|
listeners: 120,
|
|
activeTimers: 2,
|
|
inFlightRequests: 0,
|
|
storageKeys: 1,
|
|
storageBytes: 100,
|
|
});
|
|
const healthySamples = Array.from({ length: 12 }, (_, index) => base(index));
|
|
const totals = {
|
|
cycles: 1_200,
|
|
navigationFailures: 0,
|
|
featureVisits: 200,
|
|
settledFeatureVisits: 40,
|
|
finalInFlightRequests: 0,
|
|
apiRequests: 240,
|
|
telemetryPosts: 5,
|
|
telemetryEvents: 6,
|
|
telemetryPostTimes: [1_000, 20_000, 40_000, 70_000, 90_000],
|
|
};
|
|
|
|
it("passes a healthy long session", () => {
|
|
const { checks } = evaluateSoak(healthySamples, totals, 10_000);
|
|
expect(checks.filter((check) => !check.passed)).toEqual([]);
|
|
});
|
|
|
|
it("fails a vacuous soak that never exercised the backend or telemetry", () => {
|
|
const { checks } = evaluateSoak(healthySamples, { ...totals, apiRequests: 0, telemetryEvents: 0 }, 10_000);
|
|
expect(checks.find((check) => check.name === "backend failure exercised")?.passed).toBe(false);
|
|
});
|
|
|
|
it.each([
|
|
["timers", healthySamples.map((sample, index) => ({ ...sample, activeTimers: 2 + index * 3 }))],
|
|
["listeners", healthySamples.map((sample, index) => ({ ...sample, listeners: 120 + index * 20 }))],
|
|
["storage growth", healthySamples.map((sample, index) => ({ ...sample, storageKeys: 1 + index }))],
|
|
] as const)("fails a %s leak", (name, samples) => {
|
|
const { checks } = evaluateSoak(samples, totals, 10_000);
|
|
expect(checks.find((check) => check.name === name)?.passed).toBe(false);
|
|
});
|
|
|
|
it("fails request amplification and a telemetry storm", () => {
|
|
const { checks } = evaluateSoak(
|
|
healthySamples,
|
|
{
|
|
...totals,
|
|
apiRequests: 1_000,
|
|
telemetryPostTimes: Array.from({ length: 100 }, (_, index) => index * 100),
|
|
},
|
|
10_000,
|
|
);
|
|
expect(checks.find((check) => check.name === "request amplification")?.passed).toBe(false);
|
|
expect(checks.find((check) => check.name === "telemetry rate")?.passed).toBe(false);
|
|
});
|
|
|
|
it("fails too short a soak and requests that never settle", () => {
|
|
const { checks } = evaluateSoak(healthySamples.slice(0, 3), { ...totals, cycles: 10, finalInFlightRequests: 2 }, 10_000);
|
|
expect(checks.find((check) => check.name === "cycles")?.passed).toBe(false);
|
|
expect(checks.find((check) => check.name === "in-flight settles")?.passed).toBe(false);
|
|
});
|
|
|
|
it("reports skipped (never passed) without a build", async () => {
|
|
const result = await runBrowserSoak({
|
|
distRoot: "does-not-exist",
|
|
durationMs: 1,
|
|
intervalMs: 1,
|
|
warmupMs: 0,
|
|
routes: ["/"],
|
|
featureRoute: "/items",
|
|
});
|
|
expect(result.status).toBe("skipped");
|
|
});
|
|
});
|