merge: PR #37을 합친 검사 브랜치에 넣는다
This commit is contained in:
@@ -921,7 +921,7 @@ describe("candidate archive and provider upload boundaries", { timeout: PROCESS_
|
||||
environment: { PROVIDER_SUPERVISOR_TIMEOUT_MS: "5000" },
|
||||
});
|
||||
const unit = await waitForProviderUnit("vulnerability", execution.child.pid);
|
||||
await waitForFileContent(fixture.reportPath, "started\n");
|
||||
await waitForFileContent(fixture.reportPath, "started\n", execution);
|
||||
const guardianPid = await waitForDirectChildMatching(
|
||||
execution.child.pid!,
|
||||
"provider-raw-guardian.ts",
|
||||
@@ -972,7 +972,7 @@ describe("candidate archive and provider upload boundaries", { timeout: PROCESS_
|
||||
sealedPath: path.join(fixture.root, "provider-evidence/vulnerability-report.json"),
|
||||
});
|
||||
const unit = await waitForProviderUnit("vulnerability", execution.child.pid);
|
||||
await waitForFileContent(fixture.reportPath, "started\n");
|
||||
await waitForFileContent(fixture.reportPath, "started\n", execution);
|
||||
const reportIdentity = await lstat(fixture.reportPath);
|
||||
const cgroupRoot = path.resolve("/sys/fs/cgroup", `.${showProviderUnit(unit).ControlGroup}`);
|
||||
const cgroupPids = await readCgroupPids(cgroupRoot);
|
||||
@@ -1007,7 +1007,7 @@ describe("candidate archive and provider upload boundaries", { timeout: PROCESS_
|
||||
try {
|
||||
const unit = await waitForProviderUnit("vulnerability", execution.child.pid);
|
||||
await expectProviderUnitGone(unit);
|
||||
await waitForExistingPath(sealedPath);
|
||||
await waitForExistingPath(sealedPath, execution);
|
||||
const guardianPid = await waitForDirectChildMatching(
|
||||
execution.child.pid!,
|
||||
"provider-raw-guardian.ts",
|
||||
@@ -1051,7 +1051,7 @@ describe("candidate archive and provider upload boundaries", { timeout: PROCESS_
|
||||
try {
|
||||
const unit = await waitForProviderUnit("vulnerability", execution.child.pid);
|
||||
await expectProviderUnitGone(unit);
|
||||
await waitForExistingPath(sealedPath);
|
||||
await waitForExistingPath(sealedPath, execution);
|
||||
const guardianPid = await waitForDirectChildMatching(
|
||||
execution.child.pid!,
|
||||
"provider-raw-guardian.ts",
|
||||
@@ -1144,7 +1144,7 @@ describe("candidate archive and provider upload boundaries", { timeout: PROCESS_
|
||||
environment: { PROVIDER_SUPERVISOR_TIMEOUT_MS: reason === "timeout" ? "500" : "5000" },
|
||||
});
|
||||
const unit = await waitForProviderUnit("vulnerability", execution.child.pid);
|
||||
await waitForFileContent(fixture.reportPath, "started\n");
|
||||
await waitForFileContent(fixture.reportPath, "started\n", execution);
|
||||
const reportIdentity = await lstat(fixture.reportPath);
|
||||
const cgroupRoot = path.resolve("/sys/fs/cgroup", `.${showProviderUnit(unit).ControlGroup}`);
|
||||
const cgroupPids = await readCgroupPids(cgroupRoot);
|
||||
@@ -1686,6 +1686,8 @@ function startProviderSupervisor(
|
||||
stderr: string;
|
||||
stdout: string;
|
||||
}>>;
|
||||
/** The supervisor's stderr so far, for a wait that times out. */
|
||||
output: () => string;
|
||||
}> {
|
||||
const kind = input.kind ?? "vulnerability";
|
||||
const child = spawn(
|
||||
@@ -1712,7 +1714,9 @@ function startProviderSupervisor(
|
||||
child.once("error", reject);
|
||||
child.once("close", (code, signal) => resolve({ code, signal, stderr, stdout }));
|
||||
});
|
||||
return Object.freeze({ child, completion });
|
||||
// 1105/12-01 ②. What the supervisor wrote so far, for a wait that times out.
|
||||
const output = () => `supervisor stderr:\n${stderr.slice(-4_000) || "(empty)"}`;
|
||||
return Object.freeze({ child, completion, output });
|
||||
}
|
||||
|
||||
function providerSupervisorEnvironment(
|
||||
@@ -1771,7 +1775,11 @@ async function expectProviderUnitGone(unitName: string): Promise<void> {
|
||||
throw new Error(`provider scope survived completion: ${unitName}`);
|
||||
}
|
||||
|
||||
async function waitForFileContent(filename: string, expected: string): Promise<void> {
|
||||
async function waitForFileContent(
|
||||
filename: string,
|
||||
expected: string,
|
||||
execution: Readonly<{ output: () => string }>,
|
||||
): Promise<void> {
|
||||
for (let attempt = 0; attempt < 120; attempt += 1) {
|
||||
try {
|
||||
if ((await readFile(filename, "utf8")) === expected) return;
|
||||
@@ -1780,7 +1788,7 @@ async function waitForFileContent(filename: string, expected: string): Promise<v
|
||||
}
|
||||
await delay(25);
|
||||
}
|
||||
throw new Error(`provider output did not reach expected content: ${filename}`);
|
||||
throw new Error(`provider output did not reach expected content: ${filename}\n${execution.output()}`);
|
||||
}
|
||||
|
||||
async function readCgroupPids(cgroupRoot: string): Promise<number[]> {
|
||||
@@ -1800,7 +1808,10 @@ async function waitForDirectChildMatching(supervisorPid: number, pattern: string
|
||||
throw new Error(`provider supervisor child was not observable: ${pattern}`);
|
||||
}
|
||||
|
||||
async function waitForExistingPath(target: string): Promise<void> {
|
||||
async function waitForExistingPath(
|
||||
target: string,
|
||||
execution: Readonly<{ output: () => string }>,
|
||||
): Promise<void> {
|
||||
for (let attempt = 0; attempt < 120; attempt += 1) {
|
||||
try {
|
||||
await lstat(target);
|
||||
@@ -1810,7 +1821,7 @@ async function waitForExistingPath(target: string): Promise<void> {
|
||||
}
|
||||
await delay(25);
|
||||
}
|
||||
throw new Error(`expected path did not appear: ${target}`);
|
||||
throw new Error(`expected path did not appear: ${target}\n${execution.output()}`);
|
||||
}
|
||||
|
||||
async function waitForMissingPath(target: string): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user