From 185a2aee68c88f1dc2b96016fcd7382c63beefb2 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 1 Nov 2026 19:03:44 +0900 Subject: [PATCH] =?UTF-8?q?test(system):=20supervisor=20argv=EB=A5=BC=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=20=EC=A4=91=20=EA=B8=B0=EB=A1=9D=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=99=95=EC=9D=B8=ED=95=9C=EB=8B=A4=20(11-01)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: cgroup 테스트("applies effective aggregate cgroup limits ...")는 `await execution.completion` 뒤에 `showProcessArguments(child.pid)`로 supervisor의 argv를 다시 조회한다. completion은 child의 `close`에서 풀리고, 그때 Node는 이미 child를 회수했다. `/proc//cmdline`도 `ps -p`도 실패해서 이 테스트는 부하와 관계없이 항상 `ps failed: `로 끝난다. 바로 위 주석은 "아래는 실행 기록을 읽는다"고 적어서 코드와 반대로 말했다. 완료 전의 live 조회(`:793`)도 provider가 1.5초 뒤 끝나므로 부하가 있으면 같은 이유로 실패할 수 있다. 고른 방법: 이미 있는 샘플러 `recordProviderProcessTree`가 5ms마다 supervisor 자신의 argv도 읽어서, 서로 다른 값을 모두 기록한다. 완료 전 live 조회와 완료 후 조회를 이 기록으로 바꿨다. 단언은 줄이지 않았다. - supervisor argv에 command와 credential이 없다(`:793`의 정규식 그대로). - 기록에 `run-and-validate-provider.ts`가 있다. 기록이 비어서 위 단언이 공짜로 통과하는 경우를 막는다. - 실행 중 `process.title`로 argv를 바꿔도 값마다 남기므로, 순간 한 번을 본 live 조회보다 넓게 본다. 버린 대안: - 완료 후 조회 줄을 지운다: supervisor argv 검사가 사라진다. - 완료 전 스냅샷을 한 번 더 찍는다: `:793`과 같은 방식이라 부하에서 provider 종료와 경쟁한다. - `ps` 실패를 무시한다: 결함을 숨기고 검사가 공짜로 통과한다. 위험·한계: 샘플링 간격(5ms)보다 짧게 바뀌었다 돌아오는 argv는 놓칠 수 있다. 다른 프로세스 기록과 같은 한계다. 이 테스트는 base fixture가 `corepack pnpm build:release-candidate`를 부르므로 worktree에서 실행하지 않았다. `-t 'aggregate cgroup'` 반복 실행과 `test:system` 전체 통과는 메인 checkout에서 확인해야 한다. 검증: - RED: 게이트 로그 test_system.log(d99301b, 메인 checkout 실행)에서 이 테스트가 `Error: ps failed: `로 `:810:7`에서 실패. 2 failed / 110 passed. d99301b..402e1db 사이 scripts·tests/system 변경 없음. - 메커니즘: 테스트 파일에서 `readProcessArguments`·`showProcessArguments`· `recordProviderProcessTree` 원문을 잘라 타입만 지우고, 수명이 짧은 child에 돌렸다(scratchpad/fix-11-01/recorder-check.mjs). - 수정 전 20회: close 뒤 조회 실패 20, supervisor argv 기록 0, 실행 중 title 유출 기록 0 - 수정 후 20회(loadavg 1.6): 조회 실패 20, 기록 20, 유출 기록 20 - 수정 후 30회, busy loop 20개(loadavg 17.9): 기록 30, 유출 기록 30 - `npx tsc --project tsconfig.test.json --noEmit`, `tsconfig.node.json` 통과. `npx eslint tests/system/ci-runner/ci-artifact-contract.test.ts` 통과. Fixes: 5cc41467aebe ("refactor: 프론트 템플릿 리펙토링") Refs: docs/reviews/2026-11-01-maturity-review/11-tests-browser-release-scale.md 11-01 --- .../system/ci-runner/ci-artifact-contract.test.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/system/ci-runner/ci-artifact-contract.test.ts b/tests/system/ci-runner/ci-artifact-contract.test.ts index 4982fae0..f74bf8b2 100644 --- a/tests/system/ci-runner/ci-artifact-contract.test.ts +++ b/tests/system/ci-runner/ci-artifact-contract.test.ts @@ -790,7 +790,6 @@ describe("candidate archive and provider upload boundaries", () => { await expect(readFile(path.join(cgroupRoot, "pids.max"), "utf8")).resolves.toBe("64\n"); await expect(readFile(path.join(cgroupRoot, "cpu.max"), "utf8")).resolves.toBe("100000 100000\n"); expect(readProviderUnitMetadata(unit)).not.toMatch(new RegExp(`${command}|${credential}`, "u")); - expect(showProcessArguments(execution.child.pid)).not.toMatch(new RegExp(`${command}|${credential}`, "u")); const reportIdentity = await lstat(fixture.reportPath); const result = await execution.completion; tree.stop(); @@ -806,8 +805,13 @@ describe("candidate archive and provider upload boundaries", () => { const processArguments = tree.cgroupArguments(); const directChildPids = tree.directChildPids(); const directChildArguments = tree.directChildArguments(); + // The supervisor's argv comes from the recording too: once `completion` + // resolves Node has reaped it, so a lookup by PID here can only fail. + const supervisorArguments = tree.supervisorArguments(); + expect(supervisorArguments.join("\n"), "supervisor never observed").toContain("run-and-validate-provider.ts"); + expect(supervisorArguments.join("\n")).not.toMatch(new RegExp(`${command}|${credential}`, "u")); const observedArguments = [ - showProcessArguments(execution.child.pid), + ...supervisorArguments, ...directChildArguments, ...processArguments, ]; @@ -1899,6 +1903,10 @@ function readProcessArguments(pid: number): string | null { * the right instant?" into "what did this run actually contain?". */ function recordProviderProcessTree(supervisorPid: number) { + // Every distinct value, not just the first: a process can rewrite its own + // argv (`process.title`) mid-run, and the supervisor is the process whose + // argv a later lookup can no longer see. + const supervisorArguments = new Set(); const directChildren = new Map(); const cgroupMembers = new Map(); let stopped = false; @@ -1935,6 +1943,8 @@ function recordProviderProcessTree(supervisorPid: number) { }; const sample = (): void => { if (stopped) return; + const own = readProcessArguments(supervisorPid); + if (own) supervisorArguments.add(own); const direct = childrenOf(supervisorPid); for (const pid of direct) remember(directChildren, pid); // Walk the whole subtree: the scope wrapper, bubblewrap and the provider @@ -1959,6 +1969,7 @@ function recordProviderProcessTree(supervisorPid: number) { stopped = true; clearInterval(timer); }, + supervisorArguments: () => [...supervisorArguments], directChildPids: () => [...directChildren.keys()], directChildArguments: () => [...directChildren.values()], cgroupPids: () => [...cgroupMembers.keys()],