Merge origin/main for artifact admission and evidence fixes
This commit is contained in:
@@ -286,7 +286,8 @@ describe.skipIf(process.platform === "win32")(
|
||||
{
|
||||
platform: process.platform,
|
||||
architecture: process.arch,
|
||||
readText: () => "application.version=12.1.4\n",
|
||||
readText: () =>
|
||||
"application.version=12.1.4\napplication.java.min=21\n",
|
||||
executable: () => true,
|
||||
probeJava: () => ({
|
||||
version: "21.0.12",
|
||||
|
||||
@@ -84,6 +84,7 @@ describe("Hopper bridge launcher selection", () => {
|
||||
"private",
|
||||
"/usr/bin/python3",
|
||||
"/rea/hopper-demo-x11.py",
|
||||
"--owner-stdin",
|
||||
"--strategy",
|
||||
"user-mount-namespace",
|
||||
"--mount-private-x11",
|
||||
@@ -117,6 +118,7 @@ describe("Hopper bridge launcher selection", () => {
|
||||
command: "/usr/bin/python3",
|
||||
args: [
|
||||
"/rea/hopper-demo-x11.py",
|
||||
"--owner-stdin",
|
||||
"--strategy",
|
||||
"direct",
|
||||
"--hopper",
|
||||
@@ -202,3 +204,59 @@ it("launches Hopper helpers with the caller-selected environment without restori
|
||||
await launched.value.releaseLease?.();
|
||||
}
|
||||
});
|
||||
|
||||
it.skipIf(process.platform !== "linux")(
|
||||
"gives the demo helper a live owner stream through Node's actual stdio transport",
|
||||
async () => {
|
||||
const directory = await createTestTempDirectory("rea-hopper-owner-stdio-");
|
||||
const launcher = new HopperApplicationLauncher(
|
||||
{
|
||||
...options(process.execPath),
|
||||
launchMode: "verified_linux_demo",
|
||||
demoHelperPath: fileURLToPath(
|
||||
new URL("../../../fixtures/hopperLifetimeLaunch.py", import.meta.url),
|
||||
),
|
||||
},
|
||||
{
|
||||
selectPrivateDisplay: async () => ({
|
||||
ok: true,
|
||||
strategy: "direct",
|
||||
diagnostic: {
|
||||
component: "hopper_private_display",
|
||||
operation: "probe",
|
||||
status: "ready",
|
||||
failure_code: null,
|
||||
reason: "ready",
|
||||
socket_directory: "/tmp/.X11-unix",
|
||||
socket_directory_mode: "1777",
|
||||
mount_read_only: false,
|
||||
effective_socket_directory_mode: "1777",
|
||||
effective_mount_read_only: false,
|
||||
wsl: false,
|
||||
strategy: "direct",
|
||||
fallback_reason: null,
|
||||
xvfb_stderr_bytes: 0,
|
||||
},
|
||||
}),
|
||||
},
|
||||
);
|
||||
const launched = await launcher.launch({
|
||||
directory,
|
||||
socketPath: join(directory, "bridge.sock"),
|
||||
token: "fixture-token",
|
||||
runId: randomUUID(),
|
||||
});
|
||||
if (!launched.ok) throw launched.error;
|
||||
const supervisor = new ProviderProcessSupervisor(launched.value);
|
||||
try {
|
||||
expect(await supervisor.waitForOutputClose(5_000)).toBe(true);
|
||||
expect(supervisor.snapshot().exitCode).toBe(0);
|
||||
expect(JSON.parse(supervisor.snapshot().stdout.text)).toEqual({
|
||||
owner_alive: true,
|
||||
});
|
||||
} finally {
|
||||
await supervisor.stop();
|
||||
await launched.value.releaseLease?.();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -31,6 +31,9 @@ const dialogDetectionFixturePath = fileURLToPath(
|
||||
const cleanupTimeoutFixturePath = fileURLToPath(
|
||||
new URL("../../../fixtures/hopperCleanupTimeout.py", import.meta.url),
|
||||
);
|
||||
const ownerLifetimeFixturePath = fileURLToPath(
|
||||
new URL("../../../fixtures/hopperOwnerLifetime.py", import.meta.url),
|
||||
);
|
||||
|
||||
type DiagnosticOverrides = Partial<
|
||||
Omit<HopperStartupDiagnostic, "failure_code" | "status">
|
||||
@@ -107,6 +110,23 @@ describe("Hopper demo dialog detection", () => {
|
||||
});
|
||||
|
||||
describe("Hopper process cleanup", () => {
|
||||
it.skipIf(process.platform !== "linux").each(["startup", "ready"])(
|
||||
"reaps only its own children when the owner pipe closes during %s",
|
||||
(phase) => {
|
||||
const result = spawnSync(
|
||||
"/usr/bin/python3",
|
||||
[ownerLifetimeFixturePath, helperPath, phase],
|
||||
{ encoding: "utf8", timeout: 10_000 },
|
||||
);
|
||||
expect(result.status, result.stderr).toBe(0);
|
||||
expect(JSON.parse(result.stdout)).toEqual({
|
||||
phase,
|
||||
children_cleaned: true,
|
||||
sentinel_alive: true,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it.skipIf(process.platform !== "linux")(
|
||||
"kills a child that ignores SIGTERM after the bounded timeout",
|
||||
() => {
|
||||
|
||||
@@ -1200,6 +1200,138 @@ describe("native DMG command diagnostics", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("native DMG verification resource availability", () => {
|
||||
const transientFailure = {
|
||||
stdout: "",
|
||||
stderr:
|
||||
'hdiutil: verify: unable to recognize "/tmp/image.dmg" as a disk image. (Resource temporarily unavailable)\nhdiutil: verify failed - Resource temporarily unavailable\n',
|
||||
exitCode: 1,
|
||||
};
|
||||
|
||||
it("retries the explicit transient refusal before attachment and retains both attempts", async () => {
|
||||
const { host, state } = createOmittedInventoryHost();
|
||||
state.inventoryMode = "listed";
|
||||
state.detachAttempts = 4;
|
||||
const delays = vi.fn(async () => {});
|
||||
const timeouts: number[] = [];
|
||||
let attempts = 0;
|
||||
const reader = await createAttachedReader(
|
||||
"/tmp/image.dmg",
|
||||
process.env,
|
||||
undefined,
|
||||
{
|
||||
...host,
|
||||
delay: delays,
|
||||
async run(arguments_, signal, options) {
|
||||
if (arguments_[0] === "verify") {
|
||||
attempts += 1;
|
||||
if (options === undefined)
|
||||
throw new Error("missing verify deadline");
|
||||
timeouts.push(options.timeoutMs);
|
||||
if (attempts === 1) return transientFailure;
|
||||
}
|
||||
return host.run(arguments_, signal, options);
|
||||
},
|
||||
},
|
||||
);
|
||||
onTestFinished(() => reader.close());
|
||||
expect(attempts).toBe(2);
|
||||
expect(delays.mock.calls).toEqual([[250]]);
|
||||
expect(timeouts[0]).toBeLessThanOrEqual(120_000);
|
||||
expect(timeouts[1]).toBeLessThanOrEqual(timeouts[0]!);
|
||||
expect(reader.provenance().slice(0, 2)).toMatchObject([
|
||||
{
|
||||
arguments: ["verify", "/tmp/image.dmg"],
|
||||
exit_code: 1,
|
||||
effects: ["read"],
|
||||
},
|
||||
{
|
||||
arguments: ["verify", "/tmp/image.dmg"],
|
||||
exit_code: 0,
|
||||
effects: ["read"],
|
||||
},
|
||||
]);
|
||||
await reader.close();
|
||||
expect(state.attached).toBe(false);
|
||||
});
|
||||
|
||||
it("bounds repeated transient refusals and never attaches an unverified image", async () => {
|
||||
const run = vi.fn(async () => transientFailure);
|
||||
const delay = vi.fn(async () => {});
|
||||
const reader = new NativeDmgArtifactReader("/tmp/image.dmg", process.env, {
|
||||
run,
|
||||
delay,
|
||||
});
|
||||
await expect(entryPaths(reader)).rejects.toMatchObject({
|
||||
reason: "unavailable",
|
||||
message: expect.stringContaining("Resource temporarily unavailable"),
|
||||
});
|
||||
await reader.close();
|
||||
expect(run.mock.calls).toHaveLength(3);
|
||||
expect(delay.mock.calls).toEqual([[250], [500]]);
|
||||
expect(reader.provenance().map(({ exit_code }) => exit_code)).toEqual([
|
||||
1, 1, 1,
|
||||
]);
|
||||
});
|
||||
|
||||
it("honors cancellation during the wait without starting another command", async () => {
|
||||
const controller = new AbortController();
|
||||
const run = vi.fn(async () => transientFailure);
|
||||
await expect(
|
||||
createAttachedReader("/tmp/image.dmg", process.env, controller.signal, {
|
||||
run,
|
||||
async delay() {
|
||||
controller.abort(new Error("cancel verification"));
|
||||
},
|
||||
}),
|
||||
).rejects.toMatchObject({ reason: "cancelled" });
|
||||
expect(run).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not start another verification after the shared deadline", async () => {
|
||||
const clock = vi.spyOn(performance, "now").mockReturnValue(0);
|
||||
const run = vi.fn(async () => transientFailure);
|
||||
try {
|
||||
await expect(
|
||||
createAttachedReader("/tmp/image.dmg", process.env, undefined, {
|
||||
run,
|
||||
async delay() {
|
||||
clock.mockReturnValue(120_001);
|
||||
},
|
||||
}),
|
||||
).rejects.toMatchObject({
|
||||
reason: "unavailable",
|
||||
message: expect.stringContaining("Resource temporarily unavailable"),
|
||||
});
|
||||
expect(run).toHaveBeenCalledTimes(1);
|
||||
} finally {
|
||||
clock.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
["image data corrupted", "integrity"],
|
||||
["image not recognized", "format"],
|
||||
["Permission denied", "io"],
|
||||
["an unknown failure", "unavailable"],
|
||||
])("does not retry %s", async (diagnostic, reason) => {
|
||||
const run = vi.fn(async () => ({
|
||||
stdout: "",
|
||||
stderr: `hdiutil: verify failed - ${diagnostic}\n`,
|
||||
exitCode: 1,
|
||||
}));
|
||||
const delay = vi.fn(async () => {});
|
||||
await expect(
|
||||
createAttachedReader("/tmp/image.dmg", process.env, undefined, {
|
||||
run,
|
||||
delay,
|
||||
}),
|
||||
).rejects.toMatchObject({ reason });
|
||||
expect(run).toHaveBeenCalledTimes(1);
|
||||
expect(delay).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("native DMG real verification diagnostics", () => {
|
||||
it.skipIf(process.platform !== "darwin")(
|
||||
"classifies a real hdiutil verify refusal as a format failure with captured output",
|
||||
|
||||
Reference in New Issue
Block a user