Files
rea/tests/evaluation/package/packageSetupSupport.test.ts
T
86655eac66 fix(hopper): keep automated Linux setup off non-x86_64 hosts (#3422)
* fix(hopper): keep automated Linux setup off non-x86_64 hosts

Every pinned Linux Hopper package (deb, rpm, Arch) is x86_64-only, but
hopperSetupSupported was derived from os-release alone. Setup therefore
planned and confirmed an amd64 package install on arm64 Ubuntu 24.04 and
the other tested distributions.

Classify installer support with the host architecture where the
distribution is parsed, so setup planning, preflight, installation and
package verification share one decision. Setup now takes its Linux
distribution from the doctor host, as it already does for the macOS
version, and the supported-host remediation text has a single owner.

Fixes #3419

* fix(hopper): install Linux Hopper from the setup host's distribution facts

systemLinuxHopperInstallHost read os-release with process.arch on its own,
while setup planning used the doctor host's injected architecture. Both
agree in production, but a doctor host composed with another architecture
could plan one answer and install with another.

The install host now takes its distribution reader from the caller, and
systemSetupHost passes the doctor host's, so planning, preflight and
installation share one host-fact owner. The unused default host on
installLinuxHopper, the other ambient reader, is removed.

* fix(verify-package): require Hopper readiness only where Linux setup installs it

packageSetupSupport required doctor Hopper readiness on every Linux host
whose host check passed, including installer-untested distributions and,
after the architecture gate, arm64 hosts where setup never provides
Hopper. On Linux, readiness now also requires automated installer
applicability; macOS is unchanged.

This narrows the readiness assertion from #2973 on hosts outside the
installer matrix, such as Kali and ubuntu-24.04-arm.

---------

Co-authored-by: DavidFB-creator <220631175+DavidFB-creator@users.noreply.github.com>
Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
2026-10-23 02:39:05 +08:00

113 lines
3.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { packageSetupSupport } from "../../../scripts/verify-package-discovery.mjs";
import { parseLinuxDistribution } from "../../../src/application/LinuxHopper.js";
const osRelease = (
fields: Record<string, string>,
architecture: NodeJS.Architecture = "x64",
) =>
parseLinuxDistribution(
Object.entries(fields)
.map(([key, value]) => `${key}="${value}"`)
.join("\n"),
architecture,
);
/** A Debian-family host REA supports that the Hopper package never tests. */
const KALI = osRelease({ ID: "kali", VERSION_ID: "2026.3", ID_LIKE: "debian" });
const UBUNTU_24 = osRelease({ ID: "ubuntu", VERSION_ID: "24.04" });
/** A tested distribution on an architecture the pinned Hopper packages lack. */
const UBUNTU_24_ARM64 = osRelease(
{ ID: "ubuntu", VERSION_ID: "24.04" },
"arm64",
);
const checks = ({ node = true, host = true } = {}) => [
{ name: "node", ok: node },
{ name: "host", ok: host },
];
describe("packaged setup support derivation", () => {
it("keeps an installer-untested REA-supported distribution out of the automated Hopper path", () => {
// The doctor host check passes on Kali, so reading installer applicability
// from it promised an automated install the packaged setup never offers,
// and Hopper readiness that setup never provides there.
expect(
packageSetupSupport(checks(), {
platform: "linux",
linuxDistribution: KALI,
}),
).toEqual({
supportedSetupHost: true,
hopperReadinessRequired: false,
hopperSetupSupported: false,
});
});
it("keeps an arm64 host off the x86_64-only automated Hopper path", () => {
// ubuntu-24.04-arm runs REA, but every pinned Linux Hopper package is
// x86_64, so packaged setup must not expect an automated install or
// Hopper readiness there.
expect(
packageSetupSupport(checks(), {
platform: "linux",
linuxDistribution: UBUNTU_24_ARM64,
}),
).toEqual({
supportedSetupHost: true,
hopperReadinessRequired: false,
hopperSetupSupported: false,
});
});
it("follows the distribution's own applicability, not host readiness", () => {
expect(
packageSetupSupport(checks({ host: false }), {
platform: "linux",
linuxDistribution: UBUNTU_24,
}),
).toEqual({
supportedSetupHost: true,
hopperReadinessRequired: false,
hopperSetupSupported: true,
});
});
it("keeps unreadable Linux applicability unknown", () => {
expect(
packageSetupSupport(checks(), { platform: "linux" }).hopperSetupSupported,
).toBeUndefined();
});
it("uses the owner's macOS predicate and excludes Windows", () => {
expect(
packageSetupSupport(checks(), { platform: "darwin" })
.hopperSetupSupported,
).toBe(true);
expect(
packageSetupSupport(checks({ host: false }), { platform: "darwin" })
.hopperSetupSupported,
).toBe(false);
expect(
packageSetupSupport([], { platform: "darwin" }).hopperSetupSupported,
).toBeUndefined();
expect(
packageSetupSupport(checks(), { platform: "win32" }).hopperSetupSupported,
).toBe(false);
});
it("reports agent setup support from the node check alone", () => {
expect(
packageSetupSupport(checks({ node: false }), {
platform: "linux",
linuxDistribution: UBUNTU_24,
}),
).toEqual({
supportedSetupHost: false,
hopperReadinessRequired: true,
hopperSetupSupported: true,
});
});
});