From 9adb612564cb91c3ea11e8eda89c7b3dd00b2dd5 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 18 Nov 2026 21:58:34 +0900 Subject: [PATCH 1/2] =?UTF-8?q?test(ci):=20=EA=B7=B8=EB=A3=B9=20kill=20?= =?UTF-8?q?=EC=8B=9C=ED=97=98=EC=9D=B4=20=EC=86=90=EC=9E=90=EA=B0=80=20?= =?UTF-8?q?=EC=83=9D=EA=B8=B4=20=EB=92=A4=EC=97=90=20=EC=8B=9C=ED=95=9C?= =?UTF-8?q?=EC=9D=84=20=ED=84=B0=EB=9C=A8=EB=A6=B0=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `tests/system/ci-runner/provider-process-group.test.ts` 「kills and reaps a stubborn provider process group including its descendant」가 runner run 309(#57, FE-GATE-013)에서 `ENOENT … descendant.pid`로 실패했다. #57이 바꾼 시험이 아니다. 원인: 시험이 `runProviderProcess`에 실제 250 ms 시한을 주고, 그 안에 provider node가 떠서 손자를 띄우고 pid 파일을 쓴다고 가정한다. 부하가 있는 runner에서 그 시작이 250 ms를 넘으면 그룹 kill이 pid 파일보다 먼저 와 확인할 손자가 없다(고정 시간 가정). 같은 시험이 손자가 사라졌는지를 provider close 직후 한 번만 본다. SIGKILL과 init의 회수는 close 뒤에 끝날 수 있어 같은 가정이다(이쪽은 실패가 관측되지 않았다). 고른 방법: 시험의 주제는 그룹 kill이지 provider가 얼마나 돌아도 되는지가 아니다. `runProviderProcess`의 주입 칸 `setTimer`로, 손자가 pid를 쓴 뒤에 시한을 터뜨린다. kill은 그대로 기본 `defaultKillProcessGroup`이 한다. 손자는 사라질 때까지 기다린다. pid 대기와 사라짐 대기는 둘 다 감시 5초를 둔다(시험이 매달리지 않게 하는 감시이지 provider 시한이 아니다). pid가 끝내 안 생기면 감시 뒤 kill하고 pid 없음으로 실패한다. 제품 코드는 바꾸지 않는다. 버린 대안: 시한을 늘린다(시간 가정이 남고 시험이 그만큼 느려진다). provider가 준비를 알리는 경로를 제품 코드에 더한다(시험만을 위한 공개 표면이 생긴다). 약해진 검사: 기본 타이머(`dependencies.setTimer ?? setTimeout`)로 시한이 끝나는 경로를 도는 시험이 이제 없다. 그 시험들은 모두 타이머를 주입한다. 기본값은 그 한 줄이고, 시한 뒤의 처리(그룹 kill, kill 실패 때 자식 fallback, close 뒤에 끝남)는 `tests/unit/security-provider-evidence.test.ts`의 `runProviderProcess` 시험 둘이 본다. 실제 그룹 kill과 손자 정리는 이 시험이 계속 본다. 검증(desktop, 시스템 컨테이너): - RED 탐침: provider 시작을 400 ms 늦춘 사본에서 원래 시험이 `ENOENT … descendant.pid`로 실패했다(1/1). 고친 시험(pid 감시를 넣기 전 판)은 같은 사본에서 통과했다(435 ms). 탐침 사본은 커밋하지 않았다. - 이 커밋의 트리(48d460e2)로 20/20 통과(desktop 부하 8.3~9.8, 12코어). CPU 부하 프로세스는 얹지 않았다. runner가 같은 기계에서 다른 run을 돌고 있었다. - 노트북: `check:types`, `lint`, `tests/unit/test-timeout-declarations.test.ts` ·`ungated-tests.test.ts` 통과. Refs: 흔들림 기록 tests/system/ci-runner/provider-process-group.test.ts:11 --- .../ci-runner/provider-process-group.test.ts | 82 ++++++++++++++++--- 1 file changed, 70 insertions(+), 12 deletions(-) diff --git a/tests/system/ci-runner/provider-process-group.test.ts b/tests/system/ci-runner/provider-process-group.test.ts index f1bc7304..90f33072 100644 --- a/tests/system/ci-runner/provider-process-group.test.ts +++ b/tests/system/ci-runner/provider-process-group.test.ts @@ -1,4 +1,5 @@ -import { mkdtemp, readFile, rm } from "node:fs/promises"; +import { readFileSync } from "node:fs"; +import { mkdtemp, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import path from "node:path"; @@ -21,22 +22,79 @@ describe("CI-runner provider process-group lifecycle", { timeout: childProcessTi "setInterval(() => {}, 1000);", ].join("\n"); - const running = runProviderProcess({ - executable: process.execPath, - arguments: ["-e", source], - environment: { - PATH: process.env.PATH, - DESCENDANT_PID_PATH: descendantPidPath, + // 2026-11-13. A real 250 ms timer started the kill before a loaded runner + // had started the descendant, so its pid file did not exist (ENOENT, + // runner run 309). The subject is the group kill, not how long a + // provider may run: the runner's timer fires once the descendant exists, + // or after the watchdog, and then the missing pid fails the test. + const startedAt = Date.now(); + const running = runProviderProcess( + { + executable: process.execPath, + arguments: ["-e", source], + environment: { + PATH: process.env.PATH, + DESCENDANT_PID_PATH: descendantPidPath, + }, + timeoutMs: 250, }, - timeoutMs: 250, - }); + { + setTimer: (fire) => { + const poll = setInterval(() => { + const waiting = readPid(descendantPidPath) === undefined; + if (waiting && Date.now() - startedAt <= PROCESS_WATCHDOG_MS) return; + clearInterval(poll); + fire(); + }, POLL_MS); + return poll; + }, + clearTimer: (timer) => clearInterval(timer), + }, + ); await expect(running).rejects.toThrow(/timed out.*process close/u); - const descendantPid = Number(await readFile(descendantPidPath, "utf8")); - expect(Number.isSafeInteger(descendantPid) && descendantPid > 0).toBe(true); - expect(() => process.kill(descendantPid, 0)).toThrow(/ESRCH|no such process/u); + const descendantPid = readPid(descendantPidPath); + expect(descendantPid).toBeDefined(); + await expect(waitForProcessGone(descendantPid!)).resolves.toBe(true); } finally { await rm(root, { recursive: true, force: true }); } }); }); + +const POLL_MS = 10; +/** + * Test watchdog only, not a provider deadline: how long the test waits for the + * descendant to write its pid, and for it to be gone after the group kill. + * SIGKILL and the reaper (the container's init, once the provider is gone) + * finish after the provider's close event, so the descendant is polled until + * it is gone instead of checked once. + */ +const PROCESS_WATCHDOG_MS = 5_000; + +/** The pid the provider wrote, or undefined while the file is missing or partly written. */ +function readPid(file: string): number | undefined { + let text: string; + try { + text = readFileSync(file, "utf8"); + } catch (error) { + if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return undefined; + throw error; + } + const pid = Number(text); + return /^[1-9][0-9]*$/u.test(text) && Number.isSafeInteger(pid) ? pid : undefined; +} + +async function waitForProcessGone(pid: number): Promise { + const deadline = Date.now() + PROCESS_WATCHDOG_MS; + while (Date.now() <= deadline) { + try { + process.kill(pid, 0); + } catch (error) { + if (error && typeof error === "object" && "code" in error && error.code === "ESRCH") return true; + throw error; + } + await new Promise((resolve) => setTimeout(resolve, POLL_MS)); + } + return false; +} -- 2.54.0 From bdf9d4625be022459f9d512b5cff0a8b9fc69019 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Wed, 18 Nov 2026 22:35:33 +0900 Subject: [PATCH 2/2] =?UTF-8?q?docs(ledger):=20=EA=B7=B8=EB=A3=B9=20kill?= =?UTF-8?q?=20=EC=8B=9C=ED=97=98=EC=9D=98=20=EA=B3=A0=EC=A0=95=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=ED=9D=94=EB=93=A4=EB=A6=BC=EA=B3=BC=20=EA=B3=A0?= =?UTF-8?q?=EC=B9=9C=20=EB=B3=80=EA=B2=BD=EC=9D=84=20=EC=A0=81=EB=8A=94?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 흔들림 기록에 `provider-process-group.test.ts:11`(runner run 309)을 더한다. 처음 본 줄이 아직 없어 원인과 고친 PR을 한 줄에 적는다. fixed_by는 이 PR 번호를 미리 적었다(push 뒤 확인). CHANGELOG 미출시 절 「그 밖의 변경」에 앞 커밋 9adb6125를 적는다. #58과 guardian commit PR이 같은 표에 줄을 더하므로, 겹치지 않게 `fixture-node-modules` 줄 뒤에 넣었다. 검증: 노트북 `scripts/verify.sh docs`, `scripts/verify.sh hooks`, laptop-gate `tests/unit/changelog-review-ids.test.ts` 통과. --- CHANGELOG.md | 1 + docs/ledger/flaky-tests.jsonl | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4381714b..ae5a74ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ Gitea runner에서 merge 단계를 초록으로 만들고, worker를 늘리지 | --- | --- | --- | | 흔들린 시험 기록 `docs/ledger/flaky-tests.jsonl`을 둔다(칸은 `docs/ledger/README.md` 「흔들림 기록」). 복사한 프로젝트는 줄을 비우고 받고, `.gitattributes`의 `merge=union` 한 줄도 받는다. 리뷰 기준이 벽시계 상한·시작 순서 단언을 구조적 위험으로 본다 | `docs/ledger/`, `.gitattributes`, `README.md`, `docs/work/reference/review-criteria.md`, `docs/work/reference/gates.md`, `docs/work/reference/testing.md` | `fe9990b4` | | `fixture-node-modules` 시험이 「CI 아님」 설치를 `CI=false`로 흉내 낸다. runner의 벤더 변수(`GITEA_ACTIONS` 등) 때문에 FE-GATE-005·020이 runner에서만 실패했다 | `tests/unit/fixture-node-modules.test.ts` | `ddfcb6f6` | +| provider 그룹 kill 시험이 실제 250 ms 시한 대신, 손자가 pid를 쓴 뒤에 시한을 터뜨리고 손자가 사라질 때까지 기다린다. 부하가 있는 runner에서 시한이 손자보다 먼저 와 `ENOENT`로 떨어졌다 | `tests/system/ci-runner/provider-process-group.test.ts` | `9adb6125` | | `scripts/verify.sh parts`가 게이트 명령의 `args`를 넘긴다 | `scripts/verify.sh`, `scripts/tests/test_verify.py` | `79a225b6` | | `check:browser-file-storage-boundaries`가 fixture마다 eslint를 띄우지 않고 ESLint API 한 번으로 같은 판정을 한다 | `scripts/check-browser-file-storage-boundaries.ts` | `0d8e4f5a` | | FE-GATE-020 드릴이 한 복사본에서 같은 시험 파일을 두 번 돌지 않는다: scaffold 드릴은 `test:coverage`가 도는 plain suite를 빼고, feature-removal은 `test:all` 대신 `test:coverage` 밖에 남는 suite만 더 돈다 | `scripts/lib/feature-scaffold-drill.ts`, `scripts/test-sample-removal.ts`, `tests/unit/removal-drill-test-paths.test.ts` | `b4210753` | diff --git a/docs/ledger/flaky-tests.jsonl b/docs/ledger/flaky-tests.jsonl index 20df1280..46a148bb 100644 --- a/docs/ledger/flaky-tests.jsonl +++ b/docs/ledger/flaky-tests.jsonl @@ -8,3 +8,4 @@ {"date": "2026-11-13", "test": "tests/browser-capabilities/indexeddb-runtime.spec.ts:256", "category": "resource-io", "first_run": "/tmp/claude-gates/ci-pr-gate-selection-merge/gate-artifacts/FE-GATE-008.txt", "verdict": "[firefox] desktop merge(트리 148e68f4, #47 없음)에서 30초 timeout 1회. 같은 게이트가 Firefox 프로필을 RAM에 둔 #47 트리에서는 69개 전부 통과. Firefox IndexedDB·OPFS가 프로필 디스크를 기다린 것으로 봄", "quarantined_until": "", "fixed_by": "프론트 #47"} {"date": "2026-11-13", "test": "tests/browser-capabilities/local-draft-composition.spec.ts:10", "category": "resource-io", "first_run": "/tmp/claude-gates/ci-pr-gate-selection-merge/gate-artifacts/FE-GATE-008.txt", "verdict": "[firefox] desktop merge(트리 148e68f4, #47 없음)에서 30초 timeout 1회. 같은 게이트가 Firefox 프로필을 RAM에 둔 #47 트리에서는 69개 전부 통과. Firefox IndexedDB·OPFS가 프로필 디스크를 기다린 것으로 봄", "quarantined_until": "", "fixed_by": "프론트 #47"} {"date": "2026-11-13", "test": "tests/browser-capabilities/opfs-runtime.spec.ts:338", "category": "resource-io", "first_run": "/tmp/claude-gates/ci-pr-gate-selection-merge/gate-artifacts/FE-GATE-008.txt", "verdict": "[firefox] desktop merge(트리 148e68f4, #47 없음)에서 30초 timeout 1회. 같은 게이트가 Firefox 프로필을 RAM에 둔 #47 트리에서는 69개 전부 통과. Firefox IndexedDB·OPFS가 프로필 디스크를 기다린 것으로 봄", "quarantined_until": "", "fixed_by": "프론트 #47"} +{"date": "2026-11-13", "test": "tests/system/ci-runner/provider-process-group.test.ts:11", "category": "fixed-time", "first_run": "309", "verdict": "runner run 309(#57 head, FE-GATE-013)에서 1회 실패(ENOENT descendant.pid). 시험이 runProviderProcess에 실제 250 ms 시한을 주고 그 안에 provider가 손자를 띄우고 pid를 쓴다고 가정했다. provider 시작을 400 ms 늦춘 탐침으로 결정적 재현(1/1 ENOENT), 고친 시험은 같은 탐침에서 통과. 고친 트리에서 desktop 시스템 컨테이너 20회 중 실패 0(부하 8.3~9.8, 12코어)", "quarantined_until": "", "fixed_by": "프론트 #61"} -- 2.54.0