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
Partition host agent tests by platform
rcourtman211b80717d9e
diff --git a/internal/hostagent/buffer_persist_test.go b/internal/hostagent/buffer_persist_test.goindex 0c3cd2a122..7611e5711c 100644--- a/internal/hostagent/buffer_persist_test.go+++ b/internal/hostagent/buffer_persist_test.go@@ -3,6 +3,7 @@ package hostagentimport ("os""path/filepath"+ "runtime""testing""time"@@ -167,7 +168,7 @@ func TestPersistBuffer_AtomicWrite(t *testing.T) {if err != nil {t.Fatal(err)}- if perm := info.Mode().Perm(); perm != 0600 {+ if perm := info.Mode().Perm(); runtime.GOOS != "windows" && perm != 0600 {t.Fatalf("expected 0600 permissions, got %o", perm)}}diff --git a/internal/hostagent/collector_observability_test.go b/internal/hostagent/collector_observability_test.goindex bd54e0102a..24aa536c43 100644--- a/internal/hostagent/collector_observability_test.go+++ b/internal/hostagent/collector_observability_test.go@@ -1,3 +1,5 @@+//go:build !windows+package hostagentimport (diff --git a/internal/hostagent/hostagent_coverage_test.go b/internal/hostagent/hostagent_coverage_test.goindex 59baabfe8b..8fa17d8e12 100644--- a/internal/hostagent/hostagent_coverage_test.go+++ b/internal/hostagent/hostagent_coverage_test.go@@ -80,7 +80,7 @@ func TestAgent_RunOnce_Coverage(t *testing.T) {Logger: &logger,})if a != nil {- a.httpClient = &http.Client{Transport: &mockTransport{statusCode: 200}}+ a.httpClient = &http.Client{Transport: &coverageMockTransport{statusCode: 200}}_ = a.Run(context.Background())}}@@ -104,11 +104,23 @@ func TestAgent_RunProxmoxSetup(t *testing.T) {Logger: &logger,})if a != nil {- a.httpClient = &http.Client{Transport: &mockTransport{statusCode: 200}}+ a.httpClient = &http.Client{Transport: &coverageMockTransport{statusCode: 200}}a.runProxmoxSetup(context.Background())}}+type coverageMockTransport struct {+ statusCode int+}++func (m *coverageMockTransport) RoundTrip(*http.Request) (*http.Response, error) {+ return &http.Response{+ StatusCode: m.statusCode,+ Body: http.NoBody,+ Header: make(http.Header),+ }, nil+}+func TestAgent_ApplyRemoteConfig_DefersCommandStartWithoutRunContext(t *testing.T) {started := make(chan struct{}, 1)diff --git a/internal/hostagent/mdadm_test.go b/internal/hostagent/mdadm_test.goindex f56c96b1f9..a3506224c0 100644--- a/internal/hostagent/mdadm_test.go+++ b/internal/hostagent/mdadm_test.go@@ -1,3 +1,5 @@+//go:build !windows+package hostagentimport (diff --git a/internal/hostagent/proxmox_setup_network_coverage_test.go b/internal/hostagent/proxmox_setup_network_coverage_test.goindex 3de56b512f..c4cd14f21d 100644--- a/internal/hostagent/proxmox_setup_network_coverage_test.go+++ b/internal/hostagent/proxmox_setup_network_coverage_test.go@@ -1,3 +1,5 @@+//go:build !windows+package hostagentimport (diff --git a/internal/hostagent/proxmox_setup_test.go b/internal/hostagent/proxmox_setup_test.goindex 06aa6c4787..fdb1a2430e 100644--- a/internal/hostagent/proxmox_setup_test.go+++ b/internal/hostagent/proxmox_setup_test.go@@ -1,3 +1,5 @@+//go:build !windows+package hostagentimport (diff --git a/internal/hostagent/smartctl_coverage_test.go b/internal/hostagent/smartctl_coverage_test.goindex f4d24aad01..3303b6ce75 100644--- a/internal/hostagent/smartctl_coverage_test.go+++ b/internal/hostagent/smartctl_coverage_test.go@@ -1,3 +1,5 @@+//go:build !windows+package hostagentimport (@@ -21,15 +23,6 @@ func mockLsblkJSON(devices ...lsblkDevice) []byte {return out}-type fakeDirEntry struct {- name string-}--func (e fakeDirEntry) Name() string { return e.name }-func (e fakeDirEntry) IsDir() bool { return false }-func (e fakeDirEntry) Type() fs.FileMode { return 0 }-func (e fakeDirEntry) Info() (fs.FileInfo, error) { return nil, nil }-func forceLinuxLSBLKFallback(t *testing.T) {t.Helper()diff --git a/internal/hostagent/smartctl_discovery_test.go b/internal/hostagent/smartctl_discovery_test.goindex 579edfbe57..194e587ed6 100644--- a/internal/hostagent/smartctl_discovery_test.go+++ b/internal/hostagent/smartctl_discovery_test.go@@ -1,3 +1,5 @@+//go:build !windows+package hostagent// Regression tests for #1483: on a Proxmox VE node the agent reported NVMe@@ -8,11 +10,8 @@ package hostagentimport ("context""errors"- "io/fs"- "os""strings""testing"- "time")// scanOpenPVENVMeOnly reproduces the #1483 discovery failure: smartctl@@ -52,66 +51,6 @@ const smartctlNVMeProbeJSON = `{"temperature": {"current": 37}}`-// smartctlNoDataJSON is a syntactically valid smartctl JSON envelope with no-// usable SMART payload, as produced when a probe addresses a device with the-// wrong -d type.-const smartctlNoDataJSON = `{- "device": {"name": "/dev/sda", "type": "sat", "protocol": "ATA"}-}`--const smartctlUntypedHealthOnlyJSON = `{- "device": {"name": "/dev/sda", "type": "scsi", "protocol": "SCSI"},- "model_name": "WDC_WD80EFPX-68C4ZN0",- "serial_number": "WD-SAT-TEMP-1",- "smart_status": {"passed": true}-}`--const smartctlSATTemperatureAttributeJSON = `{- "device": {"name": "/dev/sda", "type": "sat", "protocol": "ATA"},- "model_name": "WDC_WD80EFPX-68C4ZN0",- "serial_number": "WD-SAT-TEMP-1",- "smart_status": {"passed": true},- "ata_smart_attributes": {- "table": [- {"id": 194, "name": "Temperature_Celsius", "raw": {"value": 0, "string": "32"}}- ]- }-}`--func stubLinuxSysfs(t *testing.T, entries []string, files map[string]string) {- t.Helper()-- origGOOS := runtimeGOOS- origReadDir := readDir- origReadFile := smartctlReadFile- origEvalSymlinks := smartctlEvalSymlinks- origNow := timeNow- t.Cleanup(func() {- runtimeGOOS = origGOOS- readDir = origReadDir- smartctlReadFile = origReadFile- smartctlEvalSymlinks = origEvalSymlinks- timeNow = origNow- })-- runtimeGOOS = "linux"- timeNow = func() time.Time { return time.Date(2026, 6, 10, 12, 0, 0, 0, time.UTC) }- readDir = func(string) ([]os.DirEntry, error) {- dirEntries := make([]os.DirEntry, 0, len(entries))- for _, name := range entries {- dirEntries = append(dirEntries, fakeDirEntry{name: name})- }- return dirEntries, nil- }- smartctlReadFile = func(path string) ([]byte, error) {- if content, ok := files[path]; ok {- return []byte(content), nil- }- return nil, fs.ErrNotExist- }- smartctlEvalSymlinks = func(string) (string, error) { return "", fs.ErrNotExist }-}-func TestParseSmartctlScanOpenTargetsRealPVEOutput(t *testing.T) {targets := parseSmartctlScanOpenTargets([]byte(scanOpenPVENVMeOnly+scanOpenPVESATA), nil)if len(targets) != 3 {diff --git a/internal/hostagent/smartctl_size_test.go b/internal/hostagent/smartctl_size_test.goindex 05b0a62a93..98886cce9b 100644--- a/internal/hostagent/smartctl_size_test.go+++ b/internal/hostagent/smartctl_size_test.go@@ -1,3 +1,5 @@+//go:build !windows+package hostagentimport (diff --git a/internal/hostagent/smartctl_test.go b/internal/hostagent/smartctl_test.goindex 9f7bbc234f..65bea3da72 100644--- a/internal/hostagent/smartctl_test.go+++ b/internal/hostagent/smartctl_test.go@@ -1,3 +1,5 @@+//go:build !windows+package hostagentimport (diff --git a/internal/hostagent/smartctl_test_helpers_test.go b/internal/hostagent/smartctl_test_helpers_test.gonew file mode 100644index 0000000000..70212b6a9b--- /dev/null+++ b/internal/hostagent/smartctl_test_helpers_test.go@@ -0,0 +1,77 @@+package hostagent++import (+ "io/fs"+ "os"+ "testing"+ "time"+)++// smartctlNoDataJSON is a syntactically valid smartctl JSON envelope with no+// usable SMART payload, as produced when a probe addresses a device with the+// wrong -d type.+const smartctlNoDataJSON = `{+ "device": {"name": "/dev/sda", "type": "sat", "protocol": "ATA"}+}`++const smartctlUntypedHealthOnlyJSON = `{+ "device": {"name": "/dev/sda", "type": "scsi", "protocol": "SCSI"},+ "model_name": "WDC_WD80EFPX-68C4ZN0",+ "serial_number": "WD-SAT-TEMP-1",+ "smart_status": {"passed": true}+}`++const smartctlSATTemperatureAttributeJSON = `{+ "device": {"name": "/dev/sda", "type": "sat", "protocol": "ATA"},+ "model_name": "WDC_WD80EFPX-68C4ZN0",+ "serial_number": "WD-SAT-TEMP-1",+ "smart_status": {"passed": true},+ "ata_smart_attributes": {+ "table": [+ {"id": 194, "name": "Temperature_Celsius", "raw": {"value": 0, "string": "32"}}+ ]+ }+}`++type fakeDirEntry struct {+ name string+}++func (e fakeDirEntry) Name() string { return e.name }+func (e fakeDirEntry) IsDir() bool { return false }+func (e fakeDirEntry) Type() fs.FileMode { return 0 }+func (e fakeDirEntry) Info() (fs.FileInfo, error) { return nil, nil }++func stubLinuxSysfs(t *testing.T, entries []string, files map[string]string) {+ t.Helper()++ origGOOS := runtimeGOOS+ origReadDir := readDir+ origReadFile := smartctlReadFile+ origEvalSymlinks := smartctlEvalSymlinks+ origNow := timeNow+ t.Cleanup(func() {+ runtimeGOOS = origGOOS+ readDir = origReadDir+ smartctlReadFile = origReadFile+ smartctlEvalSymlinks = origEvalSymlinks+ timeNow = origNow+ })++ runtimeGOOS = "linux"+ timeNow = func() time.Time { return time.Date(2026, 6, 10, 12, 0, 0, 0, time.UTC) }+ readDir = func(string) ([]os.DirEntry, error) {+ dirEntries := make([]os.DirEntry, 0, len(entries))+ for _, name := range entries {+ dirEntries = append(dirEntries, fakeDirEntry{name: name})+ }+ return dirEntries, nil+ }+ smartctlReadFile = func(path string) ([]byte, error) {+ if content, ok := files[path]; ok {+ return []byte(content), nil+ }+ return nil, fs.ErrNotExist+ }+ smartctlEvalSymlinks = func(string) (string, error) { return "", fs.ErrNotExist }+}