Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Hermeticize Linux SMART discovery tests
rcourtman7028c95ed0cb
diff --git a/internal/hostagent/collector_observability_test.go b/internal/hostagent/collector_observability_test.goindex ed072c9382..c0058d7341 100644--- a/internal/hostagent/collector_observability_test.go+++ b/internal/hostagent/collector_observability_test.go@@ -5,6 +5,7 @@ import ("context""encoding/json""errors"+ "os""os/exec""strings""testing"@@ -17,13 +18,16 @@ func TestCollectLocal_LogsStructuredContextOnDeviceCollectionFailure(t *testing.origRun := smartRunCommandOutputorigLook := execLookPathorigGOOS := runtimeGOOS+ origReadDir := readDirt.Cleanup(func() {smartRunCommandOutput = origRunexecLookPath = origLookruntimeGOOS = origGOOS+ readDir = origReadDir})runtimeGOOS = "linux"+ readDir = func(string) ([]os.DirEntry, error) { return nil, errors.New("sysfs unavailable") }execLookPath = func(string) (string, error) { return "smartctl", nil }smartRunCommandOutput = func(ctx context.Context, name string, args ...string) ([]byte, error) {if name == "lsblk" {@@ -62,10 +66,13 @@ func TestCollectLocal_LogsStructuredContextOnDeviceCollectionFailure(t *testing.func TestListBlockDevicesLinux_LogsStructuredContextForExcludedDevice(t *testing.T) {origRun := smartRunCommandOutput+ origReadDir := readDirt.Cleanup(func() {smartRunCommandOutput = origRun+ readDir = origReadDir})+ readDir = func(string) ([]os.DirEntry, error) { return nil, errors.New("sysfs unavailable") }smartRunCommandOutput = func(ctx context.Context, name string, args ...string) ([]byte, error) {data := lsblkJSON{Blockdevices: []lsblkDevice{{Name: "sda", Type: "disk", Tran: "sata", Subsystems: "block:scsi:pci"},diff --git a/internal/hostagent/smartctl_coverage_test.go b/internal/hostagent/smartctl_coverage_test.goindex 8acd76c7d3..62e2ea0587 100644--- a/internal/hostagent/smartctl_coverage_test.go+++ b/internal/hostagent/smartctl_coverage_test.go@@ -466,14 +466,17 @@ func TestCollectSMARTLocalSkipsErrors(t *testing.T) {origRun := smartRunCommandOutputorigLook := execLookPathorigNow := timeNow+ origReadDir := readDirt.Cleanup(func() {smartRunCommandOutput = origRunexecLookPath = origLooktimeNow = origNow+ readDir = origReadDir})fixed := time.Date(2024, 1, 2, 3, 4, 5, 0, time.UTC)timeNow = func() time.Time { return fixed }+ readDir = func(string) ([]os.DirEntry, error) { return nil, errors.New("sysfs unavailable") }execLookPath = func(string) (string, error) { return "smartctl", nil }smartRunCommandOutput = func(ctx context.Context, name string, args ...string) ([]byte, error) {@@ -926,8 +929,13 @@ func TestCollectDeviceSMARTWWN(t *testing.T) {func TestListBlockDevicesLinuxWithExcludes(t *testing.T) {origRun := smartRunCommandOutput- t.Cleanup(func() { smartRunCommandOutput = origRun })+ origReadDir := readDir+ t.Cleanup(func() {+ smartRunCommandOutput = origRun+ readDir = origReadDir+ })+ readDir = func(string) ([]os.DirEntry, error) { return nil, errors.New("sysfs unavailable") }smartRunCommandOutput = func(ctx context.Context, name string, args ...string) ([]byte, error) {if name != "lsblk" {return nil, errors.New("unexpected command")@@ -1045,8 +1053,13 @@ func TestLinuxSMARTSkipReason(t *testing.T) {func TestListBlockDevicesLinuxFiltersVirtualDevices(t *testing.T) {origRun := smartRunCommandOutput- t.Cleanup(func() { smartRunCommandOutput = origRun })+ origReadDir := readDir+ t.Cleanup(func() {+ smartRunCommandOutput = origRun+ readDir = origReadDir+ })+ readDir = func(string) ([]os.DirEntry, error) { return nil, errors.New("sysfs unavailable") }smartRunCommandOutput = func(ctx context.Context, name string, args ...string) ([]byte, error) {return mockLsblkJSON(lsblkDevice{Name: "sda", Type: "disk", Tran: "sata", Subsystems: "block:scsi:pci"},