From a6b85e878c0d59ccc424210c2b2f114d29013e18 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 4 Nov 2026 20:56:50 +0900 Subject: [PATCH] =?UTF-8?q?test(http):=20MAX=5FRETRY=5FATTEMPTS=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC=EA=B3=BC=20signal=20listener=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC=EB=A5=BC=20=EA=B3=A0=EC=A0=95=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 V2를 지울 때(048f490) 같이 지운 테스트 둘이 V3 동작도 지키고 있었다. - 운영 설정 MAX_RETRY_ATTEMPTS가 실행기에 닿는지. V3는 runtime-adapters.ts에서 넘긴다. 값을 상수 2로 바꾼 변이 H53이 15파일 143건을 통과했다. 장애 때 재시도를 끄는 손잡이가 조용히 사라질 수 있다 (REQUEST_TIMEOUT_MS는 실제로 한 번 그렇게 버려졌다). - 호출자·scope signal에 단 abort listener를 지우는지. 호출자 쪽 제거를 지운 H56은 머지 게이트 테스트를 모두 통과했고, scope 쪽(H57)은 nightly tier의 long-session 테스트 하나만 잡았다. 고른 방법 - tests/features/reference-feature/reference-runtime-composition.test.ts: 실제 createRuntimeAdapters에 MAX_RETRY_ATTEMPTS 0·1을 주고, 재시도 예산 2인 참조 목록 조회가 503에 1회·2회 나가는지 센다(Math.random 0으로 backoff 대기 없음). 설치된 기능의 HTTP가 있어야 조립 루트 경로를 탈 수 있어 참조 기능 테스트에 두었다. test:reference-feature는 머지 게이트다. - tests/unit/http-execution-v3.test.ts: 응답으로 끝날 때와 호출자 abort로 끝날 때, 호출자·scope signal에 더한 abort listener가 같은 함수로 모두 지워지는지 센다. 위험·한계 - ①은 참조 기능에 기댄다. 샘플을 지운 제품에서는 이 테스트도 같이 빠진다. 조립 루트를 기능 없이 부를 수단이 없어서다. - 10-04 ③(realtime snapshot의 GET 조건)은 다른 작업 몫이다. 검증 - 변이 H53·H56·H57을 하나씩 넣으면 새 테스트가 실패하고, 되돌리면 통과한다. - 두 파일 76건 통과. check:types:test, eslint 통과. Refs: docs/reviews/2026-11-03-maturity-review/10-tests-fast-layers.md 10-04 --- .../reference-runtime-composition.test.ts | 43 +++++++++++++++++++ tests/unit/http-execution-v3.test.ts | 42 ++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/tests/features/reference-feature/reference-runtime-composition.test.ts b/tests/features/reference-feature/reference-runtime-composition.test.ts index 4c4d0540..16ccec03 100644 --- a/tests/features/reference-feature/reference-runtime-composition.test.ts +++ b/tests/features/reference-feature/reference-runtime-composition.test.ts @@ -160,6 +160,49 @@ describe("reference feature runtime composition", () => { adapters.infrastructure.dispose(); }); + // 1103/10-04 ①. MAX_RETRY_ATTEMPTS is the operator's dial over every + // contract's retry budget (the list declares 2). Zero must stop retries. + it.each([ + [0, 1], + [1, 2], + ])("honours MAX_RETRY_ATTEMPTS %i: a retryable list read goes out %i time(s)", async (maxRetryAttempts, sends) => { + const fetcher = vi.fn(async (_input: RequestInfo | URL) => + Response.json( + { type: "about:blank", title: "temporary", status: 503 }, + { status: 503 }, + ), + ); + // No backoff wait: the jitter is the random draw times a ceiling. + const random = vi.spyOn(Math, "random").mockReturnValue(0); + try { + const adapters = await createRuntimeAdapters({ + runtime: { + ...runtime, + config: { ...runtime.config, MAX_RETRY_ATTEMPTS: maxRetryAttempts }, + }, + release, + host: {}, + fetcher, + }); + await adapters.outputPorts.session.beginSignIn(); + await vi.waitFor(() => + expect(adapters.infrastructure.serverStateScope.getPhase()).toBe("READY"), + ); + + await expect( + (await referenceInput(adapters)).listResources({ limit: 20 }), + ).resolves.toMatchObject({ ok: false, error: { kind: "SERVER_FAILURE" } }); + expect( + fetcher.mock.calls.filter(([url]) => + String(url).includes("/api/reference-resources"), + ), + ).toHaveLength(sends); + adapters.infrastructure.dispose(); + } finally { + random.mockRestore(); + } + }); + it("keeps private command intent identity out of URLs and diagnostics", async () => { const requests: Array> = []; const fetcher = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => { diff --git a/tests/unit/http-execution-v3.test.ts b/tests/unit/http-execution-v3.test.ts index 4f240ce1..06757200 100644 --- a/tests/unit/http-execution-v3.test.ts +++ b/tests/unit/http-execution-v3.test.ts @@ -761,6 +761,48 @@ describe("descriptor-driven HTTP execution lifetime", () => { await expect(result).resolves.toMatchObject({ kind: "CANCELLED" }); }); + // 1103/10-04 ②. A signal is shared by many requests (a screen, a session + // scope). Every abort listener an execution adds to the caller's and the + // scope's signal is removed when it ends, however it ends. + it.each(["an answer", "a caller abort"] as const)( + "removes the listeners it added to the caller and scope signals after %s", + async (ending) => { + const caller = new AbortController(); + const scopeLifetime = new AbortController(); + const watched = [caller.signal, scopeLifetime.signal].map((signal) => ({ + add: vi.spyOn(signal, "addEventListener"), + remove: vi.spyOn(signal, "removeEventListener"), + })); + const executor = createContractHttpExecutor({ + baseUrl: "https://api.example/", + maxRetryAttempts: 0, + attachCredentials: () => ({ kind: "READY", headers: {} }), + fetcher: vi.fn(async () => Response.json([])), + }); + + const result = executor.execute(installed, { limit: 20 }, { + routeId: ROUTE_ID, + scope: { ...scope, signal: scopeLifetime.signal }, + signal: caller.signal, + }); + if (ending === "a caller abort") caller.abort(); + + await expect(result).resolves.toMatchObject({ + kind: ending === "an answer" ? "SUCCESS" : "CANCELLED", + }); + for (const { add, remove } of watched) { + const added = add.mock.calls + .filter(([type]) => type === "abort") + .map(([, listener]) => listener); + const removed = remove.mock.calls + .filter(([type]) => type === "abort") + .map(([, listener]) => listener); + expect(added).toHaveLength(1); + expect(removed).toEqual(added); + } + }, + ); + it("treats an unreadable forbidden-body probe as a transport failure", async () => { const body = new ReadableStream({ pull(controller) {