bafb085995
- templates proxmox/ (update-analyze: dépôts PVE ; full-upgrade) et raspbian/ (update-analyze: espace disque ; full-upgrade) - execute résout les actions APT par profil OS (resolveTemplate) → proxmox/ raspbian si dispo, sinon fallback apt/ (non-régression debian/ubuntu vérifiée) - machine_probe (lecture seule) : template + parseProbe/proposeCorrections (TDD) → propose os_family/machine_kind/virtualization, persiste machine_hardware, n'applique jamais auto ; branche execute + allowlist route - apt_proxy_persistent : ActionType + template idempotent (/etc/apt/apt.conf.d/ 01proxy, backup) + TemplateVars.aptProxyUrl + allowlist route tsc 0 · 95 tests · build OK · résolution OS vérifiée. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
104 lines
2.6 KiB
TypeScript
104 lines
2.6 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { parseProbe, proposeCorrections } from "./machineProbe.js";
|
|
|
|
const PROXMOX = [
|
|
"===SU:PROBE_OS===",
|
|
'PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"',
|
|
"ID=debian",
|
|
'VERSION_ID="12"',
|
|
"VERSION_CODENAME=bookworm",
|
|
"===SU:PROBE_ARCH===",
|
|
"x86_64",
|
|
"amd64",
|
|
"===SU:PROBE_VIRT===",
|
|
"none",
|
|
"===SU:PROBE_PROXMOX===",
|
|
"PROXMOX=1",
|
|
"===SU:PROBE_RPI===",
|
|
"RPI=0",
|
|
"===SU:PROBE_GPU===",
|
|
"01:00.0 VGA compatible controller: Matrox MGA G200eW",
|
|
"===SU:PROBE_NET===",
|
|
"vmbr0 10.0.3.202/24",
|
|
"===SU:EXIT=0===",
|
|
].join("\n");
|
|
|
|
const RPI = [
|
|
"===SU:PROBE_OS===",
|
|
"ID=debian",
|
|
"VERSION_CODENAME=bookworm",
|
|
"===SU:PROBE_ARCH===",
|
|
"aarch64",
|
|
"arm64",
|
|
"===SU:PROBE_VIRT===",
|
|
"none",
|
|
"===SU:PROBE_PROXMOX===",
|
|
"PROXMOX=0",
|
|
"===SU:PROBE_RPI===",
|
|
"RPI=1",
|
|
"===SU:PROBE_GPU===",
|
|
"no-lspci",
|
|
"===SU:PROBE_NET===",
|
|
"eth0 192.168.1.50/24",
|
|
"===SU:EXIT=0===",
|
|
].join("\n");
|
|
|
|
const KVM_VM = [
|
|
"===SU:PROBE_OS===",
|
|
"ID=ubuntu",
|
|
'VERSION_ID="24.04"',
|
|
"VERSION_CODENAME=noble",
|
|
"===SU:PROBE_ARCH===",
|
|
"x86_64",
|
|
"amd64",
|
|
"===SU:PROBE_VIRT===",
|
|
"kvm",
|
|
"===SU:PROBE_PROXMOX===",
|
|
"PROXMOX=0",
|
|
"===SU:PROBE_RPI===",
|
|
"RPI=0",
|
|
"===SU:PROBE_GPU===",
|
|
"no-lspci",
|
|
"===SU:PROBE_NET===",
|
|
"ens18 10.0.3.5/24",
|
|
"===SU:EXIT=0===",
|
|
].join("\n");
|
|
|
|
describe("parseProbe", () => {
|
|
it("extrait os-release, arch, virt et drapeaux", () => {
|
|
const p = parseProbe(PROXMOX);
|
|
expect(p.osId).toBe("debian");
|
|
expect(p.osVersion).toBe("12");
|
|
expect(p.osCodename).toBe("bookworm");
|
|
expect(p.arch).toBe("x86_64");
|
|
expect(p.dpkgArch).toBe("amd64");
|
|
expect(p.virt).toBe("none");
|
|
expect(p.isProxmox).toBe(true);
|
|
expect(p.isRpi).toBe(false);
|
|
expect(p.gpus).toHaveLength(1);
|
|
expect(p.net).toEqual([{ iface: "vmbr0", addr: "10.0.3.202/24" }]);
|
|
});
|
|
});
|
|
|
|
describe("proposeCorrections", () => {
|
|
it("Proxmox → os_family proxmox + machine_kind proxmox_host", () => {
|
|
const c = proposeCorrections(parseProbe(PROXMOX));
|
|
expect(c.osFamily).toBe("proxmox");
|
|
expect(c.machineKind).toBe("proxmox_host");
|
|
expect(c.virtualization).toBe("none");
|
|
});
|
|
|
|
it("Raspberry Pi → raspbian + raspberry_pi", () => {
|
|
const c = proposeCorrections(parseProbe(RPI));
|
|
expect(c.osFamily).toBe("raspbian");
|
|
expect(c.machineKind).toBe("raspberry_pi");
|
|
});
|
|
|
|
it("VM KVM Ubuntu → ubuntu + vm + virtualization kvm", () => {
|
|
const c = proposeCorrections(parseProbe(KVM_VM));
|
|
expect(c.osFamily).toBe("ubuntu");
|
|
expect(c.machineKind).toBe("vm");
|
|
expect(c.virtualization).toBe("kvm");
|
|
});
|
|
});
|